public class HttpAuthConfig extends Object implements IXMLConfigurable
Generic HTTP Fetcher authentication configuration.
<method>[form|basic|digest|ntlm|spnego|kerberos]</method>
<!-- These apply to any authentication mechanism -->
<credentials>
<username>(the username)</username>
<password>(the optionally encrypted password)</password>
<passwordKey>
<value>(The actual password encryption key or a reference to it.)</value>
<source>[key|file|environment|property]</source>
<size>(Size in bits of encryption key. Default is 128.)</size>
</passwordKey>
</credentials>
<!-- These apply to FORM authentication -->
<formUsernameField>...</formUsernameField>
<formPasswordField>...</formPasswordField>
<url>
(Either a login form's action target URL or the URL of a page containing
a login form if a "formSelector" is specified.)
</url>
<formCharset>...</formCharset>
<!-- Extra form parameters required to authenticate (since 2.8.0) -->
<formParams>
<param
name="(param name)">
(param value)
</param>
<!-- You can repeat this param tag as needed. -->
</formParams>
<formSelector>
(CSS selector identifying the login page. E.g., "form")
</formSelector>
<!-- These apply to both BASIC and DIGEST authentication -->
<host>
<name>(host name)</name>
<port>(host port)</port>
</host>
<realm>...</realm>
<!-- This applies to BASIC authentication -->
<preemptive>[false|true]</preemptive>
<!-- These apply to NTLM authentication -->
<host>
<name>(host name)</name>
<port>(host port)</port>
</host>
<workstation>...</workstation>
<domain>...</domain>
The above XML configurable options can be nested in a supporting parent tag of any name. The expected parent tag name is defined by the consuming classes (e.g. "authentication").
Modifier and Type | Field and Description |
---|---|
static String |
METHOD_BASIC
BASIC authentication method.
|
static String |
METHOD_DIGEST
DIGEST authentication method.
|
static String |
METHOD_FORM
Form-based authentication method.
|
static String |
METHOD_KERBEROS
Experimental: Kerberos authentication method.
|
static String |
METHOD_NTLM
NTLM authentication method.
|
static String |
METHOD_SPNEGO
Experimental: SPNEGO authentication method.
|
Constructor and Description |
---|
HttpAuthConfig() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Credentials |
getCredentials() |
String |
getDomain()
Gets the NTLM authentication domain.
|
Charset |
getFormCharset()
Gets the authentication form character set.
|
String |
getFormParam(String name)
Gets an authentication form parameter (equivalent to "input" or other
fields in HTML forms).
|
List<String> |
getFormParamNames()
Gets all authentication form parameter names.
|
Map<String,String> |
getFormParams()
Gets all authentication form parameters (equivalent to "input" or other
fields in HTML forms).
|
String |
getFormPasswordField()
Gets the name of the HTML field where the password is set.
|
String |
getFormSelector()
Gets the CSS selelector that identifies the form in a login page.
|
String |
getFormUsernameField()
Gets the name of the HTML field where the username is set.
|
Host |
getHost()
Gets the host for the current authentication scope.
|
String |
getMethod()
Gets the authentication method.
|
String |
getRealm()
Gets the realm name for the current authentication scope.
|
String |
getUrl()
Gets the URL for "form" authentication.
|
String |
getWorkstation()
Gets the NTLM authentication workstation name.
|
int |
hashCode() |
boolean |
isPreemptive()
Gets whether to perform preemptive authentication
(valid for "basic" authentication method).
|
void |
loadFromXML(XML xml) |
String |
removeFormParameter(String name)
Remove the authentication form parameter matching the given name.
|
void |
saveToXML(XML xml) |
void |
setCredentials(Credentials authCredentials) |
void |
setDomain(String domain)
Sets the NTLM authentication domain
|
void |
setFormCharset(Charset formCharset)
Sets the authentication form character set for the form field values.
|
void |
setFormParam(String name,
String value)
Sets an authentication form parameter (equivalent to "input" or other
fields in HTML forms).
|
void |
setFormParams(Map<String,String> params)
Sets authentication form parameters (equivalent to "input" or other
fields in HTML forms).
|
void |
setFormPasswordField(String formPasswordField)
Sets the name of the HTML field where the password is set.
|
void |
setFormSelector(String formSelector)
Sets the CSS selelector that identifies the form in a login page.
|
void |
setFormUsernameField(String formUsernameField)
Sets the name of the HTML field where the username is set.
|
void |
setHost(Host host)
Sets the host for the current authentication scope.
|
void |
setMethod(String method)
Sets the authentication method.
|
void |
setPreemptive(boolean preemptive)
Sets whether to perform preemptive authentication
(valid for "basic" authentication method).
|
void |
setRealm(String realm)
Sets the realm name for the current authentication scope.
|
void |
setUrl(String url)
Sets the URL for "form" authentication.
|
void |
setWorkstation(String workstation)
Sets the NTLM authentication workstation name.
|
String |
toString() |
public static final String METHOD_FORM
public static final String METHOD_BASIC
public static final String METHOD_DIGEST
public static final String METHOD_NTLM
public static final String METHOD_SPNEGO
public static final String METHOD_KERBEROS
public String getMethod()
public void setMethod(String method)
method
- authentication methodpublic String getFormUsernameField()
public void setFormUsernameField(String formUsernameField)
formUsernameField
- name of the HTML fieldpublic String getFormPasswordField()
public void setFormPasswordField(String formPasswordField)
formPasswordField
- name of the HTML fieldpublic Credentials getCredentials()
public void setCredentials(Credentials authCredentials)
public String getUrl()
public void setUrl(String url)
url
- "form" authentication URLpublic Host getHost()
null
means any host names for the scope.
Used for BASIC and DIGEST authentication.public void setHost(Host host)
host
- host for the scopepublic String getRealm()
null
indicates "any realm"
for the scope.
Used for BASIC and DIGEST authentication.public void setRealm(String realm)
realm
- reaml name for the scopepublic Charset getFormCharset()
public void setFormCharset(Charset formCharset)
formCharset
- authentication form character setpublic String getFormSelector()
getUrl()
to be pointing to a login
page containing a login form.public void setFormSelector(String formSelector)
getUrl()
to be pointing to a login
page containing a login form.formSelector
- form selectorpublic void setFormParam(String name, String value)
name
- form parameter namevalue
- form parameter valuepublic void setFormParams(Map<String,String> params)
params
- map of form parameter names and valuespublic String getFormParam(String name)
name
- form parameter namenull
if
no match is foundpublic Map<String,String> getFormParams()
public List<String> getFormParamNames()
public String removeFormParameter(String name)
name
- name of form parameter to removenull
if there was no form parameter for the name.public boolean isPreemptive()
true
to perform preemptive authenticationpublic void setPreemptive(boolean preemptive)
preemptive
- true
to perform preemptive authenticationpublic String getWorkstation()
public void setWorkstation(String workstation)
workstation
- workstation namepublic String getDomain()
public void setDomain(String domain)
domain
- authentication domainpublic void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
public void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
Copyright © 2009–2023 Norconex Inc.. All rights reserved.