Package org.apache.shiro.authz

Examples of org.apache.shiro.authz.SimpleAuthorizationInfo


   */
  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
    User user = accountService.findUserByLoginName(shiroUser.loginName);
    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
    info.addRoles(user.getRoleList());
    return info;
  }
View Full Code Here


   */
  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
    User user = accountService.findUserByLoginName(shiroUser.loginName);
    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
    info.addRoles(user.getRoleList());
    return info;
  }
View Full Code Here

  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    ShiroUser shiroUser = (ShiroUser) principals.getPrimaryPrincipal();
    User user = accountService.findUserByLoginName(shiroUser.loginName);

    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
    for (Role role : user.getRoleList()) {
      // 基于Role的权限信息
      info.addRole(role.getName());
      // 基于Permission的权限信息
      info.addStringPermissions(role.getPermissionList());
    }
    return info;
  }
View Full Code Here

    }

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        //
        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
        //
        ProjectUserService projectUserService = beanFactory.getBean(ProjectUserService.class);
        ProjectRoleService projectRoleService = beanFactory.getBean(ProjectRoleService.class);
        ProjectMemberService projectMemberService = beanFactory.getBean(ProjectMemberService.class);
        ProjectAuthorityService projectAuthorityService = beanFactory.getBean(ProjectAuthorityService.class);
        //
        Project project = getProjectFromWebSubject();
        ProjectUser projectUser = getProjectUserFromWebSubject();
        if(project==null) {
            authorizationInfo.addObjectPermission(new AllPermission());
        } else if(project.getCreatedById()==projectUser.getId()) {// owner
            //
            List<ProjectAuthority> projectAuthorities = projectAuthorityService.listProjectAuthorities();
            for(ProjectAuthority projectAuthority : projectAuthorities) {
                //
                String authorityCode = projectAuthority.getCode();
                StringUtils.replace(authorityCode, "-", ":");
                authorizationInfo.addStringPermission(authorityCode.replaceAll("-", ":"));
            }
        } else {
            //
            authorizationInfo.addObjectPermission(new AllPermission());
        }
        //
        return authorizationInfo;
    }
View Full Code Here

      LdapContextFactory ldapContextFactory) throws NamingException {
    String username = (String) getAvailablePrincipal(principals);
        LdapContext ldapContext = ldapContextFactory.getSystemLdapContext();
    Set<String> roleNames = getRoleNamesForUser(username, ldapContext);

    return new SimpleAuthorizationInfo(roleNames);
  }
View Full Code Here

      LdapContextFactory ldapContextFactory) throws NamingException {
    String username = (String) getAvailablePrincipal(principals);
        LdapContext ldapContext = ldapContextFactory.getSystemLdapContext();
    Set<String> roleNames = getRoleNamesForUser(username, ldapContext);

    return new SimpleAuthorizationInfo(roleNames);
  }
View Full Code Here

    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        Long userId = (Long) principals.fromRealm(getName()).iterator().next();
        User user = userDAO.getUser(userId);
        if( user != null ) {
            SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
            for( Role role : user.getRoles() ) {
                info.addRole(role.getName());
                info.addStringPermissions( role.getPermissions() );
            }
            return info;
        } else {
            return null;
        }
View Full Code Here

    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        Long userId = (Long) principals.fromRealm(getName()).iterator().next();
        User user = userDAO.getUser(userId);
        if( user != null ) {
            SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
            for( Role role : user.getRoles() ) {
                info.addRole(role.getName());
                info.addStringPermissions( role.getPermissions() );
            }
            return info;
        } else {
            return null;
        }
View Full Code Here

        try {
            Long userId = (Long) (principals.fromRealm(getName()).iterator().next());
            User user = (User) identityManagerment.findById(userId);
            if (user != null) {
                SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
                for (Role role : user.getRoles()) {
                    info.addRole(role.getName());
                    info.addStringPermissions(role.getPermissions());
                }
                return info;
            } else {
                throw new RuntimeException("Not authorized");
            }
View Full Code Here

  {
    Long userId = (Long)principals.fromRealm(getName()).iterator().next();
    User user = userDAO.getUser(userId);
    if (user != null)
    {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      for (Role role : user.getRoles())
      {
        info.addRole(role.getName());
        info.addStringPermissions(role.getPermissions());
      }
      return info;
    }
    else
    {
View Full Code Here

TOP

Related Classes of org.apache.shiro.authz.SimpleAuthorizationInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.