package org.gameon.map.filter;

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.annotation.WebFilter;

@WebFilter(
        filterName = "corsFilter",
        urlPatterns = {"/*"}
          )
public class AuthFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

        String id = request.getParameter("id");

        // TODO: a bunch of verification...
        if ( id == null )
            id = "game-on.org-provisional";

        request.setAttribute("player.id", id);

        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {
    }

}

@@ -308,16 +308,62 @@
 bFilter;
+%0Aimport javax.servlet.http.HttpServletRequest;
 %0A%0A@WebFi
@@ -879,16 +879,123 @@
     id =
+ ((HttpServletRequest)request).getHeader(%22gameon-id%22);%0A            if ( id == null ) %7B%0A                id =
  %22game-o
@@ -1014,16 +1014,29 @@
 ional%22;%0A
+            %7D
 %0A       
@@ -1075,17 +1075,16 @@
 %22, id);%0A
-%0A
         

Support gameon-id header while we transition to new auth..