org.apache.catalina.Group Java Examples
The following examples show how to use
org.apache.catalina.Group.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MemoryUserDatabase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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()); } }
Example #2
Source File: MemoryUserDatabase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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); readLock.lock(); try { groups.put(group.getGroupname(), group); } finally { readLock.unlock(); } return group; }
Example #3
Source File: GroupMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @return the MBean Names of all authorized roles for this group. */ public String[] getRoles() { Group group = (Group) this.resource; ArrayList<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()]); }
Example #4
Source File: MemoryUserDatabaseMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Return the MBean Name for the specified group name (if any); * otherwise return <code>null</code>. * * @param groupname Group name to look up * @return the group object name */ 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; } }
Example #5
Source File: UserMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @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<>(); 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()]); }
Example #6
Source File: MBeanUtils.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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); }
Example #7
Source File: MemoryUserDatabaseMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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; } }
Example #8
Source File: MemoryUserDatabase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * 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(); } }
Example #9
Source File: GroupMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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()]); }
Example #10
Source File: UserMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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()]); }
Example #11
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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)); }
Example #12
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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; } }
Example #13
Source File: MemoryUserDatabaseMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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; } }
Example #14
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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); }
Example #15
Source File: GroupMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @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()]); }
Example #16
Source File: MemoryUserDatabase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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); }
Example #17
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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); }
Example #18
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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); }
Example #19
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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; } }
Example #20
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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; } }
Example #21
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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)); }
Example #22
Source File: GroupMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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()]); }
Example #23
Source File: GroupMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * 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()]); }
Example #24
Source File: MemoryUserDatabase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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); }
Example #25
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * 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); }
Example #26
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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()]); }
Example #27
Source File: UserMBean.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * 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); }
Example #28
Source File: GroupMBean.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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); }
Example #29
Source File: UserMBean.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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); }
Example #30
Source File: UserMBean.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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); }