org.apache.catalina.Role

Here are the examples of the java api org.apache.catalina.Role taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

70 Examples 7

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Return the MBean Name for the specified role name (if any);
 * otherwise return <code>null</code>.
 *
 * @param rolename Role name to look up
 */
public String findRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role [" + rolename + "]");
        iae.initCause(e);
        throw iae;
    }
}

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Remove an existing role and destroy the corresponding MBean.
 *
 * @param rolename Role name to remove
 */
public void removeRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(role);
        database.removeRole(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException("Exception destroying role [" + rolename + "] MBean");
        iae.initCause(e);
        throw iae;
    }
}

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Create a new Role and return the corresponding MBean Name.
 *
 * @param rolename Group name of the new group
 * @param description Description of the new group
 */
public String createRole(String rolename, String description) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.createRole(rolename, description);
    try {
        MBeanUtils.createMBean(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException("Exception creating role [" + rolename + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findRole(rolename));
}

19 Source : GroupMBean.java
with Apache License 2.0
from wangyingjie

// ------------------------------------------------------------- Operations
/**
 * 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);
}

19 Source : GroupMBean.java
with Apache License 2.0
from wangyingjie

/**
 * 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);
}

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from how2j

/**
 * Return the MBean Name for the specified role name (if any); otherwise
 * return <code>null</code>.
 *
 * @param rolename
 *            Role name to look up
 */
public String findRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return (null);
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role [" + rolename + "]");
        iae.initCause(e);
        throw iae;
    }
}

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from how2j

/**
 * Create a new Role and return the corresponding MBean Name.
 *
 * @param rolename
 *            Group name of the new group
 * @param description
 *            Description of the new group
 */
public String createRole(String rolename, String description) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.createRole(rolename, description);
    try {
        MBeanUtils.createMBean(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException("Exception creating role [" + rolename + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return (findRole(rolename));
}

19 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from how2j

/**
 * Remove an existing role and destroy the corresponding MBean.
 *
 * @param rolename
 *            Role name to remove
 */
public void removeRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(role);
        database.removeRole(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException("Exception destroying role [" + rolename + "] MBean");
        iae.initCause(e);
        throw iae;
    }
}

19 Source : GroupMBean.java
with Apache License 2.0
from how2j

/**
 * 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);
}

19 Source : GroupMBean.java
with Apache License 2.0
from how2j

// ------------------------------------------------------------- Operations
/**
 * 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);
}

19 Source : MemoryUserDatabaseMBean.java
with GNU General Public License v3.0
from guang19

/**
 * Remove an existing role and destroy the corresponding MBean.
 *
 * @param rolename Role name to remove
 */
public void removeRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return;
    }
    try {
        MBeanUtils.destroyMBean(role);
        database.removeRole(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(sm.getString("userMBean.destroyError.role", rolename));
        iae.initCause(e);
        throw iae;
    }
}

19 Source : MemoryUserDatabaseMBean.java
with GNU General Public License v3.0
from guang19

/**
 * Create a new Role and return the corresponding MBean Name.
 *
 * @param rolename Group name of the new group
 * @param description Description of the new group
 * @return the new role object name
 */
public String createRole(String rolename, String description) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.createRole(rolename, description);
    try {
        MBeanUtils.createMBean(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException(sm.getString("userMBean.createMBeanError.role", rolename));
        iae.initCause(e);
        throw iae;
    }
    return findRole(rolename);
}

19 Source : MBeanUtils.java
with GNU General Public License v3.0
from guang19

/**
 * Create an <code>ObjectName</code> for this
 * <code>Role</code> object.
 *
 * @param domain Domain in which this name is to be created
 * @param role The Role to be named
 * @return a new object name
 * @exception MalformedObjectNameException if a name cannot be created
 */
