APIdia Launch Partner
Top Description Fields Constructors Methods
sun.net.www.protocol.http

pack-priv final Class BasicAuthentication

extends AuthenticationInfo
Class Inheritance
Imports
java.net.URL, .URI, .URISyntaxException, .PasswordAuthentication, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, java.util.Arrays, .Base64, sun.net.www.HeaderParser, sun.nio.cs.ISO_8859_1, .UTF_8

BasicAuthentication: Encapsulate an http server authentication using the "basic" scheme.
Author
Bill Foote

Field Summary

Modifier and TypeField and Description
pack-priv final String
auth

The authentication string for this host, port, and realm.

Inherited from sun.net.www.protocol.http.AuthenticationInfo:
authSchemehostpathportprotocolPROXY_AUTHENTICATIONpwrealmserializeAuthSERVER_AUTHENTICATIONtype

Constructor Summary

AccessConstructor and Description
public
BasicAuthentication(boolean isProxy, String host, int port, String realm, PasswordAuthentication pw, boolean isUTF8)

Create a BasicAuthentication

public
BasicAuthentication(boolean isProxy, String host, int port, String realm, String auth)

Create a BasicAuthentication

public
BasicAuthentication(boolean isProxy, URL url, String realm, PasswordAuthentication pw, boolean isUTF8)

Create a BasicAuthentication

public
BasicAuthentication(boolean isProxy, URL url, String realm, String auth)

Create a BasicAuthentication

Method Summary

Modifier and TypeMethod and Description
private static String
public String

Returns:

the value of the HTTP header this authentication wants set
getHeaderValue
(URL url, String method)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.getHeaderValue.

Calculates and returns the authentication header value based on the stored authentication parameters.

pack-priv static String
getRootPath(String npath, String opath)

Returns: the common root path between npath and path.

public boolean
isAuthorizationStale(String header)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.isAuthorizationStale.

For Basic Authentication, the security parameters can never be stale.

public void
setHeaders(HttpURLConnection
The connection to apply the header(s) to
conn
,
HeaderParser
A source of header values for this connection, if needed.
p
,
String
The raw header values for this connection, if needed.
raw
)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.setHeaders.

Set header(s) on the given connection.

public boolean
supportsPreemptiveAuthorization()

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.supportsPreemptiveAuthorization.

Returns: true if this authentication supports preemptive authorization

Inherited from sun.net.www.protocol.http.AuthenticationInfo:
addToCachecacheKeyclonecredentialsdisposeContextendAuthRequestgetAuthgetAuthSchemegetAuthTypegetHeaderNamegetHostgetPathgetPortgetProtocolSchemegetProxyAuthgetProxyAuthgetProxyAuthKeygetRealmgetServerAuthgetServerAuthgetServerAuthKeyreducePathremoveFromCacheuseAuthCache

Field Detail

authback to summary
pack-priv final String auth

The authentication string for this host, port, and realm. This is a simple BASE64 encoding of "login:password".

Constructor Detail

BasicAuthenticationback to summary
public BasicAuthentication(boolean isProxy, String host, int port, String realm, PasswordAuthentication pw, boolean isUTF8)

Create a BasicAuthentication

BasicAuthenticationback to summary
public BasicAuthentication(boolean isProxy, String host, int port, String realm, String auth)

Create a BasicAuthentication

BasicAuthenticationback to summary
public BasicAuthentication(boolean isProxy, URL url, String realm, PasswordAuthentication pw, boolean isUTF8)

Create a BasicAuthentication

BasicAuthenticationback to summary
public BasicAuthentication(boolean isProxy, URL url, String realm, String auth)

Create a BasicAuthentication

Method Detail

authValueFromback to summary
private static String authValueFrom(PasswordAuthentication pw, boolean isUTF8)
getHeaderValueback to summary
public String getHeaderValue(URL url, String method)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.getHeaderValue.

Doc from sun.net.www.protocol.http.AuthenticationInfo.getHeaderValue.

Calculates and returns the authentication header value based on the stored authentication parameters. If the calculation does not depend on the URL or the request method then these parameters are ignored.

Returns:String

the value of the HTTP header this authentication wants set

Annotations
@Override
getRootPathback to summary
pack-priv static String getRootPath(String npath, String opath)
Returns:String

the common root path between npath and path. This is used to detect when we have an authentication for two paths and the root of th authentication space is the common root.

isAuthorizationStaleback to summary
public boolean isAuthorizationStale(String header)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.isAuthorizationStale.

For Basic Authentication, the security parameters can never be stale. In other words there is no possibility to reuse the credentials. They are always either valid or invalid.

Annotations
@Override
setHeadersback to summary
public void setHeaders(HttpURLConnection conn, HeaderParser p, String raw)

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.setHeaders.

Set header(s) on the given connection. This will only be called for definitive (i.e. non-preemptive) authorization.

Parameters
conn:HttpURLConnection

The connection to apply the header(s) to

p:HeaderParser

A source of header values for this connection, if needed.

raw:String

The raw header values for this connection, if needed.

Annotations
@Override
supportsPreemptiveAuthorizationback to summary
public boolean supportsPreemptiveAuthorization()

Implements abstract sun.net.www.protocol.http.AuthenticationInfo.supportsPreemptiveAuthorization.

Returns:boolean

true if this authentication supports preemptive authorization

Annotations
@Override