Skip to content

Commit

Permalink
Merge pull request #796 from cortlepp/fix/AXIS2-6044
Browse files Browse the repository at this point in the history
fix: correct http proxy configuration precedence (#AXIS2-6044)
  • Loading branch information
robertlazarski authored Nov 9, 2024
2 parents dd74683 + 247d04e commit 20eff9e
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,18 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde
String proxyUser = null;
String proxyPassword = null;

// Getting configuration values from Axis2.xml

// First: get settings from system properties
String host = System.getProperty(HTTPTransportConstants.HTTP_PROXY_HOST);
if (host != null) {
proxyHost = host;
}
String port = System.getProperty(HTTPTransportConstants.HTTP_PROXY_PORT);
if (port != null && !port.isEmpty()) {
proxyPort = Integer.parseInt(port);
}

// Override with settings from Axis2.xml
Parameter proxySettingsFromAxisConfig = messageContext.getConfigurationContext()
.getAxisConfiguration().getParameter(HTTPTransportConstants.ATTR_PROXY);
if (proxySettingsFromAxisConfig != null) {
Expand All @@ -99,17 +110,16 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde
if (proxyUser.length() > proxyUserDomainIndex + 1) {
String user = proxyUser.substring(proxyUserDomainIndex + 1);
proxyCredentials = new NTCredentials(user, proxyPassword.toCharArray(), proxyHost,
domain);
domain);
}
}
}
}

// If there is runtime proxy settings, these settings will override
// settings from axis2.xml
// Override with settings from MessageContext
HttpTransportProperties.ProxyProperties proxyProperties =
(HttpTransportProperties.ProxyProperties) messageContext
.getProperty(HTTPConstants.PROXY);
.getProperty(HTTPConstants.PROXY);
if (proxyProperties != null) {
String proxyHostProp = proxyProperties.getProxyHostName();
if (proxyHostProp == null || proxyHostProp.length() <= 0) {
Expand All @@ -132,16 +142,7 @@ public static void configure(MessageContext messageContext, RequestConfig.Builde

}

// Overriding proxy settings if proxy is available from JVM settings
String host = System.getProperty(HTTPTransportConstants.HTTP_PROXY_HOST);
if (host != null) {
proxyHost = host;
}

String port = System.getProperty(HTTPTransportConstants.HTTP_PROXY_PORT);
if (port != null && !port.isEmpty()) {
proxyPort = Integer.parseInt(port);
}

// AXIS2-6051, CredentialsProvider no longer has setCredentials() however BasicCredentialsProvider
// does have it. clientContext.getCredentialsProvider() returns CredentialsProvider.
Expand Down

0 comments on commit 20eff9e

Please sign in to comment.