|
|
@@ -1,118 +0,0 @@
|
|
|
-//package com.nb.common.util;
|
|
|
-//
|
|
|
-//import cn.dev33.satoken.spring.SpringMVCUtil;
|
|
|
-//import cn.dev33.satoken.stp.StpUtil;
|
|
|
-//import cn.hutool.core.collection.CollUtil;
|
|
|
-//import cn.hutool.core.util.StrUtil;
|
|
|
-//import cn.hutool.crypto.digest.BCrypt;
|
|
|
-//import com.nb.core.Constants;
|
|
|
-//import com.nb.common.bo.LoginUser;
|
|
|
-//import com.nb.common.bo.SysRoleBO;
|
|
|
-//import com.nb.common.bo.SysUserBO;
|
|
|
-//import com.nb.core.enums.GrantTypeEnum;
|
|
|
-//
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Objects;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * 安全服务工具类
|
|
|
-// *
|
|
|
-// * @author Kevin
|
|
|
-// */
|
|
|
-//public class SecurityUtil {
|
|
|
-// /**
|
|
|
-// * 获取用户账户
|
|
|
-// **/
|
|
|
-// public static String getUsername() {
|
|
|
-// return getLoginUser().getUsername();
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取系统用户
|
|
|
-// **/
|
|
|
-// public static SysUserBO getSysUser() {
|
|
|
-// return getLoginUser().getSysUser();
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取用户
|
|
|
-// **/
|
|
|
-// public static LoginUser getLoginUser() {
|
|
|
-// try {
|
|
|
-// return (LoginUser) StpUtil.getTokenSession().get(Constants.LOGIN_USER_KEY);
|
|
|
-// } catch (Exception ex) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 获取用户
|
|
|
-// **/
|
|
|
-// public static void setLogin(LoginUser loginUser) {
|
|
|
-// StpUtil.getTokenSession().set(Constants.LOGIN_USER_KEY,loginUser);
|
|
|
-// }
|
|
|
-//
|
|
|
-// public static boolean isSys(){
|
|
|
-// LoginUser loginUser = getLoginUser();
|
|
|
-// if(loginUser==null){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// String grantType = loginUser.getGrantType();
|
|
|
-// if (GrantTypeEnum.APPKEY_APPSECRET.getCode().equalsIgnoreCase(grantType)) {
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// return Boolean.TRUE.equals(loginUser.getIsSys());
|
|
|
-// }
|
|
|
-//
|
|
|
-// public static String getTenantId(){
|
|
|
-// return String.valueOf(SpringMVCUtil.getRequest().getAttribute("tenantId"));
|
|
|
-// }
|
|
|
-// /**
|
|
|
-// * 是否是超级管理员
|
|
|
-// **/
|
|
|
-// public static Boolean isSuperAdmin() {
|
|
|
-// String grantType = getLoginUser().getGrantType();
|
|
|
-// if (GrantTypeEnum.APPKEY_APPSECRET.getCode().equalsIgnoreCase(grantType)) {
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// List<SysRoleBO> roles = getSysUser().getRoles();
|
|
|
-// if(CollUtil.isEmpty(roles)){
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-// return roles.stream().filter(role-> StrUtil.isNotBlank(role.getRoleCode()))
|
|
|
-// .map(SysRoleBO::getRoleCode)
|
|
|
-// .collect(Collectors.toSet())
|
|
|
-// .contains("admin");
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 是否是超级管理员
|
|
|
-// **/
|
|
|
-// public static Boolean isSysSuperAdmin(Long userId) {
|
|
|
-// return Objects.nonNull(userId) && userId == 1L;
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 生成BCryptPasswordEncoder密码
|
|
|
-// *
|
|
|
-// * @param password 密码
|
|
|
-// * @return 加密字符串
|
|
|
-// */
|
|
|
-// public static String encryptPassword(String password) {
|
|
|
-// return BCrypt.hashpw(password);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 判断密码是否相同
|
|
|
-// *
|
|
|
-// * @param rawPassword 真实密码
|
|
|
-// * @param encodedPassword 加密后字符
|
|
|
-// * @return 结果
|
|
|
-// */
|
|
|
-// public static boolean matchesPassword(String rawPassword, String encodedPassword) {
|
|
|
-// return BCrypt.checkpw(rawPassword, encodedPassword);
|
|
|
-// }
|
|
|
-//
|
|
|
-//}
|