@Override
    public Set<Event> resolveInternal(final RequestContext context) throws Throwable {
        val credentials = getCredentialFromContext(context);

        val service = locateServiceForRequest(context);
        LOGGER.trace("Resolved service [{}]", service);

        try {
            if (credentials != null && !credentials.isEmpty()) {
                val agent = WebUtils.getHttpServletRequestUserAgentFromRequestContext(context);
                val geoLocation = WebUtils.getHttpServletRequestGeoLocationFromRequestContext(context);
                val properties = CollectionUtils.<String, Serializable>wrap(
                    CredentialMetadata.PROPERTY_USER_AGENT, agent,
                    CredentialMetadata.PROPERTY_GEO_LOCATION, geoLocation);
                credentials.forEach(cred -> {
                    cred.getCredentialMetadata().putProperties(properties);
                    getConfigurationContext().getTenantExtractor().extract(context).ifPresent(tenant ->
                        cred.getCredentialMetadata().setTenant(tenant.getId()));
                });
                val builder = getConfigurationContext().getAuthenticationSystemSupport()
                    .handleInitialAuthenticationTransaction(service, credentials.toArray(Credential.EMPTY_CREDENTIALS_ARRAY));
                builder.collect(credentials.toArray(Credential.EMPTY_CREDENTIALS_ARRAY));

                builder.getInitialAuthentication().ifPresent(authn -> {
                    WebUtils.putAuthenticationResultBuilder(builder, context);
                    WebUtils.putAuthentication(authn, context);
                });
            }

            val registeredService = determineRegisteredServiceForEvent(context, service);
            LOGGER.trace("Attempting to resolve candidate authentication events for service [{}]", service);
            val resolvedEvents = resolveCandidateAuthenticationEvents(context, service, registeredService);
            if (resolvedEvents.isEmpty()) {
                LOGGER.trace("No candidate authentication events were resolved for service [{}]", service);
            } else {
                LOGGER.trace("Authentication events resolved for [{}] are [{}]. Selecting final event...", service, resolvedEvents);
                WebUtils.putResolvedEventsAsAttribute(context, resolvedEvents);
                val finalResolvedEvent = this.selectiveResolver.resolveSingle(context);
                LOGGER.debug("The final authentication event resolved for [{}] is [{}]", service, finalResolvedEvent);
                if (finalResolvedEvent != null) {
                    return CollectionUtils.wrapSet(finalResolvedEvent);
                }
            }

            val builder = WebUtils.getAuthenticationResultBuilder(context);
            if (builder == null) {
                val msg = "Unable to locate authentication object in the webflow context";
                throw new IllegalArgumentException(new AuthenticationException(msg));
            }
            return CollectionUtils.wrapSet(grantTicketGrantingTicketToAuthenticationResult(context, builder, service));
        } catch (final Throwable exception) {
            val event = buildEventFromException(exception, context, credentials, service);
            val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);
            response.setStatus(HttpStatus.UNAUTHORIZED.value());
            LOGGER.debug("Authentication request failed with [{}], resulting in event [{}]", response.getStatus(), event);
            return CollectionUtils.wrapSet(event);
        }
    }
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