aerogear-controller 1.0.2

org.jboss.aerogear.controller.router.decorators.cors
Class CorsConfig

java.lang.Object
  extended by org.jboss.aerogear.controller.router.decorators.cors.CorsConfig
All Implemented Interfaces:
CorsConfiguration

public class CorsConfig
extends Object
implements CorsConfiguration

Concrete implementation of CorsConfiguration which provides configuration of CORS in AeroGear Controller.

See Also:
CorsHandler

Nested Class Summary
private static class CorsConfig.Builder
           
static interface CorsConfig.Cookies
           
static interface CorsConfig.ExposeHeaders
           
static interface CorsConfig.MaxAge
           
static interface CorsConfig.Origin
           
static interface CorsConfig.SupportedOptions
           
static interface CorsConfig.ValidRequestHeaders
           
static interface CorsConfig.ValidRequestMethods
           
 
Field Summary
private  boolean allowCookies
           
private  boolean anyOrigin
           
private  boolean corsSupportEnabled
           
private  List<String> exposeHeaders
           
private  long maxAge
           
private  List<String> validRequestHeaders
           
private  Set<String> validRequestMethods
           
 
Constructor Summary
private CorsConfig(CorsConfig.Builder builder)
           
 
Method Summary
 boolean allowCookies()
          Determines if cookies are supported.
 boolean anyOrigin()
          Determines is any origin, "*", is supported.
static CorsConfiguration defaultConfig()
          Returns a CorsConfiguration instance with the default values for all properties.
static CorsConfiguration disableCorsSupport()
           
static CorsConfig.Origin enableCorsSupport()
          Returns a CorsConfig.Origin instance which can be configured as needed
 boolean exposeHeaders()
          Determines if there are any headers configured to be exposed to calling clients.
 List<String> getExposeHeaders()
          Returns a comma separated string of headers to be exposed to calling clients.
 long getMaxAge()
          Gets the maxAge setting.
 List<String> getValidRequestHeaders()
          Returns the allowed set of Request Headers.
 Set<String> getValidRequestMethods()
          Returns the allowed set of Request Methods.
 boolean hasMaxAge()
          Determines is maxAge has been configured.
 boolean isCorsSupportEnabled()
          Determines is support for CORS is enabled.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

corsSupportEnabled

private final boolean corsSupportEnabled

anyOrigin

private final boolean anyOrigin

allowCookies

private final boolean allowCookies

maxAge

private final long maxAge

validRequestMethods

private final Set<String> validRequestMethods

validRequestHeaders

private final List<String> validRequestHeaders

exposeHeaders

private final List<String> exposeHeaders
Constructor Detail

CorsConfig

private CorsConfig(CorsConfig.Builder builder)
Method Detail

enableCorsSupport

public static CorsConfig.Origin enableCorsSupport()
Returns a CorsConfig.Origin instance which can be configured as needed

Returns:
CorsConfig.Origin to be used to configure and build a CorsConfiguration instance.

disableCorsSupport

public static CorsConfiguration disableCorsSupport()

defaultConfig

public static CorsConfiguration defaultConfig()
Returns a CorsConfiguration instance with the default values for all properties.

Returns:
CorsConfiguration with default properties set.

isCorsSupportEnabled

public boolean isCorsSupportEnabled()
Description copied from interface: CorsConfiguration
Determines is support for CORS is enabled.

Specified by:
isCorsSupportEnabled in interface CorsConfiguration
Returns:
true if support for CORS is enabled, false otherwise.

exposeHeaders

public boolean exposeHeaders()
Description copied from interface: CorsConfiguration
Determines if there are any headers configured to be exposed to calling clients.

Specified by:
exposeHeaders in interface CorsConfiguration
Returns:
true if there are headers that should be exposed to clients.
See Also:
CorsConfiguration.getExposeHeaders()

getExposeHeaders

public List<String> getExposeHeaders()
Description copied from interface: CorsConfiguration
Returns a comma separated string of headers to be exposed to calling clients.

During a simple CORS request only certain response headers are made available to a calling client: To expose other headers they need to be specified which what this method enables.

Specified by:
getExposeHeaders in interface CorsConfiguration
Returns:
String a comma separated string of headers to be exposed.

anyOrigin

public boolean anyOrigin()
Description copied from interface: CorsConfiguration
Determines is any origin, "*", is supported.

Specified by:
anyOrigin in interface CorsConfiguration
Returns:
true if any origin is allowed.

allowCookies

public boolean allowCookies()
Description copied from interface: CorsConfiguration
Determines if cookies are supported.

By default cookies are not included in CORS requests if allowCookies is true cookies will be added to CORS requests.

Specified by:
allowCookies in interface CorsConfiguration
Returns:
true if cookies are supported.

hasMaxAge

public boolean hasMaxAge()
Description copied from interface: CorsConfiguration
Determines is maxAge has been configured.

Specified by:
hasMaxAge in interface CorsConfiguration
Returns:
true if maxAge has been set.
See Also:
CorsConfiguration.getMaxAge()

getMaxAge

public long getMaxAge()
Description copied from interface: CorsConfiguration
Gets the maxAge setting.

When making a preflight request the client has to perform two request with can be inefficient. This setting enables the caching of the preflight response for the specified time. During this time no preflight request will be made.

Specified by:
getMaxAge in interface CorsConfiguration
Returns:
long the time in seconds that a preflight request may be cached.

getValidRequestMethods

public Set<String> getValidRequestMethods()
Description copied from interface: CorsConfiguration
Returns the allowed set of Request Methods.

Specified by:
getValidRequestMethods in interface CorsConfiguration
Returns:
Set strings that represent the allowed Request Methods.

getValidRequestHeaders

public List<String> getValidRequestHeaders()
Description copied from interface: CorsConfiguration
Returns the allowed set of Request Headers.

Specified by:
getValidRequestHeaders in interface CorsConfiguration
Returns:
Set of strings that represent the allowed Request Headers.

toString

public String toString()
Overrides:
toString in class Object

aerogear-controller 1.0.2

Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.