【发布时间】:2012-07-16 07:15:14
【问题描述】:
我想将 Tomcat 配置为能够连接到 AD 并相应地对用户进行身份验证。
此外,我还想使用客户端凭据调用一些 Web 服务(在本例中为 Share Point)。
到目前为止,我已成功配置 Tomcat 以使用 SPNEGO 身份验证,如教程 http://tomcat.apache.org/tomcat-7.0-doc/windows-auth-howto.html 中所述。请注意,我使用了 Tomcat 的 SPNEGO 身份验证(不是 Source Forge 或 Waffle)。
我没有使用 Source Forge 的实现,因为我想保持简单并使用开箱即用的 Tomcat。此外,我希望所有的身份验证和授权都由 Tomcat 处理,使用 SPNEGO 作为WEB.XML 中的身份验证方法和 Tomcat 的 JNDI 领域进行授权。
我也没有使用过 WAFFLE,因为这只是 Windows。
我使用 CXF 作为我的 Web 服务堆栈。根据http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-SpnegoAuthentication%28Kerberos%29 的 CXF 文档,使用 Web 服务(在我的例子中是 Share Point)进行身份验证所需要做的就是使用:
<conduit name="{http://example.com/}HelloWorldServicePort.http-conduit"
xmlns="http://cxf.apache.org/transports/http/configuration">
<authorization>
<AuthorizationType>Negotiate</AuthorizationType>
<Authorization>CXFClient</Authorization>
</authorization>
</conduit>
并在 jaas.conf 中配置 CXFClient(在我的例子中,Tomcat 的服务器 JAAS 配置所在的位置,这样我的jass.conf 看起来像:
CXFClient {
com.sun.security.auth.module.Krb5LoginModule required client=true useTicketCache=true debug=true;
};
com.sun.security.jgss.krb5.initiate {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
principal="HTTP/tomcatsrv.corporate.intra@CORPORATE.INTRA"
useKeyTab=true
keyTab="C:/Program Files/Apache/apache-tomcat-7.0.27/conf/tomcatsrv.keytab"
storeKey=true
debug=true;
};
com.sun.security.jgss.krb5.accept {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
principal="HTTP/tomcatsrv.corporate.intra@CORPORATE.INTRA"
useKeyTab=true
keyTab="C:/Program Files/Apache/apache-tomcat-7.0.27/conf/tomcatsrv.keytab"
storeKey=true
debug=true;
};
然而,当我调用 Web 服务时,它是在服务用户名(即在 AD 和 tomcatsrv.keytab 中配置的 Tomcat 的用户名)下调用的,而不是客户端的用户名(例如 duncan.attard)。
所以我的问题是:是否可以通过某种方式将客户的用户名委托(或使用某种模拟)给 CXF,这样当我调用 Share Point 的网络服务时(例如,我想使用 Copy 上传文件.asmx),文件上传为duncan.attard,而不是tomcat.srv。
谢谢大家,非常感谢您的帮助。
【问题讨论】:
标签: cxf tomcat7 windows-authentication kerberos spnego