我必须发布一些数据,并且必须使用ntlm auth的代理。我的问题是,我从代理获得了407(需要代理身份验证)。我无法控制代理,所以我不能在这里调试!
客户端日志显示此代理状态:
1。)代理身份验证状态:UNCHALLENGED
2.。)代理身份验证状态:已挑战
3.。)代理身份验证状态:HANDSHAKE
也许有人可以检查我的代码,如果它应该有用,因为我希望代理设置是错误的。
NTCredentials ntCreds = new NTCredentials(ntUsername, ntPassword,localMachineName, domainName );
CredentialsProvider credsProvider = new BasicCredentialsProvider();
HttpHost httpProxy = new HttpHost(InetAddress.getByName(proxyString), Integer.valueOf(proxyPort));
credsProvider.setCredentials( new AuthScope(httpProxy), ntCreds );
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setProxy(httpProxy);
clientBuilder.setDefaultCredentialsProvider(credsProvider);
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());
CloseableHttpClient client = clientBuilder.build();
URI destination = new URI("http://requestb.in/1bpjk7g");
HttpEntity entity = new StringEntity("test 123");
HttpPost request = new HttpPost(destination);
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
request.setConfig(config );
request.setEntity(entity);
client.execute(request);