Spring security kerberos validate token error

1k views Asked by At

I'm using Spring Security Kerberos 1.0.0.RELEASE with JDK 7, Spring Security 3.2.7.RELEASE and Spring Framework 4.1.6.RELEASE to process authentication in my app. But i always getting this error:

Caused by: java.security.PrivilegedActionException: null
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_75]
at javax.security.auth.Subject.doAs(Subject.java:415) ~[na:1.7.0_75]
at org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator.validateTicket(SunJaasKerberosTicketValidator.java:67) ~[spring-security-kerberos-core-1.0.0.RELEASE.jar:1.0.0.RELEASE]
... 57 common frames omitted
Caused by: org.ietf.jgss.GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
at sun.security.jgss.GSSHeader.<init>(GSSHeader.java:97) ~[na:1.7.0_75]
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:306) ~[na:1.7.0_75]
at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285) ~[na:1.7.0_75]
at org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:162) ~[spring-security-kerberos-core-1.0.0.RELEASE.jar:1.0.0.RELEASE]
at org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator$KerberosValidateAction.run(SunJaasKerberosTicketValidator.java:152) ~[spring-security-kerberos-core-1.0.0.RELEASE.jar:1.0.0.RELEASE]

My Spring config is

<bean id="kerberosAuthenticationService" class="com.test.app.authentication.service.impl.KerberosAuthenticationServiceImpl">
    <property name="customKerberosTicketValidator">
        <bean class="org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator">
            <property name="servicePrincipal" value="${authentication.kerberos.principal}" />
            <property name="keyTabLocation" value="${authentication.kerberos.keytab}" />
            <property name="debug" value="true" />
        </bean>
    </property>
</bean>

<!-- OVERRIDING DEFAULT KRB configuration -->
<bean class="org.springframework.security.kerberos.authentication.sun.GlobalSunJaasKerberosConfig">
    <property name="debug" value="true" />
    <property name="krbConfLocation" value="classpath:kerberos/krb5.conf" />
</bean>

And the authenticated method look like here


 try {
        base64Token = header.substring(10);
        kerberosTicket = Base64.decode(base64Token.trim().getBytes());
        KerberosServiceRequestToken authenticationRequest = new KerberosServiceRequestToken(kerberosTicket);
        byte[] token = authenticationRequest.getToken();

        KerberosTicketValidation kerberosTicketValidation = this.customKerberosTicketValidator.validateTicket(token);
        userName = kerberosTicketValidation.username();

        LOGGER.debug("USername {} ", userName);

    } -------

How can i fix this error? Thx fr yoour reply Regards

0

There are 0 answers