@Override
        public byte[] run() throws GSSException {
            var gssManager = GSSManager.getInstance();

            var gssService = gssManager.createName(serviceName, GSSName.NT_HOSTBASED_SERVICE);
            var oid = new Oid(JGSS_KERBEROS_TICKET_OID);
            var gssClient = gssManager.createName(clientPrincipal.getName(), GSSName.NT_USER_NAME);
            var credentials =
                gssManager.createCredential(
                    gssClient, GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY
                );

            var secContext =
                gssManager.createContext(
                    gssService, oid, credentials, GSSContext.DEFAULT_LIFETIME
                );

            secContext.requestMutualAuth(false);
            secContext.requestCredDeleg(false);

            var token = new byte[0];
            var returnedToken = secContext.initSecContext(token, 0, token.length);

            secContext.dispose();

            return returnedToken;
        }
This class represents a PrivilegedExceptionAction implementation to obtain a service ticket from a Kerberos
Key Distribution Center.
pac4j-kerberos/src/test/java/org/pac4j/kerberos/client/direct/SpnegoServiceTicketHelper.java