public class JwtAccessTokenConverter extends Object implements TokenEnhancer, AccessTokenConverter, InitializingBean
TokenEnhancer
when tokens are
granted.TokenEnhancer
,
AccessTokenConverter
Modifier and Type | Field and Description |
---|---|
static String |
ACCESS_TOKEN_ID
Field name for access token id.
|
static String |
TOKEN_ID
Field name for token id.
|
ATI, AUD, AUTHORITIES, CLIENT_ID, EXP, GRANT_TYPE, JTI, SCOPE
Constructor and Description |
---|
JwtAccessTokenConverter() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Map<String,?> |
convertAccessToken(OAuth2AccessToken token,
OAuth2Authentication authentication) |
protected Map<String,Object> |
decode(String token) |
protected String |
encode(OAuth2AccessToken accessToken,
OAuth2Authentication authentication) |
OAuth2AccessToken |
enhance(OAuth2AccessToken accessToken,
OAuth2Authentication authentication)
Provides an opportunity for customization of an access token (e.g. through its additional information map) during
the process of creating a new token for use by a client.
|
OAuth2AccessToken |
extractAccessToken(String value,
Map<String,?> map)
Recover an access token from the converted value.
|
OAuth2Authentication |
extractAuthentication(Map<String,?> map)
Recover an
OAuth2Authentication from the converted access token. |
AccessTokenConverter |
getAccessTokenConverter() |
JwtClaimsSetVerifier |
getJwtClaimsSetVerifier() |
Map<String,String> |
getKey()
Get the verification key for the token signatures.
|
boolean |
isPublic() |
boolean |
isRefreshToken(OAuth2AccessToken token) |
void |
setAccessTokenConverter(AccessTokenConverter tokenConverter) |
void |
setJwtClaimsSetVerifier(JwtClaimsSetVerifier jwtClaimsSetVerifier) |
void |
setKeyPair(KeyPair keyPair) |
void |
setSigner(org.springframework.security.jwt.crypto.sign.Signer signer)
Unconditionally set the signer to use (if needed).
|
void |
setSigningKey(String key)
Sets the JWT signing key.
|
void |
setVerifier(org.springframework.security.jwt.crypto.sign.SignatureVerifier verifier)
Unconditionally set the verifier (the verifer key is then ignored).
|
void |
setVerifierKey(String key)
The key used for verifying signatures produced by this class.
|
public static final String TOKEN_ID
public static final String ACCESS_TOKEN_ID
public void setAccessTokenConverter(AccessTokenConverter tokenConverter)
tokenConverter
- the tokenConverter to setpublic AccessTokenConverter getAccessTokenConverter()
public JwtClaimsSetVerifier getJwtClaimsSetVerifier()
JwtClaimsSetVerifier
used to verify the claim(s) in the JWT Claims Setpublic void setJwtClaimsSetVerifier(JwtClaimsSetVerifier jwtClaimsSetVerifier)
jwtClaimsSetVerifier
- the JwtClaimsSetVerifier
used to verify the claim(s) in the JWT Claims Setpublic Map<String,?> convertAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication)
convertAccessToken
in interface AccessTokenConverter
token
- an access tokenauthentication
- the current OAuth authenticationpublic OAuth2AccessToken extractAccessToken(String value, Map<String,?> map)
AccessTokenConverter
AccessTokenConverter.convertAccessToken(OAuth2AccessToken, OAuth2Authentication)
.extractAccessToken
in interface AccessTokenConverter
value
- the token valuemap
- information decoded from an access tokenpublic OAuth2Authentication extractAuthentication(Map<String,?> map)
AccessTokenConverter
OAuth2Authentication
from the converted access token. Half the inverse of
AccessTokenConverter.convertAccessToken(OAuth2AccessToken, OAuth2Authentication)
.extractAuthentication
in interface AccessTokenConverter
map
- information decoded from an access tokenpublic void setVerifier(org.springframework.security.jwt.crypto.sign.SignatureVerifier verifier)
verifier
- the value to usepublic void setSigner(org.springframework.security.jwt.crypto.sign.Signer signer)
signer
- the value to usepublic Map<String,String> getKey()
public void setKeyPair(KeyPair keyPair)
public void setSigningKey(String key)
key
- the key to be used for signing JWTs.public boolean isPublic()
public void setVerifierKey(String key)
key
- the signature verification key (typically an RSA public key)public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication)
TokenEnhancer
enhance
in interface TokenEnhancer
accessToken
- the current access token with its expiration and refresh tokenauthentication
- the current authentication including client and user detailspublic boolean isRefreshToken(OAuth2AccessToken token)
protected String encode(OAuth2AccessToken accessToken, OAuth2Authentication authentication)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
Copyright © 2019. All rights reserved.