public Principal run() {
try {
GSSManager gssManager = GSSManager.getInstance();
Oid kerberos5Oid = new Oid("1.2.840.113554.1.2.2");
GSSName gssService = gssManager.createName(serviceName, GSSName.NT_HOSTBASED_SERVICE);
GSSCredential credentials =
gssManager.createCredential(
gssService, GSSCredential.DEFAULT_LIFETIME, kerberos5Oid, GSSCredential.ACCEPT_ONLY
);
GSSContext secContext =
gssManager.createContext(credentials);
secContext.acceptSecContext(ticket, 0, ticket.length);
GSSName clientName = secContext.getSrcName();
secContext.dispose();
return new KerberosPrincipal(clientName.toString());
} catch (GSSException e) {
if (log.isDebugEnabled()) {
log.debug("Error in validating a Kerberos token", e);
}
}