Top Description Inners Fields Constructors Methods
org.eclipse.jetty.security.authentication

public Class DigestAuthenticator

extends LoginAuthenticator
Class Inheritance
Imports
java.io.Serial, java.nio.charset.StandardCharsets, java.security.MessageDigest, .SecureRandom, java.util.Base64, .BitSet, .Iterator, .Objects, .Queue, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentMap, org.eclipse.jetty.http.HttpHeader, .HttpStatus, org.eclipse.jetty.security.AuthenticationState, .Authenticator, .SecurityHandler, .ServerAuthException, .UserIdentity, org.eclipse.jetty.server.Request, .Response, org.eclipse.jetty.util.Callback, .QuotedStringTokenizer, .TypeUtil, org.eclipse.jetty.util.security.Credential, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

The nonce max age in ms can be set with the SecurityHandler#setParameter(String, String) using the name "maxNonceAge". The nonce max count can be set with SecurityHandler#setParameter(String, String) using the name "maxNonceCount". When the age or count is exceeded, the nonce is considered stale.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private int
private long
private final ConcurrentMap<String, DigestAuthenticator.Nonce>
private final Queue<DigestAuthenticator.Nonce>
private final SecureRandom
private static final Logger
private static final QuotedStringTokenizer
Inherited from org.eclipse.jetty.security.authentication.LoginAuthenticator:
_identityService_loginService

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private int

Returns:

-1 for a bad nonce, 0 for a stale none, 1 for a good nonce
checkNonce
(DigestAuthenticator.Digest
the digest data to check
digest
,
Request
the request object
request
)

public String
public long
public int
public UserIdentity
login(String
the username of the client to be authenticated
username
,
Object
the user's credential
credentials
,
Request
the inbound request that needs authentication
request
,
Response response)

Overrides org.eclipse.jetty.security.authentication.LoginAuthenticator.login.

If the UserIdentity returned from LoginService#login(String, Object, Request, Function) is not null, it is assumed that the user is fully authenticated and we need to change the session id to prevent session fixation vulnerability.
public String
newNonce(Request request)

public void
public void
setMaxNonceAge(long maxNonceAgeInMillis)

public void
setMaxNonceCount(int maxNC)

public AuthenticationState
validateRequest(Request
The request
req
,
Response
The response
res
,
Callback
the callback to use for writing a response
callback
)

Implements org.eclipse.jetty.security.Authenticator.validateRequest.

Validate a request
Inherited from org.eclipse.jetty.security.authentication.LoginAuthenticator:
getLoginServicelogoutupdateSession

Field Detail

_maxNCback to summary
private int _maxNC
_maxNonceAgeMsback to summary
private long _maxNonceAgeMs
_nonceMapback to summary
private final ConcurrentMap<String, DigestAuthenticator.Nonce> _nonceMap
_nonceQueueback to summary
private final Queue<DigestAuthenticator.Nonce> _nonceQueue
_randomback to summary
private final SecureRandom _random
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.security.authentication.LoginAuthenticator.LOG.

TOKENIZERback to summary
private static final QuotedStringTokenizer TOKENIZER

Constructor Detail

DigestAuthenticatorback to summary
public DigestAuthenticator()

Method Detail

checkNonceback to summary
private int checkNonce(DigestAuthenticator.Digest digest, Request request)
Parameters
digest:DigestAuthenticator.Digest

the digest data to check

request:Request

the request object

Returns:int

-1 for a bad nonce, 0 for a stale none, 1 for a good nonce

getAuthenticationTypeback to summary
public String getAuthenticationType()

Implements org.eclipse.jetty.security.Authenticator.getAuthenticationType.

Returns:String

Doc from org.eclipse.jetty.security.Authenticator.getAuthenticationType.

The name of the authentication type

Annotations
@Override
getMaxNonceAgeback to summary
public long getMaxNonceAge()
getMaxNonceCountback to summary
public int getMaxNonceCount()
loginback to summary
public UserIdentity login(String username, Object credentials, Request request, Response response)

Overrides org.eclipse.jetty.security.authentication.LoginAuthenticator.login.

Doc from org.eclipse.jetty.security.authentication.LoginAuthenticator.login.

