title: Failed Kerberos authentication when Debug logging enabled
body: <p>I am currently running a RHEL 6 server with IPA and a user test_user defined, attempting to authenticate using the 'Krb5LoginModule' Login Module I am getting the exception at the bottom of this question.</p>
  
  <p>HOWEVER - if I add the system property <code>-Dsun.security.krb5.debug=true</code> the authentication completes without error - that system property is the only change between the failure scenario and successful scenario.</p>
  
  <p>The same username and password also work flawlessly in kinit from the same machine running the Java client.</p>
  
  <p>This is using Oracle jdk1.6.0_32.</p>
  
  <p>So the question is what else is different when debug logging is enabled that would change the behaviour of the login process?  At the moment enabling debug logging to understand the failure didn't work as that in itself caused it to work.</p>
  
  <pre><code>Exception in thread "main" javax.security.auth.login.LoginException: Integrity check on decrypted field failed (31) - PREAUTH_FAILED
      at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:696)
      at com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:542)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
      at javax.security.auth.login.LoginContext$5.run(LoginContext.java:706)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokeCreatorPriv(LoginContext.java:703)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:575)
      at com.darranl.as.sasl.gssapi.KerberosLoginUtil.login(KerberosLoginUtil.java:50)
      at com.darranl.as.sasl.gssapi.KerberosLoginUtil.main(KerberosLoginUtil.java:131)
  Caused by: KrbException: Integrity check on decrypted field failed (31) - PREAUTH_FAILED
      at sun.security.krb5.KrbAsRep.&lt;init&gt;(KrbAsRep.java:72)
      at sun.security.krb5.KrbAsReq.getReply(KrbAsReq.java:446)
      at sun.security.krb5.Credentials.sendASRequest(Credentials.java:401)
      at sun.security.krb5.Credentials.acquireTGT(Credentials.java:373)
      at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:662)
      ... 13 more
  Caused by: KrbException: Identifier doesn't match expected value (906)
      at sun.security.krb5.internal.KDCRep.init(KDCRep.java:133)
      at sun.security.krb5.internal.ASRep.init(ASRep.java:58)
      at sun.security.krb5.internal.ASRep.&lt;init&gt;(ASRep.java:53)
      at sun.security.krb5.KrbAsRep.&lt;init&gt;(KrbAsRep.java:50)
      ... 17 more
  </code></pre>