Package org.apache.commons.httpclient.auth

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


    // ------------------------------------------------------------------ Tests

    public void testSimpleAuthGet() throws Exception {
        HttpClient client = createHttpClient();
        client.getState().setCredentials(
            new AuthScope(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("jakarta","commons"));
        GetMethod method = new GetMethod("/" + getWebappContext() + "/auth/basic");
       
        try {
            client.executeMethod(method);
View Full Code Here


    }

    public void testSimpleAuthPost() throws Exception {
        HttpClient client = createHttpClient();
        client.getState().setCredentials(
            new AuthScope(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("jakarta","commons"));
        PostMethod method = new PostMethod("/" + getWebappContext() + "/auth/basic");
        method.setRequestBody(new NameValuePair[] { new NameValuePair("testing","one") } );
       
        try {
View Full Code Here

    }

    public void testSimpleAuthPut() throws Exception {
        HttpClient client = createHttpClient();
        client.getState().setCredentials(
            new AuthScope(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("jakarta","commons"));
        PutMethod method = new PutMethod("/" + getWebappContext() + "/auth/basic");
        method.setRequestEntity(new StringRequestEntity("testing one two three"));
        try {
            client.executeMethod(method);
View Full Code Here

        assertEquals(401,method.getStatusCode());
        assertTrue(method.getResponseBodyAsString().indexOf("<title>BasicAuth Servlet: GET</title>") >= 0);
        assertTrue(method.getResponseBodyAsString().indexOf("<p>Not authorized.</p>") >= 0);

        client.getState().setCredentials(
            new AuthScope(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("jakarta","commons"));

        method = new GetMethod("/" + getWebappContext() + "/auth/basic");
        try {
            client.executeMethod(method);
View Full Code Here

        assertEquals(HttpStatus.SC_UNAUTHORIZED,method.getStatusCode());
        assertTrue(method.getResponseBodyAsString().indexOf("<title>BasicAuth Servlet: GET</title>") >= 0);
        assertTrue(method.getResponseBodyAsString().indexOf("<p>Not authorized.</p>") >= 0);

        client.getState().setCredentials(
            new AuthScope(getHost(), getPort(), "BasicAuthServlet"),
            new UsernamePasswordCredentials("bad","creds"));

        method = new GetMethod("/" + getWebappContext() + "/auth/basic");
        try {
            client.executeMethod(method);
View Full Code Here

        // setup HTTP client, with authentication (using default Jackrabbit credentials)
        httpClient = new HttpClient();
        httpClient.getParams().setAuthenticationPreemptive(true);
        Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin");
        httpClient.getState().setCredentials(new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);

        testClient = new SlingIntegrationTestClient(httpClient);

        waitForSlingStartup();
    }
View Full Code Here

     * @deprecated use #setCredentials(AuthScope, Credentials)
     */
   
    public synchronized void setCredentials(String realm, String host, Credentials credentials) {
        LOG.trace("enter HttpState.setCredentials(String, String, Credentials)");
        credMap.put(new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials);
    }
View Full Code Here

        Credentials creds = (Credentials)map.get(authscope);
        if (creds == null) {
            // Nope.
            // Do a full scan
            int bestMatchFactor  = -1;
            AuthScope bestMatch  = null;
            Iterator items = map.keySet().iterator();
            while (items.hasNext()) {
                AuthScope current = (AuthScope)items.next();
                int factor = authscope.match(current);
                if (factor > bestMatchFactor) {
                    bestMatchFactor = factor;
                    bestMatch = current;
                }
View Full Code Here

     */
   
    public synchronized Credentials getCredentials(String realm, String host) {
        LOG.trace("enter HttpState.getCredentials(String, String");
        return matchCredentials(this.credMap,
            new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME));
    }
View Full Code Here

        String realm,
        String proxyHost,
        Credentials credentials
    ) {
        LOG.trace("enter HttpState.setProxyCredentials(String, String, Credentials");
        proxyCred.put(new AuthScope(proxyHost, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME), credentials);
    }
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.