|
|
|
@ -2,7 +2,6 @@ package com.ruoyi.framework.shiro.realm;
|
|
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
|
import org.apache.shiro.authc.AuthenticationException;
|
|
|
|
|
import org.apache.shiro.authc.AuthenticationInfo;
|
|
|
|
|
import org.apache.shiro.authc.AuthenticationToken;
|
|
|
|
@ -14,20 +13,22 @@ import org.apache.shiro.authc.UnknownAccountException;
|
|
|
|
|
import org.apache.shiro.authc.UsernamePasswordToken;
|
|
|
|
|
import org.apache.shiro.authz.AuthorizationInfo;
|
|
|
|
|
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
|
|
|
|
import org.apache.shiro.cache.Cache;
|
|
|
|
|
import org.apache.shiro.realm.AuthorizingRealm;
|
|
|
|
|
import org.apache.shiro.subject.PrincipalCollection;
|
|
|
|
|
import org.apache.shiro.subject.SimplePrincipalCollection;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.ruoyi.common.exception.user.CaptchaException;
|
|
|
|
|
import com.ruoyi.common.exception.user.RoleBlockedException;
|
|
|
|
|
import com.ruoyi.common.exception.user.UserBlockedException;
|
|
|
|
|
import com.ruoyi.common.exception.user.UserNotExistsException;
|
|
|
|
|
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
|
|
|
|
import com.ruoyi.common.exception.user.UserPasswordRetryLimitExceedException;
|
|
|
|
|
import com.ruoyi.common.utils.ShiroUtils;
|
|
|
|
|
import com.ruoyi.framework.shiro.service.SysLoginService;
|
|
|
|
|
import com.ruoyi.framework.util.ShiroUtils;
|
|
|
|
|
import com.ruoyi.system.domain.SysUser;
|
|
|
|
|
import com.ruoyi.system.service.ISysMenuService;
|
|
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
|
|
|
|
|
|
|
@ -132,10 +133,26 @@ public class UserRealm extends AuthorizingRealm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 清理缓存权限
|
|
|
|
|
* 清理指定用户授权信息缓存
|
|
|
|
|
*/
|
|
|
|
|
public void clearCachedAuthorizationInfo()
|
|
|
|
|
public void clearCachedAuthorizationInfo(Object principal)
|
|
|
|
|
{
|
|
|
|
|
this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals());
|
|
|
|
|
SimplePrincipalCollection principals = new SimplePrincipalCollection(principal, getName());
|
|
|
|
|
this.clearCachedAuthorizationInfo(principals);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 清理所有用户授权信息缓存
|
|
|
|
|
*/
|
|
|
|
|
public void clearAllCachedAuthorizationInfo()
|
|
|
|
|
{
|
|
|
|
|
Cache<Object, AuthorizationInfo> cache = getAuthorizationCache();
|
|
|
|
|
if (cache != null)
|
|
|
|
|
{
|
|
|
|
|
for (Object key : cache.keys())
|
|
|
|
|
{
|
|
|
|
|
cache.remove(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|