|
@@ -3,11 +3,15 @@ package com.zhongzheng.framework.web.service;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
+import com.zhongzheng.common.core.domain.model.LoginBody;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.framework.manager.factory.AsyncFactory;
|
|
|
import com.zhongzheng.modules.system.service.ISysUserService;
|
|
|
import com.zhongzheng.common.utils.AES;
|
|
|
import com.zhongzheng.framework.manager.factory.AsyncFactory;
|
|
|
+import com.zhongzheng.modules.user.bo.UserBusinessLoginBo;
|
|
|
import org.apache.commons.compress.utils.IOUtils;
|
|
|
import org.bouncycastle.jcajce.provider.asymmetric.rsa.RSAUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -49,6 +53,8 @@ public class SysLoginService
|
|
|
@Autowired
|
|
|
private ISysUserService iSysUserService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 登录验证
|
|
|
*
|
|
@@ -90,8 +96,6 @@ public class SysLoginService
|
|
|
if(password.length()>20){
|
|
|
password = AES.decrypt(password,rsaPrivate);
|
|
|
}
|
|
|
- System.out.println(password);
|
|
|
- System.out.println("密码");
|
|
|
authentication = authenticationManager
|
|
|
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
|
|
}
|
|
@@ -116,6 +120,47 @@ public class SysLoginService
|
|
|
return tokenService.createToken(loginUser);
|
|
|
}
|
|
|
|
|
|
+ public String businessLogin(UserBusinessLoginBo loginBody)
|
|
|
+ {
|
|
|
+ String password;
|
|
|
+ if(Validator.isEmpty(loginBody.getPwd())){
|
|
|
+ throw new CustomException("密码不能为空");
|
|
|
+ }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ String rsaPrivate = null;
|
|
|
+ try {
|
|
|
+ InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("config/pri.key");
|
|
|
+ rsaPrivate = AES.getStringByInputStream_1(certStream);
|
|
|
+ certStream.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CustomException("参数错误"+e.getMessage());
|
|
|
+ }
|
|
|
+ password = AES.decrypt(loginBody.getPwd(),rsaPrivate);
|
|
|
+ String[] param = password.split("#");
|
|
|
+ if(param.length!=2||!"test".equals(param[0])){
|
|
|
+ throw new CustomException("参数内容非法");
|
|
|
+ }
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ Long paramTime = Long.valueOf(param[1]);
|
|
|
+ if(Validator.isEmpty(paramTime)||Math.abs(paramTime.longValue()-nowTime.longValue())>30){
|
|
|
+ throw new CustomException("参数内容错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ throw new CustomException(e.getMessage());
|
|
|
+ }
|
|
|
+ String username = "admin";
|
|
|
+ LoginUser loginUser = new LoginUser();
|
|
|
+ //普通系统用户
|
|
|
+ SysUser user = iSysUserService.selectUserByUserName(username);
|
|
|
+ user = iSysUserService.updateLoginTimeIp(user.getUserId());
|
|
|
+ loginUser.setUser(user);
|
|
|
+ // 生成token
|
|
|
+ return tokenService.createToken(loginUser);
|
|
|
+ }
|
|
|
+
|
|
|
/* public String wx_login(String username)
|
|
|
{
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|