Class JwtGenerator
java.lang.Object
org.springframework.security.oauth2.server.authorization.token.JwtGenerator
- All Implemented Interfaces:
OAuth2TokenGenerator<org.springframework.security.oauth2.jwt.Jwt>
public final class JwtGenerator
extends Object
implements OAuth2TokenGenerator<org.springframework.security.oauth2.jwt.Jwt>
- Since:
- 0.2.3
- See Also:
-
OAuth2TokenGeneratorJwtJwtEncoderOAuth2TokenCustomizerJwtEncodingContextOAuth2AccessTokenOidcIdToken
-
Constructor Summary
ConstructorsConstructorDescriptionJwtGenerator(org.springframework.security.oauth2.jwt.JwtEncoder jwtEncoder) Constructs aJwtGeneratorusing the provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.oauth2.jwt.Jwtgenerate(OAuth2TokenContext context) Generate an OAuth 2.0 Token using the attributes contained in theOAuth2TokenContext, or returnnullif theOAuth2TokenContext.getTokenType()is not supported.voidsetJwtCustomizer(OAuth2TokenCustomizer<JwtEncodingContext> jwtCustomizer)
-
Constructor Details
-
JwtGenerator
public JwtGenerator(org.springframework.security.oauth2.jwt.JwtEncoder jwtEncoder) Constructs aJwtGeneratorusing the provided parameters.- Parameters:
jwtEncoder- the jwt encoder
-
-
Method Details
-
generate
Description copied from interface:OAuth2TokenGeneratorGenerate an OAuth 2.0 Token using the attributes contained in theOAuth2TokenContext, or returnnullif theOAuth2TokenContext.getTokenType()is not supported.If the returned
OAuth2Tokenhas a set of claims, it should implementClaimAccessorin order for it to be stored with theOAuth2Authorization.- Specified by:
generatein interfaceOAuth2TokenGenerator<org.springframework.security.oauth2.jwt.Jwt>- Parameters:
context- the context containing the OAuth 2.0 Token attributes- Returns:
- an
OAuth2Tokenornullif theOAuth2TokenContext.getTokenType()is not supported
-
setJwtCustomizer
- Parameters:
jwtCustomizer- theOAuth2TokenCustomizerthat customizes the headers and/or claims for the generatedJwt
-