/*******************************************************************************
 * # Copyright 2015 InfinitiesSoft Solutions Inc.
 * #
 * # 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.infinities.keystone4j;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MultivaluedMap;

public class CORSResponseFilter implements ContainerResponseFilter {

	@Override
	public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {

		MultivaluedMap<String, Object> headers = responseContext.getHeaders();

		headers.add("Access-Control-Allow-Origin", "*");
		// headers.add("Access-Control-Allow-Origin",
		// "http://podcastpedia.org"); //allows CORS requests only coming from
		// podcastpedia.org
		headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
		headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, ,X-Subject-Token, X-Auth-Token");
		headers.add("Access-Control-Expose-Headers", "X-Requested-With, Content-Type, ,X-Subject-Token, X-Auth-Token");
	}

}

@@ -855,16 +855,50 @@
 ption;%0A%0A
+import javax.annotation.Priority;%0A
 import j
@@ -1097,76 +1097,241 @@
 p;%0A%0A
-public class CORSResponseFilter implements ContainerResponseFilter %7B
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A@Priority(1000)%0Apublic class CORSResponseFilter implements ContainerResponseFilter %7B%0A%0A%09private static final Logger logger = LoggerFactory.getLogger(CORSResponseFilter.class);%0A
 %0A%0A%09@
@@ -1462,16 +1462,46 @@
 ption %7B%0A
+%09%09logger.debug(%22filter cors%22);
 %0A%09%09Multi
@@ -1830,16 +1830,23 @@
 ETE, PUT
+, PATCH
 %22);%0A%09%09he
@@ -2071,11 +2071,10 @@
 n%22);%0A%09%7D%0A
-%0A
 %7D%0A

update CORSResponseFilter