From d7717df0f80aac77eec9ba0345ea7f4487143f75 Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期日, 25 十一月 2018 01:05:24 +0800
Subject: [PATCH] 修改域名bug

---
 java110-service/src/main/java/com/java110/service/filter/JwtFilter.java |   27 +++++++--------------------
 1 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/java110-service/src/main/java/com/java110/service/filter/JwtFilter.java b/java110-service/src/main/java/com/java110/service/filter/JwtFilter.java
index 7c7cdb0..5d2715c 100644
--- a/java110-service/src/main/java/com/java110/service/filter/JwtFilter.java
+++ b/java110-service/src/main/java/com/java110/service/filter/JwtFilter.java
@@ -1,15 +1,10 @@
 package com.java110.service.filter;
 
-import com.auth0.jwt.JWT;
-import com.auth0.jwt.JWTVerifier;
-import com.auth0.jwt.algorithms.Algorithm;
-import com.auth0.jwt.exceptions.JWTVerificationException;
-import com.auth0.jwt.interfaces.Claim;
-import com.auth0.jwt.interfaces.DecodedJWT;
 import com.java110.common.constant.CommonConstant;
 import com.java110.common.constant.ResponseConstant;
 import com.java110.common.exception.FilterException;
-import com.java110.common.factory.DataTransactionFactory;
+import com.java110.core.factory.AuthenticationFactory;
+import com.java110.core.factory.DataTransactionFactory;
 import com.java110.common.util.StringUtil;
 import org.springframework.web.filter.GenericFilterBean;
 
@@ -22,7 +17,6 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
 import java.util.Map;
 
 /**
@@ -40,17 +34,10 @@
             //鑾峰彇token
             token = this.getToken(request);
             try {
-                Algorithm algorithm = Algorithm.HMAC256("secret");
-                JWTVerifier verifier = JWT.require(algorithm).withIssuer("auth0").build();
-                DecodedJWT jwt = verifier.verify(token);
-
-                Map<String, Claim> claims = jwt.getClaims();
-                // Add the claim to request header
+                Map<String, String> claims = AuthenticationFactory.verifyToken(token);
                 request.setAttribute("claims", claims);
-            } catch (UnsupportedEncodingException e) {
-                logger.error("瑙f瀽token 澶辫触 锛�", e);
-                throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "鎮ㄨ繕娌℃湁鐧诲綍锛岃鍏堢櫥褰�");
-            } catch (JWTVerificationException e) {
+
+            } catch (Exception e) {
                 //Invalid signature/claims
                 logger.error("瑙f瀽token 澶辫触 锛�", e);
                 throw new FilterException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR, "鎮ㄨ繕娌℃湁鐧诲綍锛岃鍏堢櫥褰�");
@@ -63,11 +50,11 @@
                         DataTransactionFactory.pageResponseJson(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,e.getMessage(),null),
                         "UTF-8");
             }else{
-                response.sendRedirect("/error?code="+e.getResult().getCode()+"&msg="+e.getResult().getMsg());
+                response.sendRedirect("/login?code="+e.getResult().getCode()+"&msg="+e.getResult().getMsg());
             }
 
         }catch (Exception e){
-            response.sendRedirect("/error?code="+ResponseConstant.RESULT_CODE_INNER_ERROR+"&msg=閴存潈澶辫触");
+            response.sendRedirect("/login?code="+ResponseConstant.RESULT_CODE_INNER_ERROR+"&msg=閴存潈澶辫触");
         }
     }
 

--
Gitblit v1.8.0