public class CorsConfiguration extends Object
| Constructor and Description |
|---|
CorsConfiguration()
Default constructor.
|
CorsConfiguration(CorsConfiguration other)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAllowedHeader(String allowedHeader)
Add one actual request header to allow.
|
void |
addAllowedMethod(String method)
Add an HTTP method to allow.
|
void |
addAllowedOrigin(String origin)
Add an origin to allow.
|
void |
addExposedHeader(String exposedHeader)
Add a single response header to expose.
|
List<String> |
checkHeaders(List<String> requestHeaders)
Check the request headers (or the headers listed in the
Access-Control-Request-Headers of a pre-flight request) against the
configured allowed headers.
|
List<HttpMethod> |
checkHttpMethod(HttpMethod requestMethod)
Check the request HTTP method (or the method from the
Access-Control-Request-Method header on a pre-flight request) against the
configured allowed methods.
|
String |
checkOrigin(String requestOrigin)
Check the origin of the request against the configured allowed origins.
|
CorsConfiguration |
combine(CorsConfiguration other)
Combine the specified
CorsConfiguration with this one. |
Boolean |
getAllowCredentials()
Return the configured allowCredentials, possibly
null. |
List<String> |
getAllowedHeaders()
Return the allowed actual request headers, possibly
null. |
List<String> |
getAllowedMethods()
Return the allowed HTTP methods, possibly
null in which case only
HTTP GET is allowed. |
List<String> |
getAllowedOrigins()
Return the configured origins to allow, possibly
null. |
List<String> |
getExposedHeaders()
Return the configured response headers to expose, possibly
null. |
Long |
getMaxAge()
Return the configure maxAge value, possibly
null. |
void |
setAllowCredentials(Boolean allowCredentials)
Whether user credentials are supported.
|
void |
setAllowedHeaders(List<String> allowedHeaders)
Configure the list of headers that a pre-flight request can list as allowed
for use during an actual request.
|
void |
setAllowedMethods(List<String> methods)
Configure HTTP methods to allow, e.g.
|
void |
setAllowedOrigins(List<String> origins)
Configure origins to allow, e.g.
|
void |
setExposedHeaders(List<String> exposedHeaders)
Configure the list of response headers other than simple headers (i.e.
|
void |
setMaxAge(Long maxAge)
Configure how long, in seconds, the response from a pre-flight request
can be cached by clients.
|
public CorsConfiguration()
public CorsConfiguration(CorsConfiguration other)
public CorsConfiguration combine(CorsConfiguration other)
CorsConfiguration with this one.
Properties of this configuration are overridden only by non-null properties
of the provided one.CorsConfigurationpublic void setAllowedOrigins(List<String> origins)
By default this is not set.
public void addAllowedOrigin(String origin)
public List<String> getAllowedOrigins()
null.public void setAllowedMethods(List<String> methods)
By default this is not set.
public void addAllowedMethod(String method)
public List<String> getAllowedMethods()
null in which case only
HTTP GET is allowed.public void setAllowedHeaders(List<String> allowedHeaders)
By default this is not set.
public void addAllowedHeader(String allowedHeader)
public List<String> getAllowedHeaders()
null.public void setExposedHeaders(List<String> exposedHeaders)
By default this is not set.
public void addExposedHeader(String exposedHeader)
public List<String> getExposedHeaders()
null.public void setAllowCredentials(Boolean allowCredentials)
By default this is not set (i.e. user credentials not supported).
public Boolean getAllowCredentials()
null.public void setMaxAge(Long maxAge)
By default this is not set.
public Long getMaxAge()
null.public String checkOrigin(String requestOrigin)
requestOrigin - the origin to check.null which
means the request origin is not allowed.public List<HttpMethod> checkHttpMethod(HttpMethod requestMethod)
requestMethod - the HTTP method to check.null if the requestMethod is not allowed.public List<String> checkHeaders(List<String> requestHeaders)
requestHeaders - the headers to check.null if a requestHeader is not allowed.