继承 AuthorizingRealm 重写 doGetAuthorizationInfo 方法
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
Set<String> permissions = new HashSet<>();
Set<String> roles = new HashSet<>();
roles.add("admin");
info.addRoles(roles);
info.addStringPermissions(permissions);
return info;
}
添加角色判断
<shiro:hasRole name="admin">admin</shiro:hasRole>