public class DefaultJWTAuthority extends DefaultJWTConsumer implements JWTAuthority, org.springframework.beans.factory.InitializingBean
| Modifier and Type | Field and Description |
|---|---|
protected AuthorityKeyProvider |
authorityKeyProvider |
protected org.springframework.security.crypto.password.PasswordEncoder |
passwordEncoder |
protected boolean |
refreshSessionOnAuthentication |
protected boolean |
refreshSessionOnRenewal |
protected int |
sessionInvalidationDelayInMinutes |
protected SessionProvider |
sessionProvider |
protected int |
tokenLifetimeInSeconds |
protected org.springframework.security.core.userdetails.UserDetailsChecker |
userDetailsChecker |
protected org.springframework.security.core.userdetails.UserDetailsService |
userDetailsService |
authoritiesParameterName, jwtAuthorityConnector, jwtRequestResponseHandler, sessionIdParameterName, signingKeyResolver, SPRING_SECURITY_JWT_AUTHORITIES_PARAMETER_NAME, SPRING_SECURITY_JWT_SESSION_ID_PARAMETER_NAME, SPRING_SECURITY_JWT_XSRF_PARAMETER_NAME, TEN_YEARS_IN_SECONDS, xsrfParameterName| Constructor and Description |
|---|
DefaultJWTAuthority(org.springframework.security.core.userdetails.UserDetailsService userDetailsService) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
JWTContext |
authenticateJWTRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Authenticate HTTP request if the request contains JWT and related tokens are valid.
The created JWTAuthentication object (which is also the part of JWTContext) is implicitly
attached into SecurityContextHolder to inform spring security about the authenticated user. |
JWTContext |
authenticateLoginRequest(Credentials credentials,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Authenticate login request if the provided credentials are valid.
The created JWTAuthentication object (which is also the part of
JWTContext) is implicitly attached into SecurityContextHolder to
inform spring security about the authenticated user. |
protected String |
convertToString(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) |
JWTContext |
create(String principal,
Parameters parameters)
Creates
JWTContext for given principal. |
JWTContext |
createAndAttach(String principal,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Parameters parameters)
Create a fully fledged
JWTContext for given principal and attach
it into given HTTP Response. |
protected String |
generateXSRFToken() |
protected List<String> |
getAuthorityListAsString(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) |
protected org.springframework.security.core.userdetails.UserDetails |
getUserDetails(String principal) |
org.springframework.security.core.userdetails.UserDetailsService |
getUserDetailsService() |
protected void |
handleJWTContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
JWTContext jwtContext) |
boolean |
isTokenRenewalEnabled() |
protected boolean |
isXSRFProtectionDisabled(Parameters parameters) |
protected void |
refreshSession(JWTContext jwtContext) |
JWTContext |
renew(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Authenticate HTTP request if the request contains JWT and renew it if renewable.
|
JWTContext |
renew(TokenContainer tokenContainer,
Parameters parameters)
Renew tokens given in the
TokenContainer object. |
void |
setAuthorityKeyProvider(AuthorityKeyProvider authorityKeyProvider) |
void |
setPasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
Set custom password encoder.
|
void |
setRefreshSessionOnAuthentication(boolean refreshSessionOnAuthentication)
Refresh related session on each JWT authentication step.
|
void |
setRefreshSessionOnRenewal(boolean refreshSessionOnRenewal)
Refresh related session on each JWT renewal.
|
void |
setSessionInvalidationDelayInMinutes(int sessionInvalidationDelayInMinutes)
Set session invalidation delay in minutes.
|
void |
setSessionProvider(SessionProvider sessionProvider) |
void |
setTokenLifetimeInSeconds(int tokenLifetimeInSeconds)
Set token lifetime in seconds.
|
void |
setUserDetailsChecker(org.springframework.security.core.userdetails.UserDetailsChecker userDetailsChecker)
Set
UserDetailsChecker which will be used to validate the loaded
UserDetails object. |
void |
setUserDetailsService(org.springframework.security.core.userdetails.UserDetailsService userDetailsService) |
createJWTContext, extractPrincipal, extractSessionId, getAuthorities, getJWTModeFromParameters, getJwtRequestResponseHandler, setAuthoritiesParameterName, setJWTAuthorityConnector, setJwtRequestResponseHandler, setSessionIdParameterName, setSigningKeyResolver, setXsrfParameterName, validate, validateXSRFclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvalidateprotected org.springframework.security.core.userdetails.UserDetailsService userDetailsService
protected SessionProvider sessionProvider
protected org.springframework.security.core.userdetails.UserDetailsChecker userDetailsChecker
protected int tokenLifetimeInSeconds
protected int sessionInvalidationDelayInMinutes
protected org.springframework.security.crypto.password.PasswordEncoder passwordEncoder
protected AuthorityKeyProvider authorityKeyProvider
protected boolean refreshSessionOnAuthentication
protected boolean refreshSessionOnRenewal
public DefaultJWTAuthority(org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
public JWTContext authenticateJWTRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
JWTConsumerJWTAuthentication object (which is also the part of JWTContext) is implicitly
attached into SecurityContextHolder to inform spring security about the authenticated user.authenticateJWTRequest in interface JWTConsumerauthenticateJWTRequest in class DefaultJWTConsumerrequest - HTTP requestresponse - HTTP responseJWTContext object.public JWTContext authenticateLoginRequest(Credentials credentials, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
JWTAuthorityJWTAuthentication object (which is also the part of
JWTContext) is implicitly attached into SecurityContextHolder to
inform spring security about the authenticated user.authenticateLoginRequest in interface JWTAuthoritycredentials - Credentials instance which contains principal (unique
user identifier like user name, user id, email address etc.)
and password.request - HTTP requestresponse - HTTP responseJWTContext object.public JWTContext createAndAttach(String principal, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Parameters parameters)
JWTAuthorityJWTContext for given principal and attach
it into given HTTP Response. JWTAuthentication object (which is also the part of
JWTContext) is implicitly attached into SecurityContextHolder to
inform spring security about the authenticated user.createAndAttach in interface JWTAuthorityprincipal - Unique user identifier. This can be the user name or user id
according to underlying implementation.request - HTTP request (may be used to read clients preferences for
token handling)response - HTTP responseparameters - Additional parameters to customize processing of the request.
Possible parameters and their effects may differ depending on
specific implementation. The parameters may be empty or null.JWTContext object.public JWTContext create(String principal, Parameters parameters) throws UserNotFoundException
JWTContext for given principal. A JWTContext
contains all relevant tokens (like JWT or XSRF Tokens) and
JWTAuthentication object, which is relevant for Spring-Security.create in interface JWTAuthorityprincipal - Unique user identifier. This can be the user name or user id
according to underlying implementation.parameters - Additional parameters to customize processing of the request.
Possible parameters and their effects may differ depending on
specific implementation. The parameters may be empty or null.JWTContext object.UserNotFoundException - if the user identified with given principal cannot be found.public JWTContext renew(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
JWTAuthorityJWTAuthentication object (which is also the part of JWTContext) is implicitly
attached into SecurityContextHolder to inform spring security about the authenticated user.renew in interface JWTAuthorityrequest - HTTP request (may be used to read clients preferences for token handling)response - HTTP responseJWTContext object.public JWTContext renew(TokenContainer tokenContainer, Parameters parameters)
JWTAuthorityTokenContainer object.renew in interface JWTAuthoritytokenContainer - TokenContainer instance which contains JWT and XSRF
tokens.parameters - Additional parameters to customize processing of the request.
Possible parameters and their effects may differ depending on
specific implementation. The parameters may be empty or null.JWTContext object.public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanafterPropertiesSet in class DefaultJWTConsumerExceptionpublic boolean isTokenRenewalEnabled()
public org.springframework.security.core.userdetails.UserDetailsService getUserDetailsService()
public void setUserDetailsService(org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
public void setSessionProvider(SessionProvider sessionProvider)
public void setAuthorityKeyProvider(AuthorityKeyProvider authorityKeyProvider)
public void setUserDetailsChecker(org.springframework.security.core.userdetails.UserDetailsChecker userDetailsChecker)
UserDetailsChecker which will be used to validate the loaded
UserDetails object.userDetailsChecker - An instance of user details checker implementation.public void setTokenLifetimeInSeconds(int tokenLifetimeInSeconds)
tokenLifetimeInSeconds - Token lifetime in seconds.public void setSessionInvalidationDelayInMinutes(int sessionInvalidationDelayInMinutes)
sessionInvalidationDelayInMinutes - Session invalidation delay in minutes.public void setPasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder passwordEncoder)
passwordEncoder - Password encoderpublic void setRefreshSessionOnAuthentication(boolean refreshSessionOnAuthentication)
refreshSessionOnAuthentication - public void setRefreshSessionOnRenewal(boolean refreshSessionOnRenewal)
refreshSessionOnRenewal - protected String generateXSRFToken()
protected String convertToString(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
protected org.springframework.security.core.userdetails.UserDetails getUserDetails(String principal)
protected List<String> getAuthorityListAsString(Collection<? extends org.springframework.security.core.GrantedAuthority> authorities)
protected void refreshSession(JWTContext jwtContext)
protected void handleJWTContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
JWTContext jwtContext)
handleJWTContext in class DefaultJWTConsumerprotected boolean isXSRFProtectionDisabled(Parameters parameters)
Copyright © 2017 S&C Software. All rights reserved.