cancel
Showing results for 
Search instead for 
Did you mean: 

HTTPDestination vs PROXY

Former Member
0 Kudos

Hi skilled,

Does anybody knows how to use com.sap.security.core.server.destinations.api.HTTPDestination to get content of URL through proxy… (Paris server)

It works without proxy, but when I am setting proxy settings, they fall into unknown code hole and not used by destination.

My code:

//Creation of destionation
HTTPDestination destination = (HTTPDestination) getDestinationService().createDestination(HTTP_DESTINATION_CAPTION);
destination.setName(DEFAULT_DASTINATION_NAME);
getDestinationService().storeDestination(HTTP_DESTINATION_CAPTION, destination);
…
…
//Adding proxy settings
HTTPDestination httpDetination = (HTTPDestination) getDestinationService().getDestination(HTTP_DESTINATION_CAPTION, name);
…
httpDetination.setUrl(url);
if (m_proxySettings != null && m_proxySettings.getProxySet()) {
        Properties dp = httpDetination.getDestinationProperties();  
        dp.setProperty(HTTPDestination.PROXY_ENABLED, "true");
        dp.setProperty(
                HTTPDestination.PROXY_URL, m_proxySettings.isProxyHost() + ":" + m_proxySettings.getProxyPort());
        httpDetination.setDestinationProperties(dp);
}
getDestinationService().updateDestination(HTTP_DESTINATION_CAPTION, httpDetination);
//After this step httpDestination has proxy setting
…
//Trying to get content
URLConnection connection = httpDetination.getURLConnection();
connection.getInputStream(); //Throws UnknownHostException(proxy is not used)
…

private DestinationService getDestinationService() throws NamingException {
     if (m_destinationService != null) {
           return m_destinationService;
     } else {
          m_destinationService = (DestinationService) new InitialContext().lookup(DestinationService.JNDI_KEY_LOCAL);
          if (m_destinationService == null) {
                   throw new RuntimeException("Destination Service not available");
           }
          return m_destinationService;
     }
}

I think I’m setting wrong PROXY_URL property, but I didn’t find any documentation of it’s using…

Can somebody help me,

Thanks for your future help

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

The problem was solved by setting proxy URL to

 org.w3c.www.protocol.http.HttpManager:

Setting up proxy:


URL proxyURL = new URL("http://" + proxyHost + ":" + proxyPort);
HttpManager.getManager().setProxy(proxyURL );
HttpManager.getManager(url).setProxy(proxyURL );

Release proxy:


HttpManager.getManager().setProxy(null);
HttpManager.getManager(url).setProxy(null);

Where

url

is java.net.URL of requested url content.

This manager properties uses for create tempate of request in HTTPURLConnection class.