|
@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.basic.service.impl;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -10,9 +11,11 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.esotericsoftware.minlog.Log;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.ByteUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.SHA256;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.StringUtil;
|
|
@@ -168,6 +171,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
user.setRootOrgName(rootOrg.getName());
|
|
|
user.setOrgId(student.getOrgId());
|
|
|
user.setDisplayName(student.getName());
|
|
|
+ user.setClientIp(loginInfo.getClientIp());
|
|
|
|
|
|
List<Role> roleList = Lists.newArrayList();
|
|
|
Role role = new Role(8L, "STUDENT", "学生");
|
|
@@ -190,12 +194,44 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- user.setClientIp(loginInfo.getClientIp());
|
|
|
+ if (isLcUser) {
|
|
|
+ setSecurityIp(user);
|
|
|
+ }
|
|
|
+
|
|
|
setSession(user);
|
|
|
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 设置安全IP
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param user
|
|
|
+ */
|
|
|
+ private void setSecurityIp(User user) {
|
|
|
+ String key = "IP_" + user.getOrgId();
|
|
|
+
|
|
|
+ String clientIp = user.getClientIp();
|
|
|
+ if (StringUtils.isBlank(clientIp)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String value = redisClient.get(key, String.class);
|
|
|
+ Set<String> userKeyList = null;
|
|
|
+ if (null == value) {
|
|
|
+ userKeyList = Sets.newHashSet();
|
|
|
+ } else {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ Set<String> v = JsonUtil.fromJson(value, Set.class);
|
|
|
+ userKeyList = v;
|
|
|
+ }
|
|
|
+
|
|
|
+ userKeyList.add(user.getKey());
|
|
|
+
|
|
|
+ redisClient.set(key, JsonUtil.toJson(userKeyList), 3600 * 12);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 是否是学习中心角色
|
|
|
*
|