org.apache.http.auth.AuthState Java Examples

The following examples show how to use org.apache.http.auth.AuthState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JolokiaClientFactory.java    From hawkular-agent with Apache License 2.0 6 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

    if (authState.getAuthScheme() == null) {
        CredentialsProvider credsProvider = (CredentialsProvider) context
                .getAttribute(HttpClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(HttpClientContext.HTTP_TARGET_HOST);
        Credentials creds = credsProvider
                .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
        if (creds == null) {
            throw new HttpException("No credentials given for preemptive authentication");
        }
        authState.update(authScheme, creds);
    }
}
 
Example #2
Source File: HttpUriRequestConverter.java    From webmagic with Apache License 2.0 6 votes vote down vote up
private HttpClientContext convertHttpClientContext(Request request, Site site, Proxy proxy) {
    HttpClientContext httpContext = new HttpClientContext();
    if (proxy != null && proxy.getUsername() != null) {
        AuthState authState = new AuthState();
        authState.update(new BasicScheme(ChallengeState.PROXY), new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()));
        httpContext.setAttribute(HttpClientContext.PROXY_AUTH_STATE, authState);
    }
    if (request.getCookies() != null && !request.getCookies().isEmpty()) {
        CookieStore cookieStore = new BasicCookieStore();
        for (Map.Entry<String, String> cookieEntry : request.getCookies().entrySet()) {
            BasicClientCookie cookie1 = new BasicClientCookie(cookieEntry.getKey(), cookieEntry.getValue());
            cookie1.setDomain(UrlUtils.removePort(UrlUtils.getDomain(request.getUrl())));
            cookieStore.addCookie(cookie1);
        }
        httpContext.setCookieStore(cookieStore);
    }
    return httpContext;
}
 
Example #3
Source File: PreemptiveBasicAuthHttpRequestInterceptor.java    From cloudhopper-commons with Apache License 2.0 6 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    //
    // get the authentication state for the request
    //
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);

    //
    // if no auth scheme avaialble yet, try to initialize it preemptively
    //
    if (authState.getAuthScheme() == null) {
        // check if credentials are set
        if (this.credentials == null) {
            throw new HttpException("No credentials for preemptive authentication");
        }

        // add the credentials to the auth state
        authState.setAuthScheme(this.basicAuthScheme);
        authState.setCredentials(this.credentials);

        // HttpHost targetHost = (HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        //CredentialsProvider credsProvider = (CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
    }
}
 
Example #4
Source File: HttpSender.java    From cloudhopper-commons with Apache License 2.0 6 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    
    // If no auth scheme avaialble yet, try to initialize it preemptively
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
        CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.setAuthScheme(authScheme);
            authState.setCredentials(creds);
        }
    }
    
}
 
Example #5
Source File: LibRequestDirector.java    From YiBo with Apache License 2.0 6 votes vote down vote up
private void processChallenges(
        final Map<String, Header> challenges,
        final AuthState authState,
        final AuthenticationHandler authHandler,
        final HttpResponse response,
        final HttpContext context)
            throws MalformedChallengeException, AuthenticationException {

    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null) {
        // Authentication not attempted before
        authScheme = authHandler.selectScheme(challenges, response, context);
        authState.setAuthScheme(authScheme);
    }
    String id = authScheme.getSchemeName();

    Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
    if (challenge == null) {
        throw new AuthenticationException(id +
            " authorization challenge expected, but not found");
    }
    authScheme.processChallenge(challenge);
    if (DEBUG) {
    	Logger.debug("Authorization challenge processed");
    }
}
 
Example #6
Source File: PreemptiveAuthHttpRequestInterceptor.java    From gerrit-rest-java-client with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final HttpRequest request, final HttpContext context) {
    // never ever send credentials preemptively to a host which is not the configured Gerrit host
    if (!isForGerritHost(request)) {
        return;
    }

    AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

    // if no auth scheme available yet, try to initialize it preemptively
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute(PREEMPTIVE_AUTH);
        UsernamePasswordCredentials creds = new UsernamePasswordCredentials(authData.getLogin(), authData.getPassword());
        authState.update(authScheme, creds);
    }
}
 
