Example usage for org.apache.http.client AuthenticationStrategy authSucceeded

List of usage examples for org.apache.http.client AuthenticationStrategy authSucceeded

Introduction

In this page you can find the example usage for org.apache.http.client AuthenticationStrategy authSucceeded.

Prototype

void authSucceeded(HttpHost authhost, AuthScheme authScheme, HttpContext context);

Source Link

Document

Callback invoked in case of successful authentication.

Usage

From source file:org.callimachusproject.client.HttpAuthenticator.java

private boolean isAuthenticationRequested(final HttpHost host, final HttpResponse response,
        final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) {
    if (authStrategy.isAuthenticationRequested(host, response, context)) {
        this.log.debug("Authentication required");
        if (authState.getState() == AuthProtocolState.SUCCESS) {
            authStrategy.authFailed(host, authState.getAuthScheme(), context);
        }//from w w  w . j  a va  2  s.c  o  m
        return true;
    } else {
        switch (authState.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            this.log.debug("Authentication succeeded");
            authState.setState(AuthProtocolState.SUCCESS);
            authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
            break;
        case SUCCESS:
            break;
        default:
            authState.setState(AuthProtocolState.UNCHALLENGED);
        }
        return false;
    }
}

From source file:org.apache.http.impl.auth.HttpAuthenticator.java

public boolean isAuthenticationRequested(final HttpHost host, final HttpResponse response,
        final AuthenticationStrategy authStrategy, final AuthState authState, final HttpContext context) {
    if (authStrategy.isAuthenticationRequested(host, response, context)) {
        this.log.debug("Authentication required");
        if (authState.getState() == AuthProtocolState.SUCCESS) {
            authStrategy.authFailed(host, authState.getAuthScheme(), context);
        }/* w  ww  .j  a v  a2  s  .  c  om*/
        return true;
    } else {
        switch (authState.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            this.log.debug("Authentication succeeded");
            authState.setState(AuthProtocolState.SUCCESS);
            authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
            break;
        case SUCCESS:
            break;
        default:
            authState.setState(AuthProtocolState.UNCHALLENGED);
        }
        return false;
    }
}