Spring Security Kerberos/SPNEGO Extension

Mike Wiesner

We're pleased to announce that the first milestone of the Spring Security Kerberos Extension is now available for download. The release is also available through the Maven milestone repository at http://maven.springframework.org/milestone. With the Spring Security Kerberos Extension, your users are authenticated against your web application just by opening the URL. There is no need to enter a username/password and no need to install additional software.

Before going deeper into Kerberos, I would like to introduce Spring Security Extensions, a new Spring Extension project dedicated to provide extension modules for the core Spring Security project. Currently we have two extensions developed there: A SAML2 integration and a Kerberos/SPNEGO integration. Every module will have its own release cycle, so that people can benefit from these extensions as soon as they are ready and don't have to wait for the next Spring Security release. If you have any ideas or even some code for further extensions, please tell us!

Kerberos/SPNEGO

In the first milestone of this module we provide you with an out-of-the-box Kerberos/SPNEGO solution for web applications. Kerberos is a standardized network authentication protocol, which is designed to provide strong authentication for client/server application, like web applications where the Browser is the client. It is also the recommended way to authenticate users in a Windows network and it replaces the outdated and relatively insecure NTLM. Besides this, it is widely used in *NIX environments and there are implementations for every major platform. So, it is very likely that you already have Kerberos in place and now you can use this also in your own web application. That means that your user just enters the URL and he is automatically authenticated with his domain username, for example mikewiesner@SPRINGSOURCE.COM. You can then find out this username via Spring Security or even with request.getRemoteUser(). How does this work? Here is a brief overview:

SPNEGO

The Browser sends a GET request to your web application (1), which then returns that "negotiate" authentication is required (2). The Browser will then ask the Kerberos Server to get a so called service ticket (3). The Browser then send this service ticket, which proves the identity of the caller, and some additional things to the web application (5). After validating the ticket, based on some shared secret between your web application and the Kerberos server, you get back the username.

For this to work, every web applications needs to be registered at the Kerberos server and gets a service prinicipal and a shared secret assigned. For web applications, the service principal must be "HTTP/<full qualified domain name>@DOMAIN". For example "HTTP/web.springsource.com@SPRINGSOURCE.COM", if your app runs on web.springsource.com. You then need to export the credentials of this principal to a keytab file (shared secret) and make this available to your application. Every Kerberos based system will work this way, but the creation of this service principal and the keytab is different between the systems. I will show you how you do this with Microsoft Windows and MIT Kerberos, but it should also work with other implementations.

Creating service principal with Microsoft Windows 2008 Server

Although this refers to Microsoft Windows 2008 Server, it should be very similar in 2003 and even 2000 Server. In ActiveDirectory, you just create a normal domain user and then assign him a service principal (SPN), and create the keytab with a command line utility. And now step by step:

Create a normal user which will become the service principal. The username and the password is meaningless for Kerberos, but you should of course choose a useful name, like http-web.springsource.com. Just make sure that you deactivate the option "User must change password at next logon" and activate "Password never expires".

After that, you have to use the command line tool "ktpass.exe". It is already included in Windows 2008 Server, in earlier versions you have to install it yourself. Just make sure that you are using a version which matches to your server version and also the locale should match. This tool will assign the service principal name (SPN) to your earlier created user and will export the user key to a keytab file. If your service principal is "HTTP/web.springsource.com@SPRINGSOURCE.COM" and your user is http-web.springsource.com, then your ktpass command should look like this:

ktpass /out http-web.keytab /mapuser http-web.springsource.com@SPRINGSOURCE.COM /princ HTTP/web.springsource.com@SPRINGSOURCE.COM  /pass *

ktpass will prompt you for some password. You should choose some secure random one for it. If you now have a file http-web.keytab in your directory, then everything worked fine. This file is needed later in your application, as it contains the shared secret to validate the service tickets.

Creating service principal with MIT Kerberos

On *NIX systems and also in Mac OS X, the MIT Kerberos implementation is widely used. With MIT Kerberos it is even simpler. Just open the kadmin console and execute the following commands:

