My code currently works fine executing SPNEGO (Kerberos) authentication for users of my website. I have a special caching mechanism in place to accelerate some decisions based on confirmation of the user's identity. For plain password authentication this is simple enough - compare the "current" user+password combo with the "old" one - if there's no change, the decisions can still be cached. Otherwise, they need to be re-evaluated.
I'm trying to do the same for Kerberos. I've got it mostly working, but I'm baffled why GSSCredential.equals()
wouldn't be working. In particular, the GSSCredential instances I obtain after authenticating each request are "identical" in that they're for the same user, same service, even obtained under the same circumstances (I think). If I do a toString()
and I compare the outputs they're the same (yes, I know this is irrelevant, but it's still a good indication that they probably should be equal).
However, GSSCredential_1.equals(GSSCredential_2)
always returns false between requests. This could be because each is obtained using a different SPNEGO ticket (which is necessary, as per Kerberos, to avoid replay scenarios), but those tickets still belonged to the same principal and were "aimed" at the same service principal.
The code decision I need to make is best articulated as such:
do these new credentials represent the same security principal as the previously-used ones? The questions of expiry, validity-for-purpose and whatnot get evaluated separately, and later.
Comparing their names "works", but I was hoping for something a little more robust.
Any ideas?