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

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

Introduction

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

Prototype

public static Map extractParams(String paramString) throws MalformedChallengeException 

Source Link

Usage

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

/**
 * Processes the Bearer challenge.//from w ww.ja v  a 2 s .c  o m
 *  
 * @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:edu.cmu.cs.diamond.pathfind.DjangoAnnotationStore.java

private int maybeAuthenticate(HttpMethodBase method, int code)
        throws MalformedChallengeException, IOException, HttpException {
    while (code == 401) {
        // let's authenticate
        Header header = method.getResponseHeader("WWW-Authenticate");
        System.out.println(header);
        String scheme = AuthChallengeParser.extractScheme(header.getValue());
        Map<?, ?> params = AuthChallengeParser.extractParams(header.getValue());

        if (!scheme.equals("login")) {
            throw new IOException("Authentication requested but of unknown scheme: " + scheme);
        }/*ww  w.jav a2  s  . co  m*/

        // get the login form
        String loginuri = (String) params.get("realm");
        login(loginuri);

        // try again
        code = httpClient.executeMethod(method);
    }
    return code;
}