Java 类org.apache.catalina.Group 实例源码

项目:tomcat7    文件:GroupMBean.java   
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

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

}
项目:tomcat7    文件:GroupMBean.java   
/**
 * 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()]);

}
项目:tomcat7    文件:UserMBean.java   
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    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) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for group " + group);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
项目:tomcat7    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new Group and return the corresponding MBean Name.
 *
 * @param groupname Group name of the new group
 * @param description Description of the new group
 */
public String createGroup(String groupname, String description) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.createGroup(groupname, description);
    try {
        MBeanUtils.createMBean(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception creating group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findGroup(groupname));

}
项目:tomcat7    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing group and destroy the corresponding MBean.
 *
 * @param groupname Group name to remove
 */
public void removeGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(group);
        database.removeGroup(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception destroying group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }

}
项目:tomcat7    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:tomcat7    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link Group} defined in this user database.
 *
 * @param groupname The group name of the new group (must be unique)
 * @param description The description of this group
 */
@Override
public Group createGroup(String groupname, String description) {

    if (groupname == null || groupname.length() == 0) {
        String msg = sm.getString("memoryUserDatabase.nullGroup");
        log.warn(msg);
        throw new IllegalArgumentException(msg);
    }

    MemoryGroup group = new MemoryGroup(this, groupname, description);
    synchronized (groups) {
        groups.put(group.getGroupname(), group);
    }
    return (group);

}
项目:tomcat7    文件:MemoryUserDatabase.java   
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
项目:jerrydog    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new Group and return the corresponding MBean Name.
 *
 * @param groupname Group name of the new group
 * @param description Description of the new group
 */
public String createGroup(String groupname, String description) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.createGroup(groupname, description);
    /*
    if (roles != null) {
        for (int i = 0; i < roles.length; i++) {
            Role role = database.findRole(roles[i]);
            if (role == null) {
                createRole(roles[i], null);
                role = database.findRole(roles[i]);
            }
            group.addRole(role);
        }
    }
    */
    try {
        MBeanUtils.createMBean(group);
    } catch (Exception e) {
        throw new IllegalArgumentException("Exception creating group " +
                                           group + " MBean: " + e);
    }
    return (findGroup(groupname));

}
项目:jerrydog    文件:MemoryUserDatabaseMBean.java   
/**
 * Return the MBean Name for the specified group name (if any);
 * otherwise return <code>null</code>.
 *
 * @param groupname Group name to look up
 */
public String findGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException
            ("Cannot create object name for group " + group);
    }

}
项目:jerrydog    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing group and destroy the corresponding MBean.
 *
 * @param groupname Group name to remove
 */
public void removeGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(group);
        database.removeGroup(group);
    } catch (Exception e) {
        throw new IllegalArgumentException("Exception destroying group " +
                                           group + " MBean: " + e);
    }

}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, group);
    mserver.unregisterMBean(oname);

}
项目:jerrydog    文件:MemoryUserDatabase.java   
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator groups = getGroups();
        while (groups.hasNext()) {
            Group group = (Group) groups.next();
            group.removeRole(role);
        }
        Iterator users = getUsers();
        while (users.hasNext()) {
            User user = (User) users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:GroupMBean.java   
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

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

}
项目:apache-tomcat-7.0.73-with-comment    文件:GroupMBean.java   
/**
 * 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()]);

}
项目:apache-tomcat-7.0.73-with-comment    文件:UserMBean.java   
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    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) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for group " + group);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new Group and return the corresponding MBean Name.
 *
 * @param groupname Group name of the new group
 * @param description Description of the new group
 */
public String createGroup(String groupname, String description) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.createGroup(groupname, description);
    try {
        MBeanUtils.createMBean(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception creating group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findGroup(groupname));

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabaseMBean.java   
/**
 * Return the MBean Name for the specified group name (if any);
 * otherwise return <code>null</code>.
 *
 * @param groupname Group name to look up
 */
public String findGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for group [" + groupname + "]");
        iae.initCause(e);
        throw iae;
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing group and destroy the corresponding MBean.
 *
 * @param groupname Group name to remove
 */
public void removeGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(group);
        database.removeGroup(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception destroying group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Group</code> object.
 *
 * @param group The Group to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(Group group)
    throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, group);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link Group} defined in this user database.
 *
 * @param groupname The group name of the new group (must be unique)
 * @param description The description of this group
 */
@Override
public Group createGroup(String groupname, String description) {

    if (groupname == null || groupname.length() == 0) {
        String msg = sm.getString("memoryUserDatabase.nullGroup");
        log.warn(msg);
        throw new IllegalArgumentException(msg);
    }

    MemoryGroup group = new MemoryGroup(this, groupname, description);
    synchronized (groups) {
        groups.put(group.getGroupname(), group);
    }
    return (group);

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabase.java   
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
项目:lazycat    文件:GroupMBean.java   
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

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

}
项目:lazycat    文件:GroupMBean.java   
/**
 * 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()]);

}
项目:lazycat    文件:UserMBean.java   
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    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) {
            IllegalArgumentException iae = new IllegalArgumentException(
                    "Cannot create object name for group " + group);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
项目:lazycat    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new Group and return the corresponding MBean Name.
 *
 * @param groupname
 *            Group name of the new group
 * @param description
 *            Description of the new group
 */
