Package org.apache.shiro.authz

Examples of org.apache.shiro.authz.SimpleAuthorizationInfo


     * @return the AuthorizationInfo for the given Subject principal
     * @see #setGroupRolesMap
     * @see #getRoleNamesForGroups
     */
    protected AuthorizationInfo buildAuthorizationInfo(AuthC4JPrincipal principal) {
        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
        authorizationInfo.addRoles(getRoleNamesForGroups(principal.getGroupShortNames()));
        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

            throw new AuthorizationException(message, e);
        } finally {
            JdbcUtils.closeConnection(conn);
        }

        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roleNames);
        info.setStringPermissions(permissions);
        return info;

    }
View Full Code Here

            return null;
        }
        ObjectId userId = (ObjectId) c.iterator().next();
        User user = userDAO.get(userId);
        if (user != null) {
            SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
            for (Role role : user.getRoles()) {
                logger.debug("Add Role of " + role.getName() + " to user " + user.getUsername());
                info.addRole(role.getName());
                info.addStringPermissions(role.getPermissions());
            }
            return info;
        } else {
            return null;
        }
View Full Code Here

        if (user == null)
            return null;
        if (user.isLocked())
            throw new LockedAccountException("Account [" + username + "] is locked.");
       
        SimpleAuthorizationInfo auth = new SimpleAuthorizationInfo();
        auth.setRoles(user.getRoleStrSet());
        auth.addStringPermissions(user.getPermissionStrSet());
       
        return auth;
  }
View Full Code Here

            LOG.debug( "Found role assignee for {}: {}", username, roleAssignee );
            Set<String> roleNames = roleAssignee.roleNames();
            Set<String> permissionStrings = roleAssignee.permissionStrings();
            LOG.debug( "Found role assignee has the following roles: {}", roleNames );
            LOG.debug( "Found role assignee has the following permissions: {}", permissionStrings );
            SimpleAuthorizationInfo atzInfo = new SimpleAuthorizationInfo( roleNames );
            atzInfo.setStringPermissions( permissionStrings );
            return atzInfo;

        } finally {
            uow.discard();
        }
View Full Code Here

    // Unless your realm is very specific the XmlAuthorizingRealm will take
    // care of this. (provided you implement the PlexusUserLocator interface).
    String username = principals.getPrimaryPrincipal().toString();
    final SimpleUser user = this.userStore.getUser(username);
    if (user != null) {
      return new SimpleAuthorizationInfo(user.getRoles());
    }
    else {
      return null;
    }
View Full Code Here

        final LdapContextFactory ldapContextFactory) throws NamingException {
      if (!isAuthorizationEnabled()) {
        return null;
      }
      final Set<String> roleNames = getRoles(principals, ldapContextFactory);
        SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(roleNames);
        Set<String> stringPermissions = permsFor(roleNames);
        simpleAuthorizationInfo.setStringPermissions(stringPermissions);
        return simpleAuthorizationInfo;
    }
View Full Code Here

    String username = (String) principals.iterator().next();

    // check the userPrivilageMap key set for the user

    if (StringUtils.isNotEmpty(username) && this.userPrivileges.containsKey(username)) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();

      // "nexus:target:" + <targetId> + ":" + <repoId> + ":" + <action>
      // String priv = "nexus:target:" + "*" + ":" + "repo1" + ":" + "*";
      info.addObjectPermissions(this.buildPermissions(this.userPrivileges.get(username)));
      return info;
    }

    return null;
  }
View Full Code Here

      }
      catch (NoLdapUserRolesFoundException e) {
        this.logger.debug("User: " + username + " does not have any ldap roles.", e);
      }

      return new SimpleAuthorizationInfo(roles);
    }
    return null;

  }
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.