protected void inspect(final Event<?> evt) {
RemoteHttpProxySettings httpProxySettings = globalRemoteProxySettings.getHttpProxySettings();
if (httpProxySettings != null && httpProxySettings.isEnabled()) {
String username = null;
String password = null;
final RemoteAuthenticationSettings authentication = httpProxySettings.getProxyAuthentication();
if (authentication != null
&& UsernamePasswordRemoteAuthenticationSettings.class.isAssignableFrom(authentication.getClass())) {
username = ((UsernamePasswordRemoteAuthenticationSettings) authentication).getUsername();
password = ((UsernamePasswordRemoteAuthenticationSettings) authentication).getPassword();
}
final String hostname = httpProxySettings.getHostname();
final int port = httpProxySettings.getPort();
final Set<String> nonProxyHosts = globalRemoteProxySettings.getNonProxyHosts();
log.debug(
"Configure P2 proxy using global http proxy settings: hostname={}, port={}, username={}, nonProxyHosts={}",
hostname, port, username, nonProxyHosts
);
httpProxy.setProxySettings(hostname, port, username, password, nonProxyHosts);
}
else {
log.debug("No global http proxy settings. Resetting P2 proxy.");
httpProxy.setProxySettings(null, -1, null, null, null);
}
}