Java Code Examples for org.apache.catalina.UserDatabase#getUsers()

The following examples show how to use org.apache.catalina.UserDatabase#getUsers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemoryUserDatabaseMBean.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * @return the MBean Names of all users defined in this database.
 */
public String[] getUsers() {
    UserDatabase database = (UserDatabase) this.resource;
    ArrayList<String> results = new ArrayList<>();
    Iterator<User> users = database.getUsers();
    while (users.hasNext()) {
        User user = users.next();
        results.add(findUser(user.getUsername()));
    }
    return results.toArray(new String[results.size()]);
}
 
Example 2
Source File: MemoryUserDatabaseMBean.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * 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()]);

}
 
Example 3
Source File: MemoryUserDatabaseMBean.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * 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()]);

}
 
Example 4
Source File: GlobalResourcesLifecycleListener.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * 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 (log.isDebugEnabled()) {
        log.debug("Creating UserDatabase MBeans for resource " + name);
        log.debug("Database=" + database);
    }
    if (MBeanUtils.createMBean(database) == null) {
        throw new IllegalArgumentException
            ("Cannot create UserDatabase MBean for resource " + name);
    }

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

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

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

}