From: <jbo...@li...> - 2006-01-05 14:39:28
|
Author: rem...@jb... Date: 2006-01-05 09:39:21 -0500 (Thu, 05 Jan 2006) New Revision: 1996 Removed: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Group.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Role.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/User.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/UserDatabase.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/DefaultContextMBean.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GroupMBean.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/RoleMBean.java trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/UserMBean.java Modified: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MBeanUtils.java Log: - Remove remaining realm references. Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Group.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Group.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Group.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,122 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.catalina; - - -import java.security.Principal; -import java.util.Iterator; - - -/** - * <p>Abstract representation of a group of {@link User}s in a - * {@link UserDatabase}. Each user that is a member of this group - * inherits the {@link Role}s assigned to the group.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302726 $ $Date: 2004-02-27 15:59:07 +0100 (ven., 27 févr. 2004) $ - * @since 4.1 - */ - -public interface Group extends Principal { - - - // ------------------------------------------------------------- Properties - - - /** - * Return the description of this group. - */ - public String getDescription(); - - - /** - * Set the description of this group. - * - * @param description The new description - */ - public void setDescription(String description); - - - /** - * Return the group name of this group, which must be unique - * within the scope of a {@link UserDatabase}. - */ - public String getGroupname(); - - - /** - * Set the group name of this group, which must be unique - * within the scope of a {@link UserDatabase}. - * - * @param groupname The new group name - */ - public void setGroupname(String groupname); - - - /** - * Return the set of {@link Role}s assigned specifically to this group. - */ - public Iterator getRoles(); - - - /** - * Return the {@link UserDatabase} within which this Group is defined. - */ - public UserDatabase getUserDatabase(); - - - /** - * Return the set of {@link User}s that are members of this group. - */ - public Iterator getUsers(); - - - // --------------------------------------------------------- Public Methods - - - /** - * Add a new {@link Role} to those assigned specifically to this group. - * - * @param role The new role - */ - public void addRole(Role role); - - - /** - * Is this group specifically assigned the specified {@link Role}? - * - * @param role The role to check - */ - public boolean isInRole(Role role); - - - /** - * Remove a {@link Role} from those assigned to this group. - * - * @param role The old role - */ - public void removeRole(Role role); - - - /** - * Remove all {@link Role}s from those assigned to this group. - */ - public void removeRoles(); - - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Role.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Role.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/Role.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,75 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.catalina; - - -import java.security.Principal; - - -/** - * <p>Abstract representation of a security role, suitable for use in - * environments like JAAS that want to deal with <code>Principals</code>.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302726 $ $Date: 2004-02-27 15:59:07 +0100 (ven., 27 févr. 2004) $ - * @since 4.1 - */ - -public interface Role extends Principal { - - - // ------------------------------------------------------------- Properties - - - /** - * Return the description of this role. - */ - public String getDescription(); - - - /** - * Set the description of this role. - * - * @param description The new description - */ - public void setDescription(String description); - - - /** - * Return the role name of this role, which must be unique - * within the scope of a {@link UserDatabase}. - */ - public String getRolename(); - - - /** - * Set the role name of this role, which must be unique - * within the scope of a {@link UserDatabase}. - * - * @param rolename The new role name - */ - public void setRolename(String rolename); - - - /** - * Return the {@link UserDatabase} within which this Role is defined. - */ - public UserDatabase getUserDatabase(); - - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/User.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/User.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/User.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,173 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.catalina; - - -import java.security.Principal; -import java.util.Iterator; - - -/** - * <p>Abstract representation of a user in a {@link UserDatabase}. Each user - * is optionally associated with a set of {@link Group}s through which he or - * she inherits additional security roles, and is optionally assigned a set - * of specific {@link Role}s.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302726 $ $Date: 2004-02-27 15:59:07 +0100 (ven., 27 févr. 2004) $ - * @since 4.1 - */ - -public interface User extends Principal { - - - // ------------------------------------------------------------- Properties - - - /** - * Return the full name of this user. - */ - public String getFullName(); - - - /** - * Set the full name of this user. - * - * @param fullName The new full name - */ - public void setFullName(String fullName); - - - /** - * Return the set of {@link Group}s to which this user belongs. - */ - public Iterator getGroups(); - - - /** - * Return the logon password of this user, optionally prefixed with the - * identifier of an encoding scheme surrounded by curly braces, such as - * <code>{md5}xxxxx</code>. - */ - public String getPassword(); - - - /** - * Set the logon password of this user, optionally prefixed with the - * identifier of an encoding scheme surrounded by curly braces, such as - * <code>{md5}xxxxx</code>. - * - * @param password The new logon password - */ - public void setPassword(String password); - - - /** - * Return the set of {@link Role}s assigned specifically to this user. - */ - public Iterator getRoles(); - - - /** - * Return the {@link UserDatabase} within which this User is defined. - */ - public UserDatabase getUserDatabase(); - - - /** - * Return the logon username of this user, which must be unique - * within the scope of a {@link UserDatabase}. - */ - public String getUsername(); - - - /** - * Set the logon username of this user, which must be unique within - * the scope of a {@link UserDatabase}. - * - * @param username The new logon username - */ - public void setUsername(String username); - - - // --------------------------------------------------------- Public Methods - - - /** - * Add a new {@link Group} to those this user belongs to. - * - * @param group The new group - */ - public void addGroup(Group group); - - - /** - * Add a {@link Role} to those assigned specifically to this user. - * - * @param role The new role - */ - public void addRole(Role role); - - - /** - * Is this user in the specified {@link Group}? - * - * @param group The group to check - */ - public boolean isInGroup(Group group); - - - /** - * Is this user specifically assigned 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 - */ - public boolean isInRole(Role role); - - - /** - * Remove a {@link Group} from those this user belongs to. - * - * @param group The old group - */ - public void removeGroup(Group group); - - - /** - * Remove all {@link Group}s from those this user belongs to. - */ - public void removeGroups(); - - - /** - * Remove a {@link Role} from those assigned to this user. - * - * @param role The old role - */ - public void removeRole(Role role); - - - /** - * Remove all {@link Role}s from those assigned to this user. - */ - public void removeRoles(); - - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/UserDatabase.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/UserDatabase.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/UserDatabase.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,173 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.catalina; - - -import java.util.Iterator; - - -/** - * <p>Abstract representation of a database of {@link User}s and - * {@link Group}s that can be maintained by an application, - * along with definitions of corresponding {@link Role}s, and - * referenced by a {@link Realm} for authentication and access control.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302726 $ $Date: 2004-02-27 15:59:07 +0100 (ven., 27 févr. 2004) $ - * @since 4.1 - */ - -public interface UserDatabase { - - - // ------------------------------------------------------------- Properties - - - /** - * Return the set of {@link Group}s defined in this user database. - */ - public Iterator getGroups(); - - - /** - * Return the unique global identifier of this user database. - */ - public String getId(); - - - /** - * Return the set of {@link Role}s defined in this user database. - */ - public Iterator getRoles(); - - - /** - * Return the set of {@link User}s defined in this user database. - */ - public Iterator getUsers(); - - - // --------------------------------------------------------- Public Methods - - - /** - * Finalize access to this user database. - * - * @exception Exception if any exception is thrown during closing - */ - public void close() throws Exception; - - - /** - * 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 - */ - public Group createGroup(String groupname, String description); - - - /** - * Create and return a new {@link Role} defined in this user database. - * - * @param rolename The role name of the new role (must be unique) - * @param description The description of this role - */ - public Role createRole(String rolename, String description); - - - /** - * 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 - */ - public User createUser(String username, String password, - String fullName); - - - /** - * Return the {@link Group} with the specified group name, if any; - * otherwise return <code>null</code>. - * - * @param groupname Name of the group to return - */ - public Group findGroup(String groupname); - - - /** - * Return the {@link Role} with the specified role name, if any; - * otherwise return <code>null</code>. - * - * @param rolename Name of the role to return - */ - public Role findRole(String rolename); - - - /** - * Return the {@link User} with the specified user name, if any; - * otherwise return <code>null</code>. - * - * @param username Name of the user to return - */ - public User findUser(String username); - - - /** - * Initialize access to this user database. - * - * @exception Exception if any exception is thrown during opening - */ - public void open() throws Exception; - - - /** - * Remove the specified {@link Group} from this user database. - * - * @param group The group to be removed - */ - public void removeGroup(Group group); - - - /** - * Remove the specified {@link Role} from this user database. - * - * @param role The role to be removed - */ - public void removeRole(Role role); - - - /** - * Remove the specified {@link User} from this user database. - * - * @param user The user to be removed - */ - public void removeUser(User user); - - - /** - * Save any updated information to the persistent storage location for - * this user database. - * - * @exception Exception if any exception is thrown during saving - */ - public void save() throws Exception; - - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/DefaultContextMBean.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/DefaultContextMBean.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/DefaultContextMBean.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,338 +0,0 @@ -/* - * Copyright 1999,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.catalina.mbeans; - -import java.util.ArrayList; - -import javax.management.MBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.RuntimeOperationsException; - -import org.apache.catalina.Context; -import org.apache.catalina.deploy.ContextEnvironment; -import org.apache.catalina.deploy.ContextResource; -import org.apache.catalina.deploy.ContextResourceLink; -import org.apache.catalina.deploy.NamingResources; -import org.apache.commons.modeler.BaseModelMBean; -import org.apache.commons.modeler.ManagedBean; -import org.apache.commons.modeler.Registry; -import org.apache.tomcat.util.compat.JdkCompat; - -/** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.core.StandardDefaultContext</code> component.</p> - * - * @author Amy Roh - * @version $Revision: 303133 $ $Date: 2004-08-29 18:46:15 +0200 (dim., 29 août 2004) $ - */ - -public class DefaultContextMBean extends BaseModelMBean { - - - // ----------------------------------------------------------- Constructors - - - /** - * Construct a <code>ModelMBean</code> with default - * <code>ModelMBeanInfo</code> information. - * - * @exception MBeanException if the initializer of an object - * throws an exception - * @exception RuntimeOperationsException if an IllegalArgumentException - * occurs - */ - public DefaultContextMBean() - throws MBeanException, RuntimeOperationsException { - - super(); - - } - - - // ----------------------------------------------------- Class Variables - - - /** - * JDK compatibility support - */ - private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat(); - - - // ----------------------------------------------------- Instance Variables - - - /** - * The configuration information registry for our managed beans. - */ - protected Registry registry = MBeanUtils.createRegistry(); - - /** - * The <code>ManagedBean</code> information describing this MBean. - */ - protected ManagedBean managed = - registry.findManagedBean("DefaultContext"); - - - // ------------------------------------------------------------- Attributes - - - /** - * Return the naming resources associated with this web application. - */ - private NamingResources getNamingResources() { - - return ((Context)this.resource).getNamingResources(); - - } - - - /** - * Return the MBean Names of the set of defined environment entries for - * this web application - */ - public String[] getEnvironments() { - ContextEnvironment[] envs = getNamingResources().findEnvironments(); - ArrayList results = new ArrayList(); - for (int i = 0; i < envs.length; i++) { - try { - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), envs[i]); - results.add(oname.toString()); - } catch (MalformedObjectNameException e) { - IllegalArgumentException iae = new IllegalArgumentException - ("Cannot create object name for environment " + envs[i]); - jdkCompat.chainException(iae, e); - throw iae; - } - } - return ((String[]) results.toArray(new String[results.size()])); - - } - - - /** - * Return the MBean Names of all the defined resource references for this - * application. - */ - public String[] getResources() { - - ContextResource[] resources = getNamingResources().findResources(); - ArrayList results = new ArrayList(); - for (int i = 0; i < resources.length; i++) { - try { - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), resources[i]); - results.add(oname.toString()); - } catch (MalformedObjectNameException e) { - IllegalArgumentException iae = new IllegalArgumentException - ("Cannot create object name for resource " + resources[i]); - jdkCompat.chainException(iae, e); - throw iae; - } - } - return ((String[]) results.toArray(new String[results.size()])); - - } - - - /** - * Return the MBean Names of all the defined resource links for this - * application - */ - public String[] getResourceLinks() { - - ContextResourceLink[] links = getNamingResources().findResourceLinks(); - ArrayList results = new ArrayList(); - for (int i = 0; i < links.length; i++) { - try { - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), links[i]); - results.add(oname.toString()); - } catch (MalformedObjectNameException e) { - IllegalArgumentException iae = new IllegalArgumentException - ("Cannot create object name for resource " + links[i]); - jdkCompat.chainException(iae, e); - throw iae; - } - } - return ((String[]) results.toArray(new String[results.size()])); - - } - - // ------------------------------------------------------------- Operations - - - /** - * Add an environment entry for this web application. - * - * @param envName New environment entry name - */ - public String addEnvironment(String envName, String type) - throws MalformedObjectNameException { - - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return null; - } - ContextEnvironment env = nresources.findEnvironment(envName); - if (env != null) { - throw new IllegalArgumentException - ("Invalid environment name - already exists '" + envName + "'"); - } - env = new ContextEnvironment(); - env.setName(envName); - env.setType(type); - nresources.addEnvironment(env); - - // Return the corresponding MBean name - ManagedBean managed = registry.findManagedBean("ContextEnvironment"); - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), env); - return (oname.toString()); - - } - - - /** - * Add a resource reference for this web application. - * - * @param resourceName New resource reference name - */ - public String addResource(String resourceName, String type) - throws MalformedObjectNameException { - - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return null; - } - ContextResource resource = nresources.findResource(resourceName); - if (resource != null) { - throw new IllegalArgumentException - ("Invalid resource name - already exists'" + resourceName + "'"); - } - resource = new ContextResource(); - resource.setName(resourceName); - resource.setType(type); - nresources.addResource(resource); - - // Return the corresponding MBean name - ManagedBean managed = registry.findManagedBean("ContextResource"); - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), resource); - - return (oname.toString()); - } - - - /** - * Add a resource link for this web application. - * - * @param resourceLinkName New resource link name - */ - public String addResourceLink(String resourceLinkName, String global, - String name, String type) throws MalformedObjectNameException { - - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return null; - } - ContextResourceLink resourceLink = - nresources.findResourceLink(resourceLinkName); - if (resourceLink != null) { - throw new IllegalArgumentException - ("Invalid resource link name - already exists'" + - resourceLinkName + "'"); - } - resourceLink = new ContextResourceLink(); - resourceLink.setGlobal(global); - resourceLink.setName(resourceLinkName); - resourceLink.setType(type); - nresources.addResourceLink(resourceLink); - - // Return the corresponding MBean name - ManagedBean managed = registry.findManagedBean("ContextResourceLink"); - ObjectName oname = - MBeanUtils.createObjectName(managed.getDomain(), resourceLink); - return (oname.toString()); - } - - - /** - * Remove any environment entry with the specified name. - * - * @param envName Name of the environment entry to remove - */ - public void removeEnvironment(String envName) { - - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return; - } - ContextEnvironment env = nresources.findEnvironment(envName); - if (env == null) { - throw new IllegalArgumentException - ("Invalid environment name '" + envName + "'"); - } - nresources.removeEnvironment(envName); - - } - - - /** - * Remove any resource reference with the specified name. - * - * @param resourceName Name of the resource reference to remove - */ - public void removeResource(String resourceName) { - - resourceName = ObjectName.unquote(resourceName); - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return; - } - ContextResource resource = nresources.findResource(resourceName); - if (resource == null) { - throw new IllegalArgumentException - ("Invalid resource name '" + resourceName + "'"); - } - nresources.removeResource(resourceName); - } - - - /** - * Remove any resource link with the specified name. - * - * @param resourceLinkName Name of the resource reference to remove - */ - public void removeResourceLink(String resourceLinkName) { - - resourceLinkName = ObjectName.unquote(resourceLinkName); - NamingResources nresources = getNamingResources(); - if (nresources == null) { - return; - } - ContextResourceLink resource = nresources.findResourceLink(resourceLinkName); - if (resource == null) { - throw new IllegalArgumentException - ("Invalid resource name '" + resourceLinkName + "'"); - } - nresources.removeResourceLink(resourceLinkName); - } - - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,236 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.catalina.mbeans; - - -import java.util.Iterator; -import javax.naming.Binding; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.OperationNotSupportedException; -import org.apache.catalina.Group; -import org.apache.catalina.Lifecycle; -import org.apache.catalina.LifecycleEvent; -import org.apache.catalina.LifecycleListener; -import org.apache.catalina.Role; -import org.apache.catalina.User; -import org.apache.catalina.UserDatabase; -import org.apache.commons.modeler.Registry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -/** - * Implementation of <code>LifecycleListener</code> that instantiates the - * set of MBeans associated with global JNDI resources that are subject to - * management. - * - * @author Craig R. McClanahan - * @version $Revision: 302983 $ $Date: 2004-06-26 01:56:25 +0200 (sam., 26 juin 2004) $ - * @since 4.1 - */ - -public class GlobalResourcesLifecycleListener - implements LifecycleListener { - private static Log log = LogFactory.getLog(GlobalResourcesLifecycleListener.class); - - // ----------------------------------------------------- Instance Variables - - - /** - * The owning Catalina component that we are attached to. - */ - protected Lifecycle component = null; - - - /** - * The configuration information registry for our managed beans. - */ - protected static Registry registry = MBeanUtils.createRegistry(); - - - // ---------------------------------------------- LifecycleListener Methods - - - /** - * Primary entry point for startup and shutdown events. - * - * @param event The event that has occurred - */ - public void lifecycleEvent(LifecycleEvent event) { - - if (Lifecycle.START_EVENT.equals(event.getType())) { - component = event.getLifecycle(); - createMBeans(); - } else if (Lifecycle.STOP_EVENT.equals(event.getType())) { - destroyMBeans(); - component = null; - } - - } - - - // ------------------------------------------------------ Protected Methods - - - /** - * Create the MBeans for the interesting global JNDI resources. - */ - protected void createMBeans() { - - // Look up our global naming context - Context context = null; - try { - context = (Context) (new InitialContext()).lookup("java:/"); - } catch (NamingException e) { - log.error("No global naming context defined for server"); - return; - } - - // Recurse through the defined global JNDI resources context - try { - createMBeans("", context); - } catch (NamingException e) { - log.error("Exception processing Global JNDI Resources", e); - } - - } - - - /** - * Create the MBeans for the interesting global JNDI resources in - * the specified naming context. - * - * @param prefix Prefix for complete object name paths - * @param context Context to be scanned - * - * @exception NamingException if a JNDI exception occurs - */ - protected void createMBeans(String prefix, Context context) - throws NamingException { - - if (log.isDebugEnabled()) { - log.debug("Creating MBeans for Global JNDI Resources in Context '" + - prefix + "'"); - } - - try { - NamingEnumeration bindings = context.listBindings(""); - while (bindings.hasMore()) { - Binding binding = (Binding) bindings.next(); - String name = prefix + binding.getName(); - Object value = context.lookup(binding.getName()); - if (log.isDebugEnabled()) { - log.debug("Checking resource " + name); - } - if (value instanceof Context) { - createMBeans(name + "/", (Context) value); - } else if (value instanceof UserDatabase) { - try { - createMBeans(name, (UserDatabase) value); - } catch (Exception e) { - log.error("Exception creating UserDatabase MBeans for " + name, - e); - } - } - } - } catch( RuntimeException ex) { - log.error("RuntimeException " + ex); - } catch( OperationNotSupportedException ex) { - log.error("Operation not supported " + ex); - } - - } - - - /** - * 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 roles = database.getRoles(); - while (roles.hasNext()) { - Role 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 groups = database.getGroups(); - while (groups.hasNext()) { - Group 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 users = database.getUsers(); - while (users.hasNext()) { - User 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); - } - } - - } - - - /** - * Destroy the MBeans for the interesting global JNDI resources. - */ - protected void destroyMBeans() { - - if (log.isDebugEnabled()) { - log.debug("Destroying MBeans for Global JNDI Resources"); - } - - } - -} Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GroupMBean.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GroupMBean.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/GroupMBean.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,201 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.catalina.mbeans; - - -import java.util.ArrayList; -import java.util.Iterator; - -import javax.management.MBeanException; -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.RuntimeOperationsException; - -import org.apache.catalina.Group; -import org.apache.catalina.Role; -import org.apache.catalina.User; -import org.apache.commons.modeler.BaseModelMBean; -import org.apache.commons.modeler.ManagedBean; -import org.apache.commons.modeler.Registry; -import org.apache.tomcat.util.compat.JdkCompat; - -/** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.Group</code> component.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302833 $ $Date: 2004-04-15 03:44:09 +0200 (jeu., 15 avr. 2004) $ - */ - -public class GroupMBean extends BaseModelMBean { - - - // ----------------------------------------------------------- Constructors - - - /** - * Construct a <code>ModelMBean</code> with default - * <code>ModelMBeanInfo</code> information. - * - * @exception MBeanException if the initializer of an object - * throws an exception - * @exception RuntimeOperationsException if an IllegalArgumentException - * occurs - */ - public GroupMBean() - throws MBeanException, RuntimeOperationsException { - - super(); - - } - - - // ----------------------------------------------------- Class Variables - - - /** - * JDK compatibility support - */ - private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat(); - - - // ----------------------------------------------------- Instance Variables - - - /** - * The configuration information registry for our managed beans. - */ - protected Registry registry = MBeanUtils.createRegistry(); - - - /** - * The <code>MBeanServer</code> in which we are registered. - */ - protected MBeanServer mserver = MBeanUtils.createServer(); - - - /** - * The <code>ManagedBean</code> information describing this MBean. - */ - protected ManagedBean managed = - registry.findManagedBean("Group"); - - - // ------------------------------------------------------------- Attributes - - - /** - * Return the MBean Names of all authorized roles for this group. - */ - public String[] getRoles() { - - Group group = (Group) this.resource; - ArrayList results = new ArrayList(); - Iterator roles = group.getRoles(); - while (roles.hasNext()) { - Role role = null; - try { - role = (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); - jdkCompat.chainException(iae, e); - throw iae; - } - } - return ((String[]) results.toArray(new String[results.size()])); - - } - - - /** - * Return the MBean Names of all users that are members of this group. - */ - public String[] getUsers() { - - Group group = (Group) this.resource; - ArrayList results = new ArrayList(); - Iterator users = group.getUsers(); - while (users.hasNext()) { - User user = null; - try { - user = (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); - jdkCompat.chainException(iae, e); - throw iae; - } - } - return ((String[]) results.toArray(new String[results.size()])); - - } - - - // ------------------------------------------------------------- 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); - - } - - - /** - * 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); - - } - - -} Modified: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MBeanUtils.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MBeanUtils.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MBeanUtils.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -29,16 +29,12 @@ import org.apache.catalina.Container; import org.apache.catalina.Context; import org.apache.catalina.Engine; -import org.apache.catalina.Group; import org.apache.catalina.Host; import org.apache.catalina.Loader; import org.apache.catalina.Manager; import org.apache.catalina.Realm; -import org.apache.catalina.Role; import org.apache.catalina.Server; import org.apache.catalina.Service; -import org.apache.catalina.User; -import org.apache.catalina.UserDatabase; import org.apache.catalina.Valve; import org.apache.catalina.connector.Connector; import org.apache.catalina.deploy.ContextEnvironment; @@ -319,37 +315,6 @@ /** * 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 ModelMBean createMBean(Group group) - throws Exception { - - String mname = createManagedName(group); - ManagedBean managed = registry.findManagedBean(mname); - if (managed == null) { - Exception e = new Exception("ManagedBean is not found with "+mname); - throw new MBeanException(e); - } - String domain = managed.getDomain(); - if (domain == null) - domain = mserver.getDefaultDomain(); - ModelMBean mbean = managed.createMBean(group); - ObjectName oname = createObjectName(domain, group); - if( mserver.isRegistered( oname )) { - mserver.unregisterMBean(oname); - } - mserver.registerMBean(mbean, oname); - return (mbean); - - } - - - /** - * Create, register, and return an MBean for this * <code>Host</code> object. * * @param host The Host to be managed @@ -536,37 +501,6 @@ /** * Create, register, and return an MBean for this - * <code>Role</code> object. - * - * @param role The Role to be managed - * - * @exception Exception if an MBean cannot be created or registered - */ - static ModelMBean createMBean(Role role) - throws Exception { - - String mname = createManagedName(role); - 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(role); - ObjectName oname = createObjectName(domain, role); - if( mserver.isRegistered( oname )) { - mserver.unregisterMBean(oname); - } - mserver.registerMBean(mbean, oname); - return (mbean); - - } - - - /** - * Create, register, and return an MBean for this * <code>Server</code> object. * * @param server The Server to be managed @@ -629,68 +563,6 @@ /** * 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 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); - if( mserver.isRegistered( oname )) { - mserver.unregisterMBean(oname); - } - mserver.registerMBean(mbean, oname); - return (mbean); - - } - - - /** - * Create, register, and return an MBean for this - * <code>UserDatabase</code> object. - * - * @param userDatabase The UserDatabase to be managed - * - * @exception Exception if an MBean cannot be created or registered - */ - static ModelMBean createMBean(UserDatabase userDatabase) - throws Exception { - - String mname = createManagedName(userDatabase); - 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(userDatabase); - ObjectName oname = createObjectName(domain, userDatabase); - if( mserver.isRegistered( oname )) { - mserver.unregisterMBean(oname); - } - mserver.registerMBean(mbean, oname); - return (mbean); - - } - - - /** - * Create, register, and return an MBean for this * <code>Valve</code> object. * * @param valve The Valve to be managed @@ -931,28 +803,6 @@ /** * 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); - - } - - - /** - * Create an <code>ObjectName</code> for this * <code>Host</code> object. * * @param domain Domain in which this name is to be created @@ -1154,28 +1004,6 @@ /** * 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 - * - * @exception MalformedObjectNameException if a name cannot be created - */ - static ObjectName createObjectName(String domain, - Role role) - throws MalformedObjectNameException { - - ObjectName name = null; - name = new ObjectName(domain + ":type=Role,rolename=" + - role.getRolename() + ",database=" + - role.getUserDatabase().getId()); - return (name); - - } - - - /** - * Create an <code>ObjectName</code> for this * <code>Server</code> object. * * @param domain Domain in which this name is to be created @@ -1217,49 +1045,6 @@ /** * Create an <code>ObjectName</code> for this - * <code>User</code> object. - * - * @param domain Domain in which this name is to be created - * @param user The User to be named - * - * @exception MalformedObjectNameException if a name cannot be created - */ - static ObjectName createObjectName(String domain, - User user) - throws MalformedObjectNameException { - - ObjectName name = null; - name = new ObjectName(domain + ":type=User,username=" + - ObjectName.quote(user.getUsername()) - + ",database=" + user.getUserDatabase().getId()); - return (name); - - } - - - /** - * Create an <code>ObjectName</code> for this - * <code>UserDatabase</code> object. - * - * @param domain Domain in which this name is to be created - * @param userDatabase The UserDatabase to be named - * - * @exception MalformedObjectNameException if a name cannot be created - */ - static ObjectName createObjectName(String domain, - UserDatabase userDatabase) - throws MalformedObjectNameException { - - ObjectName name = null; - name = new ObjectName(domain + ":type=UserDatabase,database=" + - userDatabase.getId()); - return (name); - - } - - - /** - * Create an <code>ObjectName</code> for this * <code>Valve</code> object. * * @param domain Domain in which this name is to be created @@ -1553,32 +1338,6 @@ /** * 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); - - } - - - /** - * Deregister the MBean for this * <code>Host</code> object. * * @param host The Host to be managed @@ -1709,32 +1468,6 @@ /** * Deregister the MBean for this - * <code>Role</code> object. - * - * @param role The Role to be managed - * - * @exception Exception if an MBean cannot be deregistered - */ - static void destroyMBean(Role role) - throws Exception { - - String mname = createManagedName(role); - ManagedBean managed = registry.findManagedBean(mname); - if (managed == null) { - return; - } - String domain = managed.getDomain(); - if (domain == null) - domain = mserver.getDefaultDomain(); - ObjectName oname = createObjectName(domain, role); - if( mserver.isRegistered(oname) ) - mserver.unregisterMBean(oname); - - } - - - /** - * Deregister the MBean for this * <code>Server</code> object. * * @param server The Server to be managed @@ -1787,58 +1520,6 @@ /** * 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); - - } - - - /** - * Deregister the MBean for this - * <code>UserDatabase</code> object. - * - * @param userDatabase The UserDatabase to be managed - * - * @exception Exception if an MBean cannot be deregistered - */ - static void destroyMBean(UserDatabase userDatabase) - throws Exception { - - String mname = createManagedName(userDatabase); - ManagedBean managed = registry.findManagedBean(mname); - if (managed == null) { - return; - } - String domain = managed.getDomain(); - if (domain == null) - domain = mserver.getDefaultDomain(); - ObjectName oname = createObjectName(domain, userDatabase); - if( mserver.isRegistered(oname) ) - mserver.unregisterMBean(oname); - - } - - - /** - * Deregister the MBean for this * <code>Valve</code> object. * * @param valve The Valve to be managed Deleted: trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java 2006-01-05 13:52:16 UTC (rev 1995) +++ trunk/labs/jbossweb/src/share/classes/org/apache/catalina/mbeans/MemoryUserDatabaseMBean.java 2006-01-05 14:39:21 UTC (rev 1996) @@ -1,403 +0,0 @@ -/* - * Copyright 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.catalina.mbeans; - - -import java.util.ArrayList; -import java.util.Iterator; -import javax.management.MalformedObjectNameException; -import javax.management.MBeanException; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.RuntimeOperationsException; -import org.apache.catalina.Group; -import org.apache.catalina.Role; -import org.apache.catalina.User; -import org.apache.catalina.UserDatabase; -import org.apache.commons.modeler.BaseModelMBean; -import org.apache.commons.modeler.ManagedBean; -import org.apache.commons.modeler.Registry; -import org.apache.tomcat.util.compat.JdkCompat; - -/** - * <p>A <strong>ModelMBean</strong> implementation for the - * <code>org.apache.catalina.users.MemoryUserDatabase</code> component.</p> - * - * @author Craig R. McClanahan - * @version $Revision: 302833 $ $Date: 2004-04-15 03:44:09 +0200 (jeu., 15 avr. 2004) $ - */ - -public class MemoryUserDatabaseMBean extends BaseModelMBean { - - - // ----------------------------------------------------------- Constructors - - - /** - * Construct a <code>ModelMBean</code> with default - * <code>ModelMBeanInfo</code> information. - * - * @exception MBeanException if the initializer of an object - * throws an exception - * @exception RuntimeOperationsException if an IllegalArgumentException - * occurs - */ - public MemoryUserDatabaseMBean() - throws MBeanException, RuntimeOperationsException { - - super(); - - } - - - // ----------------------------------------------------- Class Variables - - - /** - * JDK compatibility support - */ - private static final JdkCompat jdkCompat = JdkCompat.getJdkCompat(); - - - // ----------------------------------------------------- Instance Variables - - - /** - * The configuration information registry for our managed beans. - */ - protected Registry registry = MBeanUtils.createRegistry(); - - - /** - * The <code>MBeanServer</code> in which we are registered. - */ - protected MBeanServer mserver = MBeanUtils.createServer(); - - - /** - * The <code>ManagedBean</code> information describing this MBean. - */ - protected ManagedBean managed = - registry.findManagedBean("MemoryUserDatabase"); - - - /** - * The <code>ManagedBean</code> information describing Group MBeans. - */ - protected ManagedBean managedGroup = - registry.findManagedBean("Group"); - - - /** - * The <code>ManagedBean</code> information describing Group MBeans. - */ - protected ManagedBean managedRole = - registry.findManagedBean("Role"); - - - /** - * The <code>ManagedBean</code> information describing User MBeans. - */ - protected ManagedBean managedUser = - registry.findManagedBean("User"); - - - // ------------------------------------------------------------- Attributes - - - /** - * Return the MBean Names of all groups defined in this database. - */ - public String[] getGroups() { - - ... [truncated message content] |