net.lightbody.bmp.proxy.http.WildcardMatchingCredentialsProvider Maven / Gradle / Ivy
package net.lightbody.bmp.proxy.http;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import java.util.HashMap;
import java.util.Map;
public class WildcardMatchingCredentialsProvider implements CredentialsProvider {
private final HashMap credMap = new HashMap();
@Override
public synchronized void setCredentials(AuthScope authscope, Credentials credentials) {
credMap.put(authscope, credentials);
}
@Override
public synchronized Credentials getCredentials(AuthScope authscope) {
for (Map.Entry entry : credMap.entrySet()) {
if (entry.getKey().getHost() == null) {
continue;
}
if (authscope.getHost().contains(entry.getKey().getHost())) {
return entry.getValue();
}
}
return null;
}
@Override
public synchronized void clear() {
credMap.clear();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy