@Override
    protected Event doExecuteInternal(final RequestContext requestContext) {
        try {
            if (WebUtils.hasSurrogateAuthenticationRequest(requestContext)) {
                WebUtils.removeSurrogateAuthenticationRequest(requestContext);
                return loadSurrogateAccounts(requestContext);
            }

            val currentCredential = WebUtils.getCredential(requestContext, Credential.class);
            if (currentCredential instanceof final MutableCredential mc
                && mc.getCredentialMetadata().getTrait(SurrogateCredentialTrait.class)
                .stream()
                .anyMatch(trait -> StringUtils.isNotBlank(trait.getSurrogateUsername()))) {
                val authenticationResultBuilder = WebUtils.getAuthenticationResultBuilder(requestContext);
                val registeredService = WebUtils.getRegisteredService(requestContext);
                val result = surrogatePrincipalBuilder.buildSurrogateAuthenticationResult(
                    authenticationResultBuilder, currentCredential, registeredService);
                result.ifPresent(builder -> WebUtils.putAuthenticationResultBuilder(builder, requestContext));
            }
            return success();
        } catch (final Throwable e) {
            WebUtils.addErrorMessageToContext(requestContext,
                "screen.surrogates.account.selection.error",
                "Unable to accept or authorize selection");
            LoggingUtils.error(LOGGER, e);
            return error(new RuntimeException(e));
        }
    }
This is {@link LoadSurrogatesListAction}.

@author Misagh Moayyed
@since 5.1.0
support/cas-server-support-surrogate-webflow/src/main/java/org/apereo/cas/web/flow/action/LoadSurrogatesListAction.java