package org.amc.game.chessserver.spring;

import org.apache.log4j.Logger;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import org.springframework.security.web.util.matcher.RequestMatcher;

import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;

public class CsrfSecurityRequestMatcher implements RequestMatcher {
    
    private static final Logger logger = Logger.getLogger(CsrfSecurityRequestMatcher.class);

    private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");
    private AntPathRequestMatcher webSocketPathRequestMatcher = new AntPathRequestMatcher("/app/chessgame/chessgame/**");
    private AntPathRequestMatcher topAntPathRequestMatcher = new AntPathRequestMatcher("/**");
    
    @Override
    public boolean matches(HttpServletRequest request) {
        if(allowedMethods.matcher(request.getMethod()).matches()){
            return false;
        } else if(webSocketPathRequestMatcher.matches(request)) {
            return false;
        } else if (topAntPathRequestMatcher.matches(request)){
            return true;
        }
        else {
            return false;
        }
    }

}

@@ -39,40 +39,8 @@
 g;%0A%0A
-import org.apache.log4j.Logger;%0A
 impo
@@ -333,106 +333,8 @@
 er %7B
-%0A    %0A    private static final Logger logger = Logger.getLogger(CsrfSecurityRequestMatcher.class);
 %0A%0A  
@@ -912,12 +912,29 @@
 lse 
-if (
+%7B%0A            return 
 topA
@@ -974,85 +974,8 @@
 est)
-)%7B%0A            return true;%0A        %7D%0A        else %7B%0A            return false
 ;%0A  

fix unnecessary if else statement