CorsConfig instance.
| Modifier and Type | Class and Description |
|---|---|
| private static class | CorsConfigBuilder.ConstantValueGenerator
This class is used for preflight HTTP response values that do not need to be generated, but instead the value is "static" in that the same value will be returned for each call. |
| private static class | CorsConfigBuilder.DateValueGenerator
This callable is used for the DATE preflight HTTP response HTTP header. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv final boolean | |
| pack-priv boolean | |
| pack-priv final Set | |
| pack-priv long | |
| private boolean | |
| pack-priv final Set | |
| pack-priv final Map | |
| pack-priv final Set | |
| pack-priv final Set | |
| pack-priv boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv | CorsConfigBuilder(final String...
the origin to be used for this builder. origins)Creates a new Builder instance with the origin passed in. |
| pack-priv | CorsConfigBuilder()
Creates a new Builder instance allowing any origin, "*" which is the wildcard origin. |
| Modifier and Type | Method and Description |
|---|---|
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.By default cookies are not included in CORS requests, but this method will enable cookies to be added to CORS requests. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the headers to be added to the preflight 'Access-Control-Allow-Headers' response header. headers)Specifies the if headers that should be returned in the CORS 'Access-Control-Allow-Headers' response header. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the headers to be added to the preflight 'Access-Control-Allow-Headers' response header. headers)Specifies the if headers that should be returned in the CORS 'Access-Control-Allow-Headers' response header. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the methods)HttpMethods that should be allowed.Specifies the allowed set of HTTP Request Methods that should be returned in the CORS 'Access-Control-Request-Method' response header. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Web browsers may set the 'Origin' request header to 'null' if a resource is loaded from the local file system. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Web browsers may set the 'Access-Control-Request-Private-Network' request header if a resource is loaded from a local network. |
| public CorsConfig | Returns: CorsConfig the configured CorsConfig instance.Builds a |
| public CorsConfigBuilder | |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the values to be added to the 'Access-Control-Expose-Headers' response header headers)Specifies the headers to be exposed to calling clients. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the values to be added to the 'Access-Control-Expose-Headers' response header headers)Specifies the headers to be exposed to calling clients. |
| public static CorsConfigBuilder | Returns: Builder to support method chaining.Creates a Builder instance with it's origin set to '*'. |
| public static CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Creates a |
| public static CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Creates a |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the maximum time, in seconds, that the preflight response may be cached. max)When making a preflight request the client has to perform two request with can be inefficient. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Specifies that no preflight response headers should be added to a preflight response. |
| private List | |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the name of the HTTP header. name, final CharSequence... the values for the HTTP header. values)Returns HTTP response headers that should be added to a CORS preflight response. |
| public < the type of values that the Iterable contains. T> CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the name of the HTTP header. name, final Iterable<CharSequence> the values for the HTTP header. values)Returns HTTP response headers that should be added to a CORS preflight response. |
| public < the type of the value that the Callable can return. T> CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.the name of the HTTP header. name, final Callable<CharSequence> a Callable which will be invoked at HTTP response creation. valueGenerator)Returns HTTP response headers that should be added to a CORS preflight response. |
| public CorsConfigBuilder | Returns: CorsConfigBuilder to support method chaining.Specifies that a CORS request should be rejected if it's invalid before being further processing. |
| allowCredentials | back to summary |
|---|---|
| pack-priv boolean allowCredentials | |
| allowNullOrigin | back to summary |
|---|---|
| pack-priv boolean allowNullOrigin | |
| allowPrivateNetwork | back to summary |
|---|---|
| pack-priv boolean allowPrivateNetwork | |
| anyOrigin | back to summary |
|---|---|
| pack-priv final boolean anyOrigin | |
| enabled | back to summary |
|---|---|
| pack-priv boolean enabled | |
| exposeHeaders | back to summary |
|---|---|
| pack-priv final Set<String> exposeHeaders | |
| maxAge | back to summary |
|---|---|
| pack-priv long maxAge | |
| noPreflightHeaders | back to summary |
|---|---|
| private boolean noPreflightHeaders | |
| origins | back to summary |
|---|---|
| pack-priv final Set<String> origins | |
| preflightHeaders | back to summary |
|---|---|
| pack-priv final Map<CharSequence, List<Callable<CharSequence>>> preflightHeaders | |
| requestHeaders | back to summary |
|---|---|
| pack-priv final Set<String> requestHeaders | |
| requestMethods | back to summary |
|---|---|
| pack-priv final Set<HttpMethod> requestMethods | |
| shortCircuit | back to summary |
|---|---|
| pack-priv boolean shortCircuit | |
| CorsConfigBuilder | back to summary |
|---|---|
| pack-priv CorsConfigBuilder(final String... origins) Creates a new Builder instance with the origin passed in.
| |
| CorsConfigBuilder | back to summary |
|---|---|
| pack-priv CorsConfigBuilder() Creates a new Builder instance allowing any origin, "*" which is the wildcard origin. | |
| allowCredentials | back to summary |
|---|---|
| public CorsConfigBuilder allowCredentials() By default cookies are not included in CORS requests, but this method will enable cookies to be added to CORS requests. Calling this method will set the CORS 'Access-Control-Allow-Credentials' response header to true. Please note, that cookie support needs to be enabled on the client side as well. The client needs to opt-in to send cookies by calling: xhr.withCredentials = true;The default value for 'withCredentials' is false in which case no cookies are sent. Setting this to true will included cookies in cross origin requests.
| |
| allowedRequestHeaders | back to summary |
|---|---|
| public CorsConfigBuilder allowedRequestHeaders(final String... headers) Specifies the if headers that should be returned in the CORS 'Access-Control-Allow-Headers' response header. If a client specifies headers on the request, for example by calling:
xhr.setRequestHeader('My-Custom-Header', "SomeValue");
the server will receive the above header name in the 'Access-Control-Request-Headers' of the
preflight request. The server will then decide if it allows this header to be sent for the
real request (remember that a preflight is not the real request but a request asking the server
if it allow a request).
| |
| allowedRequestHeaders | back to summary |
|---|---|
| public CorsConfigBuilder allowedRequestHeaders(final CharSequence... headers) Specifies the if headers that should be returned in the CORS 'Access-Control-Allow-Headers' response header. If a client specifies headers on the request, for example by calling:
xhr.setRequestHeader('My-Custom-Header', "SomeValue");
the server will receive the above header name in the 'Access-Control-Request-Headers' of the
preflight request. The server will then decide if it allows this header to be sent for the
real request (remember that a preflight is not the real request but a request asking the server
if it allow a request).
| |
| allowedRequestMethods | back to summary |
|---|---|
| public CorsConfigBuilder allowedRequestMethods(final HttpMethod... methods) Specifies the allowed set of HTTP Request Methods that should be returned in the CORS 'Access-Control-Request-Method' response header.
| |
| allowNullOrigin | back to summary |
|---|---|
| public CorsConfigBuilder allowNullOrigin() Web browsers may set the 'Origin' request header to 'null' if a resource is loaded
from the local file system. Calling this method will enable a successful CORS response
with a
| |
| allowPrivateNetwork | back to summary |
|---|---|
| public CorsConfigBuilder allowPrivateNetwork() Web browsers may set the 'Access-Control-Request-Private-Network' request header if a resource is loaded from a local network. By default direct access to private network endpoints from public websites is not allowed. Calling this method will set the CORS 'Access-Control-Request-Private-Network' response header to true.
| |
| build | back to summary |
|---|---|
| public CorsConfig build() Builds a
| |
| disable | back to summary |
|---|---|
| public CorsConfigBuilder disable() Disables CORS support.
| |
| exposeHeaders | back to summary |
|---|---|
| public CorsConfigBuilder exposeHeaders(final String... headers) Specifies the headers to be exposed to calling clients. During a simple CORS request, only certain response headers are made available by the browser, for example using:
xhr.getResponseHeader("Content-Type");
The headers that are available by default are:
| |
| exposeHeaders | back to summary |
|---|---|
| public CorsConfigBuilder exposeHeaders(final CharSequence... headers) Specifies the headers to be exposed to calling clients. During a simple CORS request, only certain response headers are made available by the browser, for example using: xhr.getResponseHeader(HttpHeaderNames.CONTENT_TYPE);The headers that are available by default are:
| |
| forAnyOrigin | back to summary |
|---|---|
| public static CorsConfigBuilder forAnyOrigin() Creates a Builder instance with it's origin set to '*'.
| |
| forOrigin | back to summary |
|---|---|
| public static CorsConfigBuilder forOrigin(final String origin) Creates a
| |
| forOrigins | back to summary |
|---|---|
| public static CorsConfigBuilder forOrigins(final String... origins) Creates a
| |
| maxAge | back to summary |
|---|---|
| public CorsConfigBuilder maxAge(final long max) When making a preflight request the client has to perform two request with can be inefficient. This setting will set the CORS 'Access-Control-Max-Age' response header and enables the caching of the preflight response for the specified time. During this time no preflight request will be made.
| |
| noPreflightResponseHeaders | back to summary |
|---|---|
| public CorsConfigBuilder noPreflightResponseHeaders() Specifies that no preflight response headers should be added to a preflight response.
| |
| preflightHeader | back to summary |
|---|---|
| private List | |
| preflightResponseHeader | back to summary |
|---|---|
| public CorsConfigBuilder preflightResponseHeader(final CharSequence name, final CharSequence... values) Returns HTTP response headers that should be added to a CORS preflight response. An intermediary like a load balancer might require that a CORS preflight request have certain headers set. This enables such headers to be added.
| |
| preflightResponseHeader | back to summary |
|---|---|
| public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Iterable<CharSequence> values) Returns HTTP response headers that should be added to a CORS preflight response. An intermediary like a load balancer might require that a CORS preflight request have certain headers set. This enables such headers to be added.
| |
| preflightResponseHeader | back to summary |
|---|---|
| public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Callable<CharSequence> valueGenerator) Returns HTTP response headers that should be added to a CORS preflight response. An intermediary like a load balancer might require that a CORS preflight request have certain headers set. This enables such headers to be added. Some values must be dynamically created when the HTTP response is created, for example the 'Date' response header. This can be accomplished by using a Callable which will have its 'call' method invoked when the HTTP response is created.
| |
| shortCircuit | back to summary |
|---|---|
| public CorsConfigBuilder shortCircuit() Specifies that a CORS request should be rejected if it's invalid before being further processing. CORS headers are set after a request is processed. This may not always be desired and this setting will check that the Origin is valid and if it is not valid no further processing will take place, and an error will be returned to the calling client.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final CharSequence |
| Access | Constructor and Description |
|---|---|
| private | ConstantValueGenerator(final CharSequence
the value that will be returned when the call method is invoked. value)Sole constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public CharSequence | call()
Implements java. |
| value | back to summary |
|---|---|
| private final CharSequence value | |
| ConstantValueGenerator | back to summary |
|---|---|
| private ConstantValueGenerator(final CharSequence value) Sole constructor.
| |
| call | back to summary |
|---|---|
| public CharSequence call() Implements java. Doc from java. Computes a result, or throws an exception if unable to do so.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final CorsConfigBuilder. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public CharSequence | call()
Implements java. |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final CorsConfigBuilder. | |
| DateValueGenerator | back to summary |
|---|---|
| private DateValueGenerator() | |
| call | back to summary |
|---|---|
| public CharSequence call() throws Exception Implements java. Doc from java. Computes a result, or throws an exception if unable to do so.
| |