Class JwtAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider
-
- All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider
public final class JwtAuthenticationProvider extends java.lang.Object implements org.springframework.security.authentication.AuthenticationProviderAnAuthenticationProviderimplementation of theJwt-encoded Bearer Tokens for protecting OAuth 2.0 Resource Servers.This
AuthenticationProvideris responsible for decoding and verifying aJwt-encoded access token, returning its claims set as part of theAuthenticationstatement.Scopes are translated into
GrantedAuthoritys according to the following algorithm: 1. If there is a "scope" or "scp" attribute, then if aString, then split by spaces and return, or if aCollection, then simply return 2. Take the resultingCollectionofStrings and prepend the "SCOPE_" keyword, adding asGrantedAuthoritys.- Since:
- 5.1
- See Also:
AuthenticationProvider,JwtDecoder
-
-
Constructor Summary
Constructors Constructor Description JwtAuthenticationProvider(org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.security.core.Authenticationauthenticate(org.springframework.security.core.Authentication authentication)Decode and validate the Bearer Token.voidsetJwtAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,? extends org.springframework.security.authentication.AbstractAuthenticationToken> jwtAuthenticationConverter)booleansupports(java.lang.Class<?> authentication)
-
-
-
Method Detail
-
authenticate
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication) throws org.springframework.security.core.AuthenticationExceptionDecode and validate the Bearer Token.- Specified by:
authenticatein interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
authentication- the authentication request object.- Returns:
- A successful authentication
- Throws:
org.springframework.security.core.AuthenticationException- if authentication failed for some reason
-
supports
public boolean supports(java.lang.Class<?> authentication)
- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider
-
setJwtAuthenticationConverter
public void setJwtAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,? extends org.springframework.security.authentication.AbstractAuthenticationToken> jwtAuthenticationConverter)
-
-