我是一名中国学生,最近在使用springMVC+shrio,但是在程序中我不能使用session,因为每次需要权限时,它都会做如下方法:doGetAuthorizationInfo(PrincipalCollection principals)
,然后查找数据库和搜索权限等等。
protected AuthorizationInfo doGetAuthorizationInfo(
PrincipalCollection principals) {
/* 这里编写授权代码 */
Object ob = principals.fromRealm(getName()).iterator().next();
String userName = (String) ob;
User user = roleService.findUser(userName);
Set<String> roleNames = roleService.findRoleName(user.getId());
Set<String> permissions = roleService.findUrls(user.getId());
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roleNames);
info.setStringPermissions(permissions);
return info;
}