|
@@ -2,12 +2,14 @@ package cn.com.qmth.examcloud.core.basic.service.impl;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.esotericsoftware.minlog.Log;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
@@ -26,11 +28,11 @@ import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessDao;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccess;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessPK;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
|
|
@@ -67,7 +69,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
StudentRepo studentRepo;
|
|
|
|
|
|
@Autowired
|
|
|
- ThirdPartyAccessDao thirdPartyAccessDao;
|
|
|
+ ThirdPartyAccessRepo thirdPartyAccessRepo;
|
|
|
|
|
|
@Override
|
|
|
public User login(LoginInfo loginInfo) {
|
|
@@ -204,7 +206,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
throw new StatusException("B-001002", "机构不存在");
|
|
|
}
|
|
|
|
|
|
- ThirdPartyAccess thirdPartyAccess = thirdPartyAccessDao
|
|
|
+ ThirdPartyAccessEntity thirdPartyAccess = thirdPartyAccessRepo
|
|
|
.findOne(new ThirdPartyAccessPK(rootOrgId, appId));
|
|
|
|
|
|
if (null == thirdPartyAccess) {
|
|
@@ -218,8 +220,9 @@ public class AuthServiceImpl implements AuthService {
|
|
|
throw new StatusException("B-001202", "timestamp错误");
|
|
|
}
|
|
|
|
|
|
- if (Math.abs(System.currentTimeMillis() - timestampLong) > thirdPartyAccess
|
|
|
- .getTimeRange()) {
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
+ Log.debug("currentTimeMillis = " + currentTimeMillis);
|
|
|
+ if (Math.abs(currentTimeMillis - timestampLong) > thirdPartyAccess.getTimeRange()) {
|
|
|
throw new StatusException("B-001203", "timestamp超出时间差范围");
|
|
|
}
|
|
|
|
|
@@ -228,7 +231,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
byte[] bytes = SHA256.encode(joinStr);
|
|
|
String hexAscii = ByteUtil.toHexAscii(bytes);
|
|
|
|
|
|
- if (!hexAscii.equals(token)) {
|
|
|
+ if (!hexAscii.toLowerCase(Locale.US).equals(token.toLowerCase(Locale.US))) {
|
|
|
throw new StatusException("B-001204", "token校验失败");
|
|
|
}
|
|
|
|
|
@@ -238,7 +241,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
|
|
|
User user = new User();
|
|
|
-
|
|
|
+ user.setUserType(UserType.COMMON.getCode());
|
|
|
user.setUserId(userEntity.getId());
|
|
|
user.setDisplayName(userEntity.getLoginName());
|
|
|
user.setRootOrgId(userEntity.getRootOrgId());
|