kadmin:  addprinc -randkey HTTP/web.springsource.com
kadmin:  ktadd -k /http-web.keytab HTTP/web.springsource.com

You should then have a file http-web.keytab under root. This file is later needed in your application, as it contains the shared secret to validate the service tickets.

Configuring Spring Security

First of all, the requirements:

  • Spring Security 3.0.0 M2
  • SUN JRE/JDK 1.6.x
  • Kerberos environment
  • Browser which supports SPNEGO (Firefox, IE, Safari)

In order to use the Kerberos module in Spring Security, you just have to declare a filter, an authentication entry point and an authentication provider. We included a sample web app which you can use as as starting point. You just have to configure your service principal name and place your generate keytab there. The sample app is included in the download mentioned above.

If you open the security.xml file of the sample application, which is under /src/main/webapp/WEB-INF, you see a basic Spring Security configuration which uses the new Kerberos module.

<sec:http entry-point-ref="spnegoEntryPoint">
	<sec:intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_FULLY" />
	<sec:custom-filter ref="spnegoAuthenticationProcessingFilter" position="BASIC_PROCESSING_FILTER" />
</sec:http>

<bean id="spnegoEntryPoint" class="org.springframework.security.extensions.kerberos.web.SpnegoEntryPoint" />

<bean id="spnegoAuthenticationProcessingFilter" class="org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter">
	<property name="authenticationManager" ref="authenticationManager" />
</bean>

<sec:authentication-manager alias="authenticationManager">
	<sec:authentication-provider ref="kerberosServiceAuthenticationProvider" />
</sec:authentication-manager>

<bean id="kerberosServiceAuthenticationProvider" class="org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider">
	<property name="ticketValidator">
		<bean class="org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator">
			<property name="servicePrincipal" value="HTTP/web.springsource.com" />
			<property name="keyTabLocation" value="classpath:http-web.keytab" />
		</bean>
	</property>
	<property name="userDetailsService" ref="dummyUserDetailsService" />
</bean>

<!-- Just returns the User authenticated by Kerberos and gives him the ROLE_USER -->
<bean id="dummyUserDetailsService" class="org.springframework.security.extensions.kerberos.sample.DummyUserDetailsService"/>

The first two beans (SpnegoEntryPoint and SpnegoAuthenticationProcessingFilter) are responsible for the handshake, and the KerberosServiceAuthenticationProvider then finally validates the service ticket. Currently we only support the Kerberos/SPNEGO implementation which is included in SUN's JRE/JDK. As you only get back the username from Kerberos, you also need an UserDetailsService to fetch the roles and maybe some other user attributes. In this sample we just use a dummy implementation to make testing easier.

As you can see, we already filled in the service prinicipal name and the keytab location. Change these values for your need and make sure that the previously generated keytab is available under this location.

Now start your server and try to attempt a SPNEGO authentication. You should see your full domain username in the Browser. In your code you can retrieve the username with the normal Spring Security classes or even with the standard Java servlet call request.getRemoteUser(). If it doesn't work (maybe you see an empty page), check these things:

  • Check the logfile
  • Make sure that you use the full qualified domain name (not the IP adress and not the short name) in your URL.
  • If you are using Internet Explorer: Turn on "Windows Integrated Authentication" and make sure that the domain (in our case web.springsource.com) is listed in IE's local intranet site section.
  • If you are using Firefox: Have a look here.
  • If you are using a Windows client: Client and Server must be on different machines, because otherwise Windows will use NTLM instead of Kerberos.
  • Check if the time is synchronized on all involved machines.
  • If you're using Microsoft AD, you will find some further help here: http://msdn.microsoft.com/en-us/library/ms995329.aspx
    • Besides this, setting up a proper Kerberos environment can be complicated, and it is important to get this right before you start using the Spring Security Kerberos extension. Most of the problems we encounter during consulting are problems with the Kerberos environment and not with the application itself.

      If you wan't to use the Spring Security Kerberos Extension in your own Maven project, you have to add the Spring Milestone Repository to your pom.xml. It should look like this:

      <repositories>
      	<repository>
      		<id>spring-milestone</id>
      		<name>Spring Portfolio Milestone Repository</name>
      		<url>http://maven.springframework.org/milestone </url>
      	</repository>
      </repositories>
      

      and of course the dependency:

      <dependency>
      	<groupId>org.springframework.security.extensions</groupId>
      	<artifactId>spring-security-kerberos-core</artifactId>
      	<version>1.0.0.M1</version>
      </dependency>
      

      There is still some work to do, for example to also provide Kerberos for Java clients and not only for the server, but we hope you'll try out this milestone release and provide some feedback. The Community Forum is the best place to ask questions or to start discussions on new features. Alternatively, if you find something amiss, you can raise a Jira Issue.

      Similar Posts

      Share this Post
      • Digg
      • Sphinn
      • del.icio.us
      • Facebook
      • Mixx
      • Google Bookmarks
      • DZone
      • LinkedIn
      • Slashdot
      • Technorati
      • TwitThis
       

