Package org.apache.http.impl.auth

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


    @Test
    public void testAuthSucceeded() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("somehost", 80);
        BasicScheme authScheme = new BasicScheme();
        authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

        AuthCache authCache = Mockito.mock(AuthCache.class);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here


    @Test
    public void testAuthSucceededNoCache() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("somehost", 80);
        BasicScheme authScheme = new BasicScheme();
        authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTH_CACHE, null);

        authStrategy.authSucceeded(authhost, authScheme, context);
View Full Code Here

    @Test
    public void testAuthScemeNotCompleted() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("somehost", 80);
        BasicScheme authScheme = new BasicScheme();

        AuthCache authCache = Mockito.mock(AuthCache.class);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

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

    @Test
    public void testAuthFailed() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("somehost", 80);
        BasicScheme authScheme = new BasicScheme();
        authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

        AuthCache authCache = Mockito.mock(AuthCache.class);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

    @Test
    public void testAuthFailedNoCache() throws Exception {
        TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        HttpHost authhost = new HttpHost("somehost", 80);
        BasicScheme authScheme = new BasicScheme();

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ClientContext.AUTH_CACHE, null);

        authStrategy.authFailed(authhost, authScheme, context);
View Full Code Here

        final URI requestURI = currentRequest.getURI();
        if (requestURI != null) {
            final String userinfo = requestURI.getUserInfo();
            if (userinfo != null) {
                final AuthState targetAuthState = localContext.getTargetAuthState();
                targetAuthState.update(new BasicScheme(), new UsernamePasswordCredentials(userinfo));
            }
        }

        HttpHost target = null;
        final HttpRequest original = currentRequest.getOriginal();
View Full Code Here

        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

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

            final 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

                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

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.