public class

AuthenticationHeader

extends Object
java.lang.Object
   ↳ sun.net.www.protocol.http.AuthenticationHeader

Class Overview

This class is used to parse the information in WWW-Authenticate: and Proxy-Authenticate: headers. It searches among multiple header lines and within each header line for the best currently supported scheme. It can also return a HeaderParser containing the challenge data for that particular scheme. Some examples: WWW-Authenticate: Basic realm="foo" Digest realm="bar" NTLM Note the realm parameter must be associated with the particular scheme. or WWW-Authenticate: Basic realm="foo" WWW-Authenticate: Digest realm="foo",qop="auth",nonce="thisisanunlikelynonce" WWW-Authenticate: NTLM or WWW-Authenticate: Basic realm="foo" WWW-Authenticate: NTLM ASKAJK9893289889QWQIOIONMNMN The last example shows how NTLM breaks the rules of rfc2617 for the structure of the authentication header. This is the reason why the raw header field is used for ntlm. At present, the class chooses schemes in following order : 1. Negotiate (if supported) 2. Kerberos (if supported) 3. Digest 4. NTLM (if supported) 5. Basic This choice can be modified by setting a system property: -Dhttp.auth.preference="scheme" which in this case, specifies that "scheme" should be used as the auth scheme when offered disregarding the default prioritisation. If scheme is not offered then the default priority is used. Attention: when http.auth.preference is set as SPNEGO or Kerberos, it's actually "Negotiate with SPNEGO" or "Negotiate with Kerberos", which means the user will prefer the Negotiate scheme with GSS/SPNEGO or GSS/Kerberos mechanism. This also means that the real "Kerberos" scheme can never be set as a preference.

Summary

Public Constructors
AuthenticationHeader(String hdrname, MessageHeader response)
parse a set of authentication headers and choose the preferred scheme that we support
AuthenticationHeader(String hdrname, MessageHeader response, String host)
parse a set of authentication headers and choose the preferred scheme that we support for a given host
Public Methods
HeaderParser headerParser()
return a header parser containing the preferred authentication scheme (only).
boolean isPresent()
returns true is the header exists and contains a recognised scheme
String raw()
String scheme()
return the name of the preferred scheme
String toString()
Returns a string representation of the object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AuthenticationHeader (String hdrname, MessageHeader response)

parse a set of authentication headers and choose the preferred scheme that we support

public AuthenticationHeader (String hdrname, MessageHeader response, String host)

parse a set of authentication headers and choose the preferred scheme that we support for a given host

Public Methods

public HeaderParser headerParser ()

return a header parser containing the preferred authentication scheme (only). The preferred scheme is the strongest of the schemes proposed by the server. The returned HeaderParser will contain the relevant parameters for that scheme

public boolean isPresent ()

returns true is the header exists and contains a recognised scheme

public String raw ()

public String scheme ()

return the name of the preferred scheme

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a string representation of the object.