public abstract class AuthenticatorBase extends ValveBase implements Authenticator, RegistrationListener
<security-constraint>
elements in the web application deployment descriptor. This functionality is implemented as a Valve so that it can be
omitted in environments that do not require these features. Individual implementations of each supported
authentication method can subclass this base class as required.
USAGE CONSTRAINT: When this class is utilized, the Context to which it is attached (or a parent Container in a hierarchy) must have an associated Realm that can be used for authenticating users and enumerating the roles to which they have been assigned.
USAGE CONSTRAINT: This Valve is only useful when processing HTTP requests. Requests of any other type will simply be passed through.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AuthenticatorBase.AllowCorsPreflight |
Lifecycle.SingleUse| Modifier and Type | Field and Description |
|---|---|
protected boolean |
alwaysUseSession
Should a session always be used once a user is authenticated?
|
protected static java.lang.String |
AUTH_HEADER_NAME
Authentication header
|
protected boolean |
cache
Should we cache authenticated Principals if the request is part of an HTTP session?
|
protected boolean |
changeSessionIdOnAuthentication
Should the session ID, if any, be changed upon a successful authentication to prevent a session fixation attack?
|
protected Context |
context
The Context to which this Valve is attached.
|
protected boolean |
disableProxyCaching
Flag to determine if we disable proxy caching, or leave the issue up to the webapp developer.
|
protected java.lang.String |
jaspicCallbackHandlerClass
The name of the JASPIC callback handler class.
|
protected static java.lang.String |
REALM_NAME
Default authentication realm name.
|
protected boolean |
securePagesWithPragma
Flag to determine if we disable proxy caching with headers incompatible with IE.
|
protected java.lang.String |
secureRandomAlgorithm
The name of the algorithm to use to create instances of
SecureRandom which are used to
generate SSO session IDs. |
protected java.lang.String |
secureRandomClass
The Java class name of the secure random number generator class to be used when generating SSO session
identifiers.
|
protected java.lang.String |
secureRandomProvider
The name of the provider to use to create instances of
SecureRandom which are used to
generate session SSO IDs. |
protected boolean |
sendAuthInfoResponseHeaders
Should the auth information (remote user and auth type) be returned as response headers for a forwarded/proxied
request?
|
protected SessionIdGeneratorBase |
sessionIdGenerator |
protected static StringManager |
sm
The string manager for this package.
|
protected SingleSignOn |
sso
The SingleSignOn implementation in our request processing chain, if there is one.
|
asyncSupported, container, containerLog, nextmserverAFTER_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 and Description |
|---|
AuthenticatorBase() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
allowCorsPreflightBypass(Request request) |
protected void |
associate(java.lang.String ssoId,
Session session)
Associate the specified single sign on identifier with the specified Session.
|
boolean |
authenticate(Request request,
HttpServletResponse httpResponse)
Authenticate the user making this request, based on the login
configuration of the
Context with which this Authenticator is
associated. |
protected java.lang.String |
changeSessionID(Request request,
Session session) |
protected boolean |
checkForCachedAuthentication(Request request,
HttpServletResponse response,
boolean useSSO)
Check to see if the user has already been authenticated earlier in the processing chain or if there is enough
information available to authenticate the user without requiring further user interaction.
|
protected abstract boolean |
doAuthenticate(Request request,
HttpServletResponse response)
Provided for sub-classes to implement their specific authentication mechanism.
|
protected java.security.Principal |
doLogin(Request request,
java.lang.String username,
java.lang.String password)
Process the login request.
|
java.lang.String |
getAllowCorsPreflight() |
boolean |
getAlwaysUseSession() |
protected abstract java.lang.String |
getAuthMethod()
Return the authentication method, which is vendor-specific and not defined by HttpServletRequest.
|
boolean |
getCache()
Return the cache authenticated Principals flag.
|
boolean |
getChangeSessionIdOnAuthentication()
Return the flag that states if we should change the session ID of an existing session upon successful
authentication.
|
Container |
getContainer()
Get the
Container with which this instance is associated. |
boolean |
getDisableProxyCaching()
Return the flag that states if we add headers to disable caching by proxies.
|
java.lang.String |
getJaspicCallbackHandlerClass()
Return the JASPIC callback handler class name
|
protected static java.lang.String |
getRealmName(Context context) |
boolean |
getSecurePagesWithPragma()
Return the flag that states, if proxy caching is disabled, what headers we add to disable the caching.
|
java.lang.String |
getSecureRandomAlgorithm()
Return the secure random number generator algorithm name.
|
java.lang.String |
getSecureRandomClass()
Return the secure random number generator class name.
|
java.lang.String |
getSecureRandomProvider()
Return the secure random number generator provider name.
|
void |
invoke(Request request,
Response response)
Enforce the security restrictions in the web application deployment descriptor of our associated Context.
|
protected boolean |
isContinuationRequired(Request request)
Does this authenticator require that
authenticate(Request, HttpServletResponse) is called to continue an
authentication process that started in a previous request? |
protected boolean |
isPreemptiveAuthPossible(Request request)
Can the authenticator perform preemptive authentication for the given request?
|
boolean |
isSendAuthInfoResponseHeaders()
Returns the flag whether authentication information will be sent to a reverse proxy on a forwarded request.
|
void |
login(java.lang.String username,
java.lang.String password,
Request request) |
void |
logout(Request request) |
void |
notify(java.lang.String layer,
java.lang.String appContext) |
protected boolean |
reauthenticateFromSSO(java.lang.String ssoId,
Request request)
Attempts reauthentication to the
Realm using the credentials included in argument
entry. |
void |
register(Request request,
HttpServletResponse response,
java.security.Principal principal,
java.lang.String authType,
java.lang.String username,
java.lang.String password)
Register an authenticated Principal and authentication type in our request, in the current session (if there is
one), and with our SingleSignOn valve, if there is one.
|
protected void |
register(Request request,
HttpServletResponse response,
java.security.Principal principal,
java.lang.String authType,
java.lang.String username,
java.lang.String password,
boolean alwaysUseSession,
boolean cache)
Register an authenticated Principal and authentication type in our request, in the current session (if there is
one), and with our SingleSignOn valve, if there is one.
|
void |
setAllowCorsPreflight(java.lang.String allowCorsPreflight) |
void |
setAlwaysUseSession(boolean alwaysUseSession) |
void |
setCache(boolean cache)
Set the cache authenticated Principals flag.
|
void |
setChangeSessionIdOnAuthentication(boolean changeSessionIdOnAuthentication)
Set the value of the flag that states if we should change the session ID of an existing session upon successful
authentication.
|
void |
setContainer(Container container)
Set the
Container with which this instance is associated. |
void |
setDisableProxyCaching(boolean nocache)
Set the value of the flag that states if we add headers to disable caching by proxies.
|
void |
setJaspicCallbackHandlerClass(java.lang.String jaspicCallbackHandlerClass)
Set the JASPIC callback handler class name
|
void |
setSecurePagesWithPragma(boolean securePagesWithPragma)
Set the value of the flag that states what headers we add to disable proxy caching.
|
void |
setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
Set the secure random number generator algorithm name.
|
void |
setSecureRandomClass(java.lang.String secureRandomClass)
Set the secure random number generator class name.
|
void |
setSecureRandomProvider(java.lang.String secureRandomProvider)
Set the secure random number generator provider name.
|
void |
setSendAuthInfoResponseHeaders(boolean sendAuthInfoResponseHeaders)
Sets the flag whether authentication information will be send to a reverse proxy on a forwarded request.
|
protected void |
startInternal()
Start this component and implement the requirements of
LifecycleBase.startInternal(). |
protected void |
stopInternal()
Stop this component and implement the requirements of
LifecycleBase.stopInternal(). |
backgroundProcess, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setNext, toStringdestroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisteraddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stopprotected static final StringManager sm
protected static final java.lang.String AUTH_HEADER_NAME
protected static final java.lang.String REALM_NAME
protected boolean alwaysUseSession
protected boolean cache
protected boolean changeSessionIdOnAuthentication
protected Context context
protected boolean disableProxyCaching
protected boolean securePagesWithPragma
protected java.lang.String secureRandomClass
SecureRandom will be generated.protected java.lang.String secureRandomAlgorithm
SecureRandom which are used to
generate SSO session IDs. If no algorithm is specified, SHA1PRNG is used. If SHA1PRNG is not available, the
platform default will be used. To use the platform default (which may be SHA1PRNG), specify the empty string. If
an invalid algorithm and/or provider is specified the SecureRandom instances will be created using the defaults.
If that fails, the SecureRandom instances will be created using platform defaults.protected java.lang.String secureRandomProvider
SecureRandom which are used to
generate session SSO IDs. If no provider is specified the platform default is used. If an invalid algorithm
and/or provider is specified the SecureRandom instances will be created using the defaults. If that fails, the
SecureRandom instances will be created using platform defaults.protected java.lang.String jaspicCallbackHandlerClass
CallbackHandlerImpl will be used.protected boolean sendAuthInfoResponseHeaders
RemoteIpValve or RemoteIpFilter mark a forwarded request with the
Globals.REQUEST_FORWARDED_ATTRIBUTE this authenticator can return the values of
HttpServletRequest.getRemoteUser() and HttpServletRequest.getAuthType() as response headers
remote-user and auth-type to a reverse proxy. This is useful, e.g., for access log consistency or
other decisions to make.protected SessionIdGeneratorBase sessionIdGenerator
protected SingleSignOn sso
protected static java.lang.String getRealmName(Context context)
public java.lang.String getAllowCorsPreflight()
public void setAllowCorsPreflight(java.lang.String allowCorsPreflight)
public boolean getAlwaysUseSession()
public void setAlwaysUseSession(boolean alwaysUseSession)
public boolean getCache()
true if authenticated Principals will be cached, otherwise falsepublic void setCache(boolean cache)
cache - The new cache flagpublic Container getContainer()
ContainedContainer with which this instance is associated.getContainer in interface ContainedgetContainer in class ValveBasenull if not associated with a Containerpublic void setContainer(Container container)
ContainedContainer with which this instance is associated.setContainer in interface ContainedsetContainer in class ValveBasecontainer - The Container instance with which this instance is to
be associated, or null to disassociate this instance
from any Containerpublic boolean getDisableProxyCaching()
true if the headers will be added, otherwise falsepublic void setDisableProxyCaching(boolean nocache)
nocache - true if we add headers to disable proxy caching, false if we leave the
headers alone.public boolean getSecurePagesWithPragma()
true if a Pragma header should be used, otherwise falsepublic void setSecurePagesWithPragma(boolean securePagesWithPragma)
securePagesWithPragma - true if we add headers which are incompatible with downloading office
documents in IE under SSL but which fix a caching problem in Mozilla.public boolean getChangeSessionIdOnAuthentication()
true to change session ID upon successful authentication, false to do not
perform the change.public void setChangeSessionIdOnAuthentication(boolean changeSessionIdOnAuthentication)
changeSessionIdOnAuthentication - true to change session ID upon successful authentication,
false to do not perform the change.public java.lang.String getSecureRandomClass()
public void setSecureRandomClass(java.lang.String secureRandomClass)
secureRandomClass - The new secure random number generator class namepublic java.lang.String getSecureRandomAlgorithm()
public void setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
secureRandomAlgorithm - The new secure random number generator algorithm namepublic java.lang.String getSecureRandomProvider()
public void setSecureRandomProvider(java.lang.String secureRandomProvider)
secureRandomProvider - The new secure random number generator provider namepublic java.lang.String getJaspicCallbackHandlerClass()
public void setJaspicCallbackHandlerClass(java.lang.String jaspicCallbackHandlerClass)
jaspicCallbackHandlerClass - The new JASPIC callback handler class namepublic boolean isSendAuthInfoResponseHeaders()
true if response headers shall be sent, false otherwisepublic void setSendAuthInfoResponseHeaders(boolean sendAuthInfoResponseHeaders)
sendAuthInfoResponseHeaders - true if response headers shall be sent, false otherwisepublic void invoke(Request request, Response response) throws java.io.IOException, ServletException
invoke in interface Valverequest - Request to be processedresponse - Response to be processedjava.io.IOException - if an input/output error occursServletException - if thrown by a processing elementprotected boolean allowCorsPreflightBypass(Request request)
public boolean authenticate(Request request, HttpServletResponse httpResponse) throws java.io.IOException
AuthenticatorContext with which this Authenticator is
associated.authenticate in interface Authenticatorrequest - Request we are processinghttpResponse - Response we are populatingtrue if any specified constraints have been
satisfied, or false if one more constraints were not
satisfied (in which case an authentication challenge will have
been written to the response).java.io.IOException - if an input/output error occursprotected abstract boolean doAuthenticate(Request request, HttpServletResponse response) throws java.io.IOException
request - The request that triggered the authenticationresponse - The response associated with the requesttrue if the the user was authenticated, otherwise false, in which case an authentication challenge will have been written to the responsejava.io.IOException - If an I/O problem occurred during the authentication processprotected boolean isContinuationRequired(Request request)
authenticate(Request, HttpServletResponse) is called to continue an
authentication process that started in a previous request?request - The request currently being processedtrue if authenticate() must be called, otherwise falseprotected void associate(java.lang.String ssoId,
Session session)
ssoId - Single sign on identifiersession - Session to be associatedprotected boolean checkForCachedAuthentication(Request request, HttpServletResponse response, boolean useSSO)
request - The current requestresponse - The current responseuseSSO - Should information available from SSO be used to attempt to authenticate the current user?true if the user was authenticated via the cache, otherwise falseprotected boolean reauthenticateFromSSO(java.lang.String ssoId,
Request request)
Realm using the credentials included in argument
entry.ssoId - identifier of SingleSignOn session with which the caller is associatedrequest - the request that needs to be authenticatedtrue if the reauthentication from SSL occurredpublic void register(Request request, HttpServletResponse response, java.security.Principal principal, java.lang.String authType, java.lang.String username, java.lang.String password)
request - The servlet request we are processingresponse - The servlet response we are generatingprincipal - The authenticated Principal to be registeredauthType - The authentication type to be registeredusername - Username used to authenticate (if any)password - Password used to authenticate (if any)protected void register(Request request, HttpServletResponse response, java.security.Principal principal, java.lang.String authType, java.lang.String username, java.lang.String password, boolean alwaysUseSession, boolean cache)
request - The servlet request we are processingresponse - The servlet response we are generatingprincipal - The authenticated Principal to be registeredauthType - The authentication type to be registeredusername - Username used to authenticate (if any)password - Password used to authenticate (if any)alwaysUseSession - Should a session always be used once a user is authenticated?cache - Should we cache authenticated Principals if the request is part of an HTTP session?public void login(java.lang.String username,
java.lang.String password,
Request request)
throws ServletException
login in interface AuthenticatorServletExceptionprotected abstract java.lang.String getAuthMethod()
protected java.security.Principal doLogin(Request request, java.lang.String username, java.lang.String password) throws ServletException
request - Associated requestusername - The userpassword - The passwordServletException - No principal was authenticated with the specified credentialspublic void logout(Request request)
logout in interface Authenticatorprotected void startInternal()
throws LifecycleException
ValveBaseLifecycleBase.startInternal().startInternal in class ValveBaseLifecycleException - if this component detects a fatal error that prevents this component from being
usedprotected void stopInternal()
throws LifecycleException
ValveBaseLifecycleBase.stopInternal().stopInternal in class ValveBaseLifecycleException - if this component detects a fatal error that prevents this component from being
usedprotected boolean isPreemptiveAuthPossible(Request request)
request - The request to check for credentialstrue if preemptive authentication is possible, otherwise falsepublic void notify(java.lang.String layer,
java.lang.String appContext)
notify in interface RegistrationListenerCopyright © 2000-2024 Apache Software Foundation.
Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo are either registered trademarks or trademarks of the Apache Software Foundation.