Top Description Inners Fields Constructors Methods
io.undertow.security.impl

public Class DigestAuthenticationMechanism

extends Object
implements AuthenticationMechanism
Class Inheritance
All Implemented Interfaces
io.undertow.security.api.AuthenticationMechanism
Static Imports
io.undertow.UndertowLogger.REQUEST_LOGGER, .UndertowMessages.MESSAGES, io.undertow.security.impl.DigestAuthorizationToken.parseHeader, io.undertow.util.Headers.AUTHENTICATION_INFO, .Headers.AUTHORIZATION, .Headers.DIGEST, .Headers.NEXT_NONCE, .Headers.WWW_AUTHENTICATE, .StatusCodes.UNAUTHORIZED

io.undertow.server.HttpHandler to handle HTTP Digest authentication, both according to RFC-2617 and draft update to allow additional algorithms to be used.
Author
Darran Lofthouse

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
public static class

Field Summary

Modifier and TypeField and Description
private static final byte
private static final String
private static final String
private final String
public static final AuthenticationMechanismFactory
private final IdentityManager
private static final Set<DigestAuthorizationToken>
private final String
private final NonceManager
private static final String
private static final int
private final String
private final String
private final List<DigestAlgorithm>
supportedAlgorithms

The List of supported algorithms, this is assumed to be in priority order.

private final List<DigestQop>

Constructor Summary

AccessConstructor and Description
public
DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager)

public
DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager, final String mechanismName)

public
DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager, final String mechanismName, final IdentityManager identityManager)

public
DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName)

public
DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName, final IdentityManager identityManager)

Method Summary

Modifier and TypeMethod and Description
public AuthenticationMechanism.AuthenticationMechanismOutcome
authenticate(final HttpServerExchange
The exchange
exchange
,
final SecurityContext securityContext)

Implements io.undertow.security.api.AuthenticationMechanism.authenticate.

Perform authentication of the request.

private byte[]
private byte[]
private byte[]
private byte[]
createRFC2069RequestDigest(final byte[] ha1, final byte[] ha2, final DigestAuthenticationMechanism.DigestContext context)

private byte[]
createRFC2617RequestDigest(final byte[] ha1, final byte[] ha2, final DigestAuthenticationMechanism.DigestContext context)

private IdentityManager
private AuthenticationMechanism.AuthenticationMechanismOutcome
handleDigestHeader(HttpServerExchange exchange, final SecurityContext securityContext)

public void
public AuthenticationMechanism.ChallengeResult
sendChallenge(final HttpServerExchange
The exchange
exchange
,
final SecurityContext
The security context
securityContext
)

Implements io.undertow.security.api.AuthenticationMechanism.sendChallenge.

Send an authentication challenge to the remote client.

private boolean
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COLONback to summary
private static final byte COLON
DEFAULT_NAMEback to summary
private static final String DEFAULT_NAME
DIGEST_PREFIXback to summary
private static final String DIGEST_PREFIX
domainback to summary
private final String domain
FACTORYback to summary
public static final AuthenticationMechanismFactory FACTORY
identityManagerback to summary
private final IdentityManager identityManager
MANDATORY_REQUEST_TOKENSback to summary
private static final Set<DigestAuthorizationToken> MANDATORY_REQUEST_TOKENS
mechanismNameback to summary
private final String mechanismName
nonceManagerback to summary
private final NonceManager nonceManager
OPAQUE_VALUEback to summary
private static final String OPAQUE_VALUE
PREFIX_LENGTHback to summary
private static final int PREFIX_LENGTH
qopStringback to summary
private final String qopString
realmNameback to summary
private final String realmName
supportedAlgorithmsback to summary
private final List<DigestAlgorithm> supportedAlgorithms

The List of supported algorithms, this is assumed to be in priority order.

supportedQopsback to summary
private final List<DigestQop> supportedQops

Constructor Detail

DigestAuthenticationMechanismback to summary
public DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager)
DigestAuthenticationMechanismback to summary
public DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager, final String mechanismName)
DigestAuthenticationMechanismback to summary
public DigestAuthenticationMechanism(final List<DigestAlgorithm> supportedAlgorithms, final List<DigestQop> supportedQops, final String realmName, final String domain, final NonceManager nonceManager, final String mechanismName, final IdentityManager identityManager)
DigestAuthenticationMechanismback to summary
public DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName)
DigestAuthenticationMechanismback to summary
public DigestAuthenticationMechanism(final String realmName, final String domain, final String mechanismName, final IdentityManager identityManager)

Method Detail

authenticateback to summary
public AuthenticationMechanism.AuthenticationMechanismOutcome authenticate(final HttpServerExchange exchange, final SecurityContext securityContext)

Implements io.undertow.security.api.AuthenticationMechanism.authenticate.

Doc from io.undertow.security.api.AuthenticationMechanism.authenticate.

Perform authentication of the request. Any potentially blocking work should be performed in the handoff executor provided

