Example usage for org.apache.commons.httpclient.auth NTLM setCredentialCharset

List of usage examples for org.apache.commons.httpclient.auth NTLM setCredentialCharset

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.auth NTLM setCredentialCharset.

Prototype

public void setCredentialCharset(String paramString) 

Source Link

Usage

From source file:it.greenvulcano.gvesb.http.ntlm.JCIFS_NTLMScheme.java

@Override
public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException {
    if (this.state == UNINITIATED) {
        throw new IllegalStateException("NTLM authentication process has not been initiated");
    }/*  w w  w.  j  a  va 2 s  .  com*/

    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();
    ntlm.setCredentialCharset(method.getParams().getCredentialCharset());

    String response = null;
    if ((this.state == INITIATED) || (this.state == FAILED)) {
        response = ntlm.generateType1Msg(ntcredentials.getHost(), ntcredentials.getDomain());
        this.state = TYPE1_MSG_GENERATED;
    } else {
        response = ntlm.generateType3Msg(ntcredentials.getUserName(), ntcredentials.getPassword(),
                ntcredentials.getHost(), ntcredentials.getDomain(), this.ntlmchallenge);
        this.state = TYPE3_MSG_GENERATED;
    }

    return "NTLM " + response;
}

From source file:com.mobilehelix.appserver.auth.JCIFS_NTLMScheme.java

@Override
public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException {

    LOG.log(Level.FINEST, "Enter JCIFS_NTLMScheme.authenticate(Credentials, HttpMethod)");

    if (this.state == UNINITIATED) {
        throw new IllegalStateException("NTLM authentication process has not been initiated");
    }//from  w  w w . ja v a 2s. co  m

    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();
    ntlm.setCredentialCharset(method.getParams().getCredentialCharset());
    String response = null;
    if (this.state == INITIATED || this.state == FAILED) {
        response = ntlm.generateType1Msg(ntcredentials.getHost(), ntcredentials.getDomain());
        this.state = TYPE1_MSG_GENERATED;
    } else {
        response = ntlm.generateType3Msg(ntcredentials.getUserName(), ntcredentials.getPassword(),
                ntcredentials.getHost(), ntcredentials.getDomain(), this.ntlmchallenge);
        this.state = TYPE3_MSG_GENERATED;
    }

    return "NTLM " + response;
}