static ObjectName createObjectName(String domain, Role role) throws MalformedObjectNameException {
    ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + ObjectName.quote(role.getRolename()) + ",database=" + role.getUserDatabase().getId());
    return name;
}

19 Source : GroupMBean.java
with GNU General Public License v3.0
from guang19

/**
 * 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(sm.getString("userMBean.invalidRole", rolename));
    }
    group.removeRole(role);
}

19 Source : GroupMBean.java
with GNU General Public License v3.0
from guang19

/**
 * 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(sm.getString("userMBean.invalidRole", rolename));
    }
    group.addRole(role);
}

19 Source : MemoryUserDatabaseMBean.java
with MIT License
from chenmudu

/**
 * Create a new Role and return the corresponding MBean Name.
 *
 * @param rolename Group name of the new group
 * @param description Description of the new group
 * @return the new role object name
 */
public String createRole(String rolename, String description) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.createRole(rolename, description);
    try {
        MBeanUtils.createMBean(role);
    } catch (Exception e) {
        IllegalArgumentException iae = new IllegalArgumentException("Exception creating role [" + rolename + "] MBean");
        iae.initCause(e);
        throw iae;
    }
    return findRole(rolename);
}

19 Source : GroupMBean.java
with MIT License
from chenmudu

/**
 * 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);
}

19 Source : GroupMBean.java
with MIT License
from chenmudu

/**
 * 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);
}

18 Source : MemoryUser.java
with Apache License 2.0
from wangyingjie

/**
 * Is this user specifically replacedigned the specified {@link Role}?  This
 * method does <strong>NOT</strong> check for roles inherited based on
 * {@link Group} membership.
 *
 * @param role The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return (roles.contains(role));
    }
}

18 Source : MemoryGroup.java
with Apache License 2.0
from wangyingjie

/**
 * Is this group specifically replacedigned the specified {@link Role}?
 *
 * @param role The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return (roles.contains(role));
    }
}

18 Source : UserMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename Role name of the old role
 */
public void removeRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    user.removeRole(role);
}

18 Source : UserMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Add a new {@link Role} to those this user belongs to.
 *
 * @param rolename Role name of the new role
 */
public void addRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    user.addRole(role);
}

18 Source : MemoryUser.java
with Apache License 2.0
from how2j

/**
 * Is this user specifically replacedigned the specified {@link Role}? This
 * method does <strong>NOT</strong> check for roles inherited based on
 * {@link Group} membership.
 *
 * @param role
 *            The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return (roles.contains(role));
    }
}

18 Source : MemoryGroup.java
with Apache License 2.0
from how2j

/**
 * Is this group specifically replacedigned the specified {@link Role}?
 *
 * @param role
 *            The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return (roles.contains(role));
    }
}

18 Source : UserMBean.java
with Apache License 2.0
from how2j

/**
 * Add a new {@link Role} to those this user belongs to.
 *
 * @param rolename
 *            Role name of the new role
 */
public void addRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    user.addRole(role);
}

18 Source : UserMBean.java
with Apache License 2.0
from how2j

/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename
 *            Role name of the old role
 */
public void removeRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException("Invalid role name '" + rolename + "'");
    }
    user.removeRole(role);
}

18 Source : MemoryGroup.java
with GNU General Public License v3.0
from guang19

/**
 * Is this group specifically replacedigned the specified {@link Role}?
 *
 * @param role The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return roles.contains(role);
    }
}

18 Source : UserMBean.java
with GNU General Public License v3.0
from guang19

/**
 * Remove a {@link Role} from those this user belongs to.
 *
 * @param rolename Role name of the old role
 */
public void removeRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename));
    }
    user.removeRole(role);
}

18 Source : UserMBean.java
with GNU General Public License v3.0
from guang19

/**
 * Add a new {@link Role} to those this user belongs to.
 *
 * @param rolename Role name of the new role
 */
