Package org.apache.http.impl.auth

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


        if( user != null && user.length() > 0 ) {
            client.getCredentialsProvider().setCredentials( AuthScope.ANY, new UsernamePasswordCredentials( user, password ) );

            // All this bollocks is just for pre-emptive authentication. It used to be a boolean...
            BasicHttpContext localcontext = new BasicHttpContext();
            BasicScheme basicAuth = new BasicScheme();
            localcontext.setAttribute( "preemptive-auth", basicAuth );
            client.addRequestInterceptor( new PreemptiveAuth(), 0 );
        }
        URI url = URI.create( sUrl );
        HttpPut p = new HttpPut( url );
View Full Code Here


        // for dealing with automatic authentication
        if (authType == AuthType.NTLM) {
            // todo: not supported yet
            //ctx.setAttribute("preemptive-auth", new NTLMScheme(new JCIFSEngine()));
        } else if (authType == AuthType.BASIC) {
            ctx.setAttribute("preemptive-auth", new BasicScheme());
        }

        StatusLine statusLine = null;
        try {
            // set the User-Agent if it's not already set
View Full Code Here

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

                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

    @Before
    public void setUp() throws Exception {
        this.target = new HttpHost("localhost", 80);
        this.proxy = new HttpHost("localhost", 8080);

        this.authscheme1 = new BasicScheme();
        this.authscheme2 = new BasicScheme();
        this.credentials = new UsernamePasswordCredentials("user", "pwd");

        this.targetState = new AuthState();
        this.proxyState = new AuthState();
    }
View Full Code Here

                }

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

                // Reset headers on the request wrapper
                wrapper.resetHeaders();
View Full Code Here

        AuthScope authScope = host != null ? new AuthScope(host) : AuthScope.ANY;
        return auth(authScope, creds);
    }

    public Executor authPreemptive(final HttpHost host) {
        this.authCache.put(host, new BasicScheme(ChallengeState.TARGET));
        return this;
    }
View Full Code Here

        this.authCache.put(host, new BasicScheme(ChallengeState.TARGET));
        return this;
    }

    public Executor authPreemptiveProxy(final HttpHost host) {
        this.authCache.put(host, new BasicScheme(ChallengeState.PROXY));
        return this;
    }
View Full Code Here

    @Test
    public void testAuthSucceededInvalidInput() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("locahost", 80);
        BasicScheme authScheme = new BasicScheme();
        HttpContext context = new BasicHttpContext();
        try {
            authStrategy.authSucceeded(null, authScheme, context);
            Assert.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException ex) {
View Full Code Here

TOP

Related Classes of org.apache.http.impl.auth.BasicScheme

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.