code: protected Privilege[] toPrivilegeArray(Session session, final String... privileges) throws RepositoryException {
  
          final AccessControlManager acm = session.getAccessControlManager();
  
          final List<Privilege> privilegeList = new ArrayList<>();
          for (String p : privileges) {
              privilegeList.add(acm.privilegeFromName(p));
          }
          return privilegeList.toArray(new Privilege[privilegeList.size()]);
      }
docs: Converts the list of privilege names to an array of {@link Privilege}s.
  
  @param session
  the current session that provides the {@link AccessControlManager}
  @param privileges
  the privileges to convert
  
  @return an array of {@link Privilege}s
  
  @throws RepositoryException
  if the access control manager could not be retrieved of the list of privileges contained unsupported
  privileges