Examples of BasicAuthCache


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

        // Enable preemptive basic authentication
        // For nice layering we need to respect existing auth cache if present
        AuthCache authCache = (AuthCache) httpContext.getAttribute(ClientContext.AUTH_CACHE);
        if (authCache == null)
            authCache = new BasicAuthCache();
        BasicScheme basicAuth = new BasicScheme(this.isProxy ? ChallengeState.PROXY : ChallengeState.TARGET);
        // TODO It is possible that this overwrites existing cached credentials
        // so potentially not ideal.
        authCache.put(new HttpHost(target.getHost(), target.getPort()), basicAuth);
        httpContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

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

            throw new IllegalArgumentException("HTTP context may not be null");
        }

        AuthCache authCache = (AuthCache) context.getAttribute(ClientContext.AUTH_CACHE);
        if (authCache == null) {
            context.setAttribute(ClientContext.AUTH_CACHE, new BasicAuthCache());
        } else {
           
            CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
                    ClientContext.CREDS_PROVIDER);
           
View Full Code Here

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

        // Enable preemptive basic authentication
        // For nice layering we need to respect existing auth cache if present
        AuthCache authCache = (AuthCache) httpContext.getAttribute(ClientContext.AUTH_CACHE);
        if (authCache == null)
            authCache = new BasicAuthCache();
        BasicScheme basicAuth = new BasicScheme(this.isProxy ? ChallengeState.PROXY : ChallengeState.TARGET);
        // TODO It is possible that this overwrites existing cached credentials so potentially not ideal.
        authCache.put(new HttpHost(target.getHost(), target.getPort()), basicAuth);
        httpContext.setAttribute(ClientContext.AUTH_CACHE, authCache);
    }
View Full Code Here

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

                log.debug( "Initial attempt did not return a 200 status code. Trying pre-emptive authentication.." );

                HttpHost targetHost = new HttpHost( uri.getHost(), uri.getPort(), uri.getScheme() );

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

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

            .build();

        final HttpHost targethost = getServerHttp();

        final HttpContext context = new BasicHttpContext();
        final AuthCache authCache = new BasicAuthCache();
        authCache.put(targethost, new BasicScheme());
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpGet httpget = new HttpGet("/");

        final HttpResponse response1 = this.httpclient.execute(targethost, httpget, context);
View Full Code Here

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

            .build();

        final HttpHost targethost = getServerHttp();

        final HttpContext context = new BasicHttpContext();
        final AuthCache authCache = new BasicAuthCache();
        authCache.put(targethost, new BasicScheme());
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpGet httpget = new HttpGet("/");

        final HttpResponse response1 = this.httpclient.execute(targethost, httpget, 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();
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNull(this.targetState.getAuthScheme());
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(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);

        this.targetState.setState(AuthProtocolState.CHALLENGED);
        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
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.