Commit 5b9e7f23 by ddx

d

parent 64a8f4c2
......@@ -3,6 +3,7 @@ package com.tax.token.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.tax.token.constants.TokenConstants;
import com.tax.token.model.CleanCookieVo;
import com.tax.token.model.CookieReq;
......@@ -20,6 +21,22 @@ public class CleanCookieUtil {
private static final Logger logger = LoggerFactory.getLogger(CleanCookieUtil.class);
public static Map<String, String> cleanTypeMap = Maps.newHashMap();
static {
//对外的 cleanType 1.清app 2.清电子税局 3.清app+电子税局
//对内的 cleanType 13.清app 2.清电子税局 14.清app+电子税局
cleanTypeMap.put("1", "13");
cleanTypeMap.put("2", "2");
cleanTypeMap.put("3", "14");
}
public static String transfarCleanType(String oldCleanType) {
if(StringUtil.isEmpty(oldCleanType) || !cleanTypeMap.containsKey(oldCleanType)) {
oldCleanType = "2";
}
return cleanTypeMap.get(oldCleanType);
}
public static CleanCookieVo cleanCookie(String uuIdFlag, CookieReq cookieReq, String cleanType) throws IOException, HttpException {
CleanCookieVo cleanCookieVo = new CleanCookieVo();
String taxno = cookieReq.getTaxno();
......@@ -36,15 +53,22 @@ public class CleanCookieUtil {
}
} else {
if(StringUtil.isNotEmpty(cookieReq.getUserInfo())) {
JSONArray jsonArray = new JSONArray();
if (cleanType.equals("3")) {
jsonArray.add(cookieReq.getZoneCode() + ":" + cookieReq.getUserInfo());
} else if (cleanType.equals("13")) {
jsonArray.add(cookieReq.getLoginName() + ":" + cookieReq.getUserInfo());
if (cleanType.equals("13") || cleanType.equals("14")) {
JSONObject loginInfoJson = new JSONObject();
loginInfoJson.put("taxno", cookieReq.getTaxno());
loginInfoJson.put("dqdm", cookieReq.getZoneCode());
loginInfoJson.put("userName", cookieReq.getLoginName());
loginInfoJson.put("session", cookieReq.getUserInfo());
json.put("loginInfoJson", loginInfoJson);
} else {
jsonArray.add(cookieReq.getZoneCode() + ":" + taxno + ":" + cookieReq.getUserInfo());
JSONArray jsonArray = new JSONArray();
if (cleanType.equals("3")) {
jsonArray.add(cookieReq.getZoneCode() + ":" + cookieReq.getUserInfo());
} else {
jsonArray.add(cookieReq.getZoneCode() + ":" + taxno + ":" + cookieReq.getUserInfo());
}
json.put("keyList", jsonArray);
}
json.put("keyList", jsonArray);
} else {
if(null!=cookieReq.getUserInfoJson()) {
JSONObject loginInfoJson = JSON.parseObject(JSON.toJSONString(cookieReq.getUserInfoJson()));
......
......@@ -46,7 +46,7 @@ public interface TkTokenService {
JsonResult<String> selectErrorTokenList(String userCode, Integer pageId);
JsonResult<String> cleanCookie(String uuId, CookieReq cookieReq, String cleanType);
JsonResult<String> cleanCookie(String uuId, CookieReq cookieReq);
JsonResult<String> cleanGroupCookie(String uuId, CookieReq cookieReq);
......
......@@ -900,11 +900,16 @@ public class TkTokenServiceImpl implements TkTokenService {
}
public JsonResult<String> cleanCookie(String uuId, CookieReq cookieReq, String cleanType) {
public JsonResult<String> cleanCookie(String uuId, CookieReq cookieReq) {
JsonResult result = new JsonResult();
String taxno = cookieReq.getTaxno();
Date reqDate = DateUtils.getDate();
String oldCleanType = cookieReq.getCleanType();
String cleanType = CleanCookieUtil.transfarCleanType(oldCleanType);
logger.info(uuId + " cleanCookie taxno is " + taxno + " oldCleanType " + oldCleanType + " to newCleanType " + cleanType);
CleanCookieVo resMap = null;
try {
String newUserInfo = "";
......@@ -917,7 +922,7 @@ public class TkTokenServiceImpl implements TkTokenService {
String cookieString = EncryptUtil.decryptAesCk(cookie);
logger.info(uuId + " cleanCookie taxno is " + taxno + ", cookieString is " + cookieString);
JSONObject cookieJson = JSON.parseObject(cookieString);
if(cleanType.equals("13")) {
if(cleanType.equals("13") || cleanType.equals("14")) {
if (cookieJson.containsKey("session") && cookieJson.containsKey("userGroupName")) {
newUserInfo = cookieJson.getString("session");
loginName = cookieJson.getString("userGroupName");
......@@ -928,7 +933,7 @@ public class TkTokenServiceImpl implements TkTokenService {
}
}
} else {
if(cleanType.equals("13")) {
if(cleanType.equals("13") || cleanType.equals("14")) {
if (cookieInfoJson.containsKey("session") && cookieInfoJson.containsKey("userGroupName")) {
newUserInfo = cookieInfoJson.getString("session");
loginName = cookieInfoJson.getString("userGroupName");
......
......@@ -4,6 +4,8 @@ import com.tax.token.constants.TokenConstants;
import com.tax.token.integration.user.UserClient;
import com.tax.token.model.*;
import com.tax.token.service.api.TkTokenService;
import com.tax.token.service.impl.TkTokenServiceImpl;
import com.tax.token.utils.CleanCookieUtil;
import com.yxcheng.token.common.annotation.LogT;
import com.yxcheng.token.common.controller.BaseClientController;
import com.yxcheng.token.common.enumutil.ResultEnum;
......@@ -14,6 +16,8 @@ import com.yxcheng.token.utils.ObjectUtil;
import com.yxcheng.token.utils.StringUtil;
import com.yxcheng.token.utils.UUIDGenerator;
import com.yxcheng.token.utils.ZoneUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;
......@@ -28,6 +32,8 @@ import java.util.List;
@ComponentScan(basePackages = {"com.tax.token.service"})
public class TokenController extends BaseClientController {
private static final Logger logger = LoggerFactory.getLogger(TokenController.class);
@Autowired
private TkTokenService tokenService;
@Autowired
......@@ -198,10 +204,8 @@ public class TokenController extends BaseClientController {
}
cookieReq.setUserCode(cookieReq.getAccessKeyID());
String uuId = UUIDGenerator.generate();
if(StringUtil.isEmpty(cookieReq.getCleanType())) {
cookieReq.setCleanType("2");
}
JsonResult<String> jsonResult = tokenService.cleanCookie(uuId, cookieReq, cookieReq.getCleanType());
JsonResult<String> jsonResult = tokenService.cleanCookie(uuId, cookieReq);
return jsonResult;
}
......
......@@ -233,6 +233,8 @@ public class TokenUnitTest {
param.put("taxno","914404003980391901");
param.put("zoneCode","4400");
param.put("cleanType","3");
Map userparam = new HashMap<>();
//
// userparam.put("loginType","b");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment