У меня есть класс ниже, чтобы подключиться к URL-адресу HTTPS,
public class HKReader {
public static void main(String[] paramArrayOfString) {
String str1 = paramArrayOfString[0];
String str2 = paramArrayOfString[1];
String str3 = paramArrayOfString[2];
String str4 = paramArrayOfString[3];
BufferedInputStream localBufferedInputStream = null;
FileOutputStream localFileOutputStream = null;
try {
URL localURL = new URL(str1);
URLConnection localURLConnection = localURL.openConnection();
localURLConnection.setRequestProperty("Proxy-Authorization", "Basic" + new BASE64Encoder()
.encode(new StringBuilder().append(str3).append(":").append(str4).toString().getBytes()));
localBufferedInputStream = new BufferedInputStream(localURLConnection.getInputStream());
localFileOutputStream = new FileOutputStream(new File(str2));
int i;
while ((i = localBufferedInputStream.read()) != -1) {
localFileOutputStream.write(i);
}
return;
} catch (MalformedURLException localMalformedURLException) {
localMalformedURLException.printStackTrace();
System.exit(-1);
} catch (IOException localIOException3) {
localIOException3.printStackTrace();
System.exit(-1);
} finally {
try {
if (localBufferedInputStream != null) {
localBufferedInputStream.close();
}
if (localFileOutputStream != null) {
localFileOutputStream.close();
}
} catch (IOException localIOException5) {
localIOException5.printStackTrace();
System.exit(-1);
}
}
}
}
И я выполняю класс, используя приведенную ниже команду на моем сервере Unix
$JAVA_HOME/bin/java -cp $LIB_DIR -Djdk.http.auth.tunneling.disabledSchemes="" -Dhttps.proxyHost=primary-proxy -Dhttps.proxyPort=8081 HKReader $url $target_file $proxyUser $proxyPassword
Я пробовал поискать в Google несколькораз, но я получаю ниже ошибки.
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
Может кто-нибудь, пожалуйста, помогите мне, где я скучаю.