public void addRole(String rolename) {
    User user = (User) this.resource;
    if (user == null) {
        return;
    }
    Role role = user.getUserDatabase().findRole(rolename);
    if (role == null) {
        throw new IllegalArgumentException(sm.getString("userMBean.invalidRole", rolename));
    }
    user.addRole(role);
}

18 Source : MemoryUserDatabaseMBean.java
with GNU General Public License v3.0
from guang19

/**
 * Return the MBean Name for the specified role name (if any);
 * otherwise return <code>null</code>.
 *
 * @param rolename Role name to look up
 * @return the role object name
 */
public String findRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return null;
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return oname.toString();
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException(sm.getString("userMBean.createError.role", rolename));
        iae.initCause(e);
        throw iae;
    }
}

18 Source : MemoryUserDatabaseMBean.java
with MIT License
from chenmudu

/**
 * Return the MBean Name for the specified role name (if any);
 * otherwise return <code>null</code>.
 *
 * @param rolename Role name to look up
 * @return the role object name
 */
public String findRole(String rolename) {
    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return null;
    }
    try {
        ObjectName oname = MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return oname.toString();
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException("Cannot create object name for role [" + rolename + "]");
        iae.initCause(e);
        throw iae;
    }
}

17 Source : MemoryUserDatabase.java
with Apache License 2.0
from wangyingjie

/**
 * 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());
    }
}

17 Source : MemoryUser.java
with Apache License 2.0
from wangyingjie

/**
 * Add a new {@link Role} to those replacedigned specifically to this user.
 *
 * @param role The new role
 */
@Override
public void addRole(Role role) {
    synchronized (roles) {
        if (!roles.contains(role)) {
            roles.add(role);
        }
    }
}

17 Source : MemoryUser.java
with Apache License 2.0
from wangyingjie

/**
 * Remove a {@link Role} from those replacedigned to this user.
 *
 * @param role The old role
 */
@Override
public void removeRole(Role role) {
    synchronized (roles) {
        roles.remove(role);
    }
}

17 Source : MemoryGroup.java
with Apache License 2.0
from wangyingjie

// --------------------------------------------------------- Public Methods
/**
 * Add a new {@link Role} to those replacedigned specifically to this group.
 *
 * @param role The new role
 */
@Override
public void addRole(Role role) {
    synchronized (roles) {
        if (!roles.contains(role)) {
            roles.add(role);
        }
    }
}

17 Source : MemoryGroup.java
with Apache License 2.0
from wangyingjie

/**
 * Remove a {@link Role} from those replacedigned to this group.
 *
 * @param role The old role
 */
@Override
public void removeRole(Role role) {
    synchronized (roles) {
        roles.remove(role);
    }
}

17 Source : MemoryUserDatabase.java
with Apache License 2.0
from how2j

/**
 * 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());
    }
}

17 Source : MemoryUser.java
with Apache License 2.0
from how2j

/**
 * Add a new {@link Role} to those replacedigned specifically to this user.
 *
 * @param role
 *            The new role
 */
@Override
public void addRole(Role role) {
    synchronized (roles) {
        if (!roles.contains(role)) {
            roles.add(role);
        }
    }
}

17 Source : MemoryUser.java
with Apache License 2.0
from how2j

/**
 * Remove a {@link Role} from those replacedigned to this user.
 *
 * @param role
 *            The old role
 */
@Override
public void removeRole(Role role) {
    synchronized (roles) {
        roles.remove(role);
    }
}

17 Source : MemoryGroup.java
with Apache License 2.0
from how2j

/**
 * Remove a {@link Role} from those replacedigned to this group.
 *
 * @param role
 *            The old role
 */
@Override
public void removeRole(Role role) {
    synchronized (roles) {
        roles.remove(role);
    }
}

17 Source : MemoryGroup.java
with Apache License 2.0
from how2j

// --------------------------------------------------------- Public Methods
/**
 * Add a new {@link Role} to those replacedigned specifically to this group.
 *
 * @param role
 *            The new role
 */
