Class JwtAuthenticationToken
java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
org.springframework.security.oauth2.server.resource.authentication.AbstractOAuth2TokenAuthenticationToken<Jwt>
org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken
- All Implemented Interfaces:
Serializable, Principal, Authentication, CredentialsContainer
- Since:
- 5.1
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class AbstractOAuth2TokenAuthenticationToken
AbstractOAuth2TokenAuthenticationToken.AbstractOAuth2TokenAuthenticationBuilder<T,B> Nested classes/interfaces inherited from class AbstractAuthenticationToken
AbstractAuthenticationToken.AbstractAuthenticationBuilder<B> -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs aJwtAuthenticationTokenusing the provided parameters.JwtAuthenticationToken(Jwt jwt, Object principal, Collection<? extends GrantedAuthority> authorities) Constructs aJwtAuthenticationTokenusing the provided parameters.JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities) Constructs aJwtAuthenticationTokenusing the provided parameters.JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String name) Constructs aJwtAuthenticationTokenusing the provided parameters.protectedJwtAuthenticationToken(JwtAuthenticationToken.Builder<?> builder) -
Method Summary
Modifier and TypeMethodDescriptiongetName()The principal name which is, by default, theJwt's subject.Returns the attributes of the access token.Return anAuthentication.Builderbased on this instance.Methods inherited from class AbstractOAuth2TokenAuthenticationToken
getCredentials, getPrincipal, getTokenMethods inherited from class AbstractAuthenticationToken
equals, eraseCredentials, getAuthorities, getDetails, hashCode, isAuthenticated, setAuthenticated, setDetails, toString
-
Constructor Details
-
JwtAuthenticationToken
Constructs aJwtAuthenticationTokenusing the provided parameters.- Parameters:
jwt- the JWT
-
JwtAuthenticationToken
Constructs aJwtAuthenticationTokenusing the provided parameters.- Parameters:
jwt- the JWTauthorities- the authorities assigned to the JWT
-
JwtAuthenticationToken
public JwtAuthenticationToken(Jwt jwt, Collection<? extends GrantedAuthority> authorities, String name) Constructs aJwtAuthenticationTokenusing the provided parameters.- Parameters:
jwt- the JWTauthorities- the authorities assigned to the JWTname- the principal name
-
JwtAuthenticationToken
-
JwtAuthenticationToken
public JwtAuthenticationToken(Jwt jwt, Object principal, Collection<? extends GrantedAuthority> authorities) Constructs aJwtAuthenticationTokenusing the provided parameters.- Parameters:
jwt- the JWTprincipal- the principalauthorities- the authorities assigned to the JWT- Since:
- 7.1
-
-
Method Details
-
getTokenAttributes
Description copied from class:AbstractOAuth2TokenAuthenticationTokenReturns the attributes of the access token.- Specified by:
getTokenAttributesin classAbstractOAuth2TokenAuthenticationToken<Jwt>- Returns:
- a
Mapof the attributes in the access token.
-
getName
-
toBuilder
Description copied from interface:AuthenticationReturn anAuthentication.Builderbased on this instance. By default, returns a builder that builds aSimpleAuthentication.Although a
defaultmethod, allAuthenticationimplementations should implement this. The reason is to ensure that theAuthenticationtype is preserved whenAuthentication.Builder.build()is invoked. This is especially important in the event that your authentication implementation contains custom fields.This isn't strictly necessary since it is recommended that applications code to the
Authenticationinterface and that custom information is often contained in theAuthentication.getPrincipal()value.- Returns:
- an
Authentication.Builderfor building a newAuthenticationbased on this instance
-