Example usage for org.apache.http.osgi.services ProxyConfiguration isEnabled

List of usage examples for org.apache.http.osgi.services ProxyConfiguration isEnabled

Introduction

In this page you can find the example usage for org.apache.http.osgi.services ProxyConfiguration isEnabled.

Prototype

boolean isEnabled();

Source Link

Usage

From source file:org.apache.http.osgi.impl.OSGiCredentialsProvider.java

/**
 * {@inheritDoc}/*ww  w  .  ja va2 s.  c o m*/
 */
@Override
public Credentials getCredentials(final AuthScope authScope) {
    // iterate over all active proxy configurations at the moment of getting the credential
    for (final ProxyConfiguration config : proxyConfigurations) {
        if (config.isEnabled() && isSuitable(config, authScope)) {
            final String scheme = authScope.getScheme();
            if (BASIC_SCHEME_NAME.equals(scheme)) {
                return new UsernamePasswordCredentials(config.getUsername(), config.getPassword());
            } else if (NTLM_SCHEME_NAME.equals(scheme)) {
                return createNTCredentials(config);
            } else {
                log.debug("credentials requested for unsupported authentication scheme " + scheme);
            }
        }
    }
    // credentials no longer available!
    return null;
}