Package org.apache.http.impl.client

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


    protected Response handleStream(final String url) {
        final AuthScope scope = ((PreemptiveAuthHttpRequestFactory) getRestTemplate().getRequestFactory()).
                getAuthScope();
        final HttpHost targetHost = new HttpHost(scope.getHost(), scope.getPort(), scope.getScheme());
        final BasicHttpContext localcontext = new BasicHttpContext();
        final AuthCache authCache = new BasicAuthCache();
        authCache.put(targetHost, new BasicScheme());
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpGet getMethod = new HttpGet(url);
        try {
            final HttpResponse httpResponse =
View Full Code Here


    try {

      // Preemptive authentication enabled - see
      // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d5e1032
      HttpHost targetHost = new HttpHost(builder.getHost(), builder.getPort(), builder.getScheme());
      AuthCache authCache = new BasicAuthCache();
      BasicScheme basicAuth = new BasicScheme();
      authCache.put(targetHost, basicAuth);
      BasicHttpContext localcontext = new BasicHttpContext();
      localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

      HttpResponse response = httpclient.execute(method, localcontext);
      int statusCode = response.getStatusLine().getStatusCode();
View Full Code Here

        // 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

        context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

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

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

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

        context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

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

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

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

        context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

        final AuthCache authCache = new BasicAuthCache();
        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
View Full Code Here

        context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

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

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

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

        context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(HttpClientContext.HTTP_ROUTE, new HttpRoute(this.target, null, this.proxy, false));
        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, this.targetState);
        context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyState);

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

        context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);

        this.targetState.setState(AuthProtocolState.CHALLENGED);
        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
View Full Code Here

        // 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);

        HttpResponse response = null;

        maxit = 10;
View Full Code Here

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope(AuthScope.ANY),
                new UsernamePasswordCredentials("admin", "admin"));

        // Create AuthCache instance
        AuthCache authCache = new BasicAuthCache();
        // Generate BASIC scheme object and add it to the local auth cache
        BasicScheme basicAuth = new BasicScheme();
        authCache.put(targetHost, basicAuth);

        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

TOP

Related Classes of org.apache.http.impl.client.BasicAuthCache

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.