From 6135498971ee5a76621f9f574927bc45bd2ad36a Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 07 五月 2019 00:33:42 +0800
Subject: [PATCH] 调整web服务docker文件
---
java110-core/src/main/java/com/java110/core/factory/AuthenticationFactory.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/java110-core/src/main/java/com/java110/core/factory/AuthenticationFactory.java b/java110-core/src/main/java/com/java110/core/factory/AuthenticationFactory.java
index d7e92a2..df20bcb 100644
--- a/java110-core/src/main/java/com/java110/core/factory/AuthenticationFactory.java
+++ b/java110-core/src/main/java/com/java110/core/factory/AuthenticationFactory.java
@@ -18,6 +18,7 @@
import com.java110.common.util.DateUtil;
import com.java110.common.util.StringUtil;
+import com.java110.core.context.ApiDataFlow;
import com.java110.core.context.DataFlow;
import org.apache.commons.codec.digest.DigestUtils;
@@ -36,6 +37,16 @@
* Created by wuxw on 2018/4/23.
*/
public class AuthenticationFactory {
+
+ private final static String PASSWD_SALT= "hc@java110";
+ /**
+ * 鐢ㄦ埛瀵嗙爜 md5绛惧悕
+ * @param inStr
+ * @return
+ */
+ public static String passwdMd5(String inStr) throws NoAuthorityException{
+ return md5(md5(inStr+PASSWD_SALT));
+ }
/**
* md5绛惧悕
@@ -62,6 +73,22 @@
String reqInfo = dataFlow.getTransactionId() +dataFlow.getAppId();
reqInfo += ((dataFlow.getReqBusiness() == null || dataFlow.getReqBusiness().size() == 0)
?dataFlow.getReqData() :dataFlow.getReqBusiness().toJSONString());
+ reqInfo += dataFlow.getAppRoutes().get(0).getSecurityCode();
+ return md5(reqInfo);
+ }
+
+ /**
+ * dataFlow 瀵硅薄绛惧悕
+ * @param dataFlow
+ * @return
+ */
+ public static String apiDataFlowMd5(ApiDataFlow dataFlow) throws NoAuthorityException{
+ if(dataFlow == null){
+ throw new NoAuthorityException(ResponseConstant.RESULT_CODE_NO_AUTHORITY_ERROR,"MD5绛惧悕杩囩▼涓嚭鐜伴敊璇�");
+ }
+ String reqInfo = dataFlow.getTransactionId() + dataFlow.getRequestTime() + dataFlow.getAppId();
+ reqInfo += "GET,DELETE".equals(dataFlow.getRequestHeaders().get(CommonConstant.HTTP_METHOD))?
+ dataFlow.getRequestHeaders().get("REQUEST_URL") :dataFlow.getReqData();
reqInfo += dataFlow.getAppRoutes().get(0).getSecurityCode();
return md5(reqInfo);
}
@@ -299,6 +326,28 @@
}
/**
+ * 鍒犻櫎Token
+ * @param token
+ * @return
+ * @throws Exception
+ */
+ public static void deleteToken(String token) throws Exception{
+ String jwtSecret = MappingCache.getValue(MappingConstant.KEY_JWT_SECRET);
+ if(StringUtil.isNullOrNone(jwtSecret)){
+ jwtSecret = CommonConstant.DEFAULT_JWT_SECRET;
+ }
+ Algorithm algorithm = Algorithm.HMAC256(jwtSecret);
+ JWTVerifier verifier = JWT.require(algorithm).withIssuer("java110").build();
+ DecodedJWT jwt = verifier.verify(token);
+ String jdi = jwt.getId();
+ //淇濆瓨token Id
+ String userId = JWTCache.getValue(jdi);
+ if(!StringUtil.isNullOrNone(userId)){ //璇存槑redis涓璲di 宸茬粡澶辨晥
+ JWTCache.removeValue(jdi);
+ }
+ }
+
+ /**
* 鏍¢獙Token
* @param token
* @return
--
Gitblit v1.8.0