简体   繁体   中英

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 (eg 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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM