Class JWTAuthenticationHandler
- java.lang.Object
 - 
- com.jalios.jcms.authentication.AuthenticationHandler
 - 
- com.jalios.jcms.authentication.handlers.JWTAuthenticationHandler
 
 
 
- 
- All Implemented Interfaces:
 PluginComponent,JPropertiesListener,java.lang.Comparable<AuthenticationHandler>
public class JWTAuthenticationHandler extends AuthenticationHandler implements JPropertiesListener
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTHENTICATION_FROM_JWTName of request attribute indicating that this request was authenticated using JWTstatic java.lang.StringJWT_CLAIM_DELEGATE_MEMBER_IDName of claim to specify the delegate member id to be set if athenticated with specified JWT Token.static java.lang.StringJWT_CLAIM_IP_MASKName of claim containing the IP mask defining IPs authorized with the JWT token.static java.lang.StringJWT_CLAIM_METHODSName of claim containing the HTTP methods authorized with the JWT token.static java.lang.StringJWT_CLAIM_URLName of claim containing the URL authorized to be access with the JWT token (can be an URL prefix prefix if claimJWT_CLAIM_URL_PREFIX_LENGTHwas specified)static java.lang.StringJWT_CLAIM_URL_PREFIX_LENGTHName of claim containing the length of the URL authorized to be access with the JWT token (if unspecified, an exact URL match will be expected)static java.lang.StringJWT_CLAIMSName of request attribute used to store the JwtClaims that were validated for this requeststatic intORDER_CLIENT_CERTIFICATE_HANDLER- 
Fields inherited from class com.jalios.jcms.authentication.AuthenticationHandler
channel, GENERIC_BAD_AUTHENTICATION_MSG, REVISION 
- 
Fields inherited from interface com.jalios.util.JPropertiesListener
REVISION 
 - 
 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JWTAuthenticationHandlergetInstance()static org.jose4j.jwt.JwtClaimsgetJwtClaims(javax.servlet.http.HttpServletRequest request)Retrieve the JWT claims that were validated for this request (as long it was authenticated using JWT).static java.lang.StringgetJwtClaimsJson(javax.servlet.http.HttpServletRequest request)Retrieve the JWT claims that were validated for this request (as long it was authenticated using JWT).static booleanisAuthenticatedWithJWT(javax.servlet.http.HttpServletRequest request)Check if the specified request was authenticated using a JWT tokenbooleanisEnabled()voidloadProperties()This method will be called by the AuthenticationManager each time the Channel properties are loaded/reloaded.
You can use it to reload properties that might have been changed.
This method is called during initialization of the AuthenticationManagervoidlogin(AuthenticationContext ctxt)Authenticate a member.voidpropertiesChange(JProperties properties)Invoked after properties have been modified in JCMS and save on disk. 
 - 
 
- 
- 
Field Detail
- 
AUTHENTICATION_FROM_JWT
public static final java.lang.String AUTHENTICATION_FROM_JWT
Name of request attribute indicating that this request was authenticated using JWT- Since:
 - jcms-10.0.4 / JCMS-7781
 - See Also:
 isAuthenticatedWithJWT(HttpServletRequest), Constant Field Values
 
- 
JWT_CLAIMS
public static final java.lang.String JWT_CLAIMS
Name of request attribute used to store the JwtClaims that were validated for this request- Since:
 - jcms-10.0.4 / JCMS-7443
 - See Also:
 getJwtClaims(HttpServletRequest),getJwtClaimsJson(HttpServletRequest), Constant Field Values
 
- 
JWT_CLAIM_IP_MASK
public static final java.lang.String JWT_CLAIM_IP_MASK
Name of claim containing the IP mask defining IPs authorized with the JWT token.- See Also:
 - Constant Field Values
 
 
- 
JWT_CLAIM_METHODS
public static final java.lang.String JWT_CLAIM_METHODS
Name of claim containing the HTTP methods authorized with the JWT token.- See Also:
 - Constant Field Values
 
 
- 
JWT_CLAIM_URL
public static final java.lang.String JWT_CLAIM_URL
Name of claim containing the URL authorized to be access with the JWT token (can be an URL prefix prefix if claimJWT_CLAIM_URL_PREFIX_LENGTHwas specified)- See Also:
 - Constant Field Values
 
 
