From 2ece6f6cd23d7b717881dd54a9fc74877096ecee Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期一, 07 五月 2018 23:13:59 +0800
Subject: [PATCH] 控制服务实现登录功能 和菜单展示,以及中心服务bug修复
---
java110-service/src/main/java/com/java110/service/filter/JwtFilter.java | 18 ++++++------------
1 files changed, 6 insertions(+), 12 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..47f59ff 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
@@ -9,6 +9,7 @@
import com.java110.common.constant.CommonConstant;
import com.java110.common.constant.ResponseConstant;
import com.java110.common.exception.FilterException;
+import com.java110.common.factory.AuthenticationFactory;
import com.java110.common.factory.DataTransactionFactory;
import com.java110.common.util.StringUtil;
import org.springframework.web.filter.GenericFilterBean;
@@ -40,17 +41,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 +57,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