Examples of BasicScheme


Examples of org.apache.http.impl.auth.BasicScheme

        // 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.auth.BasicScheme

        // 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.auth.BasicScheme

        // 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.auth.BasicScheme

                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.auth.BasicScheme

                }

                final String userinfo = wrapper.getURI().getUserInfo();
                if (userinfo != null) {
                    targetAuthState.update(
                            new BasicScheme(), new UsernamePasswordCredentials(userinfo));
                }

                // Get target.  Even if there's virtual host, we may need the target to set the port.
                if (virtualHost != null) {
                    target = virtualHost;
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        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.auth.BasicScheme

        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.auth.BasicScheme

            final URI uri = request.getURI();
            if (uri != null) {
                final String userinfo = uri.getUserInfo();
                if (userinfo != null) {
                    targetAuthState.update(
                            new BasicScheme(), new UsernamePasswordCredentials(userinfo));
                }
            }
        }

        // Re-write request URI if needed
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        final BasicSchemeFactory myBasicAuthSchemeFactory = new BasicSchemeFactory() {

            @Override
            public AuthScheme create(final HttpContext context) {
                return new BasicScheme() {

                    @Override
                    public String getSchemeName() {
                        return "MyBasic";
                    }
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        response.addHeader(new BasicHeader(AUTH.WWW_AUTH, "whatever realm=\"realm1\", stuff=\"1234\""));

        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();

        this.authState.setState(AuthProtocolState.CHALLENGED);
        this.authState.update(new BasicScheme(), this.credentials);

        Assert.assertFalse(this.httpAuthenticator.handleAuthChallenge(host,
                response, authStrategy, this.authState, this.context));
        Assert.assertEquals(AuthProtocolState.FAILURE, this.authState.getState());
        Assert.assertNull(this.authState.getCredentials());
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.