Parameters
exchange:HttpServerExchange

The exchange

createHA2Authback to summary
private byte[] createHA2Auth(final DigestAuthenticationMechanism.DigestContext context, Map<DigestAuthorizationToken, String> parsedHeader)
createHA2Authback to summary
private byte[] createHA2Auth(final DigestAuthenticationMechanism.DigestContext context)
createHA2AuthIntback to summary
private byte[] createHA2AuthInt()
createRFC2069RequestDigestback to summary
private byte[] createRFC2069RequestDigest(final byte[] ha1, final byte[] ha2, final DigestAuthenticationMechanism.DigestContext context)
createRFC2617RequestDigestback to summary
private byte[] createRFC2617RequestDigest(final byte[] ha1, final byte[] ha2, final DigestAuthenticationMechanism.DigestContext context)
getIdentityManagerback to summary
private IdentityManager getIdentityManager(SecurityContext securityContext)
Annotations
@SuppressWarnings:deprecation
handleDigestHeaderback to summary
private AuthenticationMechanism.AuthenticationMechanismOutcome handleDigestHeader(HttpServerExchange exchange, final SecurityContext securityContext)
sendAuthenticationInfoHeaderback to summary
public void sendAuthenticationInfoHeader(final HttpServerExchange exchange)
sendChallengeback to summary
public AuthenticationMechanism.ChallengeResult sendChallenge(final HttpServerExchange exchange, final SecurityContext securityContext)

Implements io.undertow.security.api.AuthenticationMechanism.sendChallenge.

Doc from io.undertow.security.api.AuthenticationMechanism.sendChallenge.

Send an authentication challenge to the remote client.

The individual mechanisms should update the response headers and body of the message as appropriate however they should not set the response code, instead that should be indicated in the ChallengeResult and the most appropriate overall response code will be selected. This method should not return null.

Parameters
exchange:HttpServerExchange

The exchange

securityContext:SecurityContext

The security context

Returns:AuthenticationMechanism.ChallengeResult

A ChallengeResult indicating if a challenge was sent and the desired response code.

Annotations
@Override
validateNonceUseback to summary
private boolean validateNonceUse(DigestAuthenticationMechanism.DigestContext context, Map<DigestAuthorizationToken, String> parsedHeader, final HttpServerExchange exchange)
validateRequestback to summary
private boolean validateRequest(final DigestAuthenticationMechanism.DigestContext context, final byte[] ha1)
io.undertow.security.impl back to summary

private Class DigestAuthenticationMechanism.DigestContext

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.security.impl.DigestAuthenticationMechanism.DigestContext

Field Summary

Modifier and TypeField and Description
private DigestAlgorithm
pack-priv static final AttachmentKey<DigestAuthenticationMechanism.DigestContext>
private MessageDigest
private byte[]
private String
private String
pack-priv Map<DigestAuthorizationToken, String>
private DigestQop
private boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv DigestAlgorithm
pack-priv MessageDigest
pack-priv byte[]
pack-priv String
pack-priv String
pack-priv Map<DigestAuthorizationToken, String>
pack-priv DigestQop
pack-priv boolean
pack-priv void
pack-priv void
pack-priv void
setHa1(byte[] ha1)

pack-priv void
setMethod(String method)

pack-priv void
pack-priv void
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private DigestAlgorithm algorithm
ATTACHMENT_KEYback to summary
pack-priv static final AttachmentKey<DigestAuthenticationMechanism.DigestContext> ATTACHMENT_KEY
digestback to summary
private MessageDigest digest
ha1back to summary
private byte[] ha1
methodback to summary
private String method
nonceback to summary
private String nonce
parsedHeaderback to summary
pack-priv Map<DigestAuthorizationToken, String> parsedHeader
qopback to summary
private DigestQop qop
staleback to summary
private boolean stale

Constructor Detail

DigestContextback to summary
private DigestContext()

Method Detail

getAlgorithmback to summary
pack-priv DigestAlgorithm getAlgorithm()
getDigestback to summary
pack-priv MessageDigest getDigest()
getHa1back to summary
pack-priv byte[] getHa1()
getMethodback to summary
pack-priv String getMethod()
getNonceback to summary
pack-priv String getNonce()
getParsedHeaderback to summary
pack-priv Map<DigestAuthorizationToken, String> getParsedHeader()
getQopback to summary
pack-priv DigestQop getQop()
isStaleback to summary
pack-priv boolean isStale()
markStaleback to summary
pack-priv void markStale()
setAlgorithmback to summary
pack-priv void setAlgorithm(DigestAlgorithm algorithm) throws NoSuchAlgorithmException
setHa1back to summary
pack-priv void setHa1(byte[] ha1)
setMethodback to summary
pack-priv void setMethod(String method)
setNonceback to summary
pack-priv void setNonce(String nonce)
setParsedHeaderback to summary
pack-priv void setParsedHeader(Map<DigestAuthorizationToken, String> parsedHeader)
setQopback to summary
pack-priv void setQop(DigestQop qop)
io.undertow.security.impl back to summary

private Class DigestAuthenticationMechanism.DigestCredentialImpl

extends Object
implements DigestCredential
Class Inheritance
  • java.lang.Object
  • io.undertow.security.impl.DigestAuthenticationMechanism.DigestCredentialImpl
All Implemented Interfaces
io.undertow.security.idm.DigestCredential, io.undertow.security.idm.Credential

Field Summary

Modifier and TypeField and Description
private final DigestAuthenticationMechanism.DigestContext

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public DigestAlgorithm
getAlgorithm()

Implements io.undertow.security.idm.DigestCredential.getAlgorithm.

Obtain the selected DigestAlgorithm for the request being authenticated.

public String
getRealm()

Implements io.undertow.security.idm.DigestCredential.getRealm.

Get the realm name the credential is being validated against.

public byte[]
getSessionData()

Implements io.undertow.security.idm.DigestCredential.getSessionData.

If the algorithm is session based return the session data to be included when generating the ha1.

public boolean
verifyHA1(byte[]
- The hex encoded a1 value.
ha1
)

Implements io.undertow.security.idm.DigestCredential.verifyHA1.

Called by the IdentityManager implementation to pass in the hex encoded a1 representation for validation against the current request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
private final DigestAuthenticationMechanism.DigestContext context

Constructor Detail

DigestCredentialImplback to summary
private DigestCredentialImpl(final DigestAuthenticationMechanism.DigestContext digestContext)

Method Detail

getAlgorithmback to summary
public DigestAlgorithm getAlgorithm()

Implements io.undertow.security.idm.DigestCredential.getAlgorithm.

Doc from io.undertow.security.idm.DigestCredential.getAlgorithm.

Obtain the selected DigestAlgorithm for the request being authenticated.

Returns:DigestAlgorithm

The DigestAlgorithm for the request being authenticated.

Annotations
@Override
getRealmback to summary
public String getRealm()

Implements io.undertow.security.idm.DigestCredential.getRealm.

Doc from io.undertow.security.idm.DigestCredential.getRealm.

Get the realm name the credential is being validated against.

Returns:String

The realm name.

Annotations
@Override
getSessionDataback to summary
public byte[] getSessionData()

Implements io.undertow.security.idm.DigestCredential.getSessionData.

Doc from io.undertow.security.idm.DigestCredential.getSessionData.

If the algorithm is session based return the session data to be included when generating the ha1.

Returns:byte[]

The session data.

Annotations
@Override
verifyHA1back to summary
public boolean verifyHA1(byte[] ha1)

Implements io.undertow.security.idm.DigestCredential.verifyHA1.

Doc from io.undertow.security.idm.DigestCredential.verifyHA1.

Called by the IdentityManager implementation to pass in the hex encoded a1 representation for validation against the current request. The Credential is self validating based on the information passed in here, if verification is successful then the IdentityManager can return the appropriate Account representation.

Parameters
ha1:byte[]

- The hex encoded a1 value.

Returns:boolean

true if verification was successful, false otherwise.

Annotations
@Override
io.undertow.security.impl back to summary

public final Class DigestAuthenticationMechanism.Factory

extends Object
implements AuthenticationMechanismFactory
Class Inheritance
  • java.lang.Object
  • io.undertow.security.impl.DigestAuthenticationMechanism.Factory
All Implemented Interfaces
io.undertow.security.api.AuthenticationMechanismFactory

Constructor Summary

AccessConstructor and Description
public
Factory(IdentityManager identityManager)
Deprecated

public

Method Summary

Modifier and TypeMethod and Description
public AuthenticationMechanism
create(String
The name under which this factory was registered
mechanismName
,
IdentityManager
the IdentityManager instance asscociated with the deployment
identityManager
,
FormParserFactory
Parser to create a form data parser for a given request.
formParserFactory
,
Map<String, String>
The properties
properties
)

Overrides default io.undertow.security.api.AuthenticationMechanismFactory.create.

Creates an authentication mechanism that needs access to the deployment IdentityManager and specified properties

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Factoryback to summary
public Factory(IdentityManager identityManager)

Deprecated

Annotations
@Deprecated
Factoryback to summary
public Factory()

Method Detail

createback to summary
public AuthenticationMechanism create(String mechanismName, IdentityManager identityManager, FormParserFactory formParserFactory, Map<String, String> properties)

Overrides default io.undertow.security.api.AuthenticationMechanismFactory.create.

Doc from io.undertow.security.api.AuthenticationMechanismFactory.create.

Creates an authentication mechanism that needs access to the deployment IdentityManager and specified properties

Parameters
mechanismName:String

The name under which this factory was registered

identityManager:IdentityManager

the IdentityManager instance asscociated with the deployment

formParserFactory:FormParserFactory

Parser to create a form data parser for a given request.

properties:Map<String, String>

The properties

Returns:AuthenticationMechanism

The mechanism

Annotations
@Override