Examples of GrantedAuthority


Examples of org.acegisecurity.GrantedAuthority

    SecurityContext securityContext = (SecurityContext) SecurityContextHolder.getContext();
    GrantedAuthority[] authorities = securityContext.getAuthentication().getAuthorities();

    for (int i = 0; i < authorities.length; i++) {
      GrantedAuthority authority = authorities[i];
      if (role.equals(authority.getAuthority())) {
        return true;
      }
    }

    return false;
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

    UserDetails user = (UserDetails) users.get(0);
    List dbAuths = this.customAuthoritiesByUsernameMapping.execute(new Object[]{user.getUsername(),user.getUsername(),user.getUsername()});
    addCustomAuthorities(user.getUsername(), dbAuths);
    //if (dbAuths.size() == 0)
    //  throw new UsernameNotFoundException("User has no GrantedAuthority");
    GrantedAuthority arrayAuths[] = (GrantedAuthority[]) (GrantedAuthority[]) dbAuths
        .toArray(new GrantedAuthority[dbAuths.size()]);
    String returnUsername = user.getUsername();
    if (!isUsernameBasedPrimaryKey())
      returnUsername = username;
    return new User(returnUsername, user.getPassword(), user.isEnabled(),
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

     */
    public void setAuthoritiesAsString(List authoritiesAsString) {
        setAuthorities(new ArrayList(authoritiesAsString.size()));
        Iterator it = authoritiesAsString.iterator();
        while (it.hasNext()) {
            GrantedAuthority grantedAuthority = new GrantedAuthorityImpl((String) it.next());
            addAuthority(grantedAuthority);
        }
    }
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

    private Set authoritiesToRoles(Collection c) {
        Set target = new HashSet();

        for (Iterator iterator = c.iterator(); iterator.hasNext();) {
            GrantedAuthority authority = (GrantedAuthority) iterator.next();

            if (null == authority.getAuthority()) {
                throw new IllegalArgumentException(
                    "Cannot process GrantedAuthority objects which return null from getAuthority() - attempting to process "
                    + authority.toString());
            }

            target.add(authority.getAuthority());
        }

        return target;
    }
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

        for (Iterator iterator = grantedRoles.iterator(); iterator.hasNext();) {
            String role = (String) iterator.next();

            for (Iterator grantedIterator = granted.iterator(); grantedIterator.hasNext();) {
                GrantedAuthority authority = (GrantedAuthority) grantedIterator.next();

                if (authority.getAuthority().equals(role)) {
                    target.add(authority);

                    break;
                }
            }
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

                && ((changeType == CHANGE_GENERAL) || (changeType == CHANGE_OWNERSHIP))) {
            return;
        }

        // Not authorized by ACL ownership; try via adminstrative permissions
        GrantedAuthority requiredAuthority = null;

        if (changeType == CHANGE_AUDITING) {
            requiredAuthority = this.gaModifyAuditing;
        } else if (changeType == CHANGE_GENERAL) {
            requiredAuthority = this.gaGeneralChanges;
        } else if (changeType == CHANGE_OWNERSHIP) {
            requiredAuthority = this.gaTakeOwnership;
        } else {
            throw new IllegalArgumentException("Unknown change type");
        }

        // Iterate this principal's authorities to determine right
        GrantedAuthority[] auths = authentication.getAuthorities();

        for (int i = 0; i < auths.length; i++) {
            if (requiredAuthority.equals(auths[i])) {
                return;
            }
        }

        // Try to get permission via ACEs within the ACL
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

            }

            NamingEnumeration attributeRoles = roleAttribute.getAll();

            while (attributeRoles.hasMore()) {
                GrantedAuthority authority = createAuthority(attributeRoles.next());

                if (authority != null) {
                    essence.addAuthority(authority);
                } else {
                    logger.debug("Failed to create an authority value from attribute with Id: "
View Full Code Here

Examples of org.acegisecurity.GrantedAuthority

        UsernamePasswordAuthenticationToken targetUserRequest;

        // grant an additional authority that contains the original Authentication object
        // which will be used to 'exit' from the current switched user.
        Authentication currentAuth = SecurityContextHolder.getContext().getAuthentication();
        GrantedAuthority switchAuthority = new SwitchUserGrantedAuthority(ROLE_PREVIOUS_ADMINISTRATOR, currentAuth);

        // get the original authorities       
        ArrayList orig = new ArrayList();
        for (int i = 0; i < targetUser.getAuthorities().length; i++) {
      orig.add(targetUser.getAuthorities()[i]);
View Full Code Here

Examples of org.beangle.security.core.GrantedAuthority

  }

  public boolean equals(Object obj) {
    // if (obj instanceof String) { return obj.equals(this.role); }
    if (obj instanceof GrantedAuthority) {
      GrantedAuthority attr = (GrantedAuthority) obj;
      return this.role.equals(attr.getAuthority());
    }
    return false;
  }
View Full Code Here

Examples of org.springframework.security.GrantedAuthority

    public static Set authoritiesToRoles(Collection c) {
        Set target = new HashSet();

        for (Iterator iterator = c.iterator(); iterator.hasNext();) {
            GrantedAuthority authority = (GrantedAuthority) iterator.next();

            if (null == authority.getAuthority()) {
                throw new IllegalArgumentException(
                        "Cannot process GrantedAuthority objects which return null from getAuthority() - attempting to process "
                                + authority.toString());
            }

            target.add(authority.getAuthority());
        }

        return target;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.