使用nimbus-jose-jwt在Java上进行代理和身份验证

时间:2019-12-11 11:00:03

标签: java authentication proxy jwk nimbus-jose-jwt

当我有一个代理(需要身份验证)时,收到以下错误:

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(HttpURLConnection.java:2142) 

当我从远程URL加载JWK时:

static JWKSet load(URL url, int connectTimeout, int readTimeout, int sizeLimit, Proxy proxy)

我创建了Proxy对象并定义了Authetication扩展了java.net.Authenticator类(以下代码中的ProxyAuthenticator)。 我尝试过:

System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
System.setProperty("jdk.http.auth.proxying.disabledSchemes", "");
java.net.Authenticator.setDefault(new ProxyAuthenticator(proxyUser, proxyUser));
publicKeys = JWKSet.load(new URL(JWKSUrl), 0, 0, 0, new Proxy(Proxy.Type.HTTP,
                    new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)))); 

但是我总是收到相同的错误(407代理身份验证)。

有什么想法吗?

0 个答案:

没有答案