private HttpUriRequest getHttpRequestByMethod(final String method, final String entity, final URI uri) {
        if ("post".equalsIgnoreCase(method)) {
            val request = new HttpPost(uri);
            if (StringUtils.isNotBlank(entity)) {
                val stringEntity = new StringEntity(entity, StandardCharsets.UTF_8);
                request.setEntity(stringEntity);
            }
            return request;
        }
        if ("delete".equalsIgnoreCase(method)) {
            return new HttpDelete(uri);
        }

        return new HttpGet(uri);
    }
Create basic auth headers.

@param basicAuthUser     the basic auth user
@param basicAuthPassword the basic auth password
@param basicCharset      The charset used to encode auth header
@return the org . springframework . http . http headers
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/HttpUtils.java