Hello Gabi,
i did this:
---------------------------------------------------
public class ...
{
  ...
  public void init() throws ConfigException
  {
    try
    {
      if (isEnableProxy())
      {
        System.setProperty("proxySet", "true");
        System.setProperty("https.proxyHost", proxyHost);
        System.setProperty("https.proxyPort", proxyPort);
        Authenticator proxyAuthenticator = new HttpAuthenticateProxy();
        Authenticator.setDefault(proxyAuthenticator);
      }
      if (isEnableHttps())
      {
        System.setProperty("javax.net.ssl.keyStore", keyStoreStore);
        System.setProperty("javax.net.ssl.keyStorePassword",
keyStorePassword);
        System.setProperty("javax.net.ssl.keyStoreType", keyStoreType);
        ...
      }
    ...
  }
  ...
}
---------------------------------------------------

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

public class HttpAuthenticateProxy extends Authenticator 
{ 
  private static final String PROXY_USERNAME = "...";
  private static final String PROXY_PASSWORD = "...";

  private String proxyUsername = PROXY_USERNAME;
  private String proxyPassword = PROXY_PASSWORD;

  /**
   * Sets the proxyUsername.
   * @param proxyUsername The proxyUsername to set
   */
  public void setProxyUsername(String proxyUsername) {
    this.proxyUsername = proxyUsername;
  }

  /**
   * Sets the proxyPassword.
   * @param proxyPassword The proxyPassword to set
   */
  public void setProxyPassword(String proxyPassword) {
    this.proxyPassword = proxyPassword;
  }

  protected PasswordAuthentication getPasswordAuthentication() 
  {
    // username, password 
    // sets http authentication 
    return new PasswordAuthentication(proxyUsername,
proxyPassword.toCharArray()); 
  }
}

And modify the source of XmlRpcClient.java
Comment Line 425 aprox. 
  //con.setRequestProperty("Content-Length",
Integer.toString(request.length));

Saludos,
  C�sar.

-----Mensaje original-----
De: Gabi [mailto:[EMAIL PROTECTED]
Enviado el: mi�rcoles, 13 de octubre de 2004 12:39
Para: [EMAIL PROTECTED]
Asunto: 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.

Reply via email to