AuthScope bestMatch = null; for (AuthScope current: map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
static public AuthScope bestmatch(AuthScope scope, Set<AuthScope> scopelist) { Credentials creds = null; int bestMatchFactor = -1; AuthScope bestMatch = null; for(final AuthScope current : scopelist) { final int factor = scope.match(current); if(factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = current; } } return bestMatch; }
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; }
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; }
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (AuthScope current: map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (AuthScope current: map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (AuthScope current: map.keySet()) { int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;
/** * Removes the credentials from the AuthScope. * @param authscope the AuthScope to remove the credentials of * @return whether it was removed or not */ public synchronized boolean removeCredentials(final AuthScope authscope) { if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } int bestMatchFactor = -1; AuthScopeProxy bestMatch = null; for (final AuthScopeProxy proxy : credentialsMap_.keySet()) { final AuthScope current = proxy.getAuthScope(); final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = proxy; } } return credentialsMap_.remove(bestMatch) != null; }
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(); delegate.setCredentials( entry.getKey(), entry.getValue().newCredentials() ); } } } return delegate.getCredentials( authScope ); }
/** * Removes the credentials from the AuthScope. * @param authscope the AuthScope to remove the credentials of * @return whether it was removed or not */ public synchronized boolean removeCredentials(final AuthScope authscope) { if (authscope == null) { throw new IllegalArgumentException("Authentication scope may not be null"); } int bestMatchFactor = -1; AuthScopeProxy bestMatch = null; for (final AuthScopeProxy proxy : credentialsMap_.keySet()) { final AuthScope current = proxy.getAuthScope(); final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = proxy; } } return credentialsMap_.remove(bestMatch) != null; }
private boolean isSuitable(final ProxyConfiguration config, final AuthScope authScope) { return authScope.match(new AuthScope(config.getHostname(), config.getPort())) >= HOST_AND_PORT_MATCH; }
/** * Find matching {@link Credentials credentials} for the given authentication scope. * * @param map the credentials hash map * @param authscope the {@link AuthScope authentication scope} * @return the credentials */ private static Credentials matchCredentials(final Map<AuthScopeProxy, Credentials> map, final AuthScope authscope) { Credentials creds = map.get(new AuthScopeProxy(authscope)); if (creds == null) { int bestMatchFactor = -1; AuthScopeProxy bestMatch = null; for (final AuthScopeProxy proxy : map.keySet()) { final AuthScope current = proxy.getAuthScope(); final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = proxy; } } if (bestMatch != null) { creds = map.get(bestMatch); } } return creds; }
for (final AuthScopeProxy proxy : map.keySet()) { final AuthScope current = proxy.getAuthScope(); final int factor = authscope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor;