@Override
    protected Event doExecuteInternal(final RequestContext context) {
        val service = WebUtils.getService(context);
        val registeredService = WebUtils.getRegisteredService(context);
        val authenticationResultBuilder = WebUtils.getAuthenticationResultBuilder(context);

        LOGGER.trace("Finalizing authentication transactions and issuing ticket-granting ticket");
        val authenticationResult = FunctionUtils.doUnchecked(() -> configurationContext.getAuthenticationSystemSupport()
            .finalizeAllAuthenticationTransactions(authenticationResultBuilder, service));
        LOGGER.trace("Finalizing authentication event...");
        val authentication = buildFinalAuthentication(authenticationResult);
        val ticketGrantingTicketId = determineTicketGrantingTicketId(context);
        LOGGER.debug("Creating ticket-granting ticket, potentially based on [{}]", ticketGrantingTicketId);
        val ticketGrantingTicket = configurationContext.getSingleSignOnBuildingStrategy()
            .buildTicketGrantingTicket(authenticationResult, authentication, ticketGrantingTicketId);

        if (registeredService != null && registeredService.getAccessStrategy() != null) {
            WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(context, registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
        }
        WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
        WebUtils.putAuthenticationResult(authenticationResult, context);
        WebUtils.putAuthentication(ticketGrantingTicket, context);

        LOGGER.trace("Calculating authentication warning messages...");
        val warnings = calculateAuthenticationWarningMessages(context);
        if (!warnings.isEmpty()) {
            val attributes = new LocalAttributeMap<Object>(CasWebflowConstants.ATTRIBUTE_ID_AUTHENTICATION_WARNINGS, warnings);
            return eventFactory.event(this, CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS, attributes);
        }
        return success();
    }
Action that handles the {@link TicketGrantingTicket} creation and destruction. If the
action is given a {@link TicketGrantingTicket} and one also already exists, the old
one is destroyed and replaced with the new one conditionally.

@author Scott Battaglia
@since 3.0.0
support/cas-server-support-actions-core/src/main/java/org/apereo/cas/web/flow/login/CreateTicketGrantingTicketAction.java