Module io.inverno.mod.security.http
Class CORSInterceptor.Builder
java.lang.Object
io.inverno.mod.security.http.cors.CORSInterceptor.Builder
- Enclosing class:
CORSInterceptor<A extends ExchangeContext,
B extends Exchange<A>>
A CORS interceptor builder.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
The allow credentials flag.The set of allowed headers.The set of allowed methods.protected Set
<CORSInterceptor.Origin> The set of allowed origins.The set of allowed origins patterns.protected boolean
The allow private network flag.The set of exposed headers.protected Integer
The max age in seconds. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowCredentials
(boolean allowCredentials) Sepcifies the allow credentials flag.allowHeader
(String allowedHeader) Specifies an allowed header.allowMethod
(Method allowedMethod) Specifies an allowed method.allowOrigin
(String allowedOrigin) Specifies an allowed origin.allowOriginPattern
(String allowedOriginRegex) Specifies an allowed origin pattern.allowPrivateNetwork
(boolean allowPrivateNetwork) Specifies the allow private network flag.<A extends ExchangeContext,
B extends Exchange<A>>
CORSInterceptor<A, B> build()
Builds and returns a CORS interceptor.exposeHeader
(String exposedHeader) Specifies a header to expose.maxAge
(int maxAge) Specifies the max age for CORS information cache.
-
Field Details
-
allowedOrigins
The set of allowed origins. -
allowedOriginsPattern
The set of allowed origins patterns. -
allowCredentials
protected boolean allowCredentialsThe allow credentials flag. -
allowedHeaders
The set of allowed headers. -
allowedMethods
The set of allowed methods. -
exposedHeaders
The set of exposed headers. -
maxAge
The max age in seconds. -
allowPrivateNetwork
protected boolean allowPrivateNetworkThe allow private network flag.
-
-
Constructor Details
-
Builder
protected Builder()Creates a CORS interceptor builder.
-
-
Method Details
-
allowOrigin
Specifies an allowed origin.
*
overrides previous and further values and allow all origins.- Parameters:
allowedOrigin
- the origin to allow- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the specified origin is invalid
-
allowOriginPattern
Specifies an allowed origin pattern.
.*
regex overrides previous and further values and allow all origins.- Parameters:
allowedOriginRegex
- the origin pattern to allow- Returns:
- this builder
- Throws:
IllegalArgumentException
- if the specified origin regex is invalid
-
allowCredentials
Sepcifies the allow credentials flag.
- Parameters:
allowCredentials
- true to allow credentials, false otherwise- Returns:
- this builder
-
allowHeader
Specifies an allowed header.
- Parameters:
allowedHeader
- the header to allow- Returns:
- this builder
-
allowMethod
Specifies an allowed method.
- Parameters:
allowedMethod
- the method to allow- Returns:
- this builder
-
exposeHeader
Specifies a header to expose.
- Parameters:
exposedHeader
- the header to expose- Returns:
- this builder
-
maxAge
Specifies the max age for CORS information cache.
- Parameters:
maxAge
- the max age in seconds- Returns:
- this builder
-
allowPrivateNetwork
Specifies the allow private network flag.
- Parameters:
allowPrivateNetwork
- true to allow private network, false otherwise- Returns:
- this builder
-
build
Builds and returns a CORS interceptor.
- Type Parameters:
A
- the type of the exchange contextB
- the type of exchange handled by the handler- Returns:
- a new CORS interceptor
-