ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karnes, Derek" <derek.kar...@ngc.com>
Subject RE: proxy authentication question
Date Thu, 14 Oct 2004 13:49:16 GMT
Gabi, 
The method and class below should just about do it. You;ll need to set the proxyXXX variables,
of course, but after that communications are as usual.
-D

import java.net.Authenticator;
import java.net.PasswordAuthentication;

public void setProxyVars() {
 Authenticator.setDefault(new MyAuthenticator(proxyUsername,proxyPassword));
 System.setProperty("proxySet", "true");
 System.setProperty("http.proxyHost", proxyHostname);
 System.setProperty("http.proxyPort", proxyPort);
 System.setProperty("http.proxyUser", proxyUsername);
 System.setProperty("http.proxyPassword", proxyPassword);
}


private final static class MyAuthenticator extends Authenticator {
        private final PasswordAuthentication _password;
        
        public MyAuthenticator(String user, String password) {
            super();
            _password = new PasswordAuthentication(user, password.toCharArray());
        }
        
        protected PasswordAuthentication getPasswordAuthentication() {
            return _password;
        }
}



-----Original Message-----
From: Gabi [mailto:gabi@idieikon.com]
Sent: Wednesday, October 13, 2004 6:39 AM
To: xmlrpc-user@ws.apache.org
Subject: proxy authentication question


Hello to everybody, I'm used to make a client connection throught xml-rpc
but now I've to make it with proxy authentication.
If the proxy has no authentication, sending the parameters -DproxyUser
and -DproxyPassword from the command line to java program is enought but not
for authentication.
I've tried to use the deprecated method setBasicAuthentication, but I get an
http 407 error (proxy authentication error).

My usual code is something like:
XmlRpcClient client=new XmlRpcClient("http://....");
Vector args=new Vector();
args.addElement(new Integer(0));
client.execute("handler.remote_method",args)

Can somebody give a brief example of code of what to do to make the same
with proxy authentication and user "user" and password "pwd" for example?

Best regards.
Gabi.


Mime
View raw message