How to open connection through proxy with Java-agent (Domino 8.5.2)?

Hello, I have troubles with using proxy from java-agent.

I develop simple Java-agent and I faced with the fact, that connection through proxy doesn’t work from domino 8.5.2 or, maybe, I do something wrong.

I tried 2 methods

  1. set system properties

System.setProperty(“http.proxySet”, “True”);

System.setProperty(“http.proxyHost”, “proxy-server-address”);

System.setProperty(“http.proxyPort”, “3128”);

and I changed file “java.policy” (located at notes\jvm\lib\security )

permission java.util.PropertyPermission "http.proxySet", "write";

permission java.util.PropertyPermission "http.proxyHost", "write";

permission java.util.PropertyPermission "http.proxyPort", "write";

I don’t know why, but this method doesn’t work - java agent ignores proxy-settings (I rebooted LOtus and OS).

  1. In J2SE 1.5 was implemented new class java.net.Proxy and method in java.net.URL-class to support it (URL.openConnection(Proxy proxy)).

     SocketAddress pa = new InetSocketAddress(proxyAddress, proxyPort);
    
     Proxy proxy = new Proxy(Proxy.Type.HTTP, pa);
    
     URL url = null;
    
     InputStream inputStream = null;
    
     HttpURLConnection http_conn = null;
    
     try {
    
     	url = new URL("http://www.site.ru/simpledata.zip");
    
     	http_conn = (HttpURLConnection)url.openConnection(proxy);
    
     }
    
     catch (MalformedURLException e1) {
    
     	e1.printStackTrace();
    
     }
    
     catch (IOException e1) {
    
     	e1.printStackTrace();
    
     }
    

This code work in eclipse with Lotus jvm, but doesn’t working from java-agent with exception

java.lang.UnsupportedOperationException: Method not implemented.

at java.net.URLStreamHandler.openConnection(URLStreamHandler

I think that is because in IBM URLStreamHandler implementation ( COM.ibm.JEmpower.applet.http.Handler and COM.ibm.JEmpower.applet.http.HttpURLConnection) doesn’t implemented method openConnection with proxy.

But, why first method doesn’t work I can’t understand

p.s. sorry for my English, thanks for reading and help

Subject: permissions

Is this code running on the server? In that case the signer of your agent needs to have unrestricted rights, since you are doing network operations. You can find more help if you look up ‘unrestricted’ rights in Domino Designer help.

Subject: Any solution???

Has anyone found solution to this problem? I am looking for the same thing!

Subject: Server Document settings

Enter the proxy address and port in the Ports==>Proxies tab in the server document. Enter the info in the form :

your.proxyaddress.com:3128

into the fields ‘HTTP Proxy’ and ‘SSL Security Proxy’

Restart your domino server for the setting to take effect. Your agent should now be able to run as expected. (excluding the ‘Not implemented’ issue)

NOTE: Enter the proxy information in your location document if you want to run the agent in your Notes Client.

If your proxy requires authentication, you have another hurdle to jump as I have not yet worked out how to supply proxy server credentials.

I also have tried your approach by attempting to update the system properties which domino/lotus notes seems to completely ignore.

I have validated that the properties are being updated by reading them back and printing them to the console. eg:

System.out.println(System.getProperty(“http.proxyHost”));

        System.out.println(System.getProperty("http.proxyPort"));

        System.out.println(System.getProperty("http.proxyUser"));

        System.out.println(System.getProperty("http.proxyPass word"));

…but still get the error “HTTP Code 407, Proxy Authentication Required” but that’s another story.

I wish IBM would document this stuff so we don’t have to spend days trying to find a solution. Your approach would work in any other JVM.

EDIT 2011.2.28: I found the reason why this does not work in this APAR - “LO40804: Issue setting proxy as property in Java” LO40804: Issue setting proxy as property in Java

cheers

Sean

Subject: 407 proxy authentication error SOLVED

I finally found a way around the 407 proxy authentication error where Domino completely ignores the username and password set using this code?

You need to include this Authenticator code.

final String authUser = “userrname”;

final String authPassword = “password”;

Authenticator.setDefault(

new Authenticator() {

  public PasswordAuthentication getPasswordAuthentication() {

	 return new PasswordAuthentication(

		   authUser, authPassword.toCharArray());

  }

}

);

System.getProperties().put( “proxySet”, “true” );

System.getProperties().put(“http.proxyHost”, “proxy.my.domain.com”);

System.getProperties().put( “http.proxyPort”, “8080”);

System.getProperties().put(“http.proxyUser”, authUser);

System.getProperties().put(“http.proxyPassword”, authPassword);