@Override
    public boolean canImpersonateInternal(final String surrogate, final Principal principal,
                                          final Optional<? extends Service> service) {
        val properties = casProperties.getAuthn().getSurrogate().getRest();
        HttpResponse response = null;
        try {
            val exec = HttpExecutionRequest.builder()
                .basicAuthPassword(properties.getBasicAuthPassword())
                .basicAuthUsername(properties.getBasicAuthUsername())
                .method(HttpMethod.valueOf(properties.getMethod().toUpperCase(Locale.ENGLISH).trim()))
                .url(properties.getUrl())
                .headers(properties.getHeaders())
                .parameters(CollectionUtils.wrap("surrogate", surrogate, "principal", principal.getId()))
                .build();
            response = HttpUtils.execute(exec);
            val statusCode = response.getCode();
            return HttpStatus.valueOf(statusCode).is2xxSuccessful();
        } finally {
            HttpUtils.close(response);
        }
    }
This is {@link SurrogateRestAuthenticationService}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-surrogate-authentication-rest/src/main/java/org/apereo/cas/authentication/surrogate/SurrogateRestAuthenticationService.java