Class CORSInterceptor.Builder

java.lang.Object
io.inverno.mod.security.http.cors.CORSInterceptor.Builder
Enclosing class:
CORSInterceptor<A extends ExchangeContext,B extends Exchange<A>>

public static class CORSInterceptor.Builder extends Object

A CORS interceptor builder.

Since:
1.5
Author:
Jeremy Kuhn
  • Field Details

    • allowedOrigins

      protected Set<CORSInterceptor.Origin> allowedOrigins
      The set of allowed origins.
    • allowedOriginsPattern

      protected Set<Pattern> allowedOriginsPattern
      The set of allowed origins patterns.
    • allowCredentials

      protected boolean allowCredentials
      The allow credentials flag.
    • allowedHeaders

      protected Set<String> allowedHeaders
      The set of allowed headers.
    • allowedMethods

      protected Set<Method> allowedMethods
      The set of allowed methods.
    • exposedHeaders

      protected Set<String> exposedHeaders
      The set of exposed headers.
    • maxAge

      protected Integer maxAge
      The max age in seconds.
    • allowPrivateNetwork

      protected boolean allowPrivateNetwork
      The allow private network flag.
  • Constructor Details

    • Builder

      protected Builder()

      Creates a CORS interceptor builder.

  • Method Details

    • allowOrigin

      public CORSInterceptor.Builder allowOrigin(String allowedOrigin) throws IllegalArgumentException

      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

      public CORSInterceptor.Builder allowOriginPattern(String allowedOriginRegex)

      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

      public CORSInterceptor.Builder allowCredentials(boolean allowCredentials)

      Sepcifies the allow credentials flag.

      Parameters:
      allowCredentials - true to allow credentials, false otherwise
      Returns:
      this builder
    • allowHeader

      public CORSInterceptor.Builder allowHeader(String allowedHeader)

      Specifies an allowed header.

      Parameters:
      allowedHeader - the header to allow
      Returns:
      this builder
    • allowMethod

      public CORSInterceptor.Builder allowMethod(Method allowedMethod)

      Specifies an allowed method.

      Parameters:
      allowedMethod - the method to allow
      Returns:
      this builder
    • exposeHeader

      public CORSInterceptor.Builder exposeHeader(String exposedHeader)

      Specifies a header to expose.

      Parameters:
      exposedHeader - the header to expose
      Returns:
      this builder
    • maxAge

      public CORSInterceptor.Builder maxAge(int maxAge)

      Specifies the max age for CORS information cache.

      Parameters:
      maxAge - the max age in seconds
      Returns:
      this builder
    • allowPrivateNetwork

      public CORSInterceptor.Builder allowPrivateNetwork(boolean allowPrivateNetwork)

      Specifies the allow private network flag.

      Parameters:
      allowPrivateNetwork - true to allow private network, false otherwise
      Returns:
      this builder
    • build

      public <A extends ExchangeContext, B extends Exchange<A>> CORSInterceptor<A,B> build()

      Builds and returns a CORS interceptor.

      Type Parameters:
      A - the type of the exchange context
      B - the type of exchange handled by the handler
      Returns:
      a new CORS interceptor