List of usage examples for org.apache.http.auth AuthScope match
public int match(final AuthScope that)
From source file:org.eclipse.ecf.internal.provider.filetransfer.httpclient4.HttpClientProxyCredentialProvider.java
private static Credentials matchCredentials(final Map<AuthScope, Credentials> map, final AuthScope authscope) { // see if we get a direct hit Credentials creds = map.get(authscope); if (creds == null) { // Nope.//from w w w .j a va2 s . com // Do a full scan int bestMatchFactor = -1; AuthScope bestMatch = null; for (AuthScope current : map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = current; } } if (bestMatch != null) { creds = map.get(bestMatch); } } return creds; }
From source file:aidev.cocis.makerere.org.whiteflycounter.common.AgingCredentialsProvider.java
/** * Find matching {@link Credentials credentials} for the given authentication scope. * * @param map the credentials hash map/* w w w . j a v a 2 s . c om*/ * @param authscope the {@link AuthScope authentication scope} * @return the credentials * */ private static Credentials matchCredentials(final Map<AuthScope, Credentials> map, final AuthScope authscope) { // see if we get a direct hit Credentials creds = map.get(authscope); if (creds == null) { // Nope. // Do a full scan int bestMatchFactor = -1; AuthScope bestMatch = null; for (AuthScope current : map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = current; } } if (bestMatch != null) { creds = map.get(bestMatch); } } return creds; }
From source file:org.eclipse.aether.transport.http.DeferredCredentialsProvider.java
public Credentials getCredentials(AuthScope authScope) { synchronized (factories) { for (Iterator<Map.Entry<AuthScope, Factory>> it = factories.entrySet().iterator(); it.hasNext();) { Map.Entry<AuthScope, Factory> entry = it.next(); if (authScope.match(entry.getKey()) >= 0) { it.remove();/* ww w. j a v a 2 s. c o m*/ delegate.setCredentials(entry.getKey(), entry.getValue().newCredentials()); } } } return delegate.getCredentials(authScope); }
From source file:org.apache.http.osgi.impl.OSGiCredentialsProvider.java
private boolean isSuitable(final ProxyConfiguration config, final AuthScope authScope) { return authScope.match(new AuthScope(config.getHostname(), config.getPort())) >= HOST_AND_PORT_MATCH; }