If the UserIdentity returned from LoginService#login(String, Object, Request, Function) is not null, it is assumed that the user is fully authenticated and we need to change the session id to prevent session fixation vulnerability. If the UserIdentity is not necessarily fully authenticated, then subclasses must override this method and determine when the UserIdentity IS fully authenticated and renew the session id.

Parameters
username:String

the username of the client to be authenticated

credentials:Object

the user's credential

request:Request

the inbound request that needs authentication

Annotations
@Override
newNonceback to summary
public String newNonce(Request request)
setConfigurationback to summary
public void setConfiguration(Authenticator.Configuration configuration)

Overrides org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration.

Implements org.eclipse.jetty.security.Authenticator.setConfiguration.

Doc from org.eclipse.jetty.security.Authenticator.setConfiguration.

Configure the Authenticator

Parameters
configuration:Authenticator.Configuration

the configuration

Annotations
@Override
setMaxNonceAgeback to summary
public void setMaxNonceAge(long maxNonceAgeInMillis)
setMaxNonceCountback to summary
public void setMaxNonceCount(int maxNC)
validateRequestback to summary
public AuthenticationState validateRequest(Request req, Response res, Callback callback) throws ServerAuthException

Implements org.eclipse.jetty.security.Authenticator.validateRequest.

Doc from org.eclipse.jetty.security.Authenticator.validateRequest.

Validate a request

Parameters
req:Request

The request

res:Response

The response

callback:Callback

the callback to use for writing a response

Returns:AuthenticationState

An Authentication. If Authentication is successful, this will be a Succeeded. If a response has been sent by the Authenticator (which can be done for both successful and unsuccessful authentications), then the result will implement AuthenticationState.ResponseSent.

Annotations
@Override
Exceptions
ServerAuthException:
if unable to validate request
org.eclipse.jetty.security.authentication back to summary

private Class DigestAuthenticator.Digest

extends Credential
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv final String
pack-priv String
pack-priv String
pack-priv String
pack-priv String
pack-priv String
private static final long
pack-priv String
pack-priv String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
check(Object
The credential to check against. This may either be another Credential object, a Password object or a String which is interpreted by this credential.
credentials
)

Implements abstract org.eclipse.jetty.util.security.Credential.check.

Check a credential
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.eclipse.jetty.util.security.Credential:
byteEqualsgetCredentialstringEquals

Field Detail

cnonceback to summary
pack-priv String cnonce
methodback to summary
pack-priv final String method
ncback to summary
pack-priv String nc
nonceback to summary
pack-priv String nonce
qopback to summary
pack-priv String qop
realmback to summary
pack-priv String realm
responseback to summary
pack-priv String response
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.eclipse.jetty.util.security.Credential.serialVersionUID.

Annotations
@Serial
uriback to summary
pack-priv String uri
usernameback to summary
pack-priv String username

Constructor Detail

Digestback to summary
pack-priv Digest(String m)

Method Detail

checkback to summary
public boolean check(Object credentials)

Implements abstract org.eclipse.jetty.util.security.Credential.check.

Doc from org.eclipse.jetty.util.security.Credential.check.

Check a credential

Parameters
credentials:Object

The credential to check against. This may either be another Credential object, a Password object or a String which is interpreted by this credential.

Returns:boolean

True if the credentials indicated that the shared secret is known to both this Credential and the passed credential.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.security.authentication back to summary

private Class DigestAuthenticator.Nonce

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.security.authentication.DigestAuthenticator.Nonce

Field Summary

Modifier and TypeField and Description
private final AutoLock
pack-priv final String
pack-priv final BitSet
pack-priv final long

Constructor Summary

AccessConstructor and Description
public
Nonce(String nonce, long ts, int size)

Method Summary

Modifier and TypeMethod and Description
public boolean
seen(int count)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_lockback to summary
private final AutoLock _lock
_nonceback to summary
pack-priv final String _nonce
_seenback to summary
pack-priv final BitSet _seen
_tsback to summary
pack-priv final long _ts

Constructor Detail

Nonceback to summary
public Nonce(String nonce, long ts, int size)

Method Detail

seenback to summary
public boolean seen(int count)