Source:
private byte[] getToken(AuthorizationPolicy authPolicy, String spn, Oid oid, Message message) throws GSSException, LoginException { GSSCredential delegatedCred = (GSSCredential)message.getContextualProperty(GSSCredential.class.getName()); Subject subject = null; if (authPolicy != null && delegatedCred == null) { String contextName = authPolicy.getAuthorization(); if (contextName == null) { contextName = ""; } if (!(StringUtils.isEmpty(authPolicy.getUserName()) && StringUtils.isEmpty(contextName) && loginConfig == null)) { CallbackHandler callbackHandler = getUsernamePasswordHandler( authPolicy.getUserName(), authPolicy.getPassword()); LoginContext lc = new LoginContext(contextName, null, callbackHandler, loginConfig); lc.login(); subject = lc.getSubject(); } } else if (loginConfig != null) { LoginContext lc = new LoginContext("", new Subject(), null, loginConfig); lc.login(); subject = lc.getSubject(); } GSSManager manager = GSSManager.getInstance(); GSSName serverName = manager.createName(spn, serviceNameType); GSSContext context = manager .createContext(serverName.canonicalize(oid), oid, delegatedCred, GSSContext.DEFAULT_LIFETIME); context.requestCredDeleg(isCredDelegationRequired(message)); final byte[] token = new byte[0]; if (delegatedCred != null) { return context.initSecContext(token, 0, token.length); } decorateSubject(subject); try { return Subject.doAs(subject, new CreateServiceTicketAction(context, token)); } catch (PrivilegedActionException e) { if (e.getCause() instanceof GSSException) { throw (GSSException) e.getCause(); } LOG.log(Level.SEVERE, "initSecContext", e); return null; } }

Target:
private byte[] getToken(AuthorizationPolicy authPolicy, String spn, Oid oid, Message message) throws GSSException, LoginException { GSSCredential delegatedCred = (GSSCredential)message.getContextualProperty(GSSCredential.class.getName()); Subject subject = null; if (authPolicy != null && delegatedCred == null) { String contextName = authPolicy.getAuthorization(); if (contextName == null) { contextName = ""; } if (!(StringUtils.isEmpty(authPolicy.getUserName()) && StringUtils.isEmpty(contextName) && loginConfig == null)) { CallbackHandler callbackHandler = getUsernamePasswordHandler( authPolicy.getUserName(), authPolicy.getPassword()); LoginContext lc = new LoginContext(contextName, null, callbackHandler, loginConfig); lc.login(); subject = lc.getSubject(); } } else if (loginConfig != null && delegatedCred == null) { LoginContext lc = new LoginContext("", null, null, loginConfig); lc.login(); subject = lc.getSubject(); } GSSManager manager = GSSManager.getInstance(); GSSName serverName = manager.createName(spn, serviceNameType); GSSContext context = manager .createContext(serverName.canonicalize(oid), oid, delegatedCred, GSSContext.DEFAULT_LIFETIME); context.requestCredDeleg(isCredDelegationRequired(message)); final byte[] token = new byte[0]; if (delegatedCred != null) { return context.initSecContext(token, 0, token.length); } decorateSubject(subject); try { return Subject.doAs(subject, new CreateServiceTicketAction(context, token)); } catch (PrivilegedActionException e) { if (e.getCause() instanceof GSSException) { throw (GSSException) e.getCause(); } LOG.log(Level.SEVERE, "initSecContext", e); return null; } }