Example usage for org.apache.commons.httpclient.auth AuthChallengeParser extractScheme

List of usage examples for org.apache.commons.httpclient.auth AuthChallengeParser extractScheme

Introduction

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

Prototype

public static String extractScheme(String paramString) throws MalformedChallengeException 

Source Link

Usage

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  ww w  .  j a v  a 2 s .c  o m*/
    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();
        }
    }
}