// Path: src/main/java/yourwebproject2/service/UserService.java
// public interface UserService extends BaseService<User, Long> {
// 
//     /**
//      * Register a new user into the system
//      *
//      * @param user
//      * @param request
//      *
//      * @return
//      */
//     public User registerUser(User user, HttpServletRequest request);
// 
// 
//     /**
//      * Login a new user into the system
//      *
//      * @param user
//      * @param request
//      *
//      * @return
//      */
//     public User loginUser(User user, HttpServletRequest request);
// 
// 
//     /**
//      * Method to validate whether the given password
//      * is same as users password stored in the system
//      *
//      * @param user
//      * @param pass
//      *
//      * @return
//      */
//     public boolean isValidPass(User user, String pass);
// 
// 
//     /**
//      * Validates whether the given email already
//      * exists in the system.
//      *
//      * @param email
//      *
//      * @return
//      */
//     public boolean isEmailExists(String email);
// 
// 
//     /**
//      * Finds a user entity by the given email
//      *
//      * @param email
//      * @return
//      */
//     public User findByEmail(String email) throws EmailNotFoundException;
// }


import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import yourwebproject2.service.UserService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
package yourwebproject2.auth;



/**
 * @author: kameshr
 */
public class JWTTokenAuthFilter extends OncePerRequestFilter {
    private static List<Pattern> AUTH_ROUTES = new ArrayList<>();
    private static List<String> NO_AUTH_ROUTES = new ArrayList<>();
    public static final String JWT_KEY = "JWT-TOKEN-SECRET";

    static {
        AUTH_ROUTES.add(Pattern.compile("/api/*"));
        NO_AUTH_ROUTES.add("/api/user/authenticate");
        NO_AUTH_ROUTES.add("/api/user/register");
    }

    private Logger LOG = LoggerFactory.getLogger(JWTTokenAuthFilter.class);

    @Autowired
// Path: src/main/java/yourwebproject2/service/UserService.java
// public interface UserService extends BaseService<User, Long> {
// 
//     /**
//      * Register a new user into the system
//      *
//      * @param user
//      * @param request
//      *
//      * @return
//      */
//     public User registerUser(User user, HttpServletRequest request);
// 
// 
//     /**
//      * Login a new user into the system
//      *
//      * @param user
//      * @param request
//      *
//      * @return
//      */
//     public User loginUser(User user, HttpServletRequest request);
// 
// 
//     /**
//      * Method to validate whether the given password
//      * is same as users password stored in the system
//      *
//      * @param user
//      * @param pass
//      *
//      * @return
//      */
//     public boolean isValidPass(User user, String pass);
// 
// 
//     /**
//      * Validates whether the given email already
//      * exists in the system.
//      *
//      * @param email
//      *
//      * @return
//      */
//     public boolean isEmailExists(String email);
// 
// 
//     /**
//      * Finds a user entity by the given email
//      *
//      * @param email
//      * @return
//      */
//     public User findByEmail(String email) throws EmailNotFoundException;
// }


// Path: src/main/java/yourwebproject2/auth/JWTTokenAuthFilter.java
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import yourwebproject2.service.UserService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

package yourwebproject2.auth;



/**
 * @author: kameshr
 */
public class JWTTokenAuthFilter extends OncePerRequestFilter {
    private static List<Pattern> AUTH_ROUTES = new ArrayList<>();
    private static List<String> NO_AUTH_ROUTES = new ArrayList<>();
    public static final String JWT_KEY = "JWT-TOKEN-SECRET";

    static {
        AUTH_ROUTES.add(Pattern.compile("/api/*"));
        NO_AUTH_ROUTES.add("/api/user/authenticate");
        NO_AUTH_ROUTES.add("/api/user/register");
    }

    private Logger LOG = LoggerFactory.getLogger(JWTTokenAuthFilter.class);

    @Autowired
    private UserService userService;