private void prepareHttpRequest(final HttpUriRequest request,
                                    final HttpExecutionRequest execution) {
        if (execution.isBasicAuthentication()) {
            val auth = EncodingUtils.encodeBase64(execution.getBasicAuthUsername() + ':' + execution.getBasicAuthPassword());
            request.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + auth);
        }
        if (execution.isBearerAuthentication()) {
            request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + execution.getBearerToken());
        }
    }
Prepare http request. Tries to set the authorization header
in cases where the URL endpoint does not actually produce the header
on its own.

@param request   the request
@param execution the execution request
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/HttpUtils.java