通过Java访问需用户密码和Windows域认证的代理
Java通过代理访问网络设置,代理服务器需要用户/密码和Windows域验证:
System.setProperty( "proxySet", "true" );
System.setProperty( "http.proxyHost", "localhost" );
System.setProperty( "http.proxyPort", "8080" );
System.setProperty( "http.auth.ntlm.domain", "searchfull.net" );
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username",
new String("password").toCharArray());
}
});
System.setProperty( "proxySet", "true" );
System.setProperty( "http.proxyHost", "localhost" );
System.setProperty( "http.proxyPort", "8080" );
System.setProperty( "http.auth.ntlm.domain", "searchfull.net" );
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username",
new String("password").toCharArray());
}
});