in jsign-core/src/main/java/net/jsign/SignerHelper.java [561:596]
private void initializeProxy(String proxyUrl, final String proxyUser, final String proxyPassword) throws MalformedURLException {
// Do nothing if there is no proxy url.
if (proxyUrl != null && proxyUrl.trim().length() > 0) {
if (!proxyUrl.trim().startsWith("http")) {
proxyUrl = "http://" + proxyUrl.trim();
}
final URL url = new URL(proxyUrl);
final int port = url.getPort() < 0 ? 80 : url.getPort();
ProxySelector.setDefault(new ProxySelector() {
public List<Proxy> select(URI uri) {
Proxy proxy;
if (uri.getScheme().equals("socket")) {
proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(url.getHost(), port));
} else {
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url.getHost(), port));
}
if (console != null) {
console.debug("Proxy selected for " + uri + " : " + proxy);
}
return Collections.singletonList(proxy);
}
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
}
});
if (proxyUser != null && proxyUser.length() > 0 && proxyPassword != null) {
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray());
}
});
}
}
}