Class DigestAuthenticationErrorInterceptor<A extends ExchangeContext,B extends ErrorExchange<A>>
- Type Parameters:
A
- the context typeB
- the error exchange type
- All Implemented Interfaces:
ExchangeInterceptor<A,
B>
An HTTP authentication error interceptor that implements RFC 7616 HTTP Digest Access Authentication.
As per RFC 7616, a digest challenge with realm
, domain
, nonce
, opaque
, stale
, algorithm
, qop
, charset
(optional) and userhash
(optional) parameters is sent to the requester to initiate digest HTTP authentication.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
MD5 algorithm (default).static final String
SHA-256 algorithm.static final String
SHA-512-256 algorithm.static final long
The default nonce validity period in seconds.Fields inherited from class io.inverno.mod.security.http.AuthenticationErrorInterceptor
terminal
-
Constructor Summary
ConstructorDescriptionDigestAuthenticationErrorInterceptor
(String realm, String secret) Creates a digest authentication error interceptor with the specified realm and secret.DigestAuthenticationErrorInterceptor
(String realm, String secret, String algorithm) Creates a digest authentication error interceptor with the specified realm, secret and algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createChallenge
(SecurityException cause) Creates the challenge to send to the requester.Returns the algorithm.long
Returns the nonce validity period in seconds.getRealm()
Returns the realm.void
setNonceValiditySeconds
(long nonceValiditySeconds) Sets the nonce validity period.Methods inherited from class io.inverno.mod.security.http.HttpAuthenticationErrorInterceptor
interceptUnauthorized
Methods inherited from class io.inverno.mod.security.http.AuthenticationErrorInterceptor
intercept
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.http.server.ExchangeInterceptor
andThen, compose
-
Field Details
-
ALGORITHM_MD5
MD5 algorithm (default).Only MD5 is supported in "modern" web browsers.
- See Also:
-
ALGORITHM_SHA_256
SHA-256 algorithm.Firefox 93 is the first browser supporting SHA-256.
- See Also:
-
ALGORITHM_SHA_512_256
SHA-512-256 algorithm.- See Also:
-
DEFAULT_NONCE_VALIDITY_SECONDS
public static final long DEFAULT_NONCE_VALIDITY_SECONDSThe default nonce validity period in seconds.- See Also:
-
-
Constructor Details
-
DigestAuthenticationErrorInterceptor
Creates a digest authentication error interceptor with the specified realm and secret.
- Parameters:
realm
- a realmsecret
- a secret
-
DigestAuthenticationErrorInterceptor
public DigestAuthenticationErrorInterceptor(String realm, String secret, String algorithm) throws IllegalArgumentException Creates a digest authentication error interceptor with the specified realm, secret and algorithm.
- Parameters:
realm
- a realmsecret
- a secretalgorithm
- an algorithm- Throws:
IllegalArgumentException
- if specified parameters are incorrect
-
-
Method Details
-
getRealm
Returns the realm.
- Returns:
- the realm
-
getAlgorithm
Returns the algorithm.
- Returns:
- the algorithm
-
setNonceValiditySeconds
public void setNonceValiditySeconds(long nonceValiditySeconds) Sets the nonce validity period.
- Parameters:
nonceValiditySeconds
- the nonce validity period in seconds
-
getNonceValiditySeconds
public long getNonceValiditySeconds()Returns the nonce validity period in seconds.
- Returns:
- the nonce validity period in seconds
-
createChallenge
Description copied from class:HttpAuthenticationErrorInterceptor
Creates the challenge to send to the requester.
- Specified by:
createChallenge
in classHttpAuthenticationErrorInterceptor<A extends ExchangeContext,
B extends ErrorExchange<A>> - Parameters:
cause
- the cause of the error (can be null)- Returns:
- a challenge
-