|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.security.oauth2.provider.token.JwtTokenServices
public class JwtTokenServices
Token services for authorization server and resource server based on JWT encoded token values. There is no need for shared storage because all of the state is carried in the token values.
| Field Summary | |
|---|---|
static String |
TOKEN_ID
Field name for token id. |
| Constructor Summary | |
|---|---|
JwtTokenServices()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
OAuth2AccessToken |
createAccessToken(OAuth2Authentication authentication)
Create an access token associated with the specified credentials. |
OAuth2AccessToken |
getAccessToken(OAuth2Authentication authentication)
Retrieve an access token stored against the provided authentication key, if it exists. |
protected int |
getAccessTokenValiditySeconds(OAuth2Request authorizationRequest)
The access token validity period in seconds |
protected int |
getRefreshTokenValiditySeconds(OAuth2Request authorizationRequest)
The refresh token validity period in seconds |
protected boolean |
isExpired(OAuth2AccessToken expiringToken)
Utility method to check if a token is expired. |
protected boolean |
isSupportRefreshToken(OAuth2Request authorizationRequest)
Is a refresh token supported for this client (or the global setting if clientDetailsService is not set. |
OAuth2Authentication |
loadAuthentication(String token)
Load the credentials for the specified access token. |
OAuth2AccessToken |
readAccessToken(String token)
Retrieve the full access token details from just the value. |
OAuth2AccessToken |
refreshAccessToken(String refreshTokenValue,
TokenRequest request)
Refresh an access token. |
void |
setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
The default validity (in seconds) of the access token. |
void |
setAuthenticationKeyGenerator(AuthenticationKeyGenerator authenticationKeyGenerator)
The key generator that is used to extract a unique identifier for an access token. |
void |
setClientDetailsService(ClientDetailsService clientDetailsService)
The client details service to use for looking up clients (if necessary). |
void |
setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)
The validity (in seconds) of the refresh token. |
void |
setReuseRefreshToken(boolean reuseRefreshToken)
Whether to reuse refresh tokens (until expired). |
void |
setSigningKey(String key)
Sets the JWT signing key. |
void |
setSupportRefreshToken(boolean supportRefreshToken)
Whether to support the refresh token. |
void |
setTokenEnhancer(TokenEnhancer accessTokenEnhancer)
An access token enhancer that will be applied to a new token before it is saved in the token store. |
void |
setVerifierKey(String key)
The key used for verifying signatures produced by this class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String TOKEN_ID
| Constructor Detail |
|---|
public JwtTokenServices()
| Method Detail |
|---|
public void setSupportRefreshToken(boolean supportRefreshToken)
supportRefreshToken - Whether to support the refresh token.public void setReuseRefreshToken(boolean reuseRefreshToken)
reuseRefreshToken - Whether to reuse refresh tokens (until expired).public void setTokenEnhancer(TokenEnhancer accessTokenEnhancer)
accessTokenEnhancer - the access token enhancer to setpublic void setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds)
refreshTokenValiditySeconds - The validity (in seconds) of the refresh token.public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds)
accessTokenValiditySeconds - The validity (in seconds) of the access token.public void setClientDetailsService(ClientDetailsService clientDetailsService)
setAccessTokenValiditySeconds(int).
clientDetailsService - the client details servicepublic void setAuthenticationKeyGenerator(AuthenticationKeyGenerator authenticationKeyGenerator)
authenticationKeyGenerator - a key generatorpublic void setVerifierKey(String key)
key - the signature verification key (typically an RSA public key)public void setSigningKey(String key)
key - the key to be used for signing JWTs.
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanException
public OAuth2Authentication loadAuthentication(String token)
throws org.springframework.security.core.AuthenticationException
ResourceServerTokenServices
loadAuthentication in interface ResourceServerTokenServicestoken - The access token value.
org.springframework.security.core.AuthenticationException - If the access token is expiredpublic OAuth2AccessToken readAccessToken(String token)
ResourceServerTokenServices
readAccessToken in interface ResourceServerTokenServicestoken - the token value
public OAuth2AccessToken createAccessToken(OAuth2Authentication authentication)
throws org.springframework.security.core.AuthenticationException
AuthorizationServerTokenServices
createAccessToken in interface AuthorizationServerTokenServicesauthentication - The credentials associated with the access token.
org.springframework.security.core.AuthenticationException - If the credentials are inadequate.
public OAuth2AccessToken refreshAccessToken(String refreshTokenValue,
TokenRequest request)
throws org.springframework.security.core.AuthenticationException
AuthorizationServerTokenServices
refreshAccessToken in interface AuthorizationServerTokenServicesrefreshTokenValue - The details about the refresh token.request - The incoming token request.
org.springframework.security.core.AuthenticationException - If the refresh token is invalid or expired.public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication)
AuthorizationServerTokenServices
getAccessToken in interface AuthorizationServerTokenServicesauthentication - the authentication key for the access token
protected boolean isExpired(OAuth2AccessToken expiringToken)
expiringToken - an access token
protected boolean isSupportRefreshToken(OAuth2Request authorizationRequest)
clientDetailsService is not set.
authorizationRequest - the current authorization request
protected int getAccessTokenValiditySeconds(OAuth2Request authorizationRequest)
authorizationRequest - the current authorization request
protected int getRefreshTokenValiditySeconds(OAuth2Request authorizationRequest)
authorizationRequest - the current authorization request
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||