修改token生成方式

master
zengwh 4 years ago
parent 693fbf0c85
commit 90c0840e7f

@ -250,7 +250,6 @@ public class FontController {
@ResponseBody
public Msg checkToken(String token) throws Exception{
if(StringUtils.isNotBlank(token) && StringUtils.isNotBlank(token) ) {
token = MD5.JM(Base64.decode(token));
Cache cache = CacheManager.getCacheInfo(token);
if (cache == null) {
return Msg.fail("token已过期或不存在");
@ -283,7 +282,6 @@ public class FontController {
if(StringUtils.isBlank(sysFlag)){
return Msg.fail("sysFlag不能为空!");
}
token = MD5.JM(Base64.decode(token));
Cache cacheInfo = CacheManager.getCacheInfo(token);
Power_UserVo user = (Power_UserVo) cacheInfo.getValue();
if(null != user){
@ -391,7 +389,7 @@ public class FontController {
return Msg.fail("用户名或密码不正确");
}
String date = String.valueOf(DateUtils.getDate());
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
List<Power_Menu> list = null;
List<User_Dept_Menu> menuList = new ArrayList<>();
@ -431,7 +429,7 @@ public class FontController {
userVo.setRemark(power_depts.toString());
//移除缓存
CacheManager.removeCacheByObject(userVo);
CacheManager.putCache(date,new Cache(date,userVo,TOKEN_EXPIRE_TIME));
CacheManager.putCache(token,new Cache(date,userVo,TOKEN_EXPIRE_TIME));
return Msg.success().add("token",token);
}

@ -82,7 +82,7 @@ public class LoginController {
MyCookieUtil.remember(request, response);
//设置token缓存
String date = String.valueOf(DateUtils.getDate());
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
//查询归属医院
@ -136,7 +136,7 @@ public class LoginController {
user.setRemark(power_depts.toString());
//设置进缓存
CacheManager.putCache(date,new Cache(date,user,TOKEN_EXPIRE_TIME));
CacheManager.putCache(token,new Cache(date,user,TOKEN_EXPIRE_TIME));
ActionScopeUtils.setSessionAttribute("CURRENT_USER",user,Integer.valueOf(String.valueOf(TOKEN_EXPIRE_TIME))/1000);
return "redirect:gatewayPage";
}else{

@ -66,10 +66,9 @@ public class PageController {
public String logout(HttpSession session,String token){
try {
session.invalidate();
token = MD5.JM(Base64.decode(token));
Cache cache = CacheManager.getCacheInfo(token);
if(cache != null){
//CacheManager.removeCacheByObject((Power_UserVo)cache.getValue());
CacheManager.removeCacheByObject((Power_UserVo)cache.getValue());
}
CacheManager.addExcCount("noExc");
}catch (Exception e){

@ -27,10 +27,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.*;
/**
* Author xuhx
@ -126,7 +123,7 @@ public class methodForEmrMedical {
if (password != null && !"".equals(password)) {
String date = String.valueOf(DateUtils.getDate());
//加密此部分代码来自FontController的getToken方法用来获取token及相关操作
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
List<Power_Menu> list = null;
List<User_Dept_Menu> menuList = new ArrayList<>();
Set<String> menus = new TreeSet<>();
@ -165,7 +162,7 @@ public class methodForEmrMedical {
user.setRemark(power_depts.toString());
//移除缓存
CacheManager.removeCacheByObject(user);
CacheManager.putCache(date, new Cache(date, user, TOKEN_EXPIRE_TIME));
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
if (!"".equals(token) && token != null) {
//返回跳转url
result = "http://" + ip + ":" + port + "/emr_medical_record/login?token=" + token + "&userName=" + userName;
@ -221,7 +218,7 @@ public class methodForEmrMedical {
if (password != null && !"".equals(password)) {
String date = String.valueOf(DateUtils.getDate());
//加密此部分代码来自FontController的getToken方法用来获取token及相关操作
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
List<Power_Menu> list = null;
List<User_Dept_Menu> menuList = new ArrayList<>();
Set<String> menus = new TreeSet<>();
@ -260,7 +257,7 @@ public class methodForEmrMedical {
user.setRemark(power_depts.toString());
//移除缓存
CacheManager.removeCacheByObject(user);
CacheManager.putCache(date, new Cache(date, user, TOKEN_EXPIRE_TIME));
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
if (!"".equals(token) && token != null) {
//返回跳转url
result = "http://" + ip2 + ":" + port2 + "/emr_record/login?token=" + token + "&userName=" + userName;
@ -299,7 +296,7 @@ public class methodForEmrMedical {
if (password != null && !"".equals(password)) {
String date = String.valueOf(DateUtils.getDate());
//加密此部分代码来自FontController的getToken方法用来获取token及相关操作
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
List<Power_Menu> list = null;
List<User_Dept_Menu> menuList = new ArrayList<>();
Set<String> menus = new TreeSet<>();
@ -337,7 +334,7 @@ public class methodForEmrMedical {
user.setRemark(power_depts.toString());
//移除缓存
CacheManager.removeCacheByObject(user);
CacheManager.putCache(date, new Cache(date, user, TOKEN_EXPIRE_TIME));
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
if (!"".equals(token) && token != null) {
//返回跳转url
result = "http://" + ip + ":" + port + "/emr_medical_record/login?token=" + token + "&userName=" + userName;
@ -374,7 +371,7 @@ public class methodForEmrMedical {
if (password != null && !"".equals(password)) {
String date = String.valueOf(DateUtils.getDate());
//加密此部分代码来自FontController的getToken方法用来获取token及相关操作
String token = Base64.encode(MD5.KL(date));
String token = UUID.randomUUID().toString();
List<Power_Menu> list = null;
List<User_Dept_Menu> menuList = new ArrayList<>();
Set<String> menus = new TreeSet<>();
@ -412,7 +409,7 @@ public class methodForEmrMedical {
user.setRemark(power_depts.toString());
//移除缓存
CacheManager.removeCacheByObject(user);
CacheManager.putCache(date, new Cache(date, user, TOKEN_EXPIRE_TIME));
CacheManager.putCache(token, new Cache(date, user, TOKEN_EXPIRE_TIME));
if (!"".equals(token) && token != null) {
//返回跳转url
result = "http://" + ip2 + ":" + port2 + "/emr_record/login?token=" + token + "&userName=" + userName;

@ -43,7 +43,6 @@ public class LoginInterceptor implements HandlerInterceptor {
}else{
String token = (String)request.getSession().getAttribute("token");
if(StringUtils.isNoneBlank(token)){
token = MD5.JM(Base64.decode(token));
Cache cache = CacheManager.getCacheInfo(token);
if (cache != null) {
return true;

@ -50,7 +50,6 @@ public class PowerWebServiceImpl implements PowerWebService {
public String getInfosByUserId(String token,String sysFlag) {
Power_UserWebServiceVo userWebServiceVo = new Power_UserWebServiceVo();
if(StringUtils.isNotBlank(token) && StringUtils.isNotBlank(token) ){
token = MD5.JM(Base64.decode(token));
Cache cache = CacheManager.getCacheInfo(token);
if(cache != null){
Power_UserVo user = (Power_UserVo) cache.getValue();
@ -62,7 +61,7 @@ public class PowerWebServiceImpl implements PowerWebService {
temp = power_user.getDeptId().split(delimeter);
for (int i = 0; i <temp.length ; i++) {
//查询表获得deptcode
if(power_deptMapper!=null&&temp[i]!=null){
if(power_deptMapper!=null&&StringUtils.isNotBlank(temp[i])){
Power_Dept power_dept = power_deptMapper.selectByPrimaryKeyDeptId(Integer.valueOf(temp[i]));
userDeptCodeList.add(power_dept.getDeptCode());
}

Loading…
Cancel
Save