Knowledgebase
Having troubles connecting thru proxy server using FTP protocol
Posted by - NA - on 11 July 2007 12:58 AM
The Ftp.setProxyAuthentication method sets the java.net.socks.password and java.net.socks.username system properties. These properties should be used by the JVM in forwarding socket requests to a SOCKS proxy. It has however been noticed that some JVM do not use this information as is documented in the following:

http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html

This appears to be a bug in some JVM. To get around this issue consider registering an Authenticator as follows:

Authenticator auth = new MyAuth(user, password);
Authenticator.setDefault(auth);

class MyAuth extends Authenticator {
/**
* PasswordAuthentication
*/
private PasswordAuthentication defaultAuth;

/**
* @param un
* @param pw
*/
MyAuth(String un, String pw) {
if (pw != null) {
defaultAuth = new PasswordAuthentication(un, pw.toCharArray());
} else {
defaultAuth = new PasswordAuthentication(un, new char[0]);
}
}

/**
*
*/
protected PasswordAuthentication getPasswordAuthentication() {
return defaultAuth;
}
}
(126 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion