Methods Summary |
---|
public org.apache.http.Header | authenticate(org.apache.http.auth.Credentials credentials, org.apache.http.HttpRequest request)
NTCredentials ntcredentials = null;
try {
ntcredentials = (NTCredentials) credentials;
} catch (ClassCastException e) {
throw new InvalidCredentialsException(
"Credentials cannot be used for NTLM authentication: "
+ credentials.getClass().getName());
}
String response = null;
if (this.state == State.CHALLENGE_RECEIVED || this.state == State.FAILED) {
response = this.engine.generateType1Msg(
ntcredentials.getDomain(),
ntcredentials.getWorkstation());
this.state = State.MSG_TYPE1_GENERATED;
} else if (this.state == State.MSG_TYPE2_RECEVIED) {
response = this.engine.generateType3Msg(
ntcredentials.getUserName(),
ntcredentials.getPassword(),
ntcredentials.getDomain(),
ntcredentials.getWorkstation(),
this.challenge);
this.state = State.MSG_TYPE3_GENERATED;
} else {
throw new AuthenticationException("Unexpected state: " + this.state);
}
CharArrayBuffer buffer = new CharArrayBuffer(32);
if (isProxy()) {
buffer.append(AUTH.PROXY_AUTH_RESP);
} else {
buffer.append(AUTH.WWW_AUTH_RESP);
}
buffer.append(": NTLM ");
buffer.append(response);
return new BufferedHeader(buffer);
|
public java.lang.String | getParameter(java.lang.String name)
// String parameters not supported
return null;
|
public java.lang.String | getRealm()
// NTLM does not support the concept of an authentication realm
return null;
|
public java.lang.String | getSchemeName()
return "ntlm";
|
public boolean | isComplete()
return this.state == State.MSG_TYPE3_GENERATED || this.state == State.FAILED;
|
public boolean | isConnectionBased()
return true;
|
protected void | parseChallenge(org.apache.http.util.CharArrayBuffer buffer, int pos, int len)
String challenge = buffer.substringTrimmed(pos, len);
if (challenge.length() == 0) {
if (this.state == State.UNINITIATED) {
this.state = State.CHALLENGE_RECEIVED;
} else {
this.state = State.FAILED;
}
this.challenge = null;
} else {
this.state = State.MSG_TYPE2_RECEVIED;
this.challenge = challenge;
}
|