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 ; }
Lists all privileges defined by this access list for the given user .