if (this.state == UNINITIATED) {
throw new IllegalStateException("NTLM authentication process has not been initiated");
}
NTCredentials ntcredentials = null;
try {
ntcredentials = (NTCredentials) credentials;
} catch (ClassCastException e) {
throw new InvalidCredentialsException(
"Credentials cannot be used for NTLM authentication: "
+ credentials.getClass().getName());
}
NTLM ntlm = new NTLM();
String response = null;
if (this.state == INITIATED || this.state == FAILED) {
response = ntlm.getType1Message(
ntcredentials.getHost(),
ntcredentials.getDomain());
this.state = TYPE1_MSG_GENERATED;
} else {
response = ntlm.getType3Message(
ntcredentials.getUserName(),
ntcredentials.getPassword(),
ntcredentials.getHost(),
ntcredentials.getDomain(),
ntlm.parseType2Message(this.ntlmchallenge));
this.state = TYPE3_MSG_GENERATED;
}
return "NTLM " + response;
}