public class ShiroDbRealm extends AuthorizingRealm
/**
* 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用.
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
Setlt;String; activeRoles = privilegeService.getActiveRolesByUserId(shiroUser.id);
Setlt;String; activePermissions = privilegeService.getActivePermissionsByUserId(shiroUser.id);
info.addRoles(activeRoles);
info.addStringPermissions(activePermissions);
return info;
}