Class BearerTokenAuthentication
java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
org.springframework.security.oauth2.server.resource.authentication.AbstractOAuth2TokenAuthenticationToken<OAuth2AccessToken>
org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication
- All Implemented Interfaces:
Serializable,Principal,Authentication,CredentialsContainer
@Transient
public class BearerTokenAuthentication
extends AbstractOAuth2TokenAuthenticationToken<OAuth2AccessToken>
An
Authentication token that represents a
successful authentication as obtained through a bearer token.- Since:
- 5.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder preserving the concreteAuthenticationtypeNested classes/interfaces inherited from class org.springframework.security.oauth2.server.resource.authentication.AbstractOAuth2TokenAuthenticationToken
AbstractOAuth2TokenAuthenticationToken.AbstractOAuth2TokenAuthenticationBuilder<T extends OAuth2Token,B extends AbstractOAuth2TokenAuthenticationToken.AbstractOAuth2TokenAuthenticationBuilder<T, B>> Nested classes/interfaces inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
AbstractAuthenticationToken.AbstractAuthenticationBuilder<B extends AbstractAuthenticationToken.AbstractAuthenticationBuilder<B>> -
Constructor Summary
ConstructorsModifierConstructorDescriptionBearerTokenAuthentication(OAuth2AuthenticatedPrincipal principal, OAuth2AccessToken credentials, Collection<? extends GrantedAuthority> authorities) Constructs aBearerTokenAuthenticationwith the provided argumentsprotected -
Method Summary
Modifier and TypeMethodDescriptionReturns the attributes of the access token.Return anAuthentication.Builderbased on this instance.Methods inherited from class org.springframework.security.oauth2.server.resource.authentication.AbstractOAuth2TokenAuthenticationToken
getCredentials, getPrincipal, getTokenMethods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken
equals, eraseCredentials, getAuthorities, getDetails, getName, hashCode, isAuthenticated, setAuthenticated, setDetails, toString
-
Constructor Details
-
BearerTokenAuthentication
public BearerTokenAuthentication(OAuth2AuthenticatedPrincipal principal, OAuth2AccessToken credentials, Collection<? extends GrantedAuthority> authorities) Constructs aBearerTokenAuthenticationwith the provided arguments- Parameters:
principal- The OAuth 2.0 attributescredentials- The verified tokenauthorities- The authorities associated with the given token
-
BearerTokenAuthentication
-
-
Method Details
-
getTokenAttributes
Description copied from class:AbstractOAuth2TokenAuthenticationTokenReturns the attributes of the access token.- Specified by:
getTokenAttributesin classAbstractOAuth2TokenAuthenticationToken<OAuth2AccessToken>- Returns:
- a
Mapof the attributes in the access token.
-
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
-