protected boolean isImpersonationAllowedFor(final Optional<? extends Service> givenService) {
        val surrogatePolicyResult = givenService
            .map(servicesManager::findServiceBy)
            .filter(WebBasedRegisteredService.class::isInstance)
            .map(WebBasedRegisteredService.class::cast)
            .filter(service -> Objects.nonNull(service.getSurrogatePolicy()))
            .map(WebBasedRegisteredService::getSurrogatePolicy)
            .stream()
            .findFirst();
        return surrogatePolicyResult
            .map(RegisteredServiceSurrogatePolicy::isEnabled)
            .orElse(Boolean.TRUE);
    }
This is {@link ChainingSurrogateAuthenticationService}.

@author Misagh Moayyed
@since 7.1.0
support/cas-server-support-surrogate-core/src/main/java/org/apereo/cas/authentication/surrogate/ChainingSurrogateAuthenticationService.java