예제 #1
0
 public static String authenticate(NTCredentials paramNTCredentials, String paramString)
     throws AuthenticationException {
   LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)");
   if (paramNTCredentials == null)
     throw new IllegalArgumentException("Credentials may not be null");
   paramNTCredentials =
       new NTLM()
           .getResponseFor(
               paramString,
               paramNTCredentials.getUserName(),
               paramNTCredentials.getPassword(),
               paramNTCredentials.getHost(),
               paramNTCredentials.getDomain());
   return "NTLM " + paramNTCredentials;
 }
예제 #2
0
 public String authenticate(Credentials paramCredentials, HttpMethod paramHttpMethod)
     throws AuthenticationException {
   LOG.trace("enter NTLMScheme.authenticate(Credentials, HttpMethod)");
   if (this.state == 0)
     throw new IllegalStateException("NTLM authentication process has not been initiated");
   while (true) {
     NTCredentials localNTCredentials;
     try {
       localNTCredentials = (NTCredentials) paramCredentials;
       paramCredentials = new NTLM();
       paramCredentials.setCredentialCharset(paramHttpMethod.getParams().getCredentialCharset());
       if ((this.state == 1) || (this.state == 2147483647)) {
         paramCredentials =
             paramCredentials.getType1Message(
                 localNTCredentials.getHost(), localNTCredentials.getDomain());
         this.state = 2;
         return "NTLM " + paramCredentials;
       }
     } catch (ClassCastException paramHttpMethod) {
       throw new InvalidCredentialsException(
           "Credentials cannot be used for NTLM authentication: "
               + paramCredentials.getClass().getName());
     }
     paramCredentials =
         paramCredentials.getType3Message(
             localNTCredentials.getUserName(),
             localNTCredentials.getPassword(),
             localNTCredentials.getHost(),
             localNTCredentials.getDomain(),
             paramCredentials.parseType2Message(this.ntlmchallenge));
     this.state = 4;
   }
 }