use of com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor in project cloud-security-xsuaa-integration by SAP.
the class TokenAuthenticationConverter method setLocalScopeAsAuthorities.
/**
* This method allows to overwrite the default behavior of the
* {@link Token#getAuthorities()} implementation.
*
* @param extractLocalScopesOnly
* true when {@link Token#getAuthorities()} should only extract local
* scopes. Local scopes means that non-application specific scopes
* are filtered out and scopes are returned without appId prefix,
* e.g. "Display". Creates a new converter with a new
* {@link LocalAuthoritiesExtractor}
* @return the token authenticator itself
*/
public TokenAuthenticationConverter setLocalScopeAsAuthorities(boolean extractLocalScopesOnly) {
if (extractLocalScopesOnly) {
Assert.state(appId != null, "For local Scope extraction 'appId' must be provided to `TokenAuthenticationConverter`");
authoritiesExtractor = new LocalAuthoritiesExtractor(appId);
} else {
authoritiesExtractor = new DefaultAuthoritiesExtractor();
}
return this;
}
use of com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor in project cloud-security-xsuaa-integration by SAP.
the class SpringXsuaaSecurityContextTest method setToken.
private static void setToken(Token token) {
XsuaaJwtDecoder mockXsuaaJwtDecoder = Mockito.mock(XsuaaJwtDecoder.class);
when(mockXsuaaJwtDecoder.decode(token.getTokenValue())).thenReturn(convertTokenToOAuthJwt(token.getTokenValue()));
// initialize SpringSecurityContext with provided token
init(token.getTokenValue(), mockXsuaaJwtDecoder, new DefaultAuthoritiesExtractor());
}
use of com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor in project cloud-security-xsuaa-integration by SAP.
the class SpringSecurityContextTest method initSecurityContextWithToken.
private static void initSecurityContextWithToken(Jwt token) throws InterruptedException {
XsuaaJwtDecoder mockXsuaaJwtDecoder = Mockito.mock(XsuaaJwtDecoder.class);
when(mockXsuaaJwtDecoder.decode(token.getTokenValue())).thenReturn(token);
// initialize SpringSecurityContext with provided token
SpringSecurityContext.init(token.getTokenValue(), mockXsuaaJwtDecoder, new DefaultAuthoritiesExtractor());
}
use of com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor in project cloud-security-xsuaa-integration by SAP.
the class OAuth2TokenAuthenticationConverterTest method setup.
@Before
public void setup() {
OAuth2AuthenticationConverter tokenConverterOauth2 = new OAuth2AuthenticationConverter(new DefaultAuthoritiesExtractor());
Jwt jwt = new JwtGenerator().addScopes(scopeAdmin, scopeRead, scopeOther).getToken();
authenticationToken = tokenConverterOauth2.convert(jwt);
}
Aggregations