Search in sources :

Example 1 with XsuaaJwtDecoder

use of com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoder 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());
}
Also used : DefaultAuthoritiesExtractor(com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor) XsuaaJwtDecoder(com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoder)

Example 2 with XsuaaJwtDecoder

use of com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoder 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());
}
Also used : DefaultAuthoritiesExtractor(com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor) XsuaaJwtDecoder(com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoder)

Aggregations

DefaultAuthoritiesExtractor (com.sap.cloud.security.xsuaa.extractor.DefaultAuthoritiesExtractor)2 XsuaaJwtDecoder (com.sap.cloud.security.xsuaa.token.authentication.XsuaaJwtDecoder)2