Bom, galera eh o seguinte:
Para acesso a internet aki na minha empresa devemos digitar senha para o proxy, e estou desenvolvendo um sistema q conecta numa URL e captura alguns dados. Em casa sem Proxy funciona td perfeito porem aki no banco ao conectar tenho q passar os parametros de user e senha do proxy,
ja tentei varias formas... e sempre caio no erro 407 q eh: HTTP Status-Code 407: Proxy Authentication Required.
import java.net.*;
import com.sun.net.ssl.*;
import java.io.*;
import sun.misc.BASE64Encoder;
import java.security.*;
public class PassProxy {
public PassProxy(String proxyhost, String proxyport, String proxylogin, String proxypass, String url) {
/* Set the proxy server host and port */
System.setProperty("http.proxyHost", proxyhost);
System.setProperty("http.proxyPort", proxyport);
byte[] encodedPassword = (proxylogin+":"+proxypass).getBytes();
BASE64Encoder encoder = new BASE64Encoder();
try
{
URL u = new URL(url);
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestProperty("Authorization","Basic " +encoder.encode(encodedPassword));
uc.connect();
//uc.setRequestMethod( "POST" );
System.out.println("iahaaaa");
//uc.setDoInput( true );
/* Print the content of the url to the console. */
showContent(uc);
} catch (IOException e) {
System.out.println("exception da conex");
e.printStackTrace();
}
}
private void showContent(HttpURLConnection uc) throws IOException {
InputStream i = uc.getInputStream();
char c;
InputStreamReader isr = new InputStreamReader(i);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
public static void main(String[] args) {
String proxyhost = "172.17.78.8";
String proxyport = "80";
String proxylogin = "login";
String proxypass = "pass";
String url = "http://www.qualquersite.com.br";
new PassProxy(proxyhost, proxyport, proxylogin, proxypass, url);
}
}
alguem pod me ajudar?

