【发布时间】:2021-11-13 00:47:25
【问题描述】:
我正在尝试使用 java 的 adal4j 库连接 azure。但我必须通过代理连接。以下是代码的 sn-p
String url = "https://login.microsoftonline.com/tenant_id/oauth2/authorize";
authContext = new AuthenticationContext(url,false,
service);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyhostname", 443));
authContext.setProxy(proxy);
ClientCredential clientCred = new ClientCredential(XXXX, xxxx);
Future<AuthenticationResult> future = authContext.acquireToken(
clientCred,
null);
authResult = future.get();
我也试过
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyUser", "xxxx");
System.setProperty("http.proxyPassword", "xxxx");
System.setProperty("http.proxyHost", "xxxxxxx");
而且我一直收到以下错误
the error is.....java.net.ConnectException: Connection timed out: connect
java.util.concurrent.ExecutionException: java.net.ConnectException: Connection timed out: connect
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at com.toyota.eap.auth.Test.main(Test.java:76)
Caused by: java.net.ConnectException: Connection timed out: connect
注意:仅当我们在办公室内有代理时才会出现此错误。如果我在办公室外运行此程序,则没有问题。
对此有任何想法。
谢谢
【问题讨论】:
-
要在 Java 中通过代理访问 AAD,您可以查看线程 *.com/questions/32522773/adal-for-java-proxy/…。同时,请使用Proxy检查办公网络,确保网络可用且有效。