/** * 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()]); }
/** * 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); }
/** * Create an <code>ObjectName</code> for this * <code>Group</code> object. * * @param domain Domain in which this name is to be created * @param group The Group to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Group group) throws MalformedObjectNameException { ObjectName name = null; name = new ObjectName(domain + ":type=Group,groupname=" + ObjectName.quote(group.getGroupname()) + ",database=" + group.getUserDatabase().getId()); return (name); }
/** * 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); } }
/** * @return the MBean Names of all groups defined in this database. */ public String[] getGroups() { UserDatabase database = (UserDatabase) this.resource; List<String> results = new ArrayList<>(); Iterator<Group> groups = database.getGroups(); while (groups.hasNext()) { Group group = groups.next(); results.add(findGroup(group.getGroupname())); } return results.toArray(new String[results.size()]); }
/** * Remove the specified {@link Role} from this user database. * * @param role The role to be removed */ 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()); } }
/** * @return the MBean Names of all users that are members of this group. */ public String[] getUsers() { Group group = (Group) this.resource; List<String> results = new ArrayList<>(); 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()]); }
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); }
while(groups.hasNext()) { Group group = (Group)groups.next(); if(group.isInRole(dbrole)) { return true;
/** * 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); }
/** * Return the MBean Names of all groups defined in this database. */ public String[] getGroups() { UserDatabase database = (UserDatabase) this.resource; ArrayList<String> results = new ArrayList<>(); Iterator<Group> groups = database.getGroups(); while (groups.hasNext()) { Group group = groups.next(); results.add(findGroup(group.getGroupname())); } return results.toArray(new String[results.size()]); }
/** * 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()); } }
/** * 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<>(); 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()]); }
role = database.createRole(rolename, null); group.addRole(role);
while (groups.hasNext()) { Group group = groups.next(); if (group.isInRole(dbrole)) { return true;
/** * 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); }
/** * 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); }
/** * Create an <code>ObjectName</code> for this * <code>Group</code> object. * * @param domain Domain in which this name is to be created * @param group The Group to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Group group) throws MalformedObjectNameException { ObjectName name = null; name = new ObjectName(domain + ":type=Group,groupname=" + ObjectName.quote(group.getGroupname()) + ",database=" + group.getUserDatabase().getId()); return (name); }
/** * @return the MBean Names of all authorized roles for this group. */ public String[] getRoles() { Group group = (Group) this.resource; List<String> results = new ArrayList<>(); 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()]); }
/** * Return the MBean Names of all groups defined in this database. */ public String[] getGroups() { UserDatabase database = (UserDatabase) this.resource; ArrayList results = new ArrayList(); Iterator groups = database.getGroups(); while (groups.hasNext()) { Group group = (Group) groups.next(); results.add(findGroup(group.getGroupname())); } return ((String[]) results.toArray(new String[results.size()])); }