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

pack-priv final Class DigestAuthentication

extends AuthenticationInfo
Class Inheritance
Imports
java.io.*, java.net.PasswordAuthentication, .ProtocolException, .URL, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.CharacterCodingException, .Charset, .CharsetEncoder, .StandardCharsets, java.security.MessageDigest, .NoSuchAlgorithmException, .Security, java.text.Normalizer, java.util.Arrays, .HashSet, .Locale, .Random, .Set, java.util.function.BiConsumer, sun.net.NetProperties, sun.net.www.HeaderParser, sun.nio.cs.ISO_8859_1, sun.security.util.KnownOIDs, sun.util.logging.PlatformLogger

DigestAuthentication: Encapsulate an http server authentication using the "Digest" scheme, as described in RFC2069 and updated in RFC2617
Author
Bill Foote

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private String
private static final char[]
private static final String
private static final boolean
private static final Set<String>
private static final String
private static final PlatformLogger
pack-priv DigestAuthentication.Parameters
private static final String
private static final String
private static final String[]
Inherited from sun.net.www.protocol.http.AuthenticationInfo:
authSchemehostpathportprotocolPROXY_AUTHENTICATIONpwrealmserializeAuthSERVER_AUTHENTICATIONtype

Constructor Summary

AccessConstructor and Description
public
DigestAuthentication(boolean isProxy, URL url, String realm, String authMethod, PasswordAuthentication pw, DigestAuthentication.Parameters params)

Create a DigestAuthentication

public
DigestAuthentication(boolean isProxy, String host, int port, String realm, String authMethod, PasswordAuthentication pw, DigestAuthentication.Parameters params)

Method Summary

Modifier and TypeMethod and Description
public void
checkResponse(String header, String method, URL url)

public void
checkResponse(String header, String method, String uri)

private String
computeDigest(boolean isRequest, String userName, char[] password, String realm, String connMethod, String requestURI, String nonceString, String cnonce, String ncValue, String algorithm, boolean session, Charset charset)

private String
computeUserhash(String digest, String user, String realm, Charset charset)

private String
encode(String src, char[] passwd, MessageDigest md, Charset charset)

public String

Returns:

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

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

Recalculates the request-digest and returns it.

pack-priv String

Returns:

the value of the HTTP header this authentication wants set
getHeaderValue
(String
the Request-URI from the HTTP request line
requestURI
,
String
the HTTP method
method
)

Recalculates the request-digest and returns it.

private String
private static byte[]
getUtf8Bytes(char[] passwd)

public boolean
isAuthorizationStale(String header)

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

Check if the header indicates that the current auth.

private static void
log(String msg)

private static void
private static void
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
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

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

Field Detail

authMethodback to summary
private String authMethod
charArrayback to summary
private static final char[] charArray
compatPropNameback to summary
private static final String compatPropName
delimCompatFlagback to summary
private static final boolean delimCompatFlag
disabledDigestsback to summary
private static final Set<String> disabledDigests
enabledAlgPropNameback to summary
private static final String enabledAlgPropName
loggerback to summary
private static final PlatformLogger logger
paramsback to summary
pack-priv DigestAuthentication.Parameters params
propPrefixback to summary
private static final String propPrefix
secPropNameback to summary
private static final String secPropName
zeroPadback to summary
private static final String[] zeroPad

Constructor Detail

DigestAuthenticationback to summary
public DigestAuthentication(boolean isProxy, URL url, String realm, String authMethod, PasswordAuthentication pw, DigestAuthentication.Parameters params)

Create a DigestAuthentication

DigestAuthenticationback to summary
public DigestAuthentication(boolean isProxy, String host, int port, String realm, String authMethod, PasswordAuthentication pw, DigestAuthentication.Parameters params)

Method Detail

checkResponseback to summary
public void checkResponse(String header, String method, URL url) throws IOException
checkResponseback to summary
public void checkResponse(String header, String method, String uri) throws IOException
computeDigestback to summary
private String computeDigest(boolean isRequest, String userName, char[] password, String realm, String connMethod, String requestURI, String nonceString, String cnonce, String ncValue, String algorithm, boolean session, Charset charset) throws NoSuchAlgorithmException, CharacterCodingException
computeUserhashback to summary
private String computeUserhash(String digest, String user, String realm, Charset charset) throws NoSuchAlgorithmException, CharacterCodingException
encodeback to summary
private String encode(String src, char[] passwd, MessageDigest md, Charset charset) throws CharacterCodingException
getHeaderValueback to summary
public String getHeaderValue(URL url, String method)

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

Recalculates the request-digest and returns it.