32 responses


  1. This is great news! We've been fighting with the buggy jcifs NTLM implementation for years and really welcome a Kerberos solution for Windows SSO!! :)


  2. As mentioned in the API that it work fine with JAAS implementation of SUN. What should I be doing if I have to use it in websphere with IBM jre.


  3. @Risom Currently you can't use it with a IBM JVM. The code which is dependent on the Sun JVM is already separated, but in M1 we don't have an implementation which works on a IBM JVM. I've created a JIRA issue for this, so that you (and others) can follow the progress: https://jira.springsource.org/browse/SES-15


  4. Hello Mike Wiesner this blog was awesome! cheers …


  5. I'm having trouble with running the sample. I use kerberos from MIT on Linux and a Tomcat 6.0 on Windows. When I try to deploy the webapp on the server I get the following error:

    Key for the principal HTTP/web.springsource.com@GENIJUSZ.ORG not available in file:/D:/Java/Tomcat 6.0/webapps/kerberos/WEB-INF/classes/http-web.keytab

    On the other hand

    $ /cygdrive/c/Java/jdk1.6.0_11/bin/klist.exe -f -k http-web.keytab

    Key tab: http-web.keytab, 2 entries found.

    [1] Service principal: HTTP/web.springsource.com@GENIJUSZ.ORG
    KVNO: 3
    [2] Service principal: HTTP/web.springsource.com@GENIJUSZ.ORG
    KVNO: 3

    I understand that this probably not the extension issue, but a JAAS issue. But anyway your help would be nice. Is there a way to verify if the key is actually available in the keytab? Does the domain name (web.springsource.com) matter? (should I use a different one)


  6. Hi,

    I'm running into some issues when i tried to run the sample SSO app from spring security v3. Getting the following exception during the server startup,

    Key for the principal HTTP/uname.company.com@COMPANY.COM not available in file:/C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/spring-security-kerberos-sample-1.0.0.M1/WEB-INF/classes/http-web.keytab
    [Krb5LoginModule] authentication failed
    Unable to obtain password from user

    I have the web.keytab placed under the above mentioned path and the keytab file was generated in a windows server.

    I'm using Tomcat 6 and JDK 1.6.0_06.

    -TP


  7. I was running into the same trouble. I've had MIT KDC and what helped was adding these encryption algorithms (rc4-hmac:normal,des-cbc-crc:normal) when generating principals in KDC

    addprinc -x containerdn=o=Novell -e rc4-hmac:normal,des-cbc-crc:normal -pw password host/testworkstation.kerberos.yourcompany.com

    When I tried it with the default one, or only with des-cbc-crc:normal it was not working. Since it is Java that tries to read the keytab, I presume that it may also help in your case.

    One more thing. Just as is said on this page – there is far greater probability that you have your kerberos setup wrong rather than there's something wrong in the spring library. The following articles helped me with clearing my kerberos setup:

    http://www.novell.com/documentation/zenworks7/dm7admin/?page=/documentation/zenworks7/dm7admin/data/b5czc1w.html
    http://www.cgl.ucsf.edu/Security/CGLAUTH/CGLAUTH.html
    http://sial.org/howto/kerberos/windows/


  8. @TP: The JAAS Kerberos module, which is used inside, seems to have problems with loading the keytab from a path which includes whitespaces. I've created a JIRA issue for that: https://jira.springsource.org/browse/SES-19.


  9. @Dominikz: Microsoft also provides some help for setting up Kerberos/SPNEGO in an Active Directory environment. It can be found here: http://msdn.microsoft.com/en-us/library/ms995329.aspx


  10. @Mike : Thanks for information. The "authentication failed" issue was resolved once I updated the keytab file's location path not to include any spaces in the referred directory names.


  11. Mike,

    You may want to consider leveraging Microsoft Windows SSPI for native Kerberos/SPNEGO. This forgoes the need for using KTPASS, works seamlessly in complex cross-forest authentication scenarios, and is critical for full single sign-on integration when your organization uses a more "Microsoft centric" Kerberos solution… such as Centrify.

    About a month ago, I successfully integrated an SSPI Kerberos implementation into JSch (a Java SSH client), and Net::SSH::Kerberos (a ruby gem that extends Net::SSH with kerberos functionality).

    I'm more than willing to lend a hand if you'd find such an enhancement potentially useful.


  12. Hi Mike,

    Thanks alot for your efforts!!! this stuff is of great help.

    I tried deploying the sample on tomcat 6 and made required changes for the service principal and keytab
    I don't understand this error, could you please give any solution or share you thoughts on this.
    this is from Tomcat logs.

    Access is denied (user is anonymous); redirecting to authentication entry point
    org.springframework.security.access.AccessDeniedException: Access is denied

    Thanks in Advance!!

    Vandana


  13. Hi Mike,

    I wonder if I can specify the path to the keytab file to be something like "/etc/krb5.keytab".
    I'm running two websites on my PC, and have chosen Kerberos for cross-site authentication.
    I think, I can handle registration by calling shell script "kadmin … add username …".
    What do you think could be the best practice to combine your Spring Kerberos authentication module and the registration procedure?
    If, say, the registration code creates a new principal using kadmin and updates the "/etc/krb5.keytab", will the new user be able to immediately authenticate through your Spring Kerberos authentication module?
    I.e. will it reload the new keytab content?
    Can I point it to an arbitrary location on the disk? (because it's gonna be used by several web-apps)


  14. I get this error:

    Access is denied (user is anonymous); redirecting to authentication entry point

    org.springframework.security.access.AccessDeniedException: Access is denied
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:71)


  15. Hi Mike,

    I get the following error

    Authentication attempt using org.springframework.security.extensions.kerberos.Ke
    rberosServiceAuthenticationProvider
    Try to validate Kerberos Token
    Checksum failed !
    Negotiate Header was invalid:

    I assume that there is something wrong with my Kerberos set up, but not clear on where to look.

    any pointers would be appreciated!


  16. I am using the sample provided above and I am getting the following exception:

    Caused by: GSSException: Failure unspecified at GSS-API level (Mechanism level: Invalid argument (400) – Cannot find key of appropriate type to decryp
    t AP REP – RC4 with HMAC)
    at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:741)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:323)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:267)
    at sun.security.jgss.spnego.SpNegoContext.GSS_acceptSecContext(SpNegoContext.java:874)
    at sun.security.jgss.spnego.SpNegoContext.acceptSecContext(SpNegoContext.java:541)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:323)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:267)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.j
    ava:135)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.j
    ava:125)
    … 22 more
    Caused by: KrbException: Invalid argument (400) – Cannot find key of appropriate type to decrypt AP REP – RC4 with HMAC
    at sun.security.krb5.KrbApReq.authenticate(KrbApReq.java:262)
    at sun.security.krb5.KrbApReq.(KrbApReq.java:134)
    at sun.security.jgss.krb5.InitSecContextToken.(InitSecContextToken.java:79)
    at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:724)
    … 30 more

    I am using the following:
    - Jdk 1.6,
    - Oracle Weblogic server 10.3,
    - Active Directory 2003; AD only uses DES-CBC-CRC or DES-CBC-MD5 (by default) encryption and I can't change to RC4 that my Server requires.

    Can anyone help how can I force to use DES encryption?

    How can I change the encryption to DES in my application.


  17. Hi,
    I have tested on a Mac 10.6, running Kerberos on a virtual Ubuntu. Works like a dream.

    My vote for Spring Security Kerberos/SPNEGO Extension.


  18. Yes the problem is finally resoloved. That was a 3 steps process:

    1. I recreated the user
    2. The setspn was called before ktpass commmand. It looks like setspn is not required as ktpass command does the job for you
    3. I was using a service principal appending my domain name like HTTP/pc43433.mydomain but it suppose to be HTTP/pc43433


  19. To use SX Spring Security Extension version 1.0.0.M1, my experience is:
    - In the security.xml: "…/spring-security-3.0.xsd" says "BASIC_PROCESSING_FILTER" is not valid, but "…/spring-security-2.5.xsd" says it is.
    - Spring security version 3.0.1 gives me "java.lang.NoSuchMethodError in constructor of KerberosServiceRequestToken" as Harald Radi (https://jira.springsource.org/browse/SES-29) experienced.
    – To define authorities: Collection authorities = AuthorityUtils.createAuthorityList("ROLE_USER");
    - Spring security version 3.0.0.M2 is OK combination.
    – To define authorities: List authorities = AuthorityUtils.createAuthorityList("ROLE_USER");


  20. I'm getting the following error with Spring Security 3.0.1:

    "org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 19 in XML document from ServletContext resource [/WEB-INF/spring/security-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'BASIC_PROCESSING_FILTER' is not facet-valid with respect to enumeration '[FIRST, CHANNEL_FILTER, CONCURRENT_SESSION_FILTER, SECURITY_CONTEXT_FILTER, LOGOUT_FILTER, X509_FILTER, PRE_AUTH_FILTER, CAS_FILTER, FORM_LOGIN_FILTER, OPENID_FILTER, BASIC_AUTH_FILTER, SERVLET_API_SUPPORT_FILTER, REMEMBER_ME_FILTER, ANONYMOUS_FILTER, EXCEPTION_TRANSLATION_FILTER, SESSION_MANAGEMENT_FILTER, FILTER_SECURITY_INTERCEPTOR, SWITCH_USER_FILTER, LAST]'. It must be a value from the enumeration."

    Any suggestions?


  21. ukdavo, my suggestion is, as said 5. feb.: Spring Security Extension version 1.0.0.M1 is OK with Spring security version 3.0.0.M2.


  22. Thanks for your help. Using Spring Security 3.0.0 M2 seems to have helped in that I'm further than I was before. Unfortunately, I now get an IllegalArgumentException – it can't find the file C:\Windows\krb5.ini. This file doesn't exist – do I have to create one? I'm running everything on a Windows Server 2003 VM that's been set up as a PDC.


  23. @Arve – I created the krb5.ini so I've got a little further. It looks like IE is sending a NTLM token instead of a Kerberos token. I added the site into the Intranet zone so I'm not sure what's going on. Thanks for your help anyway. I'll keep Googling for an answer.


  24. Mike – How does this plugin work with a load-balanced environment? I've never used Kerberos before and I'd like to set this up on an app I'm running. The issue is, the app may be running on multiple servers. Can I have my sys admins add multiple service principals to the same Windows user, one for each fully qualified server name? What if all the servers are behind a single proxy load balancer? Thanks for your help!


  25. @ukdavo
    "I'm running everything on a Windows Server 2003 VM that's been set up as a PDC."
    You MUST have the browser client on a separate machine, otherwise it will always use NTLM.


  26. Thanks Peter. I just spotted your advice on the Spring Extensions forum. Time to set up a new VM I guess!


  27. I got this error:

    Received Negotiate Header for request :
    Negotiate TlRMTV
    NTUAABAAAAB7IIogcABwA1AAAADQANACgAAAAFASgKAAAAD1cwMDI0RThEQjY3NEFPQ0VBTklB
    Authentication attempt using org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider
    Try to validate Kerberos Token
    Negotiate Header was invalid: Negotiate TlRMTVNTUAABAAAAB7IIogcABwA1AAAADQANACgAAAAFASgKAAAAD1cwMDI0RThEQjY3NEFPQ0VBTklB
    org.springframework.security.authentication.BadCredentialsException: Kerberos validation not succesfull
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator.validateTicket(SunJaasKerberosTicketValidator.java:65)
    at org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider.authenticate(KerberosServiceAuthenticationProvider.java:86)
    at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:127)
    at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:49)
    at org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter.doFilter(SpnegoAuthenticationProcessingFilter.java:118)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:150)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.security.PrivilegedActionException: GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator.validateTicket(SunJaasKerberosTicketValidator.java:63)
    … 22 more
    Caused by: GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
    at sun.security.jgss.GSSHeader.(GSSHeader.java:80)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:287)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:267)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:135)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:125)
    … 25 more
    SecurityContextHolder now cleared, as request processing completed

    Any help? Thanks.


  28. Received Negotiate Header for request http://w0024e8db674a.oceania.corp.anz.com:8080/spring-security-kerberos-sample-1.0.0.M1/secure/index.jsp: Negotiate TlRMTV
    NTUAABAAAAB7IIogcABwA1AAAADQANACgAAAAFASgKAAAAD1cwMDI0RThEQjY3NEFPQ0VBTklB
    Authentication attempt using org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider
    Try to validate Kerberos Token
    Negotiate Header was invalid: Negotiate TlRMTVNTUAABAAAAB7IIogcABwA1AAAADQANACgAAAAFASgKAAAAD1cwMDI0RThEQjY3NEFPQ0VBTklB
    org.springframework.security.authentication.BadCredentialsException: Kerberos validation not succesfull
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator.validateTicket(SunJaasKerberosTicketValidator.java:65)
    at org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider.authenticate(KerberosServiceAuthenticationProvider.java:86)
    at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:127)
    at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:49)
    at org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter.doFilter(SpnegoAuthenticationProcessingFilter.java:118)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:150)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.security.PrivilegedActionException: GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator.validateTicket(SunJaasKerberosTicketValidator.java:63)
    … 22 more
    Caused by: GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
    at sun.security.jgss.GSSHeader.(GSSHeader.java:80)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:287)
    at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:267)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:135)
    at org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:125)
    … 25 more
    SecurityContextHolder now cleared, as request processing completed


  29. Just wanted to say thanks for a great addition to Spring. I got it to work once I followed Peter Mularien's advice.

    Peter/Grant – it looks like you've got the same problem that I had. It looks like you're presenting NTLM tokens (see http://appliedcrypto.com/spnego/qa.html) instead of Kerberos tokens. Apparently, IE will use NTLM if the client and server are the same machine.


  30. Always got GSSException "Checksum failed" when validating Ticket sent back from Windows Server 2008 against Keytab file produced by ktpass. The only thing that worked for me was recreating keytab file with ktab.exe provided by JDK on windows installation


  31. @norm – I had the same problem with Windows Server 2003, and the only solution that worked for me was ktab, as you described.

    Anybody know why this error occurs with the keytab produced by ktpass?


  32. @Clarence @norm

    I had similar problems but found that they disappeared when I changed the command parameters as per http://wiki.alfresco.com/wiki/Configuring_the_CIFS_and_web_servers_for_Kerberos/AD_integration. I also followed their suggestions re the "Use DES encryption types for this account" and "Do not require Kerberos preauthentication" options. I've no idea if this will help you but it seemed to work for me.

4 trackbacks

Leave a Reply