Top Description Fields Constructors Methods
org.apache.http.impl.auth

public Class BasicScheme

extends RFC2617Scheme
Class Inheritance
Imports
java.nio.charset.Charset, org.apache.commons.codec.binary.Base64, org.apache.http.Consts, .Header, .HttpRequest, org.apache.http.auth.AUTH, .AuthenticationException, .ChallengeState, .Credentials, .MalformedChallengeException, org.apache.http.message.BufferedHeader, org.apache.http.protocol.BasicHttpContext, .HttpContext, org.apache.http.util.Args, .CharArrayBuffer, .EncodingUtils

Basic authentication scheme as defined in RFC 2617.
Since
4.0

Field Summary

Modifier and TypeField and Description
private boolean
complete

Whether the basic authentication process is complete

private static final long

Constructor Summary

AccessConstructor and Description
public
BasicScheme(final Charset credentialsCharset)

public
BasicScheme(final ChallengeState challengeState)

Deprecated (4.3) do not use.
Creates an instance of BasicScheme with the given challenge state.
public

Method Summary

Modifier and TypeMethod and Description
public Header
authenticate(final Credentials
The set of credentials to be used for athentication
credentials
,
final HttpRequest
The request being authenticated
request
)

Implements org.apache.http.auth.AuthScheme.authenticate.

Produces an authorization string for the given set of Credentials.
public Header

Returns:

a basic authorization string
authenticate
(final Credentials
The set of credentials to be used for authentication
credentials
,
final HttpRequest
The request being authenticated
request
,
final HttpContext
HTTP context
context
)

Overrides org.apache.http.impl.auth.AuthSchemeBase.authenticate.

Implements org.apache.http.auth.ContextAwareAuthScheme.authenticate.

Produces basic authorization header for the given set of Credentials.
public static Header

Returns:

a basic authorization header
authenticate
(final Credentials
The credentials to encode.
credentials
,
final String
The charset to use for encoding the credentials
charset
,
final boolean proxy)

Returns a basic Authorization header value for the given Credentials and charset.
public String

Returns:

basic
getSchemeName
()

Implements org.apache.http.auth.AuthScheme.getSchemeName.

Returns textual designation of the basic authentication scheme.
public boolean

Returns:

true if Basic authorization has been processed, false otherwise.
isComplete
()

Implements org.apache.http.auth.AuthScheme.isComplete.

Tests if the Basic authentication process has been completed.
public boolean

Returns:

false.
isConnectionBased
()

Implements org.apache.http.auth.AuthScheme.isConnectionBased.

Returns false.
public void
processChallenge(final Header
the challenge header
header
)

Overrides org.apache.http.impl.auth.AuthSchemeBase.processChallenge.

Implements org.apache.http.auth.AuthScheme.processChallenge.

Processes the Basic challenge.
public String
toString()

Overrides org.apache.http.impl.auth.AuthSchemeBase.toString.

Returns a string representation of the object.
Inherited from org.apache.http.impl.auth.RFC2617Scheme:
getCredentialsCharsetgetCredentialsCharsetgetParametergetParametersgetRealmparseChallenge

Field Detail

completeback to summary
private boolean complete

Whether the basic authentication process is complete

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.http.impl.auth.RFC2617Scheme.serialVersionUID.

Constructor Detail

BasicSchemeback to summary
public BasicScheme(final Charset credentialsCharset)
Since
4.3
BasicSchemeback to summary
public BasicScheme(final ChallengeState challengeState)

Deprecated

(4.3) do not use.

Creates an instance of BasicScheme with the given challenge state.

Annotations
@Deprecated
Since
4.2
BasicSchemeback to summary
public BasicScheme()

Method Detail

authenticateback to summary
public Header authenticate(final Credentials credentials, final HttpRequest request) throws AuthenticationException

Implements org.apache.http.auth.AuthScheme.authenticate.

Doc from org.apache.http.auth.AuthScheme.authenticate.

Produces an authorization string for the given set of Credentials.

Parameters
credentials:Credentials

The set of credentials to be used for athentication

request:HttpRequest

The request being authenticated

Returns:Header

the authorization string

Annotations
@Override
@Deprecated
Exceptions
AuthenticationException:
if authorization string cannot be generated due to an authentication failure
authenticateback to summary
public Header authenticate(final Credentials credentials, final HttpRequest request, final HttpContext context) throws AuthenticationException

Overrides org.apache.http.impl.auth.AuthSchemeBase.authenticate.

Implements org.apache.http.auth.ContextAwareAuthScheme.authenticate.

Produces basic authorization header for the given set of Credentials.

Parameters
credentials:Credentials

The set of credentials to be used for authentication

request:HttpRequest

The request being authenticated

context:HttpContext

Doc from org.apache.http.auth.ContextAwareAuthScheme.authenticate.

HTTP context

Returns:Header

a basic authorization string

Annotations
@Override
Exceptions
AuthenticationException:
if authorization string cannot be generated due to an authentication failure
InvalidCredentialsException:
if authentication credentials are not valid or not applicable for this authentication scheme
authenticateback to summary
public static Header authenticate(final Credentials credentials, final String charset, final boolean proxy)

Returns a basic Authorization header value for the given Credentials and charset.

Parameters
credentials:Credentials

The credentials to encode.

charset:String

The charset to use for encoding the credentials

Returns:Header

a basic authorization header

Annotations
@Deprecated
getSchemeNameback to summary
public String getSchemeName()

Implements org.apache.http.auth.AuthScheme.getSchemeName.

Returns textual designation of the basic authentication scheme.

Returns:String

basic

Annotations
@Override
isCompleteback to summary
public boolean isComplete()

Implements org.apache.http.auth.AuthScheme.isComplete.

Tests if the Basic authentication process has been completed.

Returns:boolean

true if Basic authorization has been processed, false otherwise.

Annotations
@Override
isConnectionBasedback to summary
public boolean isConnectionBased()

Implements org.apache.http.auth.AuthScheme.isConnectionBased.

Returns false. Basic authentication scheme is request based.

Returns:boolean

false.

Annotations
@Override
processChallengeback to summary
public void processChallenge(final Header header) throws MalformedChallengeException

Overrides org.apache.http.impl.auth.AuthSchemeBase.processChallenge.

Implements org.apache.http.auth.AuthScheme.processChallenge.

Processes the Basic challenge.

Parameters
header:Header

the challenge header

Annotations
@Override
Exceptions
MalformedChallengeException:
is thrown if the authentication challenge is malformed
toStringback to summary
public String toString()

Overrides org.apache.http.impl.auth.AuthSchemeBase.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override