/** Return the MBean Names of all users defined in this database. */
  public String[] getUsers() {

    UserDatabase database = (UserDatabase) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<User> users = database.getUsers();
    while (users.hasNext()) {
      User user = users.next();
      results.add(findUser(user.getUsername()));
    }
    return results.toArray(new String[results.size()]);
  }
  /**
   * Create the MBeans for the specified UserDatabase and its contents.
   *
   * @param name Complete resource name of this UserDatabase
   * @param database The UserDatabase to be processed
   * @exception Exception if an exception occurs while creating MBeans
   */
  protected void createMBeans(String name, UserDatabase database) throws Exception {

    // Create the MBean for the UserDatabase itself
    if (debug >= 2) {
      log("Creating UserDatabase MBeans for resource " + name);
      log("Database=" + database);
    }
    if (org.apache.catalina.mbeans.MBeanUtils.createMBean(database) == null) {
      throw new IllegalArgumentException("Cannot create UserDatabase MBean for resource " + name);
    }

    // Create the MBeans for each defined Role
    Iterator roles = database.getRoles();
    while (roles.hasNext()) {
      Role role = (Role) roles.next();
      if (debug >= 3) {
        log("  Creating Role MBean for role " + role);
      }
      if (org.apache.catalina.mbeans.MBeanUtils.createMBean(role) == null) {
        throw new IllegalArgumentException("Cannot create Role MBean for role " + role);
      }
    }

    // Create the MBeans for each defined Group
    Iterator groups = database.getGroups();
    while (groups.hasNext()) {
      Group group = (Group) groups.next();
      if (debug >= 3) {
        log("  Creating Group MBean for group " + group);
      }
      if (org.apache.catalina.mbeans.MBeanUtils.createMBean(group) == null) {
        throw new IllegalArgumentException("Cannot create Group MBean for group " + group);
      }
    }

    // Create the MBeans for each defined User
    Iterator users = database.getUsers();
    while (users.hasNext()) {
      User user = (User) users.next();
      if (debug >= 3) {
        log("  Creating User MBean for user " + user);
      }
      if (org.apache.catalina.mbeans.MBeanUtils.createMBean(user) == null) {
        throw new IllegalArgumentException("Cannot create User MBean for user " + user);
      }
    }
  }