Search in sources :

Example 51 with Group

use of org.apache.catalina.Group in project tomcat by apache.

the class UserMBean method getGroups.

// ------------------------------------------------------------- Attributes
/**
 * @return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {
    User user = (User) this.resource;
    List<String> results = new ArrayList<>();
    Iterator<Group> groups = user.getGroups();
    while (groups.hasNext()) {
        Group group = null;
        try {
            group = groups.next();
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException(sm.getString("userMBean.createError.group", group), e);
        }
    }
    return results.toArray(new String[0]);
}
Also used : Group(org.apache.catalina.Group) MalformedObjectNameException(javax.management.MalformedObjectNameException) User(org.apache.catalina.User) ArrayList(java.util.ArrayList) ObjectName(javax.management.ObjectName)

Aggregations

Group (org.apache.catalina.Group)51 User (org.apache.catalina.User)21 UserDatabase (org.apache.catalina.UserDatabase)21 Role (org.apache.catalina.Role)20 ArrayList (java.util.ArrayList)15 MalformedObjectNameException (javax.management.MalformedObjectNameException)12 ObjectName (javax.management.ObjectName)9 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 MBeanException (javax.management.MBeanException)4 RuntimeOperationsException (javax.management.RuntimeOperationsException)4 Connection (java.sql.Connection)3 ResultSet (java.sql.ResultSet)3 NamingException (javax.naming.NamingException)2 OperationNotSupportedException (javax.naming.OperationNotSupportedException)2 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 LoggingBaseTest (org.apache.catalina.startup.LoggingBaseTest)1