添加Proxy-Authorization头 HTTP Basic Authentication
Proxy-Authorization: base64(账号:密码) # Basic <base64>
[Java] 纯文本查看 复制代码 private static void setAuthProperties(List<String> authList) {
String hostname = authList.get(0);
String port = authList.get(1);
String authUser = authList.get(2);
String authPassword = authList.get(3);
System.setProperty("http.proxyHost", hostname);
System.setProperty("http.proxyPort", port);
System.setProperty("http.proxyUser", authUser);
System.setProperty("http.proxyPassword", authPassword);
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
Authenticator.setDefault(
new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(authUser, authPassword.toCharArray());
}
}
);
}
参考连接:
1.https://www.yisu.com/zixun/276251.html
2.https://blog.csdn.net/u013214212/article/details/110679367
3.https://www.dieniao.com/Help/3861.html
|