<commit_before>package org.jcors.config;

import java.util.HashSet;
import java.util.Set;

import org.jcors.util.Constraint;

/**
 * Class that represents the filter configuration
 * 
 * @author <NAME>
 */
public final class JCorsConfiguration {

	private boolean enableNonCorsRequests = true;
	private boolean resourcesSupportsCredentials = true;
	private Set<String> allowedOrigins = new HashSet<String>();
	private Set<String> exposedHeaders = new HashSet<String>();
	private Set<String> allowedHeaders = new HashSet<String>();

	public boolean isNonCorsRequestsEnabled() {

		return enableNonCorsRequests;
	}

	public boolean isCredentialsSupported() {

		return resourcesSupportsCredentials;
	}

	public boolean isAllOriginsAllowed() {

		return allowedOrigins.isEmpty() || allowedOrigins.contains("*");
	}

	public boolean isOriginAllowed(String origin) {

		return isAllOriginsAllowed() || allowedOrigins.contains(origin);
	}

	public void addAllowedOrigin(String allowedOrigin) {

		Constraint.ensureNotEmpty(allowedOrigin, String.format("Invalid allowed origin '%s'", allowedOrigin));
		allowedOrigins.add(allowedOrigin);
	}

	public boolean hasNotSimpleResponseHeadersExposed() {

		return !exposedHeaders.isEmpty();
	}

	public String getExposedHeaders() {

		StringBuffer buffer = new StringBuffer();
		for (String header : exposedHeaders) {
			buffer.append(header).append(" ");
		}
		return buffer.length() > 0 ? buffer.substring(0, buffer.length() - 1) : buffer.toString();
	}

}<commit_msg>Modifying the configuration class<commit_after>package org.jcors.config;

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

import org.jcors.util.Constraint;

/**
 * Class that represents the filter configuration
 * 
 * @author <NAME>
 */
public final class JCorsConfiguration {

	private boolean enableNonCorsRequests = true;
	private boolean resourcesSupportsCredentials = true;
	private int preflightResultCacheMaxAge = 0;
	private Set<String> allowedOrigins = new HashSet<String>();
	private Set<String> exposedHeaders = new HashSet<String>();
	private Set<String> allowedHeaders = new HashSet<String>();
	private Set<String> allowedMethods = new HashSet<String>();

	/**
	 * Check if conventional requests are enabled
	 * 
	 * @return
	 */
	public boolean isNonCorsRequestsEnabled() {

		return enableNonCorsRequests;
	}

	/**
	 * Check if the resource supports credenials
	 * 
	 * @return
	 */
	public boolean isCredentialsSupported() {

		return resourcesSupportsCredentials;
	}

	/**
	 * Check if the preflight result cache is enabled
	 * 
	 * @return
	 */
	public boolean isPreflightResultCacheEnabled() {

		return preflightResultCacheMaxAge > 0;
	}

	/**
	 * Get the delta-seconds that indicates how long the results of a preflight request can be cached in a preflight result cache
	 * 
	 * @return
	 */
	public int getPreflightResultCacheMaxAge() {
		return preflightResultCacheMaxAge;
	}

	/**
	 * Check if the origin is allowed by the resource
	 * 
	 * @param origin
	 * @return
	 */
	public boolean isOriginAllowed(String origin) {

		return allowedOrigins.isEmpty() || allowedOrigins.contains(origin);
	}

	/**
	 * Add an origin allowed by the resource
	 * 
	 * @param origin
	 */
	public void addAllowedOrigin(String origin) {

		Constraint.ensureNotEmpty(origin, String.format("Invalid origin '%s'", origin));
		allowedOrigins.add(origin);
	}

	/**
	 * Check if there are any non-simple resource header exposed
	 * 
	 * @return
	 */
	public boolean hasNotSimpleResponseHeadersExposed() {

		return !exposedHeaders.isEmpty();
	}

	/**
	 * Add a non-simple resource header exposed by the resource. A simple resource header is one of these: Cache-Control, Content-Language,
	 * Content-Type, Expires, Last-Modified, Pragma
	 * 
	 * @param header
	 */
	public void addExposedHeader(String header) {

		Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header));
		exposedHeaders.add(header);
	}

	/**
	 * Return all non-simple resource headers exposed by the resource
	 * 
	 * @return
	 */
	public Collection<String> getExposedHeaders() {

		return exposedHeaders;
	}

	/**
	 * Check if the header is allowed by the resource. This check is case-insensitive
	 * 
	 * @param header
	 * @return
	 */
	public boolean isHeaderAllowed(String header) {

		return allowedHeaders.isEmpty() || allowedHeaders.contains(header.toLowerCase());
	}

	/**
	 * Add a header allowed by the resource
	 * 
	 * @param header
	 */
	public void addAllowedHeader(String header) {

		Constraint.ensureNotEmpty(header, String.format("Invalid header '%s'", header));
		allowedHeaders.add(header.toLowerCase());
	}

	/**
	 * Return all headers allowed by the resource, including the preflight request headers
	 * 
	 * @param requestHeaders
	 * @return
	 */
	public Collection<String> getAllowedHeaders(Collection<String> requestHeaders) {

		Constraint.ensureNotNull(requestHeaders, "Null headers");
		Set<String> rtAllowedHeaders = new HashSet<String>(allowedHeaders);
		rtAllowedHeaders.addAll(requestHeaders);

		return rtAllowedHeaders;
	}

	/**
	 * Check if the method is allowed by the resource This check is case-sensitive
	 * 
	 * @param method
	 * @return
	 */
	public boolean isMethodAllowed(String method) {

		return allowedMethods.isEmpty() || allowedMethods.contains(method);
	}

	/**
	 * Add a method allowed by the resource
	 * 
	 * @param method
	 */
	public void addAllowedMethod(String method) {

		Constraint.ensureNotEmpty(method, String.format("Invalid method '%s'", method));
		allowedMethods.add(method.toUpperCase());
	}

	/**
	 * Return all methods allowed by the resource, including the preflight request method
	 * 
	 * @param requestMethod
	 * @return
	 */
	public Collection<String> getAllowedMethods(String requestMethod) {

		Constraint.ensureNotEmpty(requestMethod, String.format("Invalid method '%s'", requestMethod));
		Set<String> rtAllowedMethods = new HashSet<String>(allowedMethods);
		rtAllowedMethods.add(requestMethod.toUpperCase());

		return rtAllowedMethods;
	}

}
{'fraction_non_alphanumeric': 0.1056198347107438, 'fraction_numerical': 0.0008264462809917355, 'mean_word_length': 4.480978260869565, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6884996', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1672, 'n_words': 471}