Class JwtAuthenticator
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.valves.ValveBase
org.apache.catalina.authenticator.AuthenticatorBase
media.pepperpot.tca.authenticator.JwtAuthenticator
- All Implemented Interfaces:
MBeanRegistration
,javax.security.auth.message.config.RegistrationListener
,org.apache.catalina.Authenticator
,org.apache.catalina.Contained
,org.apache.catalina.JmxEnabled
,org.apache.catalina.Lifecycle
,org.apache.catalina.Valve
public class JwtAuthenticator
extends org.apache.catalina.authenticator.AuthenticatorBase
If a JWT Bearer token is included with the request, validate the token and return the token subject as the principal.
- Author:
- minfrin
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.catalina.authenticator.AuthenticatorBase
org.apache.catalina.authenticator.AuthenticatorBase.AllowCorsPreflight
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
org.apache.catalina.Lifecycle.SingleUse
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
ConstantALLOW_PLAIN="media.pepperpot.jwt.allowPlain"
static final String
ConstantBEARER="BEARER"
static final String
ConstantDEFAULT_ALLOW_PLAIN="Boolean.FALSE.toString()"
static final String
ConstantJWE_ALGORITHM="media.pepperpot.jwt.JWEAlgorithm"
static final String
ConstantJWE_ENCRYPTION_METHOD="media.pepperpot.jwt.JWEEncryptionMethod"
static final String
ConstantJWE_JWK_SET_FILE="media.pepperpot.jwe.JwkSetFile"
static final String
ConstantJWE_REMOTE_JWK_SET_URL="media.pepperpot.jwe.RemoteJwkSetUrl"
static final String
ConstantJWE_SECRET_FILE="media.pepperpot.jwe.SecretFile"
static final String
ConstantJWS_ALGORITHM="media.pepperpot.jwt.JWSAlgorithm"
static final String
ConstantJWS_JWK_SET_FILE="media.pepperpot.jws.JwkSetFile"
static final String
ConstantJWS_REMOTE_JWK_SET_URL="media.pepperpot.jws.RemoteJwkSetUrl"
static final String
ConstantJWS_SECRET_FILE="media.pepperpot.jws.SecretFile"
static final String
ConstantJWT_ACCEPTED_AUDIENCE="media.pepperpot.jwt.AcceptedAudience"
static final String
ConstantJWT_MAX_CLOCK_SKEW="media.pepperpot.jwt.MaxClockSkew"
static final String
ConstantJWT_MAX_CLOCK_SKEW_DEFAULT="60"
static final String
ConstantJWT_PROHIBITED_CLAIMS="media.pepperpot.jwt.ProhibitedClaims"
static final String
ConstantJWT_REQUIRED_CLAIMS="media.pepperpot.jwt.RequiredClaims"
protected Properties
Properties passed to the authenticator.Fields inherited from class org.apache.catalina.authenticator.AuthenticatorBase
alwaysUseSession, AUTH_HEADER_NAME, cache, changeSessionIdOnAuthentication, context, disableProxyCaching, jaspicCallbackHandlerClass, REALM_NAME, securePagesWithPragma, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, sendAuthInfoResponseHeaders, sessionIdGenerator, sm, sso
Fields inherited from class org.apache.catalina.valves.ValveBase
asyncSupported, container, containerLog, next
Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserver
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
Constructor Summary
ConstructorDescriptionConstructor for JwtAuthenticator.JwtAuthenticator
(Properties properties) Constructor for JwtAuthenticator. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
doAuthenticate
(org.apache.catalina.connector.Request request, javax.servlet.http.HttpServletResponse response) protected String
protected static String
parseAuthorization
(Properties properties, org.apache.catalina.connector.Request request, String claimName) Parse the Authorization header, and extract the sub from the first valid JWT found.Methods inherited from class org.apache.catalina.authenticator.AuthenticatorBase
allowCorsPreflightBypass, associate, authenticate, changeSessionID, checkForCachedAuthentication, doLogin, getAllowCorsPreflight, getAlwaysUseSession, getCache, getChangeSessionIdOnAuthentication, getContainer, getDisableProxyCaching, getJaspicCallbackHandlerClass, getRealmName, getSecurePagesWithPragma, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, invoke, isContinuationRequired, isPreemptiveAuthPossible, isSendAuthInfoResponseHeaders, login, logout, notify, reauthenticateFromSSO, register, register, setAllowCorsPreflight, setAlwaysUseSession, setCache, setChangeSessionIdOnAuthentication, setContainer, setDisableProxyCaching, setJaspicCallbackHandlerClass, setSecurePagesWithPragma, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSendAuthInfoResponseHeaders, startInternal, stopInternal
Methods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setNext, toString
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Field Details
-
BEARER
ConstantBEARER="BEARER"
- See Also:
-
ALLOW_PLAIN
ConstantALLOW_PLAIN="media.pepperpot.jwt.allowPlain"
- See Also:
-
DEFAULT_ALLOW_PLAIN
ConstantDEFAULT_ALLOW_PLAIN="Boolean.FALSE.toString()"
-
JWS_SECRET_FILE
ConstantJWS_SECRET_FILE="media.pepperpot.jws.SecretFile"
- See Also:
-
JWS_JWK_SET_FILE
ConstantJWS_JWK_SET_FILE="media.pepperpot.jws.JwkSetFile"
- See Also:
-
JWS_REMOTE_JWK_SET_URL
ConstantJWS_REMOTE_JWK_SET_URL="media.pepperpot.jws.RemoteJwkSetUrl"
- See Also:
-
JWS_ALGORITHM
ConstantJWS_ALGORITHM="media.pepperpot.jwt.JWSAlgorithm"
- See Also:
-
JWE_SECRET_FILE
ConstantJWE_SECRET_FILE="media.pepperpot.jwe.SecretFile"
- See Also:
-
JWE_JWK_SET_FILE
ConstantJWE_JWK_SET_FILE="media.pepperpot.jwe.JwkSetFile"
- See Also:
-
JWE_REMOTE_JWK_SET_URL
ConstantJWE_REMOTE_JWK_SET_URL="media.pepperpot.jwe.RemoteJwkSetUrl"
- See Also:
-
JWE_ALGORITHM
ConstantJWE_ALGORITHM="media.pepperpot.jwt.JWEAlgorithm"
- See Also:
-
JWE_ENCRYPTION_METHOD
ConstantJWE_ENCRYPTION_METHOD="media.pepperpot.jwt.JWEEncryptionMethod"
- See Also:
-
JWT_MAX_CLOCK_SKEW
ConstantJWT_MAX_CLOCK_SKEW="media.pepperpot.jwt.MaxClockSkew"
- See Also:
-
JWT_MAX_CLOCK_SKEW_DEFAULT
ConstantJWT_MAX_CLOCK_SKEW_DEFAULT="60"
- See Also:
-
JWT_ACCEPTED_AUDIENCE
ConstantJWT_ACCEPTED_AUDIENCE="media.pepperpot.jwt.AcceptedAudience"
- See Also:
-
JWT_REQUIRED_CLAIMS
ConstantJWT_REQUIRED_CLAIMS="media.pepperpot.jwt.RequiredClaims"
- See Also:
-
JWT_PROHIBITED_CLAIMS
ConstantJWT_PROHIBITED_CLAIMS="media.pepperpot.jwt.ProhibitedClaims"
- See Also:
-
properties
Properties passed to the authenticator.
-
-
Constructor Details
-
JwtAuthenticator
public JwtAuthenticator()Constructor for JwtAuthenticator.
-
JwtAuthenticator
Constructor for JwtAuthenticator.
- Parameters:
properties
- aProperties
object.
-
-
Method Details
-
parseAuthorization
protected static String parseAuthorization(Properties properties, org.apache.catalina.connector.Request request, String claimName) Parse the Authorization header, and extract the sub from the first valid JWT found.- Parameters:
request
- aRequest
object.properties
- aProperties
object.claimName
- aString
object.- Returns:
- a
String
object.
-
getAuthMethod
- Specified by:
getAuthMethod
in classorg.apache.catalina.authenticator.AuthenticatorBase
-
doAuthenticate
protected boolean doAuthenticate(org.apache.catalina.connector.Request request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
doAuthenticate
in classorg.apache.catalina.authenticator.AuthenticatorBase
- Throws:
IOException
-