Java Code Examples for org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials()

The following examples show how to use org.apache.commons.httpclient.auth.CredentialsProvider#getCredentials() . 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: HttpMethodDirector.java    From http4e with Apache License 2.0 5 votes vote down vote up
private Credentials promptForCredentials(
    final AuthScheme authScheme,
    final HttpParams params, 
    final AuthScope authscope)
{
    LOG.debug("Credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), false);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Credentials provider not available");
    }
    return creds;
}
 
Example 2
Source File: HttpMethodDirector.java    From http4e with Apache License 2.0 5 votes vote down vote up
private Credentials promptForProxyCredentials(
    final AuthScheme authScheme,
    final HttpParams params,
    final AuthScope authscope) 
{
    LOG.debug("Proxy credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), true);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setProxyCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Proxy credentials provider not available");
    }
    return creds;
}
 
Example 3
Source File: HttpMethodDirector.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Credentials promptForCredentials(
    final AuthScheme authScheme,
    final HttpParams params, 
    final AuthScope authscope)
{
    LOG.debug("Credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), false);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Credentials provider not available");
    }
    return creds;
}
 
Example 4
Source File: HttpMethodDirector.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Credentials promptForProxyCredentials(
    final AuthScheme authScheme,
    final HttpParams params,
    final AuthScope authscope) 
{
    LOG.debug("Proxy credentials required");
    Credentials creds = null;
    CredentialsProvider credProvider = 
        (CredentialsProvider)params.getParameter(CredentialsProvider.PROVIDER);
    if (credProvider != null) {
        try {
            creds = credProvider.getCredentials(
                authScheme, authscope.getHost(), authscope.getPort(), true);
        } catch (CredentialsNotAvailableException e) {
            LOG.warn(e.getMessage());
        }
        if (creds != null) {
            this.state.setProxyCredentials(authscope, creds);
            if (LOG.isDebugEnabled()) {
                LOG.debug(authscope + " new credentials given");
            }
        }
    } else {
        LOG.debug("Proxy credentials provider not available");
    }
    return creds;
}