org.apache.commons.httpclient.auth

Class NTLMScheme

Implemented Interfaces:
AuthScheme

public class NTLMScheme
extends java.lang.Object
implements AuthScheme

An implementation of the Microsoft proprietary NTLM authentication scheme. For a detailed explanation of the NTLM scheme please see http://davenport.sourceforge.net/ntlm.html.
Authors:
Remy Maucherat
Rodney Waldhoff
Jeff Dever
Ortwin Gl???ck
Sean C. Sullivan
Adrian Sutton
Mike Bowler
Oleg Kalnichevski

Constructor Summary

NTLMScheme()
Default constructor for the NTLM authentication scheme.
NTLMScheme(String challenge)
Constructor for the NTLM authentication scheme.

Method Summary

String
authenticate(Credentials credentials, String method, String uri)
Deprecated. Use authenticate(Credentials,HttpMethod)
String
authenticate(Credentials credentials, HttpMethod method)
Produces NTLM authorization string for the given set of Credentials.
static String
authenticate(NTCredentials credentials, String challenge)
Deprecated. Use non-static authenticate(Credentials,HttpMethod)
static String
authenticate(NTCredentials credentials, String challenge, String charset)
Deprecated. Use non-static authenticate(Credentials,HttpMethod)
String
getID()
Deprecated. no longer used
String
getParameter(String name)
Returns the authentication parameter with the given name, if available.
String
getRealm()
The concept of an authentication realm is not supported by the NTLM authentication scheme.
String
getSchemeName()
Returns textual designation of the NTLM authentication scheme.
boolean
isComplete()
Tests if the NTLM authentication process has been completed.
boolean
isConnectionBased()
Returns true.
void
processChallenge(String challenge)
Processes the NTLM challenge.

Constructor Details

NTLMScheme

public NTLMScheme()
Default constructor for the NTLM authentication scheme.
Since:
3.0

NTLMScheme

public NTLMScheme(String challenge)
            throws MalformedChallengeException
Constructor for the NTLM authentication scheme.
Parameters:
challenge - The authentication challenge
Throws:
MalformedChallengeException - is thrown if the authentication challenge is malformed

Method Details

authenticate

public String authenticate(Credentials credentials,
                           String method,
                           String uri)
            throws AuthenticationException

Deprecated. Use authenticate(Credentials,HttpMethod)

Produces NTLM authorization string for the given set of Credentials.
Specified by:
authenticate in interface AuthScheme
Parameters:
credentials - The set of credentials to be used for athentication
method - Method name is ignored by the NTLM authentication scheme
uri - URI is ignored by the NTLM authentication scheme
Returns:
an NTLM authorization string
Throws:
AuthenticationException - if authorization string cannot be generated due to an authentication failure

authenticate

public String authenticate(Credentials credentials,
                           HttpMethod method)
            throws AuthenticationException
Produces NTLM authorization string for the given set of Credentials.
Specified by:
authenticate in interface AuthScheme
Parameters:
credentials - The set of credentials to be used for athentication
method - The method being authenticated
Returns:
an NTLM authorization string
Throws:
AuthenticationException - if authorization string cannot be generated due to an authentication failure
Since:
3.0

authenticate

public static String authenticate(NTCredentials credentials,
                                  String challenge)
            throws AuthenticationException

Deprecated. Use non-static authenticate(Credentials,HttpMethod)

Create a NTLM authorization string for the given challenge and NT credentials.
Parameters:
credentials - NTCredentials
challenge - The challenge.
Returns:
a ntlm authorization string
Throws:
AuthenticationException - is thrown if authentication fails

authenticate

public static String authenticate(NTCredentials credentials,
                                  String challenge,
                                  String charset)
            throws AuthenticationException

Deprecated. Use non-static authenticate(Credentials,HttpMethod)

Create a NTLM authorization string for the given challenge and NT credentials.
Parameters:
credentials - NTCredentials
challenge - The challenge.
charset - The charset to use for encoding the credentials
Returns:
a ntlm authorization string
Throws:
AuthenticationException - is thrown if authentication fails
Since:
3.0

getID

public String getID()

Deprecated. no longer used

Returns a String identifying the authentication challenge. This is used, in combination with the host and port to determine if authorization has already been attempted or not. Schemes which require multiple requests to complete the authentication should return a different value for each stage in the request.

Additionally, the ID should take into account any changes to the authentication challenge and return a different value when appropriate. For example when the realm changes in basic authentication it should be considered a different authentication attempt and a different value should be returned.

Specified by:
getID in interface AuthScheme
Returns:
String a String identifying the authentication challenge. The returned value may be null.

getParameter

public String getParameter(String name)
Returns the authentication parameter with the given name, if available.

There are no valid parameters for NTLM authentication so this method always returns null.

Specified by:
getParameter in interface AuthScheme
Parameters:
name - The name of the parameter to be returned
Returns:
the parameter with the given name

getRealm

public String getRealm()
The concept of an authentication realm is not supported by the NTLM authentication scheme. Always returns null.
Specified by:
getRealm in interface AuthScheme
Returns:
null

getSchemeName

public String getSchemeName()
Returns textual designation of the NTLM authentication scheme.
Specified by:
getSchemeName in interface AuthScheme
Returns:
ntlm

isComplete

public boolean isComplete()
Tests if the NTLM authentication process has been completed.
Specified by:
isComplete in interface AuthScheme
Returns:
true if Basic authorization has been processed, false otherwise.
Since:
3.0

isConnectionBased

public boolean isConnectionBased()
Returns true. NTLM authentication scheme is connection based.
Specified by:
isConnectionBased in interface AuthScheme
Returns:
true.
Since:
3.0

processChallenge

public void processChallenge(String challenge)
            throws MalformedChallengeException
Processes the NTLM challenge.
Specified by:
processChallenge in interface AuthScheme
Parameters:
challenge - the challenge string
Throws:
MalformedChallengeException - is thrown if the authentication challenge is malformed
Since:
3.0

Copyright (c) 1999-2005 - Apache Software Foundation