(编辑:正如OP所指出的,
java.net.Authenticator也需要使用a 。为了正确起见,我相应地更新了我的答案。)
(编辑#2:正如另一个答案中指出的那样,在JDK 8中,需要
basic从
jdk.http.auth.tunneling.disabledSchemes属性中删除身份验证方案)
对于身份验证,用于
java.net.Authenticator设置代理的配置并设置系统属性
http.proxyUser和
http.proxyPassword。
final String authUser = "user";final String authPassword = "password";Authenticator.setDefault( new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(authUser, authPassword.toCharArray()); } });System.setProperty("http.proxyUser", authUser);System.setProperty("http.proxyPassword", authPassword);System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)