package com.awesometickets.config;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;


/**
 * Cross-Origin Resource Sharing filter.
 */
public class CORSFilter implements Filter {

    public void init(FilterConfig filterConfig) throws ServletException {}

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
        HttpServletResponse res = (HttpServletResponse)response;
        res.setHeader("Access-Control-Allow-Origin", "http://localhost:8080");
        res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
        res.setHeader("Access-Control-Max-Age", "3600");
        res.setHeader("Access-Control-Allow-Headers", "x-requested-with");
        res.setHeader("Access-Control-Allow-Credentials", "true");
        chain.doFilter(request, response);
    }

    public void destroy() {}

}
@@ -40,27 +40,217 @@
 ort 
-java.io.IOException
+com.awesometickets.web.controller.CinemaController;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0Aimport java.util.HashSet;%0Aimport java.util.Set
 ;%0A%0Ai
@@ -460,16 +460,62 @@
 sponse;%0A
+import javax.servlet.http.HttpServletRequest;%0A
 import j
@@ -647,16 +647,257 @@
 Filter %7B
+%0A    private static final Logger Log = LoggerFactory.getLogger(CORSFilter.class);%0A    private static Set%3CString%3E allowedOrigins = new HashSet%3CString%3E(Arrays.asList(%0A        %22http://localhost%22, %22http://localhost:8080%22, %22http://stevennl.cn%22));
 %0A%0A    pu
@@ -1107,16 +1107,187 @@
 ption %7B%0A
+        HttpServletRequest req = (HttpServletRequest)request;%0A        String ori = req.getHeader(%22Origin%22);%0A        if (ori != null && allowedOrigins.contains(ori)) %7B%0A    
         
@@ -1343,16 +1343,20 @@
 sponse;%0A
+    
         
@@ -1404,34 +1404,18 @@
 n%22, 
-%22http://localhost:8080%22);%0A
+ori);%0A    
     
@@ -1495,32 +1495,36 @@
 LETE%22);%0A        
+    
 res.setHeader(%22A
@@ -1552,24 +1552,28 @@
 %22, %223600%22);%0A
+    
         res.
@@ -1635,32 +1635,36 @@
 with%22);%0A        
+    
 res.setHeader(%22A
@@ -1702,24 +1702,34 @@
 %22, %22true%22);%0A
+        %7D%0A
         chai

Update CROS fileter: allow only a few origins