Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy settings in Spring Boot

My application needs to fetch an XML file from the web, as follows:

@Bean
public HTTPMetadataProvider metadataProvider()
        throws MetadataProviderException {
    String metadataURL = "http://idp.ssocircle.com/idp-meta.xml";
    final Timer backgroundTaskTimer = new Timer(true);
    HTTPMetadataProvider provider = 
            new HTTPMetadataProvider(backgroundTaskTimer, httpClient(), metadataURL);
    provider.setParserPool(parserPool());
    return provider;
}

I'm working by using a filtered network, thus the app is unable to retrieve that file.

There is a way to setup an HTTP Proxy (e.g. myproxy.eu:8080) in Spring Boot?


Alternatively, I could retrieve the XML file by using the HTTPS protocol, but I should properly setup the metadata provider in order to support an encrypted connection... How?

like image 954
vdenotaris Avatar asked Oct 27 '25 06:10

vdenotaris


1 Answers

This is not something you can configure in spring boot, HttpClient is not using java variables.

Therefor you need to set the proxy on the httpClient manually:

HostConfiguration hostConfig = new HostConfiguration();
hostConfig.setProxyHost(new ProxyHost("your.proxy.host", 8080));
httpClient.setHostConfiguration(hostConfig);
like image 170
Peter Bartels Avatar answered Oct 30 '25 05:10

Peter Bartels