- * A {@link Filter} that enable client-side cross-origin requests by - * implementing W3C's CORS (Cross-Origin Resource - * Sharing) specification for resources. Each {@link HttpServletRequest} - * request is inspected as per specification, and appropriate response headers - * are added to {@link HttpServletResponse}. - *
- * - *- * By default, it also sets following request attributes, that helps to - * determine nature of request downstream. - *
- *true
if CORS request; false
- * otherwise.simple
or
- * preflight
or not_cors
or invalid_cors
true
if CORS request; false
- * otherwise.simple
or preflight
or not_cors
or
- * invalid_cors
null
if elements
- * {@link Set} is null.
- */
- public static String join(final Collectiontrue
if origin is allowed; false
- * otherwise.
- */
- private boolean isOriginAllowed(final String origin) {
- if (anyOriginAllowed) {
- return true;
- }
-
- // If 'Origin' header is a case-sensitive match of any of allowed
- // origins, then return true, else return false.
- return allowedOrigins.contains(origin);
- }
-
- private void log(String message) {
- if (loggingEnabled) {
- filterConfig.getServletContext().log(message);
- }
- }
-
- /**
- * Parses each param-value and populates configuration variables. If a param
- * is provided, it overrides the default.
- *
- * @param allowedOrigins
- * A {@link String} of comma separated origins.
- * @param allowedHttpMethods
- * A {@link String} of comma separated HTTP methods.
- * @param allowedHttpHeaders
- * A {@link String} of comma separated HTTP headers.
- * @param exposedHeaders
- * A {@link String} of comma separated headers that needs to be
- * exposed.
- * @param supportsCredentials
- * "true" if support credentials needs to be enabled.
- * @param preflightMaxAge
- * The amount of seconds the user agent is allowed to cache the
- * result of the pre-flight request.
- * @param loggingEnabled
- * Flag to control logging to access log.
- * @throws ServletException
- */
- private void parseAndStore(final String allowedOrigins,
- final String allowedHttpMethods, final String allowedHttpHeaders,
- final String exposedHeaders, final String supportsCredentials,
- final String preflightMaxAge, final String loggingEnabled,
- final String decorateRequest)
- throws ServletException {
- if (allowedOrigins != null) {
- if (allowedOrigins.trim().equals("*")) {
- this.anyOriginAllowed = true;
- } else {
- this.anyOriginAllowed = false;
- Settrue
if it's enabled; false otherwise.
- */
- public boolean isLoggingEnabled() {
- return loggingEnabled;
- }
-
- /**
- * Determines if any origin is allowed to make CORS request.
- *
- * @return true
if it's enabled; false otherwise.
- */
- public boolean isAnyOriginAllowed() {
- return anyOriginAllowed;
- }
-
- /**
- * Returns a {@link Set} of headers that should be exposed by browser.
- *
- * @return
- */
- public Collection( | ' + response.triples[i][0] + '; | '; - gloss += '' + response.triples[i][1] + '; | '; - gloss += '' + response.triples[i][2] + ' | ) |