protected Event grantServiceTicket(final RequestContext context) throws Throwable {
        val ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
        val credentials = getCredentialFromContext(context);

        try {
            val service = WebUtils.getService(context);
            val configContext = getConfigurationContext();

            val existingAuthn = configContext.getTicketRegistrySupport().getAuthenticationFrom(ticketGrantingTicketId);
            val registeredService = configContext.getServicesManager().findServiceBy(service);

            if (existingAuthn != null && registeredService != null) {
                LOGGER.debug("Enforcing access strategy policies for registered service [{}] and principal [{}]",
                    registeredService, existingAuthn.getPrincipal());

                val audit = AuditableContext.builder().service(service)
                    .authentication(existingAuthn)
                    .registeredService(registeredService)
                    .build();
                val accessResult = configContext.getRegisteredServiceAccessStrategyEnforcer().execute(audit);
                accessResult.throwExceptionIfNeeded();
            }

            val principal = getActivePrincipal(credentials, service, existingAuthn);
            LOGGER.debug("Primary principal for this authentication session to receive a service ticket is [{}]", principal);

            if (existingAuthn != null && !existingAuthn.getPrincipal().equals(principal)) {
                LOGGER.trace("Existing authentication context linked to ticket-granting ticket [{}] is issued for principal [{}] "
                        + " which does not match [{}], established by the requested authentication transaction. CAS will NOT reuse the existing "
                        + "authentication context to issue service tickets",
                    ticketGrantingTicketId, existingAuthn.getPrincipal(), principal);
                return null;
            }

            return newEvent(CasWebflowConstants.TRANSITION_ID_GENERATE_SERVICE_TICKET);
        } catch (final AuthenticationException | AbstractTicketException e) {
            LOGGER.trace(e.getMessage(), e);
            return newEvent(CasWebflowConstants.TRANSITION_ID_AUTHENTICATION_FAILURE, e);
        }
    }
Grant service ticket for the given credential based on the service and tgt
that are found in the request context.

@param context the context
@return the resulting event. Warning, authentication failure or error.
@since 4.1.0
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/ServiceTicketRequestWebflowEventResolver.java