Example #7
Source File: PreemptiveAuth.java    From verigreen with Apache License 2.0 6 votes vote down vote up
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    Credentials creds;
    
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
        CredentialsProvider credsProvider =
                (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost =
                (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            creds =
                    credsProvider.getCredentials(new AuthScope(
                            targetHost.getHostName(),
                            targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.update(authScheme, creds);
        }
    }
}
 
Example #8
Source File: UriStrategy.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
   AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

   // If no auth scheme available yet, try to initialize it preemptively
   if (authState.getAuthScheme() == null) {
      AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
      CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
      HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
      if (authScheme != null) {
         Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
         if (creds == null) {
            throw new HttpException("No credentials for preemptive authentication");
         }
         authState.update(authScheme, creds);
      }
   }
}
 
Example #9
Source File: WebRealmServiceTest.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public void process( final HttpRequest request, final HttpContext context )
    throws HttpException, IOException
{
    AuthState authState = (AuthState) context.getAttribute( ClientContext.TARGET_AUTH_STATE );
    CredentialsProvider credsProvider = (CredentialsProvider) context
        .getAttribute( ClientContext.CREDS_PROVIDER );
    HttpHost targetHost = (HttpHost) context.getAttribute( ExecutionContext.HTTP_TARGET_HOST );

    // If not auth scheme has been initialized yet
    if( authState.getAuthScheme() == null )
    {
        AuthScope authScope = new AuthScope( targetHost.getHostName(),
                                             targetHost.getPort() );
        // Obtain credentials matching the target host
        Credentials creds = credsProvider.getCredentials( authScope );
        // If found, generate BasicScheme preemptively
        if( creds != null )
        {
            authState.setAuthScheme( new BasicScheme() );
            authState.setCredentials( creds );
        }
    }
}
 
Example #10
Source File: PreemptiveAuth.java    From jenkins-client-java with MIT License 6 votes vote down vote up
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);

    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
        CredentialsProvider credsProvider = (CredentialsProvider) context
                .getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            Credentials creds = credsProvider
                    .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.update(authScheme, creds);
        }
    }
}
 
Example #11
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
Example #12
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void process(HttpRequest httprequest, HttpContext httpcontext)
{
    AuthState authstate = (AuthState)httpcontext.getAttribute("http.auth.target-scope");
    CredentialsProvider credentialsprovider = (CredentialsProvider)httpcontext.getAttribute("http.auth.credentials-provider");
    HttpHost httphost = (HttpHost)httpcontext.getAttribute("http.target_host");
    if (authstate.getAuthScheme() == null)
    {
        org.apache.http.auth.Credentials credentials = credentialsprovider.getCredentials(new AuthScope(httphost.getHostName(), httphost.getPort()));
        if (credentials != null)
        {
            authstate.setAuthScheme(new BasicScheme());
            authstate.setCredentials(credentials);
        }
    }
}
 
Example #13
Source File: c.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void process(HttpRequest httprequest, HttpContext httpcontext)
{
    AuthState authstate = (AuthState)httpcontext.getAttribute("http.auth.target-scope");
    CredentialsProvider credentialsprovider = (CredentialsProvider)httpcontext.getAttribute("http.auth.credentials-provider");
    HttpHost httphost = (HttpHost)httpcontext.getAttribute("http.target_host");
    if (authstate.getAuthScheme() == null)
    {
        org.apache.http.auth.Credentials credentials = credentialsprovider.getCredentials(new AuthScope(httphost.getHostName(), httphost.getPort()));
        if (credentials != null)
        {
            authstate.setAuthScheme(new BasicScheme());
            authstate.setCredentials(credentials);
        }
    }
}
 