public String createGroup(String groupname, String description) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.createGroup(groupname, description);
    try {
        MBeanUtils.createMBean(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Exception creating group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findGroup(groupname));

}
项目:lazycat    文件:MemoryUserDatabaseMBean.java   
/**
 * Return the MBean Name for the specified group name (if any); otherwise
 * return <code>null</code>.
 *
 * @param groupname
 *            Group name to look up
 */
public String findGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Cannot create object name for group [" + groupname + "]");
        iae.initCause(e);
        throw iae;
    }

}
项目:lazycat    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing group and destroy the corresponding MBean.
 *
 * @param groupname
 *            Group name to remove
 */
public void removeGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(group);
        database.removeGroup(group);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Exception destroying group [" + groupname + "] MBean");
        iae.initCause(e);
        throw iae;
    }

}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this <code>Group</code> object.
 *
 * @param group
 *            The Group to be managed
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Group group) throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with " + mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(group);
    ObjectName oname = createObjectName(domain, group);
    if (mserver.isRegistered(oname)) {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this <code>Group</code> object.
 *
 * @param group
 *            The Group to be managed
 *
 * @exception Exception
 *                if an MBean cannot be deregistered
 */
static void destroyMBean(Group group) throws Exception {

    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, group);
    if (mserver.isRegistered(oname))
        mserver.unregisterMBean(oname);

}
项目:lazycat    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link Group} defined in this user database.
 *
 * @param groupname
 *            The group name of the new group (must be unique)
 * @param description
 *            The description of this group
 */
@Override
public Group createGroup(String groupname, String description) {

    if (groupname == null || groupname.length() == 0) {
        String msg = sm.getString("memoryUserDatabase.nullGroup");
        log.warn(msg);
        throw new IllegalArgumentException(msg);
    }

    MemoryGroup group = new MemoryGroup(this, groupname, description);
    synchronized (groups) {
        groups.put(group.getGroupname(), group);
    }
    return (group);

}
项目:lazycat    文件:MemoryUserDatabase.java   
/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role
 *            The role to be removed
 */
@Override
public void removeRole(Role role) {

    synchronized (roles) {
        Iterator<Group> groups = getGroups();
        while (groups.hasNext()) {
            Group group = groups.next();
            group.removeRole(role);
        }
        Iterator<User> users = getUsers();
        while (users.hasNext()) {
            User user = users.next();
            user.removeRole(role);
        }
        roles.remove(role.getRolename());
    }

}
项目:tomcat7    文件:GroupMBean.java   
/**
 * Add a new {@link Role} to those this group belongs to.
 *
 * @param rolename Role name of the new role
 */
public void addRole(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.addRole(role);

}
项目:tomcat7    文件:GroupMBean.java   
/**
 * 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);

}
项目:tomcat7    文件:UserMBean.java   
/**
 * Add a new {@link Group} to those this user belongs to.
 *
 * @param groupname Group name of the new group
 */
public void addGroup(String groupname) {

    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Group group = user.getUserDatabase().findGroup(groupname);
    if (group == null) {
        throw new IllegalArgumentException
            ("Invalid group name '" + groupname + "'");
    }
    user.addGroup(group);

}
项目:tomcat7    文件:UserMBean.java   
/**
 * Remove a {@link Group} from those this user belongs to.
 *
 * @param groupname Group name of the old group
 */
public void removeGroup(String groupname) {

    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Group group = user.getUserDatabase().findGroup(groupname);
    if (group == null) {
        throw new IllegalArgumentException
            ("Invalid group name '" + groupname + "'");
    }
    user.removeGroup(group);

}
项目:tomcat7    文件:MemoryUserDatabaseMBean.java   
/**
 * 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()]);

}
项目:lazycat    文件:MemoryUserDatabase.java   
@Override
public Object createObject(Attributes attributes) {
    String groupname = attributes.getValue("groupname");
    if (groupname == null) {
        groupname = attributes.getValue("name");
    }
    String description = attributes.getValue("description");
    String roles = attributes.getValue("roles");
    Group group = database.createGroup(groupname, description);
    if (roles != null) {
        while (roles.length() > 0) {
            String rolename = null;
            int comma = roles.indexOf(',');
            if (comma >= 0) {
                rolename = roles.substring(0, comma).trim();
                roles = roles.substring(comma + 1);
            } else {
                rolename = roles.trim();
                roles = "";
            }
            if (rolename.length() > 0) {
                Role role = database.findRole(rolename);
                if (role == null) {
                    role = database.createRole(rolename, null);
                }
                group.addRole(role);
            }
        }
    }
    return (group);
}