Examples of BasicAuthCache


Examples of org.apache.http.impl.client.BasicAuthCache

        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ClientContext.ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyState);

        final AuthCache authCache = new BasicAuthCache();
        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ClientContext.ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyState);

        final AuthCache authCache = new BasicAuthCache();
        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_PROXY_HOST, this.proxy);
        context.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyState);

        final AuthCache authCache = new BasicAuthCache();
        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpResponseInterceptor interceptor = new ResponseAuthCache();
        interceptor.process(response, context);

        Assert.assertNull(authCache.get(this.target));
        Assert.assertNull(authCache.get(this.proxy));
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

                .setDefaultCredentialsProvider(credsProvider)
                .build();
        try {

            // Create AuthCache instance
            AuthCache authCache = new BasicAuthCache();
            // Generate DIGEST scheme object, initialize it and add it to the local
            // auth cache
            DigestScheme digestAuth = new DigestScheme();
            // Suppose we already know the realm name
            digestAuth.overrideParamter("realm", "some realm");
            // Suppose we already know the expected nonce value
            digestAuth.overrideParamter("nonce", "whatever");
            authCache.put(target, digestAuth);

            // Add AuthCache to the execution context
            HttpClientContext localContext = HttpClientContext.create();
            localContext.setAuthCache(authCache);
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

            String host = url.getHost();
            int port = url.getPort() > -1 ? url.getPort() : AuthScope.ANY_PORT;

            httpClient.getCredentialsProvider().setCredentials( new AuthScope( host, port ), creds );

            AuthCache authCache = new BasicAuthCache();
            BasicScheme basicAuth = new BasicScheme();
            HttpHost targetHost = new HttpHost( url.getHost(), url.getPort(), url.getProtocol() );
            authCache.put( targetHost, basicAuth );

            localContext = new BasicHttpContext();
            localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
        }
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

            String host = url.getHost();
            int port = url.getPort() > -1 ? url.getPort() : AuthScope.ANY_PORT;

            httpClient.getCredentialsProvider().setCredentials( new AuthScope( host, port ), creds );

            AuthCache authCache = new BasicAuthCache();
            BasicScheme basicAuth = new BasicScheme();
            HttpHost targetHost = new HttpHost( url.getHost(), url.getPort(), url.getProtocol() );
            authCache.put( targetHost, basicAuth );

            localContext = new BasicHttpContext();
            localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
        }
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        httpClient.getCredentialsProvider().setCredentials( new AuthScope( uri.getHost(), uri.getPort() ),
                                                            new UsernamePasswordCredentials( username, password ) );

        HttpHost targetHost = new HttpHost( url.getHost(), url.getPort(), url.getProtocol() );

        AuthCache authCache = new BasicAuthCache();
        BasicScheme basicAuth = new BasicScheme();
        authCache.put( targetHost, basicAuth );

        BasicHttpContext localcontext = new BasicHttpContext();
        localcontext.setAttribute( ClientContext.AUTH_CACHE, authCache );

        System.out.println( "Retrieving resource '" + url.toString() + "' using HttpClient's get method.." );
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();

        // Generate BASIC scheme object and add it to the local auth cache
        AuthCache authCache = new BasicAuthCache();
        authCache.put(targetHost, new BasicScheme());
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

        return localcontext;
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        final AuthScope scope = ((PreemptiveAuthHttpRequestFactory) SyncopeSession.get().getRestTemplate().
                getRequestFactory()).getAuthScope();
        final HttpHost targetHost = new HttpHost(scope.getHost(), scope.getPort(), scope.getScheme());
        BasicHttpContext localcontext = new BasicHttpContext();
        // Generate BASIC scheme object and add it to the local auth cache
        AuthCache authCache = new BasicAuthCache();
        authCache.put(targetHost, new BasicScheme());
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

        HttpGet getMethod = new HttpGet(this.uri);
        HttpResponse response;
        try {
View Full Code Here

Examples of org.apache.http.impl.client.BasicAuthCache

        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_PROXY_HOST, this.proxy);
        context.setAttribute(ClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(ClientContext.PROXY_AUTH_STATE, this.proxyState);

        AuthCache authCache = new BasicAuthCache();
        authCache.put(this.target, this.authscheme1);
        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        HttpResponseInterceptor interceptor = new ResponseAuthCache();
        interceptor.process(response, context);

        Assert.assertNull(authCache.get(this.target));
        Assert.assertNull(authCache.get(this.proxy));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.