|
@@ -574,25 +574,14 @@ public class AuthServiceImpl implements AuthService {
|
|
|
throw new StatusException("003205", "用户不存在");
|
|
|
}
|
|
|
|
|
|
- User user = new User();
|
|
|
- user.setUserType(UserType.COMMON);
|
|
|
- user.setUserId(userEntity.getId());
|
|
|
- user.setDisplayName(userEntity.getLoginName());
|
|
|
- user.setRootOrgId(userEntity.getRootOrgId());
|
|
|
-
|
|
|
- List<Role> roleList = getUserRoles(userEntity.getId());
|
|
|
- user.setRoleList(roleList);
|
|
|
-
|
|
|
- user.setClientIp(clientIp);
|
|
|
- setSession(user);
|
|
|
-
|
|
|
- boolean isLcUser = isLcUser(user);
|
|
|
-
|
|
|
- if (isLcUser) {
|
|
|
- setSecurityIp(user, userEntity.getOrgId());
|
|
|
- }
|
|
|
-
|
|
|
- return user;
|
|
|
+ LoginInfo loginInfo = new LoginInfo();
|
|
|
+ loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.name());
|
|
|
+ loginInfo.setAccountValue(loginName);
|
|
|
+ loginInfo.setClientIp(clientIp);
|
|
|
+ loginInfo.setRootOrgId(rootOrgId);
|
|
|
+ loginInfo.setPassword(userEntity.getPassword());
|
|
|
+
|
|
|
+ return login(loginInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -641,7 +630,77 @@ public class AuthServiceImpl implements AuthService {
|
|
|
@Override
|
|
|
public User thirdPartyStudentAccess(Long rootOrgId, String accountType, String accountValue,
|
|
|
String appId, String timestamp, String token, String clientIp) throws StatusException {
|
|
|
- return null;
|
|
|
+
|
|
|
+ OrgEntity rootOrg = GlobalHelper.getEntity(orgRepo, rootOrgId, OrgEntity.class);
|
|
|
+ if (null == rootOrg) {
|
|
|
+ throw new StatusException("003003", "机构不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ ThirdPartyAccessEntity thirdPartyAccess = GlobalHelper.getEntity(thirdPartyAccessRepo,
|
|
|
+ new ThirdPartyAccessPK(rootOrgId, appId), ThirdPartyAccessEntity.class);
|
|
|
+
|
|
|
+ if (null == thirdPartyAccess) {
|
|
|
+ throw new StatusException("003201", "第三方系统接入信息未配置");
|
|
|
+ }
|
|
|
+
|
|
|
+ long timestampLong = 0L;
|
|
|
+ try {
|
|
|
+ timestampLong = Long.parseLong(timestamp);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new StatusException("003202", "timestamp错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTimeMillis - timestampLong) > thirdPartyAccess.getTimeRange()) {
|
|
|
+ throw new StatusException("003203", "timestamp超出时间差范围");
|
|
|
+ }
|
|
|
+
|
|
|
+ String secretKey = thirdPartyAccess.getSecretKey();
|
|
|
+ String joinStr = StringUtil.join(accountType, accountValue, rootOrgId, appId, timestamp,
|
|
|
+ secretKey);
|
|
|
+ byte[] bytes = SHA256.encode(joinStr);
|
|
|
+ String hexAscii = ByteUtil.toHexAscii(bytes);
|
|
|
+
|
|
|
+ if (!hexAscii.equalsIgnoreCase(token)) {
|
|
|
+ throw new StatusException("003204", "token校验失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ AccountType accountTypeEnum = null;
|
|
|
+ try {
|
|
|
+ accountTypeEnum = AccountType.valueOf(accountType);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new StatusException("003204", "accountType is wrong");
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentEntity student = null;
|
|
|
+
|
|
|
+ if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)) {
|
|
|
+ student = studentRepo.findBySecurityPhone(accountValue);
|
|
|
+ } else if (AccountType.STUDENT_CODE.equals(accountTypeEnum)) {
|
|
|
+ StudentCodeEntity scEntity = studentCodeRepo.findByStudentCodeAndRootOrgId(accountValue,
|
|
|
+ rootOrg.getId());
|
|
|
+ if (null != scEntity) {
|
|
|
+ student = GlobalHelper.getEntity(studentRepo, scEntity.getStudentId(),
|
|
|
+ StudentEntity.class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 学生身份证号登录
|
|
|
+ else if (AccountType.STUDENT_IDENTITY_NUMBER.equals(accountTypeEnum)) {
|
|
|
+ student = studentRepo.findByIdentityNumberAndRootOrgId(accountValue, rootOrg.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == student) {
|
|
|
+ throw new StatusException("003110", "账号或密码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ LoginInfo loginInfo = new LoginInfo();
|
|
|
+ loginInfo.setAccountType(AccountType.STUDENT_IDENTITY_NUMBER.name());
|
|
|
+ loginInfo.setAccountValue(student.getIdentityNumber());
|
|
|
+ loginInfo.setClientIp(clientIp);
|
|
|
+ loginInfo.setRootOrgId(rootOrgId);
|
|
|
+ loginInfo.setPassword(student.getPassword());
|
|
|
+
|
|
|
+ return login(loginInfo);
|
|
|
}
|
|
|
|
|
|
}
|