Package org.apache.http.impl.client

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


    Executor(final HttpClient httpclient) {
        super();
        this.httpclient = httpclient;
        this.localContext = new BasicHttpContext();
        this.authCache = new BasicAuthCache();
    }
View Full Code Here


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

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

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

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

        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();
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

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

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

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

        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

                    Scheme scheme = schemeRegistry.getScheme(target);
                    target = new HttpHost(target.getHostName(),
                            scheme.resolvePort(target.getPort()), target.getSchemeName());
                }
                if (authCache == null) {
                    authCache = new BasicAuthCache();
                    context.setAttribute(ClientContext.AUTH_CACHE, authCache);
                }
                switch (targetState.getState()) {
                case CHALLENGED:
                    cache(authCache, target, targetState.getAuthScheme());
                    break;
                case FAILURE:
                    uncache(authCache, target, targetState.getAuthScheme());
                }
            }
        }

        HttpHost proxy = (HttpHost) context.getAttribute(ExecutionContext.HTTP_PROXY_HOST);
        AuthState proxyState = (AuthState) context.getAttribute(ClientContext.PROXY_AUTH_STATE);
        if (proxy != null && proxyState != null) {
            if (this.log.isDebugEnabled()) {
                this.log.debug("Proxy auth state: " + proxyState.getState());
            }
            if (isCachable(proxyState)) {
                if (authCache == null) {
                    authCache = new BasicAuthCache();
                    context.setAttribute(ClientContext.AUTH_CACHE, authCache);
                }
                switch (proxyState.getState()) {
                case CHALLENGED:
                    cache(authCache, proxy, proxyState.getAuthScheme());
View Full Code Here

        final HttpHost targetHost =
            new HttpHost(method.getURI().getHost(), method.getURI().getPort(), method.getURI().getScheme());
        httpClient.getCredentialsProvider().setCredentials(
            new AuthScope(targetHost.getHostName(), targetHost.getPort()),
            new UsernamePasswordCredentials(testContext.getUsername(), testContext.getPassword()));
        AuthCache authCache = new BasicAuthCache();
        BasicScheme basicAuth = new BasicScheme();
        authCache.put(targetHost, basicAuth);
        localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
      }
    }

    HttpEntity entity = null;
View Full Code Here

    final HttpHost targetHost =
        new HttpHost(nexusBaseURI.getHost(), nexusBaseURI.getPort(), nexusBaseURI.getScheme());
    httpClient.getCredentialsProvider().setCredentials(
        new AuthScope(targetHost.getHostName(), targetHost.getPort()),
        new UsernamePasswordCredentials(username, password));
    AuthCache authCache = new BasicAuthCache();
    BasicScheme basicAuth = new BasicScheme();
    authCache.put(targetHost, basicAuth);
    localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

    HttpGet getMethod = new HttpGet(url);
    getMethod.addHeader(userAgentHeader);
    try {
View Full Code Here

    final HttpHost targetHost =
        new HttpHost(nexusBaseURI.getHost(), nexusBaseURI.getPort(), nexusBaseURI.getScheme());
    httpClient.getCredentialsProvider().setCredentials(
        new AuthScope(targetHost.getHostName(), targetHost.getPort()),
        new UsernamePasswordCredentials(username, password));
    AuthCache authCache = new BasicAuthCache();
    BasicScheme basicAuth = new BasicScheme();
    authCache.put(targetHost, basicAuth);
    localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

    // stateful clients must login first, since other rest urls create no sessions
    String loginUrl = this.getBaseNexusUrl() + "service/local/authentication/login";
    assertThat(executeAndRelease(httpClient, new HttpGet(loginUrl), localcontext), equalTo(200));
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.