我尝试使用Tomcat 7.0.54设置SPNEGO r7,但是在调用时 request.getRemoteUser()
来自jsp,我收到以下错误:
SEVERE: Servlet.service() for servlet [ssoServlet] in context with path [/rightitnow] threw exception [GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)] with root cause
GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
at sun.security.jgss.GSSHeader.<init>(GSSHeader.java:97)
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:306)
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
at sun.security.jgss.spnego.SpNegoContext.GSS_acceptSecContext(SpNegoContext.java:871)
at sun.security.jgss.spnego.SpNegoContext.acceptSecContext(SpNegoContext.java:544)
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:342)
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
at net.sourceforge.spnego.SpnegoAuthenticator.doSpnegoAuth(SpnegoAuthenticator.java:444)
at net.sourceforge.spnego.SpnegoAuthenticator.authenticate(SpnegoAuthenticator.java:283)
at net.sourceforge.spnego.SpnegoHttpFilter.doFilter(SpnegoHttpFilter.java:229)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.rivermuse.server.filter.GWTCacheControlFilter.doFilter(GWTCacheControlFilter.java:43)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
我在这里看过帖子 http://sourceforge.net/p/spnego/discussion/1003769/thread/990913cc/ "Defective token detected" error (NTLM not Kerberos) with Kerberos/Spring Security/IE/Active Directory
但我仍然无法弄清问题是什么。
Tomcat在Ubuntu 12.04 LTS上运行,我使用domainjoin-cli将其添加到Windows域。 我在不同的客户端(Firefox / IE / Chrome)上测试了差异操作系统(Windows XP,7,2008 Server,MacOS),每个组合的结果都不同,其中一些组合给出了上面的错误,其他组合给出了完全没有警告,但仍然没有getRemoteUser()。
在http://spnego.sourceforge.net/pre_flight.html执行飞行前检查,我能够成功运行HelloKDC。
我确保IE已启用IWA,并且服务器beer.test.co.uk位于本地Intranet站点列表中,并将其添加到firefox中的network.negotiate-auth.trusted-uris。
我已按照一篇文章的建议检查了前向/反向DNS有关此问题的问题我已经得到以下信息:
rabbit-stew:logs $ host beer.test.co.uk
beer.test.co.uk is an alias for beer.uk.river.com.
beer.uk.river.com has address 192.168.12.236
rabbit-stew:logs $ host 192.168.12.236
236.12.168.192.in-addr.arpa domain name pointer beer.uk.river.com.
dev@beer:~/deploy/conf$ cat jaas.conf
com.sun.security.jgss.krb5.initiate {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
principal="HTTP/beer.rivertest.co.uk@TEST.CO.UK"
useKeyTab=true
keyTab="/home/dev/deploy/conf/tomcat.keytab"
storeKey=true;
};
com.sun.security.jgss.krb5.accept {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
principal="HTTP/beer.test.co.uk@TEST.CO.UK"
useKeyTab=true
keyTab="/home/dev/deploy/conf/tomcat.keytab"
storeKey=true;
};
dev@beer:~/deploy/conf$ cat krb5.ini
[libdefaults]
default_realm = TEST.CO.UK
default_keytab_name = FILE:/home/dev/deploy/conf/tomcat.keytab
default_tkt_enctypes = rc4-hmac,aes256-cts-hmac-sha1-96,aes128-cts-hmac-sha1-96
default_tgs_enctypes = rc4-hmac,aes256-cts-hmac-sha1-96,aes128-cts-hmac-sha1-96
forwardable=true
[realms]
TEST.CO.UK = {
kdc = vs5gen2.test.co.uk:88
}
[domain_realm]
test.co.uk= TEST.CO.UK
.test.co.uk= TEST.CO.UK
dev@beer:~/deploy/conf$ cat login.conf
spnego-client {
com.sun.security.auth.module.Krb5LoginModule required;
};
spnego-server {
com.sun.security.auth.module.Krb5LoginModule required
storeKey=true
isInitiator=false;
};
最令我困惑的是,当我在Mac上运行相同的代码时,我能够让SSO工作。
提前感谢并提供有关修复此问题的任何提示,我们将不胜感激。
编辑:通过添加DNS A记录而不是别名+使用kinit在我的Mac上获取手动kerberos票证来解决问题。
答案 0 :(得分:1)
当Windows客户端未为所请求的服务发送正确的服务令牌时,我看到了此错误。
E.g。 service是HTTP / server.example.com,但Windows为不同的服务发送服务票据。
使用Windows客户端,使用'kerbtray'实用程序验证客户端是否真的具有服务HTTP / ...的服务令牌。
答案 1 :(得分:1)
您遇到DNS问题。请咨询您的管理员。