private static void addSurrogateInformation(final RequestContext context, final SurrogateAuthenticationRequest surrogateRequest) {
        val credential = surrogateRequest.getCredential();
        credential.setId(surrogateRequest.getUsername());

        if (surrogateRequest.hasSurrogateUsername()) {
            credential.getCredentialMetadata().addTrait(new SurrogateCredentialTrait(surrogateRequest.getSurrogateUsername()));
            WebUtils.putSurrogateAuthenticationRequest(context, Boolean.FALSE);
            LOGGER.debug("Converted credential to surrogate for username [{}] and assigned it to webflow", surrogateRequest.getUsername());
        } else {
            WebUtils.putSurrogateAuthenticationRequest(context, Boolean.TRUE);
            LOGGER.debug("No surrogate username is defined; Signal webflow to request for surrogate credentials");
        }
        WebUtils.putCredential(context, credential);
    }
This is {@link SurrogateInitialAuthenticationAction}.

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