public static HttpServletResponse getHttpServletResponseFromRequestAttributes() {
        val requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return Optional.ofNullable(requestAttributes).map(ServletRequestAttributes::getResponse).orElse(null);
    }
Gets http servlet response from request attributes.

@return the http servlet response from request attributes
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/HttpRequestUtils.java