Top Description Inners Fields Constructors Methods
org.apache.catalina.authenticator

public abstract Class AuthenticatorBase

extends ValveBase
implements Authenticator, RegistrationListener
Class Inheritance
All Implemented Interfaces
jakarta.security.auth.message.config.RegistrationListener, org.apache.catalina.Authenticator
Known Direct Subclasses
org.apache.catalina.authenticator.BasicAuthenticator, org.apache.catalina.authenticator.DigestAuthenticator, org.apache.catalina.authenticator.FormAuthenticator, org.apache.catalina.authenticator.NonLoginAuthenticator, org.apache.catalina.authenticator.SpnegoAuthenticator, org.apache.catalina.authenticator.SSLAuthenticator
Imports
java.io.IOException, java.security.Principal, java.util.Locale, .Map, .Optional, .Set, javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, jakarta.security.auth.message.AuthException, .AuthStatus, .MessageInfo, jakarta.security.auth.message.config.AuthConfigFactory, .AuthConfigProvider, .RegistrationListener, .ServerAuthConfig, .ServerAuthContext, jakarta.servlet.DispatcherType, .ServletContext, .ServletException, jakarta.servlet.http.Cookie, .HttpServletRequest, .HttpServletResponse, org.apache.catalina.Authenticator, .Contained, .Container, .Context, .Globals, .LifecycleException, .Realm, .Session, .TomcatPrincipal, .Valve, org.apache.catalina.authenticator.jaspic.MessageInfoImpl, org.apache.catalina.connector.Request, .Response, org.apache.catalina.filters.CorsFilter, .RemoteIpFilter, org.apache.catalina.realm.GenericPrincipal, org.apache.catalina.util.SessionIdGeneratorBase, .StandardSessionIdGenerator, org.apache.catalina.valves.RemoteIpValve, .ValveBase, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.descriptor.web.FilterDef, .FilterMap, .LoginConfig, .SecurityConstraint, org.apache.tomcat.util.http.FastHttpDateFormat, .RequestUtil, org.apache.tomcat.util.res.StringManager

Basic implementation of the Valve interface that enforces the <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.

Author
Craig R. McClanahan

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
private static class

Field Summary

Modifier and TypeField and Description
private AuthenticatorBase.AllowCorsPreflight
protected boolean
alwaysUseSession

Should a session always be used once a user is authenticated?

protected static final 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.

private static final String
DATE_ONE

"Expires" header always set to Date(1), so generate once only

protected boolean
disableProxyCaching

Flag to determine if we disable proxy caching, or leave the issue up to the webapp developer.

private volatile String
private volatile CallbackHandler
protected String
jaspicCallbackHandlerClass

The name of the JASPIC callback handler class.

private volatile Optional<AuthConfigProvider>
private final Log
protected static final String
REALM_NAME

Default authentication realm name.

protected boolean
securePagesWithPragma

Flag to determine if we disable proxy caching with headers incompatible with IE.

protected String
secureRandomAlgorithm

The name of the algorithm to use to create instances of java.security.SecureRandom which are used to generate SSO session IDs.

protected String
secureRandomClass

The Java class name of the secure random number generator class to be used when generating SSO session identifiers.

protected String
secureRandomProvider

The name of the provider to use to create instances of java.security.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
protected static final StringManager
sm

Hides org.apache.catalina.valves.ValveBase.sm.

The string manager for this package.
protected SingleSignOn
sso

The SingleSignOn implementation in our request processing chain, if there is one.

Inherited from org.apache.catalina.valves.ValveBase:
asyncSupportedcontainercontainerLognext

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
protected void
associate(String
Single sign on identifier
ssoId
,
Session
Session to be associated
session
)

Associate the specified single sign on identifier with the specified Session.

public boolean
authenticate(Request
Request we are processing
request
,
HttpServletResponse
Response we are populating
httpResponse
)

Implements org.apache.catalina.Authenticator.authenticate.

Authenticate the user making this request, based on the login configuration of the Context with which this Authenticator is associated.

private boolean
authenticateJaspic(Request request, Response response, AuthenticatorBase.JaspicState state, boolean requirePrincipal)

protected String
changeSessionID(Request request, Session session)

protected boolean

Returns:

