コード例 #1
0
  /** Return the MBean Names of all groups defined in this database. */
  public String[] getGroups() {

    UserDatabase database = (UserDatabase) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Group> groups = database.getGroups();
    while (groups.hasNext()) {
      Group group = groups.next();
      results.add(findGroup(group.getGroupname()));
    }
    return results.toArray(new String[results.size()]);
  }
コード例 #2
0
  /**
   * Remove a {@link Role} from those this group belongs to.
   *
   * @param rolename Role name of the old role
   */
  public void removeRole(String rolename) {

    Group group = (Group) this.resource;
    if (group == null) {
      return;
    }
    Role role = group.getUserDatabase().findRole(rolename);
    if (role == null) {
      throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    group.removeRole(role);
  }
コード例 #3
0
  /** Return the MBean Names of all users that are members of this group. */
  public String[] getUsers() {

    Group group = (Group) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<User> users = group.getUsers();
    while (users.hasNext()) {
      User user = null;
      try {
        user = users.next();
        ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user);
        results.add(oname.toString());
      } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae =
            new IllegalArgumentException("Cannot create object name for user " + user);
        iae.initCause(e);
        throw iae;
      }
    }
    return results.toArray(new String[results.size()]);
  }