Fixed compilation errors for SECOAUTH milestone updates
parent
61f0db20f6
commit
27f391ef01
|
@ -122,7 +122,7 @@ public class IntrospectingTokenService implements ResourceServerTokenServices {
|
|||
Map<String, String> parameters = new HashMap<String, String>();
|
||||
parameters.put("client_id", clientId);
|
||||
parameters.put("scope", OAuth2Utils.formatParameterList(scopes));
|
||||
OAuth2Request storedRequest = new OAuth2Request(parameters, clientId, null, true, scopes, null, null, null);
|
||||
OAuth2Request storedRequest = new OAuth2Request(parameters, clientId, null, true, scopes, null, null, null, null);
|
||||
return storedRequest;
|
||||
}
|
||||
|
||||
|
|
|
@ -1024,4 +1024,12 @@ public class ClientDetailsEntity implements ClientDetails {
|
|||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our framework doesn't use this construct, we use WhitelistedSites and ApprovedSites instead.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAutoApprove(String scope) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ import org.mitre.oauth2.service.SystemScopeService;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.oauth2.common.exceptions.InvalidScopeException;
|
||||
import org.springframework.security.oauth2.common.util.OAuth2Utils;
|
||||
import org.springframework.security.oauth2.provider.AuthorizationRequest;
|
||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
||||
import org.springframework.security.oauth2.provider.OAuth2RequestValidator;
|
||||
import org.springframework.security.oauth2.provider.TokenRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -28,11 +31,9 @@ public class StructuredScopeAwareOAuth2RequestValidator implements OAuth2Request
|
|||
/* (non-Javadoc)
|
||||
* @see org.springframework.security.oauth2.provider.OAuth2RequestValidator#validateScope(java.util.Map, java.util.Set)
|
||||
*/
|
||||
@Override
|
||||
public void validateScope(Map<String, String> parameters, Set<String> clientScopes) throws InvalidScopeException {
|
||||
if (parameters.containsKey("scope")) {
|
||||
private void validateScope(Set<String> requestedScopes, Set<String> clientScopes) throws InvalidScopeException {
|
||||
if (requestedScopes != null && !requestedScopes.isEmpty()) {
|
||||
if (clientScopes != null && !clientScopes.isEmpty()) {
|
||||
Set<String> requestedScopes = OAuth2Utils.parseParameterList(parameters.get("scope"));
|
||||
if (!scopeService.scopesMatch(clientScopes, requestedScopes)) {
|
||||
throw new InvalidScopeException("Invalid scope", clientScopes);
|
||||
}
|
||||
|
@ -40,4 +41,14 @@ public class StructuredScopeAwareOAuth2RequestValidator implements OAuth2Request
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateScope(AuthorizationRequest authorizationRequest, ClientDetails client) throws InvalidScopeException {
|
||||
validateScope(authorizationRequest.getScope(), client.getScope());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateScope(TokenRequest tokenRequest, ClientDetails client) throws InvalidScopeException {
|
||||
validateScope(tokenRequest.getScope(), client.getScope());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ConnectOAuth2RequestFactory extends DefaultOAuth2RequestFactory {
|
|||
@Override
|
||||
public OAuth2Request createOAuth2Request(AuthorizationRequest request) {
|
||||
return new OAuth2Request(request.getRequestParameters(), request.getClientId(), request.getAuthorities(),
|
||||
request.isApproved(), request.getScope(), request.getResourceIds(), request.getRedirectUri(), request.getExtensions());
|
||||
request.isApproved(), request.getScope(), request.getResourceIds(), request.getRedirectUri(), request.getResponseTypes(), request.getExtensions());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -136,7 +136,7 @@ public class DefaultOIDCTokenService implements OIDCTokenService {
|
|||
Map<String, String> authorizationParameters = Maps.newHashMap();
|
||||
OAuth2Request clientAuth = new OAuth2Request(authorizationParameters, client.getClientId(),
|
||||
Sets.newHashSet(new SimpleGrantedAuthority("ROLE_CLIENT")), true,
|
||||
Sets.newHashSet(OAuth2AccessTokenEntity.REGISTRATION_TOKEN_SCOPE), null, null, null);
|
||||
Sets.newHashSet(OAuth2AccessTokenEntity.REGISTRATION_TOKEN_SCOPE), null, null, null, null);
|
||||
OAuth2Authentication authentication = new OAuth2Authentication(clientAuth, null);
|
||||
|
||||
OAuth2AccessTokenEntity token = new OAuth2AccessTokenEntity();
|
||||
|
|
|
@ -103,7 +103,7 @@ public class TestDefaultOAuth2ProviderTokenService {
|
|||
|
||||
|
||||
authentication = Mockito.mock(OAuth2Authentication.class);
|
||||
OAuth2Request clientAuth = new OAuth2Request(null, clientId, null, true, scope, null, null, null);
|
||||
OAuth2Request clientAuth = new OAuth2Request(null, clientId, null, true, scope, null, null, null, null);
|
||||
Mockito.when(authentication.getOAuth2Request()).thenReturn(clientAuth);
|
||||
|
||||
client = Mockito.mock(ClientDetailsEntity.class);
|
||||
|
@ -191,7 +191,7 @@ public class TestDefaultOAuth2ProviderTokenService {
|
|||
@Test
|
||||
public void createAccessToken_yesRefresh() {
|
||||
|
||||
OAuth2Request clientAuth = new OAuth2Request(null, clientId, null, true, Sets.newHashSet("offline_access"), null, null, null);
|
||||
OAuth2Request clientAuth = new OAuth2Request(null, clientId, null, true, Sets.newHashSet("offline_access"), null, null, null, null);
|
||||
Mockito.when(authentication.getOAuth2Request()).thenReturn(clientAuth);
|
||||
Mockito.when(client.isAllowRefresh()).thenReturn(true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue