Package org.apache.http.impl.auth

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


        BasicHttpContext localcontext = new BasicHttpContext();

        // Generate BASIC scheme object and stick it to the local
        // execution context
        BasicScheme basicAuth = new BasicScheme();
        localcontext.setAttribute("preemptive-auth", basicAuth);
       
        // Add as the first request interceptor
        httpclient.addRequestInterceptor(new PreemptiveAuth(), 0);
       
View Full Code Here


            this.currentRequest = this.mainRequest.getRequest();

            String userinfo = this.currentRequest.getURI().getUserInfo();
            if (userinfo != null) {
                this.targetAuthState.update(
                        new BasicScheme(), new UsernamePasswordCredentials(userinfo));
            }
           
            // Re-write request URI if needed
            rewriteRequestURI(this.currentRequest, route);
        }
View Full Code Here

    public Executor auth(final String host, final Credentials creds) {
        return auth(HttpHost.create(host), creds);
    }

    public Executor authPreemptive(final HttpHost host) {
        final BasicScheme basicScheme = new BasicScheme();
        try {
            basicScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "BASIC "));
        } catch (final MalformedChallengeException ignore) {
        }
        this.authCache.put(host, basicScheme);
        return this;
    }
View Full Code Here

    public Executor authPreemptive(final String host) {
        return authPreemptive(HttpHost.create(host));
    }

    public Executor authPreemptiveProxy(final HttpHost proxy) {
        final BasicScheme basicScheme = new BasicScheme();
        try {
            basicScheme.processChallenge(new BasicHeader(AUTH.PROXY_AUTH, "BASIC "));
        } catch (final MalformedChallengeException ignore) {
        }
        this.authCache.put(proxy, basicScheme);
        return this;
    }
View Full Code Here

        Mockito.when(connRequest.get(
                Mockito.anyLong(), Mockito.<TimeUnit>any())).thenReturn(managedConn);
        final Map<String, Header> challenges = new HashMap<String, Header>();
        challenges.put("basic", new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));
        final AuthOption authOption = new AuthOption(
                new BasicScheme(), new UsernamePasswordCredentials("user:pass"));
        Mockito.when(targetAuthStrategy.getChallenges(
                Mockito.eq(target),
                Mockito.<HttpResponse>any(),
                Mockito.<HttpClientContext>any())).thenReturn(challenges);
        Mockito.when(targetAuthStrategy.getChallenges(
View Full Code Here

        new UsernamePasswordCredentials( user, password ) );

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

        new UsernamePasswordCredentials( user, password ) );

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

            String password = authenticationInfo.getPassword();
            // preemptive for put
            if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
            {
                AuthCache authCache = new BasicAuthCache();
                BasicScheme basicAuth = new BasicScheme();
                HttpHost targetHost =
                    new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
                authCache.put( targetHost, basicAuth );

                localContext = new BasicHttpContext();
View Full Code Here

                else
                {
                    creds = new UsernamePasswordCredentials( proxyInfo.getUserName(), proxyInfo.getPassword() );
                }

                Header bs = new BasicScheme().authenticate( creds, httpMethod );
                httpMethod.addHeader( "Proxy-Authorization", bs.getValue() );
            }

        }
View Full Code Here

                if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
                {

                    AuthCache authCache = new BasicAuthCache();
                    BasicScheme basicAuth = new BasicScheme();
                    HttpHost targetHost =
                        new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
                    authCache.put( targetHost, basicAuth );

                    localContext = new BasicHttpContext();
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.