public class DigestAuthenticator extends AuthenticatorBase
Modifier and Type | Field and Description |
---|---|
protected String |
key
Private key.
|
protected static MessageDigest |
md5Helper
Deprecated.
Unused - will be removed in Tomcat 8.0.x onwards
|
protected int |
nonceCacheSize
Maximum number of server nonces to keep in the cache.
|
protected Map<String,org.apache.catalina.authenticator.DigestAuthenticator.NonceInfo> |
nonces
List of server nonce values currently being tracked
|
protected long |
nonceValidity
How long server nonces are valid for in milliseconds.
|
protected String |
opaque
Opaque string.
|
protected static String |
QOP
Tomcat's DIGEST implementation only supports auth quality of protection.
|
protected boolean |
validateUri
Should the URI be validated as required by RFC2617? Can be disabled in
reverse proxies where the proxy has modified the URI.
|
AUTH_HEADER_NAME, cache, changeSessionIdOnAuthentication, context, disableProxyCaching, info, lifecycle, REALM_NAME, securePagesWithPragma, SESSION_ID_BYTES, sso, started
container, controller, domain, mserver, next, oname
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
Constructor and Description |
---|
DigestAuthenticator() |
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(Request request,
javax.servlet.http.HttpServletResponse response,
LoginConfig config)
Authenticate the user making this request, based on the specified
login configuration.
|
protected String |
generateNonce(Request request)
Generate a unique token.
|
String |
getKey() |
int |
getNonceCacheSize() |
long |
getNonceValidity() |
String |
getOpaque() |
boolean |
isValidateUri() |
protected static String |
removeQuotes(String quotedString)
Removes the quotes on a string.
|
protected static String |
removeQuotes(String quotedString,
boolean quotesRequired)
Removes the quotes on a string.
|
protected void |
setAuthenticateHeader(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
LoginConfig config,
String nonce,
boolean isNonceStale)
Generates the WWW-Authenticate header.
|
void |
setKey(String key) |
void |
setNonceCacheSize(int nonceCacheSize) |
void |
setNonceValidity(long nonceValidity) |
void |
setOpaque(String opaque) |
void |
setValidateUri(boolean validateUri) |
void |
start()
Prepare for the beginning of active use of the public methods of this
component.
|
addLifecycleListener, associate, authenticate, findLifecycleListeners, generateSessionId, getCache, getContainer, getDisableProxyCaching, getInfo, getSecurePagesWithPragma, invoke, isChangeSessionIdOnAuthentication, login, logout, reauthenticateFromSSO, register, removeLifecycleListener, setCache, setChangeSessionIdOnAuthentication, setContainer, setDisableProxyCaching, setSecurePagesWithPragma, stop, unregister
backgroundProcess, createObjectName, event, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setController, setNext, setObjectName, toString
protected static final String QOP
protected static MessageDigest md5Helper
protected Map<String,org.apache.catalina.authenticator.DigestAuthenticator.NonceInfo> nonces
protected int nonceCacheSize
protected String key
protected long nonceValidity
protected String opaque
protected boolean validateUri
public int getNonceCacheSize()
public void setNonceCacheSize(int nonceCacheSize)
public String getKey()
public void setKey(String key)
public long getNonceValidity()
public void setNonceValidity(long nonceValidity)
public String getOpaque()
public void setOpaque(String opaque)
public boolean isValidateUri()
public void setValidateUri(boolean validateUri)
public 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.authenticate
in class AuthenticatorBase
request
- Request we are processingresponse
- Response we are creatingconfig
- Login configuration describing how authentication
should be performedIOException
- if an input/output error occursprotected static String removeQuotes(String quotedString, boolean quotesRequired)
protected static String removeQuotes(String quotedString)
protected String generateNonce(Request request)
request
- HTTP Servlet requestprotected void setAuthenticateHeader(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, LoginConfig config, String nonce, boolean isNonceStale)
The header MUST follow this template :
WWW-Authenticate = "WWW-Authenticate" ":" "Digest" digest-challenge digest-challenge = 1#( realm | [ domain ] | nonce | [ digest-opaque ] |[ stale ] | [ algorithm ] ) realm = "realm" "=" realm-value realm-value = quoted-string domain = "domain" "=" <"> 1#URI <"> nonce = "nonce" "=" nonce-value nonce-value = quoted-string opaque = "opaque" "=" quoted-string stale = "stale" "=" ( "true" | "false" ) algorithm = "algorithm" "=" ( "MD5" | token )
request
- HTTP Servlet requestresponse
- HTTP Servlet responsenonce
- nonce tokenpublic void start() throws LifecycleException
AuthenticatorBase
configure()
,
and before any of the public methods of the component are utilized.start
in interface Lifecycle
start
in class AuthenticatorBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedCopyright © 2013 JBoss, a division of Red Hat, Inc.. All rights reserved.