on 12-22-2006 10:11 AM
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 Im setting wrong PROXY_URL property, but I didnt find any documentation of its using
Can somebody help me,
Thanks for your future help
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.