<commit_before>/**
 * Copyright 2012-2013 eBay Software Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.ebay.web.cors;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;

/**
 * The configuration for {@link CORSFilter}.
 * 
 * <ul>
 * <li>
 * <b>Allowed Origins:</b> A {@link Collection} of origins consisting of zero or
 * more origins that are allowed access to the resource.</li>
 * <li>
 * <b>Allowed HTTP Methods:</b> A {@link Collection} of methods consisting of
 * zero or more methods that are supported by the resource.</li>
 * <li>
 * <b>Allowed HTTP Headers:</b> A {@link Collection} of headers consisting of
 * zero or more header field names that are supported by the resource.</li>
 * <li>
 * <b>Exposed headers:</b> A {@link Collection} of exposed headers consisting of
 * zero or more header field names of headers other than the simple response
 * headers that the resource might use and can be exposed.</li>
 * <li>
 * <b>Pre-flight max age:</b> The amount of seconds the user agent is allowed to
 * cache the result of the pre-flight request.</li>
 * <li>
 * <b>Supports credentials:</b> A supports credentials flag that indicates
 * whether the resource supports user credentials in the request. It is true
 * when the resource does and false otherwise.</li>
 * </ul>
 * <p>
 * Defaults:
 * </p>
 * <ul>
 * <li>Allowed HTTP methods: [GET, POST, OPTIONS, HEAD]</li>
 * <li>Supports credentials: false</li>
 * </ul>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * 
 */
public final class CORSConfiguration {
    /**
     * By default, time duration to cache pre-flight response is 30 mins.
     */
    public static final String DEFAULT_PREFLIGHT_MAXAGE = "1800";

    /**
     * By default, cookie based auth is turned off.
     */
    public static final String DEFAULT_SUPPORTS_CREDENTIALS = "false";

    /**
     * By default, all origins are allowed to make requests.
     */
    public static final String DEFAULT_ALLOWED_ORIGINS = "*";

    /**
     * By default, following methods are supported: GET, POST, HEAD and OPTIONS.
     */
    public static final String DEFAULT_ALLOWED_HTTP_METHODS = "GET,POST,HEAD,OPTIONS";

    /**
     * By default, following headers are supported:
     * Origin,Accept,X-Requested-With, and Content-Type.
     */
    public static final String DEFAULT_ALLOWED_HTTP_HEADERS = "Origin,Accept,X-Requested-With,Content-Type";

    /**
     * By default, none of the headers are exposed in response.
     */
    public static final String DEFAULT_EXPOSED_HEADERS = "";

    /**
     * Key to retrieve allowed origins from {@link FilterConfig}.
     */
    public static final String CORS_ALLOWED_ORIGINS = "cors.allowed.origins";

    /**
     * Key to retrieve support credentials from {@link FilterConfig}.
     */
    public static final String CORS_SUPPORT_CREDENTIALS = "cors.support.credentials";

    /**
     * Key to retrieve exposed headers from {@link FilterConfig}.
     */
    public static final String CORS_EXPOSED_HEADERS = "cors.exposed.headers";

    /**
     * Key to retrieve allowed headers from {@link FilterConfig}.<commit_msg>Updated documentation.<commit_after>/**
 * Copyright 2012-2013 eBay Software Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.ebay.web.cors;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import javax.servlet.FilterConfig;
import javax.servlet.ServletException;

/**
 * <p>
 * The configuration object for {@link CORSFilter}.
 * </p>
 * <ul>
 * <li>
 * <b>Allowed Origins:</b> A {@link Collection} of origins consisting of zero or
 * more origins that are allowed access to the resource. Init param name:
 * <code>cors.allowed.origins</code></li>
 * <li>
 * <b>Allowed HTTP Methods:</b> A {@link Collection} of methods consisting of
 * zero or more methods that are supported by the resource. Init param name:
 * <code>cors.allowed.methods</code></li>
 * <li>
 * <b>Allowed HTTP Headers:</b> A {@link Collection} of headers consisting of
 * zero or more header field names that are supported by the resource. Init
 * param name: <code>cors.allowed.headers</code></li>
 * <li>
 * <b>Exposed headers:</b> A {@link Collection} of exposed headers consisting of
 * zero or more header field names of headers other than the simple response
 * headers that the resource might use and can be exposed. Init param name:
 * <code>cors.exposed.headers</code></li>
 * <li>
 * <b>Pre-flight max age:</b> The amount of seconds the user agent is allowed to
 * cache the result of the pre-flight request. Init param name:
 * <code>cors.preflight.maxage</code></li>
 * <li>
 * <b>Supports credentials:</b> A supports credentials flag that indicates
 * whether the resource supports user credentials in the request. It is true
 * when the resource does and false otherwise. Init param name:
 * <code>cors.support.credentials</code></li>
 * </ul>
 * <p>
 * If {@link FilterConfig} is not provided. Following defaults are used:
 * </p>
 * <ul>
 * <li><b>Allowed origin:</b> *</li>
 * <li><b>Allowed HTTP methods:</b> [GET, POST, OPTIONS, HEAD]</li>
 * <li><b>Pre-flight max age:</b> 1800 seconds</li>
 * <li><b>Supports credentials:</b> false</li>
 * <li><b>Allowed HTTP headers:</b> Origin,Accept,X-Requested-With,Content-Type</li>
 * </ul>
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * 
 */
public final class CORSConfiguration {
    /**
     * By default, all origins are allowed to make requests.
     */
    public static final String DEFAULT_ALLOWED_ORIGINS = "*";

    /**
     * By default, following methods are supported: GET, POST, HEAD and OPTIONS.
     */
    public static final String DEFAULT_ALLOWED_HTTP_METHODS = "GET,POST,HEAD,OPTIONS";

    /**
     * By default, time duration to cache pre-flight response is 30 mins.
     */
    public static final String DEFAULT_PREFLIGHT_MAXAGE = "1800";

    /**
     * By default, cookie based auth is turned off.
     */
    public static final String DEFAULT_SUPPORTS_CREDENTIALS = "false";

    /**
     * By default, following headers are supported:
     * Origin,Accept,X-Requested-With, and Content-Type.
     */
    public static final String DEFAULT_ALLOWED_HTTP_HEADERS = "Origin,Accept,X-Requested-With,Content-Type";

    /**
     * By default, none of the headers are exposed in response.
     */
    public static final String DEFAULT_EXPOSED_HEADERS = "";

    /**
     * Key to retrieve allowed origins from {@link FilterConfig}.
     */
    public static final String CORS_ALLOWED_ORIGINS = "cors.allowed.origins";

    /**
     * Key to retrieve support credentials from {@link FilterConfig}.
     */
    public static final String CORS_SUPPORT_CREDENTIALS = "cors.support.credentials";

    /**
     * Key to retrieve exposed headers from {@link FilterConfig}.
     */
    public static final String CORS_EXPOSED_HEADERS = "cors.exposed.headers";

    /**
     * Key to retrieve allowed headers from {@link FilterConfig}.
{'fraction_non_alphanumeric': 0.11161480029404558, 'fraction_numerical': 0.00490075961774075, 'mean_word_length': 3.514933628318584, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4328937', 'n_tokens_mistral': 2368, 'n_tokens_neox': 2292, 'n_words': 882}