private RegisteredService determineRegisteredServiceForEvent(final RequestContext context, final Service service) throws Throwable {
        if (service == null) {
            return null;
        }
        LOGGER.trace("Locating authentication event in the request context...");
        val authn = WebUtils.getAuthentication(context);
        if (authn == null) {
            val msg = "Unable to locate authentication object in the webflow context";
            throw new IllegalArgumentException(new AuthenticationException(msg));
        }
        LOGGER.trace("Locating service [{}] in service registry to determine authentication policy", service);
        val registeredService = getConfigurationContext().getServicesManager().findServiceBy(service);
        LOGGER.trace("Enforcing access strategy policies for registered service [{}] and principal [{}]",
            registeredService, authn.getPrincipal());
        val unauthorizedRedirectUrl = registeredService.getAccessStrategy().getUnauthorizedRedirectUrl();
        if (unauthorizedRedirectUrl != null) {
            WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(context, unauthorizedRedirectUrl);
        }

        val attributeReleaseContext = RegisteredServiceAttributeReleasePolicyContext.builder()
            .registeredService(registeredService)
            .service(service)
            .principal(authn.getPrincipal())
            .applicationContext(getConfigurationContext().getApplicationContext())
            .build();
        val releasingAttributes = registeredService.getAttributeReleasePolicy().getAttributes(attributeReleaseContext);
        releasingAttributes.putAll(authn.getAttributes());

        val accessStrategyAttributes = CoreAuthenticationUtils.mergeAttributes(
            authn.getPrincipal().getAttributes(), releasingAttributes);
        val accessStrategyPrincipal = getConfigurationContext().getPrincipalFactory()
            .createPrincipal(authn.getPrincipal().getId(), accessStrategyAttributes);

        val audit = AuditableContext.builder()
            .service(service)
            .principal(accessStrategyPrincipal)
            .registeredService(registeredService)
            .build();
        val result = getConfigurationContext().getRegisteredServiceAccessStrategyEnforcer().execute(audit);
        result.throwExceptionIfNeeded();
        return registeredService;
    }
This is {@link DefaultCasDelegatingWebflowEventResolver},
which handles the initial authentication attempt and calls upon a number of
embedded resolvers to produce the next event in the authentication flow.

@author Misagh Moayyed
@since 5.0.0
core/cas-server-core-webflow-api/src/main/java/org/apereo/cas/web/flow/resolver/impl/DefaultCasDelegatingWebflowEventResolver.java