Example #14
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
Example #15
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
Example #16
Source File: RemoteSystemClient.java    From ghwatch with Apache License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
  AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
  HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

  if (authState.getAuthScheme() == null) {
    AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
    Credentials creds = credsProvider.getCredentials(authScope);
    if (creds != null) {
      authState.setAuthScheme(new BasicScheme());
      authState.setCredentials(creds);
    }
  }
}
 
Example #17
Source File: PreemptiveAuthHttpRequestInterceptor.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
  HttpClientContext clientContext = HttpClientContext.adapt(context);
  AuthState authState = clientContext.getTargetAuthState();
  if (authState.getAuthScheme() == null) {
    CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
    HttpHost targetHost = clientContext.getTargetHost();
    Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
    if (creds != null) {
      authState.update(new BasicScheme(), creds);
    }
  }
}
 
Example #18
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
Example #19
Source File: HttpPostMain.java    From cloudhopper-commons with Apache License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    
    AuthState authState = (AuthState) context.getAttribute(
            ClientContext.TARGET_AUTH_STATE);
    
    // If no auth scheme avaialble yet, try to initialize it preemptively
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute(
                "preemptive-auth");
        CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
                ClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(
                ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            Credentials creds = credsProvider.getCredentials(
                    new AuthScope(
                            targetHost.getHostName(), 
                            targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.setAuthScheme(authScheme);
            authState.setCredentials(creds);
        }
    }
    
}
 
Example #20
Source File: PreemptiveAuth.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException,
    IOException {

  AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
  // If no auth scheme available yet, try to initialize it preemptively
  if (authState.getAuthScheme() == null) {
    CredentialsProvider credsProvider = (CredentialsProvider) context
        .getAttribute(ClientContext.CREDS_PROVIDER);
    Credentials creds = credsProvider.getCredentials(AuthScope.ANY);
    authState.update(authScheme, creds);
  }
}
 
