protected String callRestEndpointForMultifactor(final Principal principal,
                                                    final Service resolvedService) throws Exception {
        HttpResponse response = null;
        try {
            val rest = casProperties.getAuthn().getMfa().getTriggers().getRest();
            val entity = new RestEndpointEntity(principal.getId(), resolvedService.getId());

            val headers = CollectionUtils.<String, String>wrap(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
            headers.putAll(rest.getHeaders());

            val exec = HttpExecutionRequest.builder()
                .basicAuthPassword(rest.getBasicAuthPassword())
                .basicAuthUsername(rest.getBasicAuthUsername())
                .method(HttpMethod.valueOf(rest.getMethod().toUpperCase(Locale.ENGLISH).trim()))
                .url(rest.getUrl())
                .headers(headers)
                .entity(MAPPER.writeValueAsString(entity))
                .build();
            response = HttpUtils.execute(exec);
            val status = HttpStatus.valueOf(response.getCode());
            if (status.is2xxSuccessful()) {
                try (val content = ((HttpEntityContainer) response).getEntity().getContent()) {
                    return IOUtils.toString(content, StandardCharsets.UTF_8);
                }
            }
        } finally {
            HttpUtils.close(response);
        }
        return null;
    }
Call rest endpoint for multifactor.

@param principal       the principal
@param resolvedService the resolved service
@return return the rest response, typically the mfa id.
@throws Exception the exception
core/cas-server-core-authentication-mfa-api/src/main/java/org/apereo/cas/authentication/mfa/trigger/RestEndpointMultifactorAuthenticationTrigger.java