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

public Class BasicAuthentication

extends AbstractAuthentication
Class Inheritance
Imports
java.net.URI, java.nio.charset.Charset, .StandardCharsets, java.util.Base64, org.eclipse.jetty.http.HttpHeader, org.eclipse.jetty.util.Attributes

Implementation of the HTTP "Basic" authentication defined in RFC 2617.

Applications should create objects of this class and add them to the AuthenticationStore retrieved from the HttpClient via HttpClient#getAuthenticationStore().

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
BasicAuthentication.BasicResult

Basic authentication result.

Field Summary

Modifier and TypeField and Description
private final String
private final String

Constructor Summary

AccessConstructor and Description
public
BasicAuthentication(URI
the URI to match for the authentication
uri
,
String
the realm to match for the authentication
realm
,
String
the user that wants to authenticate
user
,
String
the password of the user
password
)

Method Summary

Modifier and TypeMethod and Description
public Authentication.Result
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
)

Implements org.eclipse.jetty.client.Authentication.authenticate.

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 String
Inherited from org.eclipse.jetty.client.AbstractAuthentication:
getRealmgetURImatchesmatchesURI

Field Detail

passwordback to summary
private final String password
userback to summary
private final String user

Constructor Detail

BasicAuthenticationback to summary
public BasicAuthentication(URI uri, String realm, String user, String password)
Parameters
uri:URI

the URI to match for the authentication

realm:String

the realm to match for the authentication

user:String

the user that wants to authenticate

password:String

the password of the user

Method Detail

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

Implements org.eclipse.jetty.client.Authentication.authenticate.

Doc from org.eclipse.jetty.client.Authentication.authenticate.

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

Annotations
@Override
getTypeback to summary
public String getType()

Implements abstract org.eclipse.jetty.client.AbstractAuthentication.getType.

Annotations
@Override
org.eclipse.jetty.client back to summary

public Class BasicAuthentication.BasicResult

extends Object
implements Result
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.client.Authentication.Result

Basic authentication result.

Application may utilize this class directly via AuthenticationStore#addAuthenticationResult(Result) to perform preemptive authentication, that is immediately sending the authorization header based on the fact that the URI is known to require authentication and that username and password are known a priori.

Field Summary

Modifier and TypeField and Description
private final HttpHeader
private final URI
private final String

Constructor Summary

AccessConstructor and Description
public
BasicResult(URI uri, String user, String password)

public
BasicResult(URI uri, HttpHeader header, String user, String password)

public
BasicResult(URI uri, HttpHeader header, String user, String password, Charset charset)

Method Summary

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

Implements org.eclipse.jetty.client.Authentication.Result.apply.

Applies the authentication result to the given request.

public URI
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

headerback to summary
private final HttpHeader header
uriback to summary
private final URI uri
valueback to summary
private final String value

Constructor Detail

BasicResultback to summary
public BasicResult(URI uri, String user, String password)
BasicResultback to summary
public BasicResult(URI uri, HttpHeader header, String user, String password)
BasicResultback to summary
public BasicResult(URI uri, HttpHeader header, String user, String password, Charset charset)

Method Detail

applyback to summary
public void apply(Request request)

Implements org.eclipse.jetty.client.Authentication.Result.apply.

Doc from org.eclipse.jetty.client.Authentication.Result.apply.

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

Annotations
@Override
getURIback to summary
public URI getURI()

Implements org.eclipse.jetty.client.Authentication.Result.getURI.

Returns:URI

Doc from org.eclipse.jetty.client.Authentication.Result.getURI.

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

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. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override