Package org.eclipse.jetty.client.util
Class DigestAuthentication
- java.lang.Object
-
- org.eclipse.jetty.client.util.AbstractAuthentication
-
- org.eclipse.jetty.client.util.DigestAuthentication
-
- All Implemented Interfaces:
Authentication
public class DigestAuthentication extends AbstractAuthentication
Implementation of the HTTP "Digest" authentication defined in RFC 2617.Applications should create objects of this class and add them to the
AuthenticationStore
retrieved from theHttpClient
viaHttpClient.getAuthenticationStore()
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Authentication
Authentication.HeaderInfo, Authentication.Result
-
-
Field Summary
-
Fields inherited from interface org.eclipse.jetty.client.api.Authentication
ANY_REALM
-
-
Constructor Summary
Constructors Constructor Description DigestAuthentication(java.net.URI uri, java.lang.String realm, java.lang.String user, java.lang.String password)
Construct a DigestAuthentication with aSecureRandom
nonce.DigestAuthentication(java.net.URI uri, java.lang.String realm, java.lang.String user, java.lang.String password, java.util.Random random)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Authentication.Result
authenticate(Request request, ContentResponse response, Authentication.HeaderInfo headerInfo, Attributes context)
Executes the authentication mechanism for the given request, returning aAuthentication.Result
that can be used to actually authenticate the request viaAuthentication.Result.apply(Request)
.java.lang.String
getType()
boolean
matches(java.lang.String type, java.net.URI uri, java.lang.String realm)
MatchesAuthentication
s based on the given parameters-
Methods inherited from class org.eclipse.jetty.client.util.AbstractAuthentication
getRealm, getURI, matchesURI
-
-
-
-
Constructor Detail
-
DigestAuthentication
public DigestAuthentication(java.net.URI uri, java.lang.String realm, java.lang.String user, java.lang.String password)
Construct a DigestAuthentication with aSecureRandom
nonce.- Parameters:
uri
- the URI to match for the authenticationrealm
- the realm to match for the authenticationuser
- the user that wants to authenticatepassword
- the password of the user
-
DigestAuthentication
public DigestAuthentication(java.net.URI uri, java.lang.String realm, java.lang.String user, java.lang.String password, java.util.Random random)
- Parameters:
uri
- the URI to match for the authenticationrealm
- the realm to match for the authenticationuser
- the user that wants to authenticatepassword
- the password of the userrandom
- the Random generator to use for nonces.
-
-
Method Detail
-
getType
public java.lang.String getType()
- Specified by:
getType
in classAbstractAuthentication
-
matches
public boolean matches(java.lang.String type, java.net.URI uri, java.lang.String realm)
Description copied from interface:Authentication
MatchesAuthentication
s based on the given parameters- Specified by:
matches
in interfaceAuthentication
- Overrides:
matches
in classAbstractAuthentication
- Parameters:
type
- theAuthentication
type such as "Basic" or "Digest"uri
- the request URIrealm
- the authentication realm as provided in theWWW-Authenticate
response header- Returns:
- true if this authentication matches, false otherwise
-
authenticate
public Authentication.Result authenticate(Request request, ContentResponse response, Authentication.HeaderInfo headerInfo, Attributes context)
Description copied from interface:Authentication
Executes the authentication mechanism for the given request, returning aAuthentication.Result
that can be used to actually authenticate the request viaAuthentication.Result.apply(Request)
.If a request for
"/secure"
returns aAuthentication.Result
, then the result may be used for other requests such as"/secure/foo"
or"/secure/bar"
, unless those resources are protected by other realms.- Parameters:
request
- the request to execute the authentication mechanism forresponse
- the 401 response obtained in the previous attempt to request the protected resourceheaderInfo
- theWWW-Authenticate
(orProxy-Authenticate
) header chosen for this authentication (among the many that the response may contain)context
- the conversation context in case the authentication needs multiple exchanges to be completed and information needs to be stored across exchanges- Returns:
- the authentication result, or null if the authentication could not be performed
-
-