Example usage for org.apache.commons.httpclient.auth MalformedChallengeException MalformedChallengeException

List of usage examples for org.apache.commons.httpclient.auth MalformedChallengeException MalformedChallengeException

Introduction

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

Prototype

public MalformedChallengeException(String paramString) 

Source Link

Usage

From source file:davmail.http.SpNegoScheme.java

/**
 * Processes the Negotiate challenge./*from   w w  w  . j  a v a  2  s .co m*/
 *
 * @param challenge the challenge string
 * @throws MalformedChallengeException is thrown if the authentication challenge is malformed
 */
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String authScheme = AuthChallengeParser.extractScheme(challenge);
    if (!authScheme.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid Negotiate challenge: " + challenge);
    }
    int spaceIndex = challenge.indexOf(' ');
    if (spaceIndex != -1) {
        // step 2: received server challenge
        serverToken = Base64.decodeBase64(
                EncodingUtil.getBytes(challenge.substring(spaceIndex, challenge.length()).trim(), "ASCII"));
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.serverToken = null;
        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

From source file:davmail.http.NTLMv2Scheme.java

/**
 * Processes the NTLM challenge./*from w  ww  . j  a v  a  2  s  .  c  om*/
 *
 * @param challenge the challenge string
 * @throws MalformedChallengeException is thrown if the authentication challenge
 *                                     is malformed
 */
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String authScheme = AuthChallengeParser.extractScheme(challenge);
    if (!authScheme.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }
    int spaceIndex = challenge.indexOf(' ');
    if (spaceIndex != -1) {
        try {
            type2Message = new Type2Message(Base64.decodeBase64(EncodingUtil
                    .getBytes(challenge.substring(spaceIndex, challenge.length()).trim(), "ASCII")));
        } catch (IOException e) {
            throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge, e);
        }
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.type2Message = null;
        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

From source file:com.cerema.cloud2.lib.common.network.BearerAuthScheme.java

/**
 * Processes the Bearer challenge./* w  ww .ja  v a  2  s .c om*/
 *  
 * @param   challenge                   The challenge string
 * 
 * @throws MalformedChallengeException  Thrown if the authentication challenge is malformed
 */
public void processChallenge(String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);
    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid " + getSchemeName() + " challenge: " + challenge);
    }
    mParams = AuthChallengeParser.extractParams(challenge);
    mComplete = true;
}

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

/**
 *
 * Processes the NTLM challenge.//from ww  w  . java  2  s. c om
 *
 * @param challenge the challenge string
 *
 * @throws MalformedChallengeException is thrown if the authentication challenge is malformed
 * @since 3.0
 */
@Override
public void processChallenge(final String challenge) throws MalformedChallengeException {

    String s = AuthChallengeParser.extractScheme(challenge);
    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }

    int i = challenge.indexOf(' ');
    if (i != -1) {
        s = challenge.substring(i, challenge.length());
        this.ntlmchallenge = s.trim();
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.ntlmchallenge = "";

        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

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

/**
 * Processes the NTLM challenge./*ww  w .  j a v  a 2s.co m*/
 * 
 * @param challenge
 *        the challenge string
 * @throws MalformedChallengeException
 *         is thrown if the authentication challenge is malformed
 * @since 3.0
 */
@Override
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);

    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }

    int i = challenge.indexOf(' ');
    if (i != -1) {
        s = challenge.substring(i, challenge.length());
        this.ntlmchallenge = s.trim();
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.ntlmchallenge = "";
        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

From source file:org.jetbrains.tfsIntegration.webservice.auth.NTLM2Scheme.java

/**
 * Processes the NTLM challenge./* ww  w.j a  v  a 2  s  . c  om*/
 *
 * @param challenge the challenge string
 *
 * @throws MalformedChallengeException is thrown if the authentication challenge
 * is malformed
 *
 * @since 3.0
 */
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);
    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }
    int i = challenge.indexOf(' ');
    if (i != -1) {
        s = challenge.substring(i, challenge.length());
        this.ntlmchallenge = s.trim();
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.ntlmchallenge = "";
        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

From source file:org.mule.transport.http.ntlm.NTLMScheme.java

/**
 * Processes the NTLM challenge.//w  w w .  j  a  va 2s.  c o  m
 *
 * @param challenge the challenge string
 * @throws MalformedChallengeException is thrown if the authentication challenge is malformed
 */
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);

    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }

    int i = challenge.indexOf(' ');

    if (i != -1) {
        s = challenge.substring(i, challenge.length());
        receivedNtlmChallenge = s.trim();
        authenticationState = AUTHENTICATION_STATE.TYPE2_MSG_RECEIVED;
    } else {
        receivedNtlmChallenge = null;
        authenticationState = authenticationState == AUTHENTICATION_STATE.UNINITIATED
                ? AUTHENTICATION_STATE.INITIATED
                : AUTHENTICATION_STATE.FAILED;
    }
}

From source file:org.wso2.carbon.mediator.ntlm.CustomNTLMAuthScheme.java

/**
 * Processes the NTLM challenge./*from   w ww  .ja v a  2 s  . co m*/
 *
 * @param challenge
 *            the challenge string
 *
 * @throws MalformedChallengeException
 *             is thrown if the authentication challenge is malformed
 *
 * @since 3.0
 */
public void processChallenge(final String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);
    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }
    int i = challenge.indexOf(' ');
    if (i != -1) {
        s = challenge.substring(i, challenge.length());
        this.ntlmChallenge = s.trim();
        this.state = TYPE2_MSG_RECEIVED;
    } else {
        this.ntlmChallenge = "";
        if (this.state == UNINITIATED) {
            this.state = INITIATED;
        } else {
            this.state = FAILED;
        }
    }
}

From source file:org.zaproxy.zap.network.ZapNTLMScheme.java

@Override
public void processChallenge(String challenge) throws MalformedChallengeException {
    String s = AuthChallengeParser.extractScheme(challenge);
    if (!s.equalsIgnoreCase(getSchemeName())) {
        throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge);
    }//from   www. j a va2  s.c om
    int i = challenge.indexOf(' ');
    if (i == -1) {
        if (this.state == State.UNINITIATED) {
            this.state = State.CHALLENGE_RECEIVED;
        } else {
            this.state = State.FAILED;
        }
    } else {
        if (this.state.compareTo(State.MSG_TYPE1_GENERATED) < 0) {
            this.state = State.FAILED;
            throw new MalformedChallengeException("Out of sequence NTLM response message");
        } else if (this.state == State.MSG_TYPE1_GENERATED) {
            this.state = State.MSG_TYPE2_RECEVIED;
            this.challenge = challenge.substring(i, challenge.length()).trim();
        }
    }
}