Nic*_* A. 6 java proxy ntlm httpurlconnection
我们在客户(java应用程序,而不是applet)中部署了一个Java客户端应用程序.此应用程序检查与url.openConnection()的连接,并通过Internet调用Web服务(使用CXF/JAX-WS).
我们的一些客户网络使用代理来访问外部世界.客户端应用程序在java系统属性中设置代理参数:
System.setProperty("proxySet", "true"); //Obsolete ?
System.setProperty("http.keepAlive", "false");
System.setProperty("java.net.useSystemProxies", "false");
System.setProperty("https.proxyHost", httpsProxyHost);
System.setProperty("https.proxyPort", httpsProxyPort);
System.setProperty("https.proxyUser", httpsProxyUser);
System.setProperty("https.proxyPassword", httpsProxyPassword);
System.setProperty("http.proxyHost", httpProxyHost);
System.setProperty("http.proxyPort", httpProxyPort);
System.setProperty("http.proxyUser", httpProxyUser);
System.setProperty("http.proxyPassword", httpProxyPassword);
Authenticator.setDefault(new NtlmAuthenticator(httpsProxyUser, httpsProxyPassword));
Run Code Online (Sandbox Code Playgroud)
NtlmAuthenticator类:
public class NtlmAuthenticator extends Authenticator {
private final String username;
private final char[] password;
public NtlmAuthenticator(final String username, final String password) {
super();
this.username = username;
this.password = password.toCharArray();
}
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication (username, password));
}
Run Code Online (Sandbox Code Playgroud)
}
我们使用的是Java 6(客户端应用程序嵌入了JRE 1.6.0_39),应用程序部署在Windows(XP/Seven)上.我读到自Windows平台上的1.4.2以来支持NTLM协议.所以我们使用Trend代理进行了测试并成功执行了NTLM代理身份验证(我们看到3个包使用Wireshark NTLMSSP_NEGOCIATE(来自app)/ NTLMSSP_CHALLENGE(来自代理)/ NTLMSSP_AUTH(来自app))
但是对于使用Bluecoat代理的客户之一,NTLM认证在NTLMSSP_CHALLENGE之后失败.使用Wireshark,我们只看到2个第一个数据包NTLMSSP_NEGOCIATE(来自app)和NTLMSSP_CHALLENGE(来自代理),NTLMSSP_AUTH永远不会被我们的应用程序发送.在应用程序中,我们捕获一个SocketException:socket已关闭
我们也尝试使用jCIFS HttpUrlNltmHandler,但身份验证也失败了(相同的诊断).
我发现这个帖子有类似的问题,但它没有提供任何线索.我还发现了关于NTLM会话安全性的这个帖子
有任何想法吗 ?
谢谢.
只需将http.keepalive设置为true即可找到解决方案:System.setProperty("http.keepAlive"," true ");
但我不知道为什么,它具有错误价值,它适用于我们的Trend代理,并且不适用于我们客户的bluecoat代理
| 归档时间: |
|
| 查看次数: |
11088 次 |
| 最近记录: |