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

项目: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    文件:UserMBean.java   
/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.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    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new User and return the corresponding MBean Name.
 *
 * @param username User name of the new user
 * @param password Password for the new user
 * @param fullName Full name for the new user
 */
public String createUser(String username, String password,
                         String fullName) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.createUser(username, password, fullName);
    try {
        MBeanUtils.createMBean(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception creating user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findUser(username));

}
项目:tomcat7    文件:MemoryUserDatabaseMBean.java   
/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }

}
项目:tomcat7    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing user and destroy the corresponding MBean.
 *
 * @param username User name to remove
 */
public void removeUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(user);
        database.removeUser(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception destroying user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }

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

    String mname = createManagedName(user);
    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(user);
    ObjectName oname = createObjectName(domain, user);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

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

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

}
项目:tomcat7    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link User} defined in this user database.
 *
 * @param username The logon username of the new user (must be unique)
 * @param password The logon password of the new user
 * @param fullName The full name of the new user
 */
@Override
public User createUser(String username, String password,
                       String fullName) {

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

    MemoryUser user = new MemoryUser(this, username, password, fullName);
    synchronized (users) {
        users.put(user.getUsername(), user);
    }
    return (user);
}
项目: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   
/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException
            ("Cannot create object name for user " + user);
    }

}
项目:jerrydog    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing user and destroy the corresponding MBean.
 *
 * @param username User name to remove
 */
public void removeUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(user);
        database.removeUser(user);
    } catch (Exception e) {
        throw new IllegalArgumentException("Exception destroying user " +
                                           user + " MBean: " + e);
    }

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

    String mname = createManagedName(user);
    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(user);
    ObjectName oname = createObjectName(domain, user);
    mserver.registerMBean(mbean, oname);
    return (mbean);

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

    String mname = createManagedName(user);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, user);
    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 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    文件:UserMBean.java   
/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.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    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new User and return the corresponding MBean Name.
 *
 * @param username User name of the new user
 * @param password Password for the new user
 * @param fullName Full name for the new user
 */
public String createUser(String username, String password,
                         String fullName) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.createUser(username, password, fullName);
    try {
        MBeanUtils.createMBean(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception creating user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findUser(username));

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

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }

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

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(user);
        database.removeUser(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception destroying user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }

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

    String mname = createManagedName(user);
    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(user);
    ObjectName oname = createObjectName(domain, user);
    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>User</code> object.
 *
 * @param user The User to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(User user)
    throws Exception {

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

}
项目:apache-tomcat-7.0.73-with-comment    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link User} defined in this user database.
 *
 * @param username The logon username of the new user (must be unique)
 * @param password The logon password of the new user
 * @param fullName The full name of the new user
 */
@Override
public User createUser(String username, String password,
                       String fullName) {

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

    MemoryUser user = new MemoryUser(this, username, password, fullName);
    synchronized (users) {
        users.put(user.getUsername(), user);
    }
    return (user);
}
项目: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 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    文件:UserMBean.java   
/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.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    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new User and return the corresponding MBean Name.
 *
 * @param username
 *            User name of the new user
 * @param password
 *            Password for the new user
 * @param fullName
 *            Full name for the new user
 */
public String createUser(String username, String password, String fullName) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.createUser(username, password, fullName);
    try {
        MBeanUtils.createMBean(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Exception creating user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findUser(username));

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

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }

}
项目:lazycat    文件:MemoryUserDatabaseMBean.java   
/**
 * Remove an existing user and destroy the corresponding MBean.
 *
 * @param username
 *            User name to remove
 */
public void removeUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(user);
        database.removeUser(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(
                "Exception destroying user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }

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

    String mname = createManagedName(user);
    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(user);
    ObjectName oname = createObjectName(domain, user);
    if (mserver.isRegistered(oname)) {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

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

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

}
项目:lazycat    文件:MemoryUserDatabase.java   
/**
 * Create and return a new {@link User} defined in this user database.
 *
 * @param username
 *            The logon username of the new user (must be unique)
 * @param password
 *            The logon password of the new user
 * @param fullName
 *            The full name of the new user
 */
@Override
public User createUser(String username, String password, String fullName) {

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

    MemoryUser user = new MemoryUser(this, username, password, fullName);
    synchronized (users) {
        users.put(user.getUsername(), user);
    }
    return (user);
}
项目: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());
    }

}
项目:sonar-xanitizer    文件:UserTracker.java   
public void deleteUser(String user)
{
    synchronized (usersDB)
    {
        try
        {
            usersDB.open();
            Iterator users = usersDB.getUsers();
            while (users.hasNext())
            {
                User tomcatUser = (User) users.next();
                if (tomcatUser.getUsername().equals(user))
                {
                    usersDB.removeUser(tomcatUser);
                    // FIXME: delete all the lesson tracking property files
                    break;
                }
            }
            usersDB.close();

        } catch (Exception e)
        {
        }
    }
}
项目:class-guard    文件: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()]);

}
项目:class-guard    文件: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()]);

}
项目:class-guard    文件:UserMBean.java   
/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.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()]);

}
项目:class-guard    文件:MemoryUserDatabaseMBean.java   
/**
 * Create a new User and return the corresponding MBean Name.
 *
 * @param username User name of the new user
 * @param password Password for the new user
 * @param fullName Full name for the new user
 */
public String createUser(String username, String password,
                         String fullName) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.createUser(username, password, fullName);
    try {
        MBeanUtils.createMBean(user);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Exception creating user [" + username + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findUser(username));

}