public abstract class AuthenticatorBase extends ValveBase implements Authenticator, Lifecycle
<security-constraint> elements in the web application
deployment descriptor. This functionality is implemented as a Valve
so that it can be ommitted 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 | Field and Description |
|---|---|
protected static 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 static String |
info
Descriptive information about this implementation.
|
protected LifecycleSupport |
lifecycle
The lifecycle event support for this component.
|
protected static String |
REALM_NAME
Default authentication realm name.
|
protected boolean |
securePagesWithPragma
Flag to determine if we disable proxy caching with headers incompatible
with IE
|
protected static int |
SESSION_ID_BYTES
The number of random bytes to include when generating a
session identifier.
|
protected SingleSignOn |
sso
The SingleSignOn implementation in our request processing chain,
if there is one.
|
protected boolean |
started
Has this component been started?
|
container, controller, domain, mserver, next, onameAFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT| Constructor and Description |
|---|
AuthenticatorBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.
|
protected void |
associate(String ssoId,
Session session)
Associate the specified single sign on identifier with the
specified Session.
|
boolean |
authenticate(Request request,
javax.servlet.http.HttpServletResponse response)
API login.
|
protected abstract boolean |
authenticate(Request request,
javax.servlet.http.HttpServletResponse response,
LoginConfig config)
Authenticate the user making this request, based on the specified
login configuration.
|
LifecycleListener[] |
findLifecycleListeners()
Get the lifecycle listeners associated with this lifecycle.
|
protected String |
generateSessionId(Random random)
Generate and return a new session identifier for the cookie that
identifies an SSO principal.
|
boolean |
getCache()
Return the cache authenticated Principals flag.
|
Container |
getContainer()
Return the Container to which this Valve is attached.
|
boolean |
getDisableProxyCaching()
Return the flag that states if we add headers to disable caching by
proxies.
|
String |
getInfo()
Return descriptive information about this Valve implementation.
|
boolean |
getSecurePagesWithPragma()
Return the flag that states, if proxy caching is disabled, what headers
we add to disable the caching.
|
void |
invoke(Request request,
Response response)
Enforce the security restrictions in the web application deployment
descriptor of our associated Context.
|
boolean |
isChangeSessionIdOnAuthentication() |
void |
login(Request request,
String username,
String password) |
void |
logout(Request request) |
protected boolean |
reauthenticateFromSSO(String ssoId,
Request request)
Attempts reauthentication to the
Realm using
the credentials included in argument entry. |
protected void |
register(Request request,
javax.servlet.http.HttpServletResponse response,
Principal principal,
String authType,
String username,
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.
|
void |
removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.
|
void |
setCache(boolean cache)
Set the cache authenticated Principals flag.
|
void |
setChangeSessionIdOnAuthentication(boolean changeSessionIdOnAuthentication) |
void |
setContainer(Container container)
Set the Container to which this Valve is attached.
|
void |
setDisableProxyCaching(boolean nocache)
Set the value of the flag that states if we add headers to disable
caching by proxies.
|
void |
setSecurePagesWithPragma(boolean securePagesWithPragma)
Set the value of the flag that states what headers we add to disable
proxy caching.
|
void |
start()
Prepare for the beginning of active use of the public methods of this
component.
|
void |
stop()
Gracefully terminate the active use of the public methods of this
component.
|
protected void |
unregister(Request request,
javax.servlet.http.HttpServletResponse response)
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.
|
backgroundProcess, createObjectName, event, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setController, setNext, setObjectName, toStringprotected static final String AUTH_HEADER_NAME
protected static final String REALM_NAME
protected static final int SESSION_ID_BYTES
protected boolean cache
protected boolean changeSessionIdOnAuthentication
protected Context context
protected static final String info
protected boolean disableProxyCaching
protected boolean securePagesWithPragma
protected LifecycleSupport lifecycle
protected SingleSignOn sso
protected boolean started
public boolean getCache()
public void setCache(boolean cache)
cache - The new cache flagpublic boolean isChangeSessionIdOnAuthentication()
public void setChangeSessionIdOnAuthentication(boolean changeSessionIdOnAuthentication)
public Container getContainer()
getContainer in interface ContainedgetContainer in class ValveBasepublic void setContainer(Container container)
setContainer in interface ContainedsetContainer in class ValveBasecontainer - The container to which we are attachedpublic String getInfo()
public boolean getDisableProxyCaching()
public void setDisableProxyCaching(boolean nocache)
nocache - true if we add headers to disable proxy
caching, false if we leave the headers alone.public boolean getSecurePagesWithPragma()
public 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 authenticate(Request request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
authenticate in interface Authenticatorrequest - Request we are processingresponse - Response we are creatingconfig - Login configuration describing how authentication
should be performedIOException - if an input/output error occursjavax.servlet.ServletExceptionpublic void login(Request request, String username, String password) throws javax.servlet.ServletException
login in interface Authenticatorjavax.servlet.ServletExceptionpublic void logout(Request request) throws javax.servlet.ServletException
logout in interface Authenticatorjavax.servlet.ServletExceptionpublic void invoke(Request request, Response response) throws IOException, javax.servlet.ServletException
invoke in interface Valveinvoke in class ValveBaserequest - Request to be processedresponse - Response to be processedIOException - if an input/output error occursjavax.servlet.ServletException - if thrown by a processing elementprotected void associate(String ssoId, Session session)
ssoId - Single sign on identifiersession - Session to be associatedprotected abstract boolean authenticate(Request request, javax.servlet.http.HttpServletResponse response, LoginConfig config) throws IOException
true if any specified
constraint has been satisfied, or false if we have
created a response challenge already.request - Request we are processingresponse - Response we are creatingconfig - Login configuration describing how authentication
should be performedIOException - if an input/output error occursprotected String generateSessionId(Random random)
protected boolean reauthenticateFromSSO(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 authenticatedprotected void register(Request request, javax.servlet.http.HttpServletResponse response, Principal principal, String authType, String username, 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 unregister(Request request, javax.servlet.http.HttpServletResponse response)
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)public void addLifecycleListener(LifecycleListener listener)
addLifecycleListener in interface Lifecyclelistener - The listener to addpublic LifecycleListener[] findLifecycleListeners()
findLifecycleListeners in interface Lifecyclepublic void removeLifecycleListener(LifecycleListener listener)
removeLifecycleListener in interface Lifecyclelistener - The listener to removepublic void start()
throws LifecycleException
configure(),
and before any of the public methods of the component are utilized.start in interface LifecycleLifecycleException - if this component detects a fatal error
that prevents this component from being usedpublic void stop()
throws LifecycleException
stop in interface LifecycleLifecycleException - if this component detects a fatal error
that needs to be reportedCopyright © 2016 JBoss by Red Hat. All rights reserved.