Package org.apache.commons.httpclient.auth

Examples of org.apache.commons.httpclient.auth.AuthScope


     * @deprecated use #getProxyCredentials(AuthScope)
     */
    public synchronized Credentials getProxyCredentials(String realm, String proxyHost) {
       LOG.trace("enter HttpState.getCredentials(String, String");
        return matchCredentials(this.proxyCred,
            new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME));
    }
View Full Code Here


                }
                port = conn.getPort();
            }
        }
        String realm = authscheme.getRealm();
        AuthScope authscope = new AuthScope(host, port, realm);
        Credentials credentials = proxy
            ? state.getProxyCredentials(authscope)
            : state.getCredentials(authscope);
        if (credentials == null) {
            throw new CredentialsNotAvailableException("No credentials available");
View Full Code Here

    public void testDigestAuthenticationWithMultipleRealms() throws Exception {
        String challenge1 = "Digest realm=\"realm1\", nonce=\"abcde\"";
        String challenge2 = "Digest realm=\"realm2\", nonce=\"123546\"";
        HttpState state = new HttpState();
        UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
        state.setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm1"), cred);
        UsernamePasswordCredentials cred2 = new UsernamePasswordCredentials("uname2","password2");
        state.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm2"), cred2);
        AuthScheme authscheme1 = new DigestScheme();
        authscheme1.processChallenge(challenge1);
        AuthScheme authscheme2 = new DigestScheme();
        authscheme2.processChallenge(challenge2);
        {
View Full Code Here

            + "qop=\"auth,auth-int\""; // we pass both but expect auth to be used

        HttpState state = new HttpState();
        UsernamePasswordCredentials cred =
            new UsernamePasswordCredentials(username, password);
        state.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, realm), cred);
        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        HttpMethod method =
            new SimpleHttpMethod(new Header("WWW-Authenticate", challenge));
        assertTrue(authenticate(
View Full Code Here

            + "algorithm=MD5-sess";

        HttpState state = new HttpState();
        UsernamePasswordCredentials cred =
            new UsernamePasswordCredentials(username, password);
        state.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, realm), cred);
        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        HttpMethod method =
            new SimpleHttpMethod(new Header("WWW-Authenticate", challenge));
        assertTrue(authenticate(
View Full Code Here

            + "qop=\"jakarta\""; // jakarta is an invalid qop value

        HttpState state = new HttpState();
        UsernamePasswordCredentials cred =
            new UsernamePasswordCredentials(username, password);
        state.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm1"), cred);
        try {
            AuthScheme authscheme = new DigestScheme();
            authscheme.processChallenge(challenge);
            fail("MalformedChallengeException exception expected due to invalid qop value");
        } catch(MalformedChallengeException e) {
View Full Code Here

    /**
     * Test that the Unauthorized response is returned when doAuthentication is false.
     */
    public void testDoAuthenticateFalse() throws Exception {
        client.getState().setCredentials(
            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "Protected"),
            new UsernamePasswordCredentials("name", "pass"));
        HttpMethod method = new SimpleHttpMethod();
        method.setDoAuthentication(false);
        conn.addResponse(
            "HTTP/1.1 401 Unauthorized\r\n" +
View Full Code Here

    /**
     */
    public void testInvalidCredentials() throws Exception {
        client.getState().setCredentials(
            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "Protected"),
            new UsernamePasswordCredentials("name", "pass"));
        HttpMethod method = new SimpleHttpMethod();
        method.setDoAuthentication(false);
        conn.addResponse(
            "HTTP/1.1 401 Unauthorized\r\n" +
View Full Code Here

    }


    public void testMultipleProxyChallengeBasic() throws Exception {
        client.getState().setProxyCredentials(
            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "Protected"),
            new UsernamePasswordCredentials("name", "pass"));
        HttpMethod method = new SimpleHttpMethod();
        conn.addResponse(
            "HTTP/1.1 407 Proxy Authentication Required\r\n" +
            "Proxy-Authenticate: Basic realm=\"Protected\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\"\r\n" +
View Full Code Here

    }


    public void testMultipleProxyChallengeDigest() throws Exception {
        client.getState().setProxyCredentials(
            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "Protected"),
            new UsernamePasswordCredentials("name", "pass"));
        HttpMethod method = new SimpleHttpMethod();
        conn.addResponse(
            "HTTP/1.1 407 Proxy Authentication Required\r\n" +
            "Proxy-Authenticate: Basic realm=\"Protected\"\r\n" +
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.auth.AuthScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.