@Override
    public AuthenticationResultBuilder process(final AuthenticationResultBuilder resultBuilder,
                                               final PasswordlessUserAccount passwordlessUserAccount,
                                               final Service service,
                                               final Credential credential,
                                               final PasswordlessAuthenticationToken token) throws Throwable {
        LOGGER.debug("Evaluating passwordless authentication token [{}] issued for [{}]", token, passwordlessUserAccount);
        if (token.getProperties().containsKey(SurrogatePasswordlessAuthenticationRequestParser.PROPERTY_SURROGATE_USERNAME)
            && credential instanceof final MutableCredential mutableCredential) {
            val surrogateUsername = token.getProperties().get(SurrogatePasswordlessAuthenticationRequestParser.PROPERTY_SURROGATE_USERNAME);
            val principal = resultBuilder.getInitialAuthentication().map(Authentication::getPrincipal).orElseThrow();
            LOGGER.debug("Evaluating principal [{}] authorization to impersonate [{}]", principal, surrogateUsername);
            if (surrogateAuthenticationService.canImpersonate(surrogateUsername, principal, Optional.ofNullable(service))) {
                mutableCredential.getCredentialMetadata().addTrait(new SurrogateCredentialTrait(surrogateUsername));
                val registeredService = servicesManager.findServiceBy(service);
                LOGGER.debug("Principal [{}] is authorized to impersonate [{}]", principal, surrogateUsername);
                return surrogatePrincipalBuilder
                    .buildSurrogateAuthenticationResult(resultBuilder, mutableCredential, registeredService)
                    .orElse(resultBuilder);
            }
        }
        return resultBuilder;
    }
This is {@link SurrogatePasswordlessAuthenticationPreProcessor}.

@author Misagh Moayyed
@since 7.0.0
support/cas-server-support-surrogate-webflow/src/main/java/org/apereo/cas/web/flow/passwordless/SurrogatePasswordlessAuthenticationPreProcessor.java