| | |
| | | package cn.gistack.auth.service; |
| | | |
| | | import cn.gistack.auth.constant.AuthConstant; |
| | | import cn.gistack.common.utils.Base64Utils; |
| | | import cn.gistack.pwd.dto.CBCResultDTO; |
| | | import cn.gistack.pwd.dto.ResultDTO; |
| | | import cn.gistack.pwd.fegin.IPwdClient; |
| | | import cn.gistack.sm.collect.feign.ICollectClient; |
| | | import cn.gistack.sm.collect.feign.ICollectClientFallback; |
| | | import cn.gistack.sm.sjztmd.entity.AttResManagePerson; |
| | | import cn.gistack.sm.sjztmd.feign.IAttResManagePersonClient; |
| | | import cn.gistack.system.entity.Dept; |
| | | import cn.gistack.system.user.supo.UserSUPO; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import io.jsonwebtoken.Claims; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.time.Duration; |
| | | import java.util.Base64; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private final JwtProperties jwtProperties; |
| | | |
| | | private final ICollectClient collectClient; |
| | | |
| | | private final IPwdClient pwdClient; |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | |
| | | String collectResIds = collectClient.getMyCollect(user.getId().toString()); |
| | | userInfo.getDetail().set("collect",collectResIds); |
| | | |
| | | User loginUserInfo = userInfo.getUser(); |
| | | |
| | | //获取解密后的Base64字符串 |
| | | R<ResultDTO> encryptRes = pwdClient.getDecrypt(loginUserInfo.getSm4iv(), loginUserInfo.getKeyindexs(),loginUserInfo.getEncdata()); |
| | | |
| | | if (encryptRes.getCode() != 200){ |
| | | throw new UserDeniedAuthorizationException("获取密钥失败"); |
| | | } |
| | | |
| | | //解码Base64 |
| | | String base64Decode = Base64Utils.getBase64Decode(encryptRes.getData().getData()); |
| | | |
| | | UserSUPO userSUPO = JSONObject.parseObject(base64Decode, UserSUPO.class); |
| | | |
| | | //若登录用户的电话、角色、部门与原加密数据不符,登录失败 |
| | | if (!(loginUserInfo.getPhone().equals(userSUPO.getPhone()) && loginUserInfo.getRoleId().equals(userSUPO.getRoleId()) && loginUserInfo.getDeptId().equals(userSUPO.getDeptId())) ){ |
| | | throw new UserDeniedAuthorizationException("用户信息异常,请联系管理员"); |
| | | } |
| | | |
| | | return new BladeUserDetails(user.getId(), |
| | | user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR), |
| | | username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true, |