|
@@ -33,7 +33,7 @@ public class ActionApi {
|
|
|
|
|
|
@Autowired
|
|
|
private IDanganService danganService;
|
|
|
- protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger("sys-user");
|
|
|
|
|
|
/**
|
|
|
* JSESSIONID=abbf57c4-eb7e-4ce8-9556-061a1cb9c016
|
|
@@ -43,10 +43,10 @@ public class ActionApi {
|
|
|
*/
|
|
|
@ApiOperation("子系统调AD")
|
|
|
@PostMapping()
|
|
|
- public AjaxResult userList(@RequestBody ValidateMessage validateMessage)throws Exception
|
|
|
+ public AjaxResult userList(@RequestBody ValidateMessage validateMessage)
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+ try {
|
|
|
if (!StringUtils.isNotEmpty(validateMessage.getClientKey())) {
|
|
|
return AjaxResult.error("请求失败!");
|
|
|
|
|
@@ -67,11 +67,12 @@ public class ActionApi {
|
|
|
|
|
|
//TODO 新逻辑 传递的reqid加上了自定义的字符串newReqid+时间,
|
|
|
//TODO 所以要取掉该字符串以便保证原逻辑不变的情况下设定每分钟更新新的reqid的进行验证,即当前系统会话内每一分钟传递新的reqid
|
|
|
- if(!StringUtils.isEmpty(validateMessage.getReqid())){
|
|
|
+ logger.info("reqid=" + validateMessage.getReqid());
|
|
|
+ if (!StringUtils.isEmpty(validateMessage.getReqid())) {
|
|
|
String reqid = validateMessage.getReqid();
|
|
|
- if(reqid.indexOf("newReqid")>0){
|
|
|
+ if (reqid.indexOf("newReqid") > 0) {
|
|
|
String[] reqidlist = reqid.split("newReqid");
|
|
|
- if(reqidlist.length>1){
|
|
|
+ if (reqidlist.length > 1) {
|
|
|
//TODO 说明有newReqid
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
long nh = 1000 * 60 * 60;
|
|
@@ -81,42 +82,38 @@ public class ActionApi {
|
|
|
// 获得两个时间的毫秒时间差异
|
|
|
long diff = new Date().getTime() - date.getTime();
|
|
|
long min = diff % nd % nh / nm;
|
|
|
- if(min>1){
|
|
|
+ if (min > 1) {
|
|
|
logger.error("reqid已过期");
|
|
|
return AjaxResult.error("授权已过期!");
|
|
|
}
|
|
|
}
|
|
|
- StringBuilder stringBuilder = new StringBuilder(reqid);
|
|
|
- stringBuilder.replace(reqid.indexOf("newReqid"),reqid.length(),"");
|
|
|
- validateMessage.setReqid(stringBuilder.toString());
|
|
|
+ validateMessage.setReqid(reqidlist[0]);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
logger.error("子系统未传递reqid");
|
|
|
}
|
|
|
- SysUserOnline sysUserOnline = onlineService.selectOnlineById( validateMessage.getReqid());
|
|
|
+ logger.info("reqidOut=" + validateMessage.getReqid());
|
|
|
+ SysUserOnline sysUserOnline = onlineService.selectOnlineById(validateMessage.getReqid());
|
|
|
|
|
|
if (StringUtils.isNull(sysUserOnline)) {
|
|
|
-
|
|
|
+ logger.error("授权已过期!");
|
|
|
return AjaxResult.error("授权已过期!");
|
|
|
}
|
|
|
String authCode = validateMessage.getAuthCode();
|
|
|
Dangan dangan = danganService.selectDanganByDanganName(validateMessage.getCid());
|
|
|
String keyId = dangan.getKeyId();
|
|
|
- String auth= keyId+validateMessage.getReqid();
|
|
|
+ String auth = keyId + validateMessage.getReqid();
|
|
|
|
|
|
- auth=new Md5Hash(auth).toHex();
|
|
|
+ auth = new Md5Hash(auth).toHex();
|
|
|
if (!auth.equals(authCode)) {
|
|
|
+ logger.error("授权码错误!");
|
|
|
return AjaxResult.error("授权码错误!");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
// bbccji7920f9df-baa7-4e9c-9e68-72c79454589a
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
String loginName = sysUserOnline.getLoginName();
|
|
|
UserRelate userRelate = new UserRelate();
|
|
|
userRelate.setLoginName(loginName);
|
|
@@ -125,6 +122,7 @@ public class ActionApi {
|
|
|
List<UserRelate> userRelates = userRelateService.selectUserRelateList(userRelate);
|
|
|
|
|
|
if (!StringUtils.isNotEmpty(userRelates)) {
|
|
|
+ logger.error("授权已过期!");
|
|
|
return AjaxResult.error("授权已过期!");
|
|
|
}
|
|
|
|
|
@@ -132,14 +130,18 @@ public class ActionApi {
|
|
|
//把用户名返回去
|
|
|
|
|
|
//生成校验码
|
|
|
- String str= keyId+validateMessage.getClientKey();
|
|
|
- str=new Md5Hash(str).toHex();
|
|
|
-
|
|
|
- AjaxResult ajaxResult=AjaxResult.success();
|
|
|
- ajaxResult.put("loginName",userRelate1.getDanganLoginName());
|
|
|
- ajaxResult.put("rspid",str);
|
|
|
+ String str = keyId + validateMessage.getClientKey();
|
|
|
+ str = new Md5Hash(str).toHex();
|
|
|
|
|
|
+ AjaxResult ajaxResult = AjaxResult.success();
|
|
|
+ ajaxResult.put("loginName", userRelate1.getDanganLoginName());
|
|
|
+ ajaxResult.put("rspid", str);
|
|
|
+ logger.error("授权成功!",ajaxResult.toString());
|
|
|
return ajaxResult;
|
|
|
+ }catch(Exception ex){
|
|
|
+ logger.error("异常:"+ex.getLocalizedMessage());
|
|
|
+ return AjaxResult.error("异常");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|