Search in sources :

Example 16 with JwtEncodingContext

use of org.springframework.security.oauth2.server.authorization.JwtEncodingContext in project herodotus-engine by herodotus-cloud.

the class OAuth2ConfigurerUtils method getJwtGenerator.

private static <B extends HttpSecurityBuilder<B>> JwtGenerator getJwtGenerator(B builder) {
    JwtGenerator jwtGenerator = builder.getSharedObject(JwtGenerator.class);
    if (jwtGenerator == null) {
        JwtEncoder jwtEncoder = getJwtEncoder(builder);
        if (jwtEncoder != null) {
            jwtGenerator = new JwtGenerator(jwtEncoder);
            OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer = getJwtCustomizer(builder);
            if (jwtCustomizer != null) {
                jwtGenerator.setJwtCustomizer(jwtCustomizer);
            }
            builder.setSharedObject(JwtGenerator.class, jwtGenerator);
        }
    }
    return jwtGenerator;
}
Also used : JwtEncoder(org.springframework.security.oauth2.jwt.JwtEncoder)

Aggregations

RegisteredClient (org.springframework.security.oauth2.server.authorization.client.RegisteredClient)11 Authentication (org.springframework.security.core.Authentication)10 JwtEncodingContext (org.springframework.security.oauth2.server.authorization.JwtEncodingContext)9 OAuth2Authorization (org.springframework.security.oauth2.server.authorization.OAuth2Authorization)9 Test (org.junit.Test)7 OAuth2AuthorizationRequest (org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest)6 JwtClaimsSet (org.springframework.security.oauth2.jwt.JwtClaimsSet)6 Instant (java.time.Instant)4 HashMap (java.util.HashMap)3 OAuth2AuthorizationCode (org.springframework.security.oauth2.core.OAuth2AuthorizationCode)3 JoseHeader (org.springframework.security.oauth2.jwt.JoseHeader)3 JwtEncoder (org.springframework.security.oauth2.jwt.JwtEncoder)3 OAuth2ClientAuthenticationToken (org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken)3 Gw2AuthUser (com.gw2auth.oauth2.server.service.user.Gw2AuthUser)2 Duration (java.time.Duration)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 OAuth2TokenType (org.springframework.security.oauth2.core.OAuth2TokenType)2 OAuth2TokenCustomizer (org.springframework.security.oauth2.server.authorization.OAuth2TokenCustomizer)2