Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.FakeHttpMethod


    public void testNTLMAuthenticationResponse1() throws Exception {
        String challenge = "NTLM";
        String expected = "NTLM TlRMTVNTUAABAAAABlIAAAYABgAkAAAABAAEACAAAABIT" +
            "1NURE9NQUlO";
        NTCredentials cred = new NTCredentials("username","password", "host", "domain");
        FakeHttpMethod method = new FakeHttpMethod();
        AuthScheme authscheme = new NTLMScheme(challenge);
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        assertEquals(expected, response);
        assertFalse(authscheme.isComplete());
View Full Code Here


        String expected = "NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAAAAAAagAAAAYABgB" +
            "AAAAACAAIAEYAAAAEAAQATgAAAAAAAABqAAAABlIAAERPTUFJTlVTRVJOQU1FSE" +
            "9TVAaC+vLxUEHnUtpItj9Dp4kzwQfd61Lztg==";
        NTCredentials cred = new NTCredentials("username","password", "host", "domain");
        FakeHttpMethod method = new FakeHttpMethod();
       
        AuthScheme authscheme = new NTLMScheme(challenge);
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        assertEquals(expected, response);
View Full Code Here

                Protocol.getProtocol("http"));
       
        this.client.getState().setCredentials(AuthScope.ANY,
                new NTCredentials("username", "password", "host", "domain"));
       
        FakeHttpMethod httpget = new FakeHttpMethod("/");
        try {
            client.executeMethod(httpget);
        } finally {
            httpget.releaseConnection();
        }
        assertNull(httpget.getResponseHeader("WWW-Authenticate"));
        assertEquals(200, httpget.getStatusCode());
    }
View Full Code Here

                Protocol.getProtocol("http"));
       
        client.getState().setCredentials(AuthScope.ANY,
            new NTCredentials("username", "password", "host", "domain"));
       
        FakeHttpMethod httpget = new FakeHttpMethod("/");
        try {
            assertEquals(403, client.executeMethod(httpget));
        } catch (Exception e) {
            fail("Exception caught: " + e.getMessage());
        }
        finally {
            httpget.releaseConnection();
        }
        server.destroy();
    }
View Full Code Here

        }
    }

    public void testDigestAuthenticationWithDefaultCreds() throws Exception {
        String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\"";
        FakeHttpMethod method = new FakeHttpMethod("/");
        UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        Map table = AuthChallengeParser.extractParams(response);
View Full Code Here

    }

    public void testDigestAuthentication() throws Exception {
        String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\"";
        UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
        FakeHttpMethod method = new FakeHttpMethod("/");
        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        Map table = AuthChallengeParser.extractParams(response);
        assertEquals("username", table.get("username"));
View Full Code Here

    }

    public void testDigestAuthenticationWithQueryStringInDigestURI() throws Exception {
        String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\"";
        UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
        FakeHttpMethod method = new FakeHttpMethod("/");
        method.setQueryString("param=value");
        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        Map table = AuthChallengeParser.extractParams(response);
        assertEquals("username", table.get("username"));
View Full Code Here

        String challenge1 = "Digest realm=\"realm1\", nonce=\"abcde\"";
        String challenge2 = "Digest realm=\"realm2\", nonce=\"123546\"";
        UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
        UsernamePasswordCredentials cred2 = new UsernamePasswordCredentials("uname2","password2");

        FakeHttpMethod method = new FakeHttpMethod("/");
        AuthScheme authscheme1 = new DigestScheme();
        authscheme1.processChallenge(challenge1);
        String response1 = authscheme1.authenticate(cred, method);
        Map table = AuthChallengeParser.extractParams(response1);
        assertEquals("username", table.get("username"));
View Full Code Here

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

        UsernamePasswordCredentials cred =
            new UsernamePasswordCredentials(username, password);
        FakeHttpMethod method = new FakeHttpMethod("/");

        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
        assertTrue(response.indexOf("nc=00000001") > 0); // test for quotes
View Full Code Here

            + "stale=false, "
            + "algorithm=MD5-sess";

        UsernamePasswordCredentials cred =
            new UsernamePasswordCredentials(username, password);
        FakeHttpMethod method = new FakeHttpMethod("/");

        AuthScheme authscheme = new DigestScheme();
        authscheme.processChallenge(challenge);
        String response = authscheme.authenticate(cred, method);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.FakeHttpMethod

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.