@Override
    public Optional<AcceptableUsagePolicyTerms> fetchPolicy(final RequestContext requestContext) {
        HttpResponse response = null;
        try {
            val rest = aupProperties.getRest();
            val url = StringUtils.appendIfMissing(rest.getUrl(), "/").concat("policy");
            val principal = WebUtils.getAuthentication(requestContext).getPrincipal();
            val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(requestContext);

            val exec = HttpExecutionRequest.builder()
                .basicAuthPassword(rest.getBasicAuthPassword())
                .basicAuthUsername(rest.getBasicAuthUsername())
                .method(HttpMethod.GET)
                .url(url)
                .headers(rest.getHeaders())
                .httpClient(this.httpClient)
                .parameters(CollectionUtils.wrap("username", principal.getId(),
                    "locale", request.getLocale().toString()))
                .build();
            response = HttpUtils.execute(exec);
            val statusCode = Optional.ofNullable(response).map(HttpResponse::getCode).orElseGet(HttpStatus.SERVICE_UNAVAILABLE::value);
            if (HttpStatus.valueOf(statusCode).is2xxSuccessful()) {
                try (val content = ((HttpEntityContainer) response).getEntity().getContent()) {
                    val result = IOUtils.toString(content, StandardCharsets.UTF_8);
                    val terms = MAPPER.readValue(JsonValue.readHjson(result).toString(), AcceptableUsagePolicyTerms.class);
                    return Optional.ofNullable(terms);
                }
            }
            LOGGER.warn("AUP fetch policy request returned with response code [{}]", statusCode);
        } catch (final Exception e) {
            LoggingUtils.error(LOGGER, e);
        } finally {
            HttpUtils.close(response);
        }
        return Optional.empty();
    }
This is {@link RestAcceptableUsagePolicyRepository}.
Examines the principal attribute collection to determine if
the policy has been accepted, and if not, allows for a configurable
way so that user's choice can later be remembered and saved back via REST.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-aup-rest/src/main/java/org/apereo/cas/aup/RestAcceptableUsagePolicyRepository.java