/**
 *    Copyright 2016 Sven Loesekann

   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 ch.xxx.trader.jwt;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.filter.GenericFilterBean;

public class JwtTokenFilter extends GenericFilterBean {

	private JwtTokenProvider jwtTokenProvider;

	  public JwtTokenFilter(JwtTokenProvider jwtTokenProvider) {
	    this.jwtTokenProvider = jwtTokenProvider;
	  }

	  @Override
	  public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain)
	      throws IOException, ServletException {
	    
	    String token = jwtTokenProvider.resolveToken((HttpServletRequest) req);
	    if (token != null && jwtTokenProvider.validateToken(token)) {
	      Authentication auth = token != null ? jwtTokenProvider.getAuthentication(token) : null;
	      SecurityContextHolder.getContext().setAuthentication(auth);
	    }
	    filterChain.doFilter(req, res);
	}

}

@@ -837,24 +837,81 @@
 etRequest;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import org.s
@@ -1141,16 +1141,90 @@
 rBean %7B%0A
+%09private final Logger LOG = LoggerFactory.getLogger(JwtTokenFilter.class);
 %0A%09privat
@@ -1262,18 +1262,16 @@
 ider;%0A%0A%09
-  
 public J
@@ -1322,20 +1322,17 @@
 der) %7B%0A%09
-    
+%09
 this.jwt
@@ -1370,16 +1370,12 @@
 r;%0A%09
-  
 %7D%0A%0A%09
-  
 @Ove
@@ -1381,18 +1381,16 @@
 erride%0A%09
-  
 public v
@@ -1469,22 +1469,18 @@
 Chain)%0A%09
-      
+%09%09
 throws I
@@ -1514,19 +1514,68 @@
 n %7B%0A
-%09    %0A%09    
+%0A%09%09HttpServletRequest httpReq = (HttpServletRequest) req;%0A%09%09
 Stri
@@ -1647,16 +1647,74 @@
 );%0A%09
-    if (
+%09if (httpReq.getRequestURL().toString().contains(%22/orderbook%22) && 
 toke
@@ -1768,22 +1768,18 @@
 en)) %7B%0A%09
-      
+%09%09
 Authenti
@@ -1859,22 +1859,18 @@
  null;%0A%09
-      
+%09%09
 Security
@@ -1926,19 +1926,14 @@
 );%0A%09
-    %7D%0A%09    
+%09%7D%0A%0A%09%09
 filt

improve filter