Package org.forgerock.http.filter.cors
Class CorsPolicy.Builder
java.lang.Object
org.forgerock.http.filter.cors.CorsPolicy.Builder
- Enclosing class:
- CorsPolicy
Builder for
CorsPolicy
instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptedOrigin
(String acceptedOrigin) Adds an accepted origin to this configuration (case insensitive).acceptHeaders
(Predicate<Set<String>> predicate) Will accept the set of headers accepted by the givenpredicate
.acceptMethods
(Predicate<String> predicate) Will accept any method accepted by the givenpredicate
.acceptOrigin
(Predicate<String> predicate) This configuration accepts whatever origin is accepted by the given predicate.allowCredentials
(boolean allowCredentials) Sets totrue
to inform the CORS client that credentials are allowed.static <T> Predicate<T>
any()
Accepts any input value.Accepts String that are contained within the given set (case sensitive).build()
Returns a newCorsPolicy
immutable instance.containedIn
(Set<String> acceptedValues) Accepts a set of values if all values from that set are contained in the given set ofacceptedValues
.containedInIgnoringCase
(String... acceptedValues) Accepts a set of values if all values from that set are contained (case insensitively) in the given set ofacceptedValues
.exposedHeader
(String exposedHeader) Adds an exposed header name to this configuration.Sets a maximum age for user-agent to cache for valid pre-flight responses.static <T> Predicate<T>
none()
Rejects any input value.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
any
Accepts any input value.- Type Parameters:
T
- input type- Returns:
- a new predicate that always returns
true
-
none
Rejects any input value.- Type Parameters:
T
- input type- Returns:
- a new predicate that always returns
false
-
anyOf
Accepts String that are contained within the given set (case sensitive).- Parameters:
values
- allowed values- Returns:
- a predicate that accepts Strings that are contained within the given set (case sensitive)
-
containedInIgnoringCase
Accepts a set of values if all values from that set are contained (case insensitively) in the given set ofacceptedValues
.If a single tested value is not within that set, this predicate returns
false
.- Parameters:
acceptedValues
- all accepted values- Returns:
- a predicate that accepts a set of values if all values from that set are contained
in the given set of
acceptedValues
(case insensitively). - See Also:
-
containedIn
Accepts a set of values if all values from that set are contained in the given set ofacceptedValues
.If a single tested value is not within that set, this predicate returns
false
.- Parameters:
acceptedValues
- set of accepted values- Returns:
- a predicate that accepts a set of values if all values from that set are contained
in the given set of
acceptedValues
.
-
acceptedOrigin
Adds an accepted origin to this configuration (case insensitive).- Parameters:
acceptedOrigin
- URL of the origin to add- Returns:
- this builder
-
acceptOrigin
This configuration accepts whatever origin is accepted by the given predicate.- Parameters:
predicate
- Additional origin predicate (Or-ed)- Returns:
- this builder
-
acceptMethods
Will accept any method accepted by the givenpredicate
. Removes any prior accepted methods from this configuration.- Parameters:
predicate
- predicate for matching requested method name- Returns:
- this builder
-
acceptHeaders
Will accept the set of headers accepted by the givenpredicate
. Removes any prior accepted headers from this configuration.- Parameters:
predicate
- predicate for matching requested headers- Returns:
- this builder
-
exposedHeader
Adds an exposed header name to this configuration.- Parameters:
exposedHeader
- name of the header to expose- Returns:
- this builder
-
maxAge
Sets a maximum age for user-agent to cache for valid pre-flight responses.- Parameters:
maxAge
- maximum age for user-agent to cache for valid pre-flight responses (not negative, can be null)- Returns:
- this builder
-
allowCredentials
Sets totrue
to inform the CORS client that credentials are allowed.- Parameters:
allowCredentials
- are credentials allowed- Returns:
- this builder
-
build
Returns a newCorsPolicy
immutable instance.- Returns:
- a new
CorsPolicy
immutable instance.
-