Package org.apache.http.impl.auth

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


        this.credProvider = new BasicCredentialsProvider();
        this.creds1 = new UsernamePasswordCredentials("user1", "secret1");
        this.creds2 = new UsernamePasswordCredentials("user2", "secret2");
        this.authscope1 = new AuthScope(this.target);
        this.authscope2 = new AuthScope(this.proxy);
        this.authscheme1 = new BasicScheme();
        this.authscheme2 = new BasicScheme();

        this.credProvider.setCredentials(this.authscope1, this.creds1);
        this.credProvider.setCredentials(this.authscope2, this.creds2);

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


        authCache.put(this.proxy, this.authscheme2);

        context.setAttribute(ClientContext.AUTH_CACHE, authCache);

        this.targetState.setState(AuthProtocolState.CHALLENGED);
        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3", "secret3"));
        this.proxyState.setState(AuthProtocolState.CHALLENGED);
        this.proxyState.update(new BasicScheme(), new UsernamePasswordCredentials("user4", "secret4"));

        final HttpRequestInterceptor interceptor = new RequestAuthCache();
        interceptor.process(request, context);
        Assert.assertNotSame(this.authscheme1, this.targetState.getAuthScheme());
        Assert.assertNotSame(this.creds1, this.targetState.getCredentials());
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

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

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

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

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

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

        final 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 {
        final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
        final HttpHost authhost = new HttpHost("somehost", 80);
        final BasicScheme authScheme = new BasicScheme();

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

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

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

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

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

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

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

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

        authStrategy.authFailed(authhost, authScheme, context);
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.