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.AllowCorsPreflightNested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
org.apache.catalina.Lifecycle.SingleUse -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstantALLOW_PLAIN="media.pepperpot.jwt.allowPlain"static final StringConstantBEARER="BEARER"static final StringConstantDEFAULT_ALLOW_PLAIN="Boolean.FALSE.toString()"static final StringConstantJWE_ALGORITHM="media.pepperpot.jwt.JWEAlgorithm"static final StringConstantJWE_ENCRYPTION_METHOD="media.pepperpot.jwt.JWEEncryptionMethod"static final StringConstantJWE_JWK_SET_FILE="media.pepperpot.jwe.JwkSetFile"static final StringConstantJWE_REMOTE_JWK_SET_URL="media.pepperpot.jwe.RemoteJwkSetUrl"static final StringConstantJWE_SECRET_FILE="media.pepperpot.jwe.SecretFile"static final StringConstantJWS_ALGORITHM="media.pepperpot.jwt.JWSAlgorithm"static final StringConstantJWS_JWK_SET_FILE="media.pepperpot.jws.JwkSetFile"static final StringConstantJWS_REMOTE_JWK_SET_URL="media.pepperpot.jws.RemoteJwkSetUrl"static final StringConstantJWS_SECRET_FILE="media.pepperpot.jws.SecretFile"static final StringConstantJWT_ACCEPTED_AUDIENCE="media.pepperpot.jwt.AcceptedAudience"static final StringConstantJWT_MAX_CLOCK_SKEW="media.pepperpot.jwt.MaxClockSkew"static final StringConstantJWT_MAX_CLOCK_SKEW_DEFAULT="60"static final StringConstantJWT_PROHIBITED_CLAIMS="media.pepperpot.jwt.ProhibitedClaims"static final StringConstantJWT_REQUIRED_CLAIMS="media.pepperpot.jwt.RequiredClaims"protected PropertiesProperties 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, ssoFields inherited from class org.apache.catalina.valves.ValveBase
asyncSupported, container, containerLog, nextFields inherited from class org.apache.catalina.util.LifecycleMBeanBase
mserverFields 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
ConstructorsConstructorDescriptionConstructor for JwtAuthenticator.JwtAuthenticator(Properties properties) Constructor for JwtAuthenticator. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandoAuthenticate(org.apache.catalina.connector.Request request, javax.servlet.http.HttpServletResponse response) protected Stringprotected static StringparseAuthorization(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, stopInternalMethods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setNext, toStringMethods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisterMethods 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- aPropertiesobject.
-
-
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- aRequestobject.properties- aPropertiesobject.claimName- aStringobject.- Returns:
- a
Stringobject.
-
getAuthMethod
- Specified by:
getAuthMethodin classorg.apache.catalina.authenticator.AuthenticatorBase
-
doAuthenticate
protected boolean doAuthenticate(org.apache.catalina.connector.Request request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
doAuthenticatein classorg.apache.catalina.authenticator.AuthenticatorBase- Throws:
IOException
-