使用 NTLM/Kerberos 从 Tomcat 中的 Java 网络应用中调用 .NET 网络服务
Calling a .NET web service from within a Java web app in Tomcat with NTLM / Kerberos
我有一个 Java 网络应用程序,其中包含一个指向远程 .NET SOAP 网络服务的 HttpClient。到目前为止,一切都很好。 Java 网络应用程序在 Windows 服务器上的 Apache Tomcat 中运行,并使用服务帐户。
不幸的是,该远程 .net Web 服务使用 NTLM。这个answer gives me some insight into how to do it. But it seems that the configuration stills requires a username/password rather than leveraging the service account Tomcat is running with. Also, I'm not sure what the Java authenticator should look like (as seen here).
有人试过吗?
更新
一些有趣的链接:
- Apache HTTP 组件支持不同的authentication schemes
- NTLMv2 authentication 的示例 - 我尚未对其进行测试。
似乎 Java 7/8 Tomcat 8.x,以下足以利用 NTLM 身份验证 "transparently"。
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.client.methods.HttpUriRequest;
其次是
boolean useWindowsAuthentication = true;
HttpUriRequest request;
CloseableHttpClient httpclient;
if (useWindowsAuthentication){
log.info("Using Windows Authentication");
httpclient = WinHttpClients.createDefault();
} else {
httpclient = HttpClients.createDefault();
}
我有一个 Java 网络应用程序,其中包含一个指向远程 .NET SOAP 网络服务的 HttpClient。到目前为止,一切都很好。 Java 网络应用程序在 Windows 服务器上的 Apache Tomcat 中运行,并使用服务帐户。
不幸的是,该远程 .net Web 服务使用 NTLM。这个answer gives me some insight into how to do it. But it seems that the configuration stills requires a username/password rather than leveraging the service account Tomcat is running with. Also, I'm not sure what the Java authenticator should look like (as seen here).
有人试过吗?
更新
一些有趣的链接:
- Apache HTTP 组件支持不同的authentication schemes
- NTLMv2 authentication 的示例 - 我尚未对其进行测试。
似乎 Java 7/8 Tomcat 8.x,以下足以利用 NTLM 身份验证 "transparently"。
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.client.methods.HttpUriRequest;
其次是
boolean useWindowsAuthentication = true;
HttpUriRequest request;
CloseableHttpClient httpclient;
if (useWindowsAuthentication){
log.info("Using Windows Authentication");
httpclient = WinHttpClients.createDefault();
} else {
httpclient = HttpClients.createDefault();
}