true if the user was authenticated via the cache, otherwise false
checkForCachedAuthentication
(Request
The current request
request
,
HttpServletResponse
The current response
response
,
boolean
Should information available from SSO be used to attempt to authenticate the current user?
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.

private CallbackHandler
protected abstract boolean

Returns:

true if the the user was authenticated, otherwise false, in which case an authentication challenge will have been written to the response
doAuthenticate
(Request
The request that triggered the authentication
request
,
HttpServletResponse
The response associated with the request
response
)

Provided for sub-classes to implement their specific authentication mechanism.

protected Principal

Returns:

The authenticated Principal
doLogin
(Request
Associated request
request
,
String
The user
username
,
String
The password
password
)

Process the login request.

private Optional<AuthConfigProvider>
public String
public boolean
protected abstract String

Returns:

the authentication method, which is vendor-specific and not defined by HttpServletRequest.
getAuthMethod
()

Return the authentication method, which is vendor-specific and not defined by HttpServletRequest.

public boolean

Returns:

true if authenticated Principals will be cached, otherwise false
getCache
()

Return the cache authenticated Principals flag.

private CallbackHandler
public boolean

Returns:

true to change session ID upon successful authentication, false to do not perform the change.
getChangeSessionIdOnAuthentication
()

Return the flag that states if we should change the session ID of an existing session upon successful authentication.

public Container
getContainer()

Overrides org.apache.catalina.valves.ValveBase.getContainer.

Implements org.apache.catalina.Contained.getContainer.

Get the Container with which this instance is associated.

public boolean

Returns:

true if the headers will be added, otherwise false
getDisableProxyCaching
()

Return the flag that states if we add headers to disable caching by proxies.

public String

Returns:

The name of the JASPIC callback handler
getJaspicCallbackHandlerClass
()

Return the JASPIC callback handler class name

private AuthConfigProvider
private AuthenticatorBase.JaspicState
getJaspicState(AuthConfigProvider jaspicProvider, Request request, Response response, boolean authMandatory)

private GenericPrincipal
protected static String
public boolean

Returns:

true if a Pragma header should be used, otherwise false
getSecurePagesWithPragma
()

Return the flag that states, if proxy caching is disabled, what headers we add to disable the caching.

public String

Returns:

The name of the SecureRandom algorithm used
getSecureRandomAlgorithm
()

Return the secure random number generator algorithm name.

public String

Returns:

The fully qualified name of the SecureRandom implementation to use
getSecureRandomClass
()

Return the secure random number generator class name.

public String

Returns:

The name of the SecureRandom provider
getSecureRandomProvider
()

Return the secure random number generator provider name.

public void
invoke(Request
Request to be processed
request
,
Response
Response to be processed
response
)

Implements org.apache.catalina.Valve.invoke.

Enforce the security restrictions in the web application deployment descriptor of our associated Context.

protected boolean

Returns:

true if authenticate() must be called, otherwise false
isContinuationRequired
(Request
The request currently being processed
request
)

Does this authenticator require that authenticate(Request, HttpServletResponse) is called to continue an authentication process that started in a previous request?

protected boolean

Returns:

true if preemptive authentication is possible, otherwise false
isPreemptiveAuthPossible
(Request
The request to check for credentials
request
)

Can the authenticator perform preemptive authentication for the given request?

public boolean

Returns:

true if response headers shall be sent, false otherwise
isSendAuthInfoResponseHeaders
()

Returns the flag whether authentication information will be sent to a reverse proxy on a forwarded request.

public void
login(String username, String password, Request request)

Implements org.apache.catalina.Authenticator.login.

public void
public void
protected boolean

Returns:

true if the reauthentication from SSL occurred
reauthenticateFromSSO
(String
identifier of SingleSignOn session with which the caller is associated
ssoId
,
Request
the request that needs to be authenticated
request
)

Attempts reauthentication to the Realm using the credentials included in argument entry.

public void
register(Request
The servlet request we are processing
request
,
HttpServletResponse
The servlet response we are generating
response
,
Principal
The authenticated Principal to be registered
principal
,
String
The authentication type to be registered
authType
,
String
Username used to authenticate (if any)
username
,
String
Password used to authenticate (if any)
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
The servlet request we are processing
request
,
HttpServletResponse
The servlet response we are generating
response
,
Principal
The authenticated Principal to be registered
principal
,
String
The authentication type to be registered
authType
,
String
Username used to authenticate (if any)
username
,
String
Password used to authenticate (if any)
password
,
boolean
Should a session always be used once a user is authenticated?
alwaysUseSession
,
boolean
Should we cache authenticated Principals if the request is part of an HTTP session?
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.

private void
public void
setAllowCorsPreflight(String allowCorsPreflight)

public void
setAlwaysUseSession(boolean alwaysUseSession)

public void
setCache(boolean
The new cache flag
cache
)

Set the cache authenticated Principals flag.

public void
setChangeSessionIdOnAuthentication(boolean
true to change session ID upon successful authentication, false to do not perform the change.
changeSessionIdOnAuthentication
)

Set the value of the flag that states if we should change the session ID of an existing session upon successful authentication.

public void
setContainer(Container
The Container instance with which this instance is to be associated, or null to disassociate this instance from any Container
container
)

Overrides org.apache.catalina.valves.ValveBase.setContainer.

Implements org.apache.catalina.Contained.setContainer.

Set the Container with which this instance is associated.

public void
setDisableProxyCaching(boolean
true if we add headers to disable proxy caching, false if we leave the headers alone.
nocache
)

Set the value of the flag that states if we add headers to disable caching by proxies.

public void
setJaspicCallbackHandlerClass(String
The new JASPIC callback handler class name
jaspicCallbackHandlerClass
)

Set the JASPIC callback handler class name

public void
setSecurePagesWithPragma(boolean
true if we add headers which are incompatible with downloading office documents in IE under SSL but which fix a caching problem in Mozilla.
securePagesWithPragma
)

Set the value of the flag that states what headers we add to disable proxy caching.

public void
setSecureRandomAlgorithm(String
The new secure random number generator algorithm name
secureRandomAlgorithm
)

Set the secure random number generator algorithm name.

public void
setSecureRandomClass(String
The new secure random number generator class name
secureRandomClass
)

Set the secure random number generator class name.

public void
setSecureRandomProvider(String
The new secure random number generator provider name
secureRandomProvider
)

Set the secure random number generator provider name.

public void
setSendAuthInfoResponseHeaders(boolean
true if response headers shall be sent, false otherwise
sendAuthInfoResponseHeaders
)

Sets the flag whether authentication information will be send to a reverse proxy on a forwarded request.

protected void
protected void
Inherited from org.apache.catalina.valves.ValveBase:
backgroundProcessgetDomainInternalgetNextgetObjectNameKeyPropertiesinitInternalisAsyncSupportedsetAsyncSupportedsetNexttoString