Class WebUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanGets a value that indicates if CORS is enabled, in principle.static voidsetCorsResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Sets the default CORS response headers if CORS is enabled and the request origin is allowed.static voidsetCorsResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String, List<String>> corsHeadersConfiguration) Sets the default CORS response headers and the additional provided headers if CORS is enabled and the request origin is allowed.
-
Method Details
-
setCorsResponseHeaders
public static void setCorsResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Sets the default CORS response headers if CORS is enabled and the request origin is allowed.The default headers are the
Access-Control-Allow-Originheader with the current allowed origin as a value and theAccess-Control-Allow-Credentialswith valuetrue.This method exists for when it is needed to set CORS headers programmatically. It's generally preferable to configure the system's CORS filter, by editing
applicationContext-spring-security-cors.xmlor by publishing an implementation ofcom.hitachivantara.security.web.api.model.cors.CorsRequestSetConfigurationwith the Pentaho system.- Parameters:
request- The HTTP request.response- The HTTP response.
-
setCorsResponseHeaders
public static void setCorsResponseHeaders(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Map<String, List<String>> corsHeadersConfiguration) Sets the default CORS response headers and the additional provided headers if CORS is enabled and the request origin is allowed.The default headers are the
Access-Control-Allow-Originheader with the current allowed origin as a value and theAccess-Control-Allow-Credentialswith valuetrue.This method exists for when it is needed to set CORS headers programmatically. It's generally preferable to configure the system's CORS filter, by editing
applicationContext-spring-security-cors.xmlor by publishing an implementation ofcom.hitachivantara.security.web.api.model.cors.CorsRequestSetConfigurationwith the Pentaho system.- Parameters:
request- The HTTP request.response- The HTTP response.corsHeadersConfiguration- Additional headers to conditionally define.
-
isCorsRequestsAllowed
public static boolean isCorsRequestsAllowed()Gets a value that indicates if CORS is enabled, in principle.Further restrictions apply to determine if a specific cross origin or CORS request is actualy enabled.
- Returns:
trueif enabled;false, otherwise.
-