protected Event grantServiceTicket ( final RequestContext context ) { val ticketGrantingTicketId = WebUtils . getTicketGrantingTicketId ( context ) ; val credential = getCredentialFromContext ( context ) ; try { val service = WebUtils . getService ( context ) ; val authn = getWebflowEventResolutionConfigurationContext ( ) . getTicketRegistrySupport ( ) . getAuthenticationFrom ( ticketGrantingTicketId ) ; val registeredService = getWebflowEventResolutionConfigurationContext ( ) . getServicesManager ( ) . findServiceBy ( service ) ; if ( authn != null && registeredService != null ) { LOGGER . debug ( "Enforcing access strategy policies for registered service [{}] and principal [{}]" , registeredService , authn . getPrincipal ( ) ) ; val audit = AuditableContext . builder ( ) . service ( service ) . authentication ( authn ) . registeredService ( registeredService ) . retrievePrincipalAttributesFromReleasePolicy ( Boolean . TRUE ) . build ( ) ; val accessResult = getWebflowEventResolutionConfigurationContext ( ) . getRegisteredServiceAccessStrategyEnforcer ( ) . execute ( audit ) ; accessResult . throwExceptionIfNeeded ( ) ; } val authenticationResult = getWebflowEventResolutionConfigurationContext ( ) . getAuthenticationSystemSupport ( ) . handleAndFinalizeSingleAuthenticationTransaction ( service , credential ) ; val serviceTicketId = getWebflowEventResolutionConfigurationContext ( ) . getCentralAuthenticationService ( ) . grantServiceTicket ( ticketGrantingTicketId , service , authenticationResult ) ; WebUtils . putServiceTicketInRequestScope ( context , serviceTicketId ) ; WebUtils . putWarnCookieIfRequestParameterPresent ( getWebflowEventResolutionConfigurationContext ( ) . getWarnCookieGenerator ( ) , context ) ; return newEvent ( CasWebflowConstants . TRANSITION_ID_WARN ) ; } catch ( final AuthenticationException | AbstractTicketException 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 .