@Override
public void addRole(Role role) {
    synchronized (roles) {
        if (!roles.contains(role)) {
            roles.add(role);
        }
    }
}

17 Source : MemoryUserDatabase.java
with GNU General Public License v3.0
from guang19

/**
 * Remove the specified {@link Role} from this user database.
 *
 * @param role The role to be removed
 */
@Override
public void removeRole(Role role) {
    readLock.lock();
    try {
        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());
    } finally {
        readLock.unlock();
    }
}

17 Source : MemoryUser.java
with GNU General Public License v3.0
from guang19

/**
 * Is this user specifically replacedigned the specified {@link Role}?  This
 * method does <strong>NOT</strong> check for roles inherited based on
 * {@link Group} membership.
 *
 * @param role The role to check
 */
@Override
public boolean isInRole(Role role) {
    synchronized (roles) {
        return roles.contains(role);
    }
}

16 Source : MemoryUserDatabase.java
with Apache License 2.0
from wangyingjie

@Override
public Object createObject(Attributes attributes) {
    String rolename = attributes.getValue("rolename");
    if (rolename == null) {
        rolename = attributes.getValue("name");
    }
    String description = attributes.getValue("description");
    Role role = database.createRole(rolename, description);
    return (role);
}

16 Source : MemoryUserDatabaseMBean.java
with Apache License 2.0
from wangyingjie

/**
 * Return the MBean Names of all roles defined in this database.
 */
public String[] getRoles() {
    UserDatabase database = (UserDatabase) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = database.getRoles();
    while (roles.hasNext()) {
        Role role = roles.next();
        results.add(findRole(role.getRolename()));
    }
    return results.toArray(new String[results.size()]);
}

16 Source : GlobalResourcesLifecycleListener.java
with Apache License 2.0
from wangyingjie

/**
 * 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);
    }
    try {
        MBeanUtils.createMBean(database);
    } catch (Exception e) {
        throw new IllegalArgumentException("Cannot create UserDatabase MBean for resource " + name, e);
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(role);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create Role MBean for role " + role, e);
        }
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(group);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create Group MBean for group " + group, e);
        }
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(user);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create User MBean for user " + user, e);
        }
    }
}

16 Source : GlobalResourcesLifecycleListener.java
with Apache License 2.0
from tryandcatch

/**
 * 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);
        }
    }
}

16 Source : GlobalResourcesLifecycleListener.java
with Apache License 2.0
from how2j

/**
 * 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);
    }
    try {
        MBeanUtils.createMBean(database);
    } catch (Exception e) {
        throw new IllegalArgumentException("Cannot create UserDatabase MBean for resource " + name, e);
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(role);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create Role MBean for role " + role, e);
        }
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(group);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create Group MBean for group " + group, e);
        }
    }
    // 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);
        }
        try {
            MBeanUtils.createMBean(user);
        } catch (Exception e) {
            throw new IllegalArgumentException("Cannot create User MBean for user " + user, e);
        }
    }
}

16 Source : MemoryUserDatabase.java
with GNU General Public License v3.0
from guang19

@Override
public Object createObject(Attributes attributes) {
    String rolename = attributes.getValue("rolename");
    if (rolename == null) {
        rolename = attributes.getValue("name");
    }
    String description = attributes.getValue("description");
    Role role = database.createRole(rolename, description);
    return role;
}

16 Source : MemoryUserDatabaseMBean.java
with GNU General Public License v3.0
from guang19

/**
 * @return the MBean Names of all roles defined in this database.
 */
public String[] getRoles() {
    UserDatabase database = (UserDatabase) this.resource;
    List<String> results = new ArrayList<>();
    Iterator<Role> roles = database.getRoles();
    while (roles.hasNext()) {
        Role role = roles.next();
        results.add(findRole(role.getRolename()));
    }
    return results.toArray(new String[results.size()]);
}

See More Examples