Top Description Inners Fields Methods
org.eclipse.jetty.client

public Interface Authentication

Known Direct Implementers
org.eclipse.jetty.client.AbstractAuthentication
Imports
java.net.URI, java.util.Map, org.eclipse.jetty.http.HttpHeader, org.eclipse.jetty.util.Attributes, .StringUtil

Authentication represents a mechanism to authenticate requests for protected resources.

Authentications are added to an AuthenticationStore, which is then queried to find the right Authentication mechanism to use based on its type, URI and realm, as returned by WWW-Authenticate response headers.

If an Authentication mechanism is found, it is then executed for the given request, returning an Authentication.Result, which is then stored in the AuthenticationStore so that subsequent requests can be preemptively authenticated.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Authentication.HeaderInfo

Structure holding information about the WWW-Authenticate (or Proxy-Authenticate) header.

public static interface
Authentication.Result

Result holds the information needed to authenticate a Request via Authentication.Result#apply(Request).

Field Summary

Modifier and TypeField and Description
public static final String
ANY_REALM

Constant used to indicate that any realm will match.

Method Summary

Modifier and TypeMethod and Description
public Authentication.Result

Returns:

the authentication result, or null if the authentication could not be performed
authenticate
(Request
the request to execute the authentication mechanism for
request
,
ContentResponse
the 401 response obtained in the previous attempt to request the protected resource
response
,
Authentication.HeaderInfo
the WWW-Authenticate (or Proxy-Authenticate) header chosen for this authentication (among the many that the response may contain)
headerInfo
,
Attributes
the conversation context in case the authentication needs multiple exchanges to be completed and information needs to be stored across exchanges
context
)

Executes the authentication mechanism for the given request, returning a Result that can be used to actually authenticate the request via Authentication.Result#apply(Request).

public boolean

Returns:

true if this authentication matches, false otherwise
matches
(String
the Authentication type such as "Basic" or "Digest"
type
,
URI
the request URI
uri
,
String
the authentication realm as provided in the WWW-Authenticate response header
realm
)

Matches Authentications based on the given parameters

Field Detail

ANY_REALMback to summary
public static final String ANY_REALM

Constant used to indicate that any realm will match.

See Also
matches(String, URI, String)

Method Detail

authenticateback to summary
public Authentication.Result authenticate(Request request, ContentResponse response, Authentication.HeaderInfo headerInfo, Attributes context)

Executes the authentication mechanism for the given request, returning a Result that can be used to actually authenticate the request via Authentication.Result#apply(Request).

If a request for "/secure" returns a 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:Request

the request to execute the authentication mechanism for

response:ContentResponse

the 401 response obtained in the previous attempt to request the protected resource

headerInfo:Authentication.HeaderInfo

the WWW-Authenticate (or Proxy-Authenticate) header chosen for this authentication (among the many that the response may contain)

context:Attributes

the conversation context in case the authentication needs multiple exchanges to be completed and information needs to be stored across exchanges

Returns:Authentication.Result

the authentication result, or null if the authentication could not be performed

matchesback to summary
public boolean matches(String type, URI uri, String realm)

Matches Authentications based on the given parameters

Parameters
type:String

the Authentication type such as "Basic" or "Digest"

uri:URI

the request URI

realm:String

the authentication realm as provided in the WWW-Authenticate response header

Returns:boolean

true if this authentication matches, false otherwise

org.eclipse.jetty.client back to summary

public Class Authentication.HeaderInfo

extends Object
Class Inheritance

Structure holding information about the WWW-Authenticate (or Proxy-Authenticate) header.

Field Summary

Modifier and TypeField and Description
private final HttpHeader
private final Map<String, String>
private final String

Constructor Summary

AccessConstructor and Description
public
HeaderInfo(HttpHeader header, String type, Map<String, String> params)

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the base64 content as a string if it exists otherwise null
getBase64
()

public HttpHeader

Returns:

the Authorization (or Proxy-Authorization) header
getHeader
()

public String

Returns:

specified authentication parameter or null if does not exist
getParameter
(String paramName)

public Map<String, String>

Returns:

additional authentication parameters
getParameters
()

public String

Returns:

the realm name or null if there is no realm parameter
getRealm
()

public String

Returns:

the authentication type (for example "Basic" or "Digest")
getType
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headerback to summary
private final HttpHeader header
paramsback to summary
private final Map<String, String> params
typeback to summary
private final String type

Constructor Detail

HeaderInfoback to summary
public HeaderInfo(HttpHeader header, String type, Map<String, String> params) throws IllegalArgumentException

Method Detail

getBase64back to summary
public String getBase64()
Returns:String

the base64 content as a string if it exists otherwise null

getHeaderback to summary
public HttpHeader getHeader()
Returns:HttpHeader

the Authorization (or Proxy-Authorization) header

getParameterback to summary
public String getParameter(String paramName)
Returns:String

specified authentication parameter or null if does not exist

getParametersback to summary
public Map<String, String> getParameters()
Returns:Map<String, String>

additional authentication parameters

getRealmback to summary
public String getRealm()
Returns:String

the realm name or null if there is no realm parameter

getTypeback to summary
public String getType()
Returns:String

the authentication type (for example "Basic" or "Digest")

org.eclipse.jetty.client back to summary

public Interface Authentication.Result

Known Direct Implementers
org.eclipse.jetty.client.BasicAuthentication.BasicResult, org.eclipse.jetty.client.DigestAuthentication.DigestResult, org.eclipse.jetty.client.SPNEGOAuthentication.SPNEGOResult

Result holds the information needed to authenticate a Request via Authentication.Result#apply(Request).

Method Summary

Modifier and TypeMethod and Description
public void
apply(Request
the request to authenticate
request
)

Applies the authentication result to the given request.

public URI

Returns:

the URI of the request that has been used to generate this Result
getURI
()

Method Detail

applyback to summary
public void apply(Request request)

Applies the authentication result to the given request. Typically, a Authorization header is added to the request, with the right information to successfully authenticate at the server.

Parameters
request:Request

the request to authenticate

getURIback to summary
public URI getURI()
Returns:URI

the URI of the request that has been used to generate this Result