public class DigestAuthenticator extends AuthenticatorBase
Modifier and Type | Field and Description |
---|---|
protected static String |
algorithm
The message digest algorithm to be used when generating session identifiers.
|
protected int |
cnonceCacheSize
Maximum number of client nonces to keep in the cache.
|
protected static String |
DEFAULT_ALGORITHM
The default message digest algorithm to use if we cannot use the requested one.
|
protected static DigestEncoder |
digestEncoder
The MD5 helper object for this class.
|
protected static String |
info
Descriptive information about this implementation.
|
protected String |
key
Private key.
|
protected static MessageDigest |
messageDigest
MD5 message digest provider.
|
protected long |
nonceValidity
How long server nonces are valid for in milliseconds.
|
protected String |
opaque
Opaque string.
|
protected static String |
QOP
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.
|
alwaysUseSession, AUTH_HEADER_NAME, cache, changeSessionIdOnAuthentication, context, disableProxyCaching, entropy, random, randomClass, REALM_NAME, securePagesWithPragma, SESSION_ID_BYTES, sso
container, controller, debug, domain, lifecycle, log, next, oname, rb, started
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
END_PIPELINE, INVOKE_NEXT
Constructor and Description |
---|
DigestAuthenticator() |
Modifier and Type | Method and Description |
---|---|
boolean |
authenticate(HttpRequest request,
HttpResponse response,
LoginConfig config)
Authenticate the user making this request, based on the specified login configuration.
|
protected static byte[] |
digest(byte[] data) |
protected String |
generateNonce(javax.servlet.http.HttpServletRequest request)
Generate a unique token.
|
static String |
getAlgorithm()
Return the message digest algorithm for this Manager.
|
protected String |
getAuthMethod() |
int |
getCnonceCacheSize() |
String |
getInfo()
Return descriptive information about this Valve implementation.
|
String |
getKey() |
protected static MessageDigest |
getMessageDigest() |
long |
getNonceValidity() |
String |
getOpaque() |
boolean |
isValidateUri() |
protected String |
parseUsername(String authorization)
Parse the username from the specified authorization string.
|
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.
|
static void |
setAlgorithm(String alg)
Set the message digest algorithm for this Manager.
|
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 |
setCnonceCacheSize(int cnonceCacheSize) |
void |
setKey(String key) |
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.
|
associate, doLogin, generateSessionId, getAlwaysUseSession, getCache, getContainer, getDebug, getDisableProxyCaching, getEntropy, getRandom, getRandomClass, getRealmName, getSession, getSession, getSingleSignOn, invoke, isChangeSessionIdOnAuthentication, isSecurePagesWithPragma, log, log, login, logout, postInvoke, register, setAlwaysUseSession, setCache, setChangeSessionIdOnAuthentication, setContainer, setDebug, setDisableProxyCaching, setEntropy, setRandomClass, setRealmName, setSecurePagesWithPragma, setSingleSignOn, stop
addLifecycleListener, backgroundProcess, createObjectName, event, findLifecycleListeners, getController, getDomain, getNext, getObjectName, getParentName, invoke, isStarted, removeLifecycleListener, setController, setNext, setObjectName
protected static final DigestEncoder digestEncoder
protected static final String info
protected static final String QOP
protected static final String DEFAULT_ALGORITHM
protected static volatile String algorithm
java.security.MessageDigest
class on your platform.protected static volatile MessageDigest messageDigest
protected int cnonceCacheSize
protected String key
protected long nonceValidity
protected String opaque
protected boolean validateUri
public boolean authenticate(HttpRequest request, HttpResponse 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 occurspublic static String getAlgorithm()
public static void setAlgorithm(String alg)
alg
- The new message digest algorithmpublic String getInfo()
getInfo
in interface Valve
getInfo
in interface GlassFishValve
getInfo
in class AuthenticatorBase
public int getCnonceCacheSize()
public void setCnonceCacheSize(int cnonceCacheSize)
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)
protected String parseUsername(String authorization)
null
authorization
- Authorization string to be parsedprotected String getAuthMethod()
getAuthMethod
in class AuthenticatorBase
protected static String removeQuotes(String quotedString, boolean quotesRequired)
protected static String removeQuotes(String quotedString)
protected String generateNonce(javax.servlet.http.HttpServletRequest 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 responseconfig
- Login configuration describing how authentication should be performednOnce
- nonce tokenprotected static MessageDigest getMessageDigest()
protected static byte[] digest(byte[] data)
public 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 © 2021. All rights reserved.