Used in the common case where the requestURI is simply the abs_path.

Parameters
url:URL

the URL

method:String

the HTTP method

Returns:String

the value of the HTTP header this authentication wants set

Annotations
@Override
getHeaderValueback to summary
pack-priv String getHeaderValue(String requestURI, String method)

Recalculates the request-digest and returns it.

Used when the requestURI is not the abs_path. The exact requestURI can be passed as a String.

Parameters
requestURI:String

the Request-URI from the HTTP request line

method:String

the HTTP method

Returns:String

the value of the HTTP header this authentication wants set

getHeaderValueImplback to summary
private String getHeaderValueImpl(String uri, String method) throws IOException
getUtf8Bytesback to summary
private static byte[] getUtf8Bytes(char[] passwd) throws CharacterCodingException
isAuthorizationStaleback to summary
public boolean isAuthorizationStale(String header)

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

Check if the header indicates that the current auth. parameters are stale. If so, then replace the relevant field with the new value and return true. Otherwise return false. returning true means the request can be retried with the same userid/password returning false means we have to go back to the user to ask for a new username password.

Annotations
@Override
logback to summary
private static void log(String msg)
processPropValueback to summary
private static void processPropValue(String input, Set<String> theSet, BiConsumer<Set<String>, String> consumer)
setAlgorithmNamesback to summary
private static void setAlgorithmNames(HeaderParser p, DigestAuthentication.Parameters params) throws IOException
setHeadersback to summary
public void setHeaders(HttpURLConnection conn, HeaderParser p, String raw) throws IOException

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

Set header(s) on the given connection.

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

Raw header values for this connection, if needed.

Annotations
@Override
Exceptions
IOException:
if no headers were set
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
validateDigestback to summary
private void validateDigest(String name) throws IOException
sun.net.www.protocol.http back to summary

pack-priv Class DigestAuthentication.Parameters

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private String
private String
private String
private String
pack-priv int
private static final int
private static final int
private String
private int
private String
private String
private static final Random
private boolean
private static final long
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
pack-priv synchronized String
pack-priv synchronized String
pack-priv synchronized Charset
pack-priv synchronized String
pack-priv synchronized String
pack-priv synchronized int
pack-priv synchronized String
pack-priv synchronized String
pack-priv synchronized boolean
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
setCharset(String charset)

pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
pack-priv synchronized void
setUserhash(boolean userhash)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private String algorithm
cachedHA1back to summary
private String cachedHA1
charsetback to summary
private String charset
cnonceback to summary
private String cnonce
cnonce_countback to summary
pack-priv int cnonce_count
cnoncelenback to summary
private static final int cnoncelen
cnonceRepeatback to summary
private static final int cnonceRepeat
digestNameback to summary
private String digestName
NCcountback to summary
private int NCcount
nonceback to summary
private String nonce
opaqueback to summary
private String opaque
randomback to summary
private static final Random random
redoCachedHA1back to summary
private boolean redoCachedHA1
serialVersionUIDback to summary
private static final long serialVersionUID
serverQopback to summary
private boolean serverQop
userhashback to summary
private boolean userhash

Constructor Detail

Parametersback to summary
pack-priv Parameters()

Method Detail

authQopback to summary
pack-priv boolean authQop()
getAlgorithmback to summary
pack-priv synchronized String getAlgorithm()
getCachedHA1back to summary
pack-priv synchronized String getCachedHA1()
getCharsetback to summary
pack-priv synchronized Charset getCharset()
getCnonceback to summary
pack-priv synchronized String getCnonce()
getDigestNameback to summary
pack-priv synchronized String getDigestName()
getNCCountback to summary
pack-priv synchronized int getNCCount()
getNonceback to summary
pack-priv synchronized String getNonce()
getOpaqueback to summary
pack-priv synchronized String getOpaque()
getUserhashback to summary
pack-priv synchronized boolean getUserhash()
incrementNCback to summary
pack-priv synchronized void incrementNC()
setAlgorithmback to summary
pack-priv synchronized void setAlgorithm(String s)
setCachedHA1back to summary
pack-priv synchronized void setCachedHA1(String s)
setCharsetback to summary
pack-priv synchronized void setCharset(String charset)
setDigestNameback to summary
pack-priv synchronized void setDigestName(String s)
setNewCnonceback to summary
pack-priv synchronized void setNewCnonce()
setNonceback to summary
pack-priv synchronized void setNonce(String s)
setOpaqueback to summary
pack-priv synchronized void setOpaque(String s)
setQopback to summary
pack-priv synchronized void setQop(String qop)
setUserhashback to summary
pack-priv synchronized void setUserhash(boolean userhash)