- 
JWT_CLAIM_URL_PREFIX_LENGTH
public static final java.lang.String JWT_CLAIM_URL_PREFIX_LENGTH
Name of claim containing the length of the URL authorized to be access with the JWT token (if unspecified, an exact URL match will be expected)- See Also:
 - Constant Field Values
 
 
- 
JWT_CLAIM_DELEGATE_MEMBER_ID
public static final java.lang.String JWT_CLAIM_DELEGATE_MEMBER_ID
Name of claim to specify the delegate member id to be set if athenticated with specified JWT Token.Example to propagate the current delegate member :
JwtClaims claims = JwtManager.getInstance().generateDefaultClaims(someMember, [...]); claims.setClaim(JWTAuthenticationHandler.JWT_CLAIM_DELEGATE_MEMBER_ID, JcmsUtil.getId(Channel.getChannel().getCurrentDelegateMember()));- Since:
 - jcms-10.0.6 / JCMS-8856
 - See Also:
 - Constant Field Values
 
 
- 
ORDER_CLIENT_CERTIFICATE_HANDLER
public static final int ORDER_CLIENT_CERTIFICATE_HANDLER
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
getInstance
public static final JWTAuthenticationHandler getInstance()
 
- 
isEnabled
public boolean isEnabled()
 
- 
loadProperties
public void loadProperties()
Description copied from class:AuthenticationHandlerThis method will be called by the AuthenticationManager each time the Channel properties are loaded/reloaded.
You can use it to reload properties that might have been changed.
This method is called during initialization of the AuthenticationManager- Overrides:
 loadPropertiesin classAuthenticationHandler
 
- 
login
public void login(AuthenticationContext ctxt) throws java.io.IOException
Description copied from class:AuthenticationHandlerAuthenticate a member.
This method is invoked by the authentication chain on each request.
A typical implementation of this method would follow the following pattern :- Examine informations required to perform the authentication through
       the 
AuthenticationContextobject (request, response, login.. etc) - Perform your authentication before chain invokation and set the logged Member
       
AuthenticationContext.setLoggedMember(com.jalios.jcms.Member) - a) Either invoke the next entity in the chain using 
AuthenticationContext.doChain(), - b) or else skip the chain invokation and block other authentication handler of the chain (do this with caution...)
 - Perform redirection, set information/warning/error message or any
       other process, after chain invokation, using 
AuthenticationContext. 
Default implementation is to invoke the next handler in the chain.- Overrides:
 loginin classAuthenticationHandler- Parameters:
 ctxt- theAuthenticationContextused for this login- Throws:
 java.io.IOException
 - Examine informations required to perform the authentication through
       the 
 
- 
propertiesChange
public void propertiesChange(JProperties properties)
Description copied from interface:JPropertiesListenerInvoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getPropertiesorchannel.getProperty.- Specified by:
 propertiesChangein interfaceJPropertiesListener- Parameters:
 properties- the properties which have been submitted to change
 
- 
isAuthenticatedWithJWT
public static boolean isAuthenticatedWithJWT(javax.servlet.http.HttpServletRequest request)
Check if the specified request was authenticated using a JWT token- Parameters:
 request- the current HttpServletRequest, may be null- Returns:
 - true if request was authenticated with JWT, false otherwise
 - Since:
 - jcms-10.0.4 / JCMS-7781
 
 
- 
getJwtClaimsJson
public static java.lang.String getJwtClaimsJson(javax.servlet.http.HttpServletRequest request)
Retrieve the JWT claims that were validated for this request (as long it was authenticated using JWT).- Parameters:
 request- the current HttpServletRequest, may be null- Returns:
 - the JWT claims as a raw JSON string (if request was authenticated with JWT), null otherwise
 - Since:
 - jcms-10.0.4 / JCMS-7443
 
 
- 
getJwtClaims
public static org.jose4j.jwt.JwtClaims getJwtClaims(javax.servlet.http.HttpServletRequest request)
Retrieve the JWT claims that were validated for this request (as long it was authenticated using JWT).- Parameters:
 request- the current HttpServletRequest, may be null- Returns:
 - the JWT claims (if request was authenticated with JWT), null otherwise
 - Since:
 - jcms-10.0.4 / JCMS-7443
 
 
 - 
 
 -