Example #21
Source File: PreemtiveAuthorizationHttpRequestInterceptor.java    From Mobike with Apache License 2.0 5 votes vote down vote up
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
Example #22
Source File: LibRequestDirector.java    From YiBo with Apache License 2.0 4 votes vote down vote up
public LibRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectHandler redirectHandler,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {

    if (requestExec == null) {
        throw new IllegalArgumentException("Request executor may not be null.");
    }
    if (conman == null) {
        throw new IllegalArgumentException("Client connection manager may not be null.");
    }
    if (reustrat == null) {
        throw new IllegalArgumentException("Connection reuse strategy may not be null.");
    }
    if (kastrat == null) {
        throw new IllegalArgumentException("Connection keep alive strategy may not be null.");
    }
    if (rouplan == null) {
        throw new IllegalArgumentException("Route planner may not be null.");
    }
    if (httpProcessor == null) {
        throw new IllegalArgumentException("HTTP protocol processor may not be null.");
    }
    if (retryHandler == null) {
        throw new IllegalArgumentException("HTTP request retry handler may not be null.");
    }
    if (redirectHandler == null) {
        throw new IllegalArgumentException("Redirect handler may not be null.");
    }
    if (targetAuthHandler == null) {
        throw new IllegalArgumentException("Target authentication handler may not be null.");
    }
    if (proxyAuthHandler == null) {
        throw new IllegalArgumentException("Proxy authentication handler may not be null.");
    }
    if (userTokenHandler == null) {
        throw new IllegalArgumentException("User token handler may not be null.");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.requestExec       = requestExec;
    this.connManager       = conman;
    this.reuseStrategy     = reustrat;
    this.keepAliveStrategy = kastrat;
    this.routePlanner      = rouplan;
    this.httpProcessor     = httpProcessor;
    this.retryHandler      = retryHandler;
    this.redirectHandler   = redirectHandler;
    this.targetAuthHandler = targetAuthHandler;
    this.proxyAuthHandler  = proxyAuthHandler;
    this.userTokenHandler  = userTokenHandler;
    this.params            = params;

    this.managedConn       = null;

    this.execCount = 0;
    this.redirectCount = 0;
    this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
    this.targetAuthState = new AuthState();
    this.proxyAuthState = new AuthState();
}
 
Example #23
Source File: LibRequestDirector.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void updateAuthState(
        final AuthState authState,
        final HttpHost host,
        final CredentialsProvider credsProvider) {

    if (!authState.isValid()) {
        return;
    }

    String hostname = host.getHostName();
    int port = host.getPort();
    if (port < 0) {
        Scheme scheme = connManager.getSchemeRegistry().getScheme(host);
        port = scheme.getDefaultPort();
    }

    AuthScheme authScheme = authState.getAuthScheme();
    AuthScope authScope = new AuthScope(
            hostname,
            port,
            authScheme.getRealm(),
            authScheme.getSchemeName());

    if (DEBUG) {
    	Logger.debug("Authentication scope: {}", authScope);
    }
    Credentials creds = authState.getCredentials();
    if (creds == null) {
        creds = credsProvider.getCredentials(authScope);
        if (DEBUG) {
            if (creds != null) {
            	Logger.debug("Found credentials");
            } else {
            	Logger.debug("Credentials not found");
            }
        }
    } else {
        if (authScheme.isComplete()) {
        	if (DEBUG) {
        		Logger.debug("Authentication failed");
        	}
            creds = null;
        }
    }
    authState.setAuthScope(authScope);
    authState.setCredentials(creds);
}
 
Example #24
Source File: SiteToSiteRestApiClient.java    From localization_nifi with Apache License 2.0 3 votes vote down vote up
/**
 * Print AuthState in HttpContext for debugging purpose.
 * <p>
 * If the proxy server requires 407 and resend cycle, this method logs as followings, for Basic Auth:
 * <ul><li>state:UNCHALLENGED;</li>
 * <li>state:CHALLENGED;auth scheme:basic;credentials present</li></ul>
 * </p>
 * <p>
 * For Digest Auth:
 * <ul><li>state:UNCHALLENGED;</li>
 * <li>state:CHALLENGED;auth scheme:digest;credentials present</li></ul>
 * </p>
 * <p>
 * But if the proxy uses the same connection, it doesn't return 407, in such case
 * this method is called only once with:
 * <ul><li>state:UNCHALLENGED</li></ul>
 * </p>
 */
private void debugProxyAuthState(HttpContext context) {
    final AuthState proxyAuthState;
    if (shouldCheckProxyAuth()
            && logger.isDebugEnabled()
            && (proxyAuthState = (AuthState)context.getAttribute("http.auth.proxy-scope")) != null){
        logger.debug("authProxyScope={}", proxyAuthState);
    }
}
 
Example #25
Source File: SiteToSiteRestApiClient.java    From nifi with Apache License 2.0 3 votes vote down vote up
/**
 * Print AuthState in HttpContext for debugging purpose.
 * <p>
 * If the proxy server requires 407 and resend cycle, this method logs as followings, for Basic Auth:
 * <ul><li>state:UNCHALLENGED;</li>
 * <li>state:CHALLENGED;auth scheme:basic;credentials present</li></ul>
 * </p>
 * <p>
 * For Digest Auth:
 * <ul><li>state:UNCHALLENGED;</li>
 * <li>state:CHALLENGED;auth scheme:digest;credentials present</li></ul>
 * </p>
 * <p>
 * But if the proxy uses the same connection, it doesn't return 407, in such case
 * this method is called only once with:
 * <ul><li>state:UNCHALLENGED</li></ul>
 * </p>
 */
private void debugProxyAuthState(HttpContext context) {
    final AuthState proxyAuthState;
    if (shouldCheckProxyAuth()
            && logger.isDebugEnabled()
            && (proxyAuthState = (AuthState)context.getAttribute("http.auth.proxy-scope")) != null){
        logger.debug("authProxyScope={}", proxyAuthState);
    }
}