Search in sources :

Example 1 with SysRole

use of com.neo.entity.SysRole in project spring-boot-examples by ityouknow.

the class MyShiroRealm method doGetAuthorizationInfo.

@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    System.out.println("权限配置-->MyShiroRealm.doGetAuthorizationInfo()");
    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
    UserInfo userInfo = (UserInfo) principals.getPrimaryPrincipal();
    for (SysRole role : userInfo.getRoleList()) {
        authorizationInfo.addRole(role.getRole());
        for (SysPermission p : role.getPermissions()) {
            authorizationInfo.addStringPermission(p.getPermission());
        }
    }
    return authorizationInfo;
}
Also used : SimpleAuthorizationInfo(org.apache.shiro.authz.SimpleAuthorizationInfo) SysRole(com.neo.entity.SysRole) UserInfo(com.neo.entity.UserInfo) SysPermission(com.neo.entity.SysPermission)

Aggregations

SysPermission (com.neo.entity.SysPermission)1 SysRole (com.neo.entity.SysRole)1 UserInfo (com.neo.entity.UserInfo)1 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)1