public Privilege[] getPrivileges( SecurityContext context ) {
        ArrayList<Privilege> privs = new ArrayList<Privilege>();
        for (AccessControlEntryImpl ace : principals.values()) {
            // add privileges granted for everyone
            if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) {
                privs.addAll(Arrays.asList(ace.getPrivileges()));
            }

            // add privileges granted for given user
            if (ace.getPrincipal().getName().equals(username(context.getUserName()))) {
                privs.addAll(Arrays.asList(ace.getPrivileges()));
            }

            // add privileges granted for given role
            if (context.hasRole(ace.getPrincipal().getName())) {
                privs.addAll(Arrays.asList(ace.getPrivileges()));
            }
        }

        Privilege[] res = new Privilege[privs.size()];
        privs.toArray(res);

        return res;
    }
public Privilege [ ] getPrivileges ( SecurityContext context ) { ArrayList < Privilege > privs = new ArrayList < Privilege > ( ) ; for ( AccessControlEntryImpl ace : principals . values ( ) ) { if ( ace . getPrincipal ( ) . equals ( SimplePrincipal . EVERYONE ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } if ( ace . getPrincipal ( ) . getName ( ) . equals ( username ( context . getUserName ( ) ) ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } if ( context . hasRole ( ace . getPrincipal ( ) . getName ( ) ) ) { privs . addAll ( Arrays . asList ( ace . getPrivileges ( ) ) ) ; } } Privilege [ ] res = new Privilege [ privs . size ( ) ] ; privs . toArray ( res ) ; return res ; }
Lists all privileges defined by this access list for the given user.

@param context the security context of the user; never null
@return list of privilege objects.