Skip to content

Commit 7dd3ff4

Browse files
committed
Fix #25863: Use http_proxy system-properties in HttpClient of SAML
Co-authored-by: bleboeuf <bart.leboeuf@teamwork.net> commit 558ccbea03ade2a5574e968eb76de1a3fbedd865 Author: bleboeuf <bart.leboeuf@teamwork.net> Date: Mon Mar 8 13:42:17 2021 +0100 Fix: use java proxy variables commit 60c9fc3d2f093a0e7fb9112fbbd3dc90f032719c Author: bleboeuf <bart.leboeuf@teamwork.net> Date: Sat Mar 6 15:26:13 2021 +0100 Feat: add corporate proxy support on httpClient used by saml configuration.
1 parent 6ae5cde commit 7dd3ff4

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/auth/impl/saml/SAMLConfiguration.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import eu.openanalytics.containerproxy.auth.UserLogoutHandler;
2424
import eu.openanalytics.containerproxy.auth.impl.SAMLAuthenticationBackend;
25+
import org.apache.commons.httpclient.HostConfiguration;
2526
import org.apache.commons.httpclient.HttpClient;
2627
import org.apache.logging.log4j.LogManager;
2728
import org.apache.logging.log4j.Logger;
@@ -261,17 +262,29 @@ public ExtendedMetadata extendedMetadata() {
261262
}
262263

263264
@Bean
264-
public ExtendedMetadataDelegate idpMetadata() throws MetadataProviderException, ResourceException {
265+
public ExtendedMetadataDelegate idpMetadata() throws MetadataProviderException {
265266
String metadataURL = environment.getProperty(PROP_METADATA_URL);
266267

267268
Timer backgroundTaskTimer = new Timer(true);
268-
HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider(backgroundTaskTimer, new HttpClient(), metadataURL); httpMetadataProvider.setParserPool(parserPool());
269+
HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider(backgroundTaskTimer, getHttpClient(), metadataURL);
270+
httpMetadataProvider.setParserPool(parserPool());
269271
ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(httpMetadataProvider , extendedMetadata());
270272
extendedMetadataDelegate.setMetadataTrustCheck(false);
271273
extendedMetadataDelegate.setMetadataRequireSignature(false);
272274
return extendedMetadataDelegate;
273275
}
274276

277+
private HttpClient getHttpClient() {
278+
HttpClient httpClient = new HttpClient();
279+
String proxyHost = System.getProperty("http.proxyHost");
280+
if (proxyHost != null) {
281+
HostConfiguration hostConfiguration = new HostConfiguration();
282+
hostConfiguration.setProxy(proxyHost, Integer.parseInt(System.getProperty("http.proxyPort","80")));
283+
httpClient.setHostConfiguration(hostConfiguration);
284+
}
285+
return httpClient;
286+
}
287+
275288
@Bean
276289
@Qualifier("metadata")
277290
public CachingMetadataManager metadata() throws MetadataProviderException, ResourceException {

0 commit comments

Comments
 (0)