Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 65280 invoked from network); 8 Apr 2002 17:46:21 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 8 Apr 2002 17:46:21 -0000 Received: (qmail 10963 invoked by uid 97); 8 Apr 2002 17:46:14 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 10947 invoked by uid 97); 8 Apr 2002 17:46:14 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 10930 invoked by uid 97); 8 Apr 2002 17:46:13 -0000 Date: 8 Apr 2002 17:46:08 -0000 Message-ID: <20020408174608.74950.qmail@icarus.apache.org> From: craigmcc@apache.org To: jakarta-tomcat-4.0-cvs@apache.org Subject: cvs commit: jakarta-tomcat-4.0/webapps/manager/WEB-INF web.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N craigmcc 02/04/08 10:46:08 Modified: catalina/src/share/org/apache/catalina/servlets LocalStrings.properties ManagerServlet.java webapps/manager manager.xml webapps/manager/WEB-INF web.xml Log: Implement a lookup mechanism to enumerate the security roles (and corresponding descriptions) defined in the user database. This will be useful, for example, in deployment tools that wish to create elements in the web.xml file that link role names used in the web application to those that are actually defined in the container. Revision Changes Path 1.15 +3 -0 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties Index: LocalStrings.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/LocalStrings.properties,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- LocalStrings.properties 12 Mar 2002 21:14:15 -0000 1.14 +++ LocalStrings.properties 8 Apr 2002 17:46:08 -0000 1.15 @@ -34,6 +34,7 @@ managerServlet.removed=OK - Removed application at context path {0} managerServlet.resourcesAll=OK - Listed global resources of all types managerServlet.resourcesType=OK - Listed global resources of type {0} +managerServlet.rolesList=OK - Listed security roles managerServlet.sessiondefaultmax=Default maximum session inactive interval {0} minutes managerServlet.sessiontimeout={0} minutes:{1} sessions managerServlet.sessions=OK - Session information for application at context path {0} @@ -42,6 +43,8 @@ managerServlet.stopped=OK - Stopped application at context path {0} managerServlet.undeployed=OK - Undeployed application at context path {0} managerServlet.unknownCommand=FAIL - Unknown command {0} +managerServlet.userDatabaseError=FAIL - Cannot resolve user database reference +managerServlet.userDatabaseMissing=FAIL - No user database is available webdavservlet.jaxpfailed=JAXP initialization failed directory.filename=Filename directory.lastModified=Last Modified 1.19 +63 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java Index: ManagerServlet.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ManagerServlet.java 13 Mar 2002 01:26:49 -0000 1.18 +++ ManagerServlet.java 8 Apr 2002 17:46:08 -0000 1.19 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java,v 1.18 2002/03/13 01:26:49 craigmcc Exp $ - * $Revision: 1.18 $ - * $Date: 2002/03/13 01:26:49 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/ManagerServlet.java,v 1.19 2002/04/08 17:46:08 craigmcc Exp $ + * $Revision: 1.19 $ + * $Date: 2002/04/08 17:46:08 $ * * ==================================================================== * @@ -73,8 +73,11 @@ import java.io.PrintWriter; import java.net.URL; import java.util.Enumeration; +import java.util.Iterator; +import javax.naming.InitialContext; import javax.naming.NameClassPair; import javax.naming.NamingEnumeration; +import javax.naming.NamingException; import javax.naming.directory.DirContext; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; @@ -88,9 +91,11 @@ import org.apache.catalina.Deployer; import org.apache.catalina.Globals; import org.apache.catalina.Host; +import org.apache.catalina.Role; import org.apache.catalina.Server; import org.apache.catalina.ServerFactory; import org.apache.catalina.Session; +import org.apache.catalina.UserDatabase; import org.apache.catalina.Wrapper; import org.apache.catalina.core.StandardServer; import org.apache.catalina.util.StringManager; @@ -137,6 +142,9 @@ *
  • /resources?type=xxxx - Enumerate the available global JNDI * resources, optionally limited to those of the specified type * (fully qualified Java class name), if available.
  • + *
  • /roles - Enumerate the available security role names and + * descriptions from the user database connected to the users + * resource reference. *
  • /sessions?path=/xxx - List session information about the web * application attached to context path /xxx for this * virtual host.
  • @@ -188,7 +196,7 @@ * * * @author Craig R. McClanahan - * @version $Revision: 1.18 $ $Date: 2002/03/13 01:26:49 $ + * @version $Revision: 1.19 $ $Date: 2002/04/08 17:46:08 $ */ public class ManagerServlet @@ -327,6 +335,8 @@ remove(writer, path); } else if (command.equals("/resources")) { resources(writer, type); + } else if (command.equals("/roles")) { + roles(writer); } else if (command.equals("/sessions")) { sessions(writer, path); } else if (command.equals("/start")) { @@ -782,6 +792,55 @@ writer.println(sm.getString("managerServlet.exception", t.toString())); } + + } + + + /** + * Render a list of security role names (and corresponding descriptions) + * from the org.apache.catalina.UserDatabase resource that is + * connected to the users resource reference. Typically, this + * will be the global user database, but can be adjusted if you have + * different user databases for different virtual hosts. + * + * @param writer Writer to render to + */ + protected void roles(PrintWriter writer) { + + if (debug >= 1) { + log("roles: List security roles from user database"); + } + + // Look up the UserDatabase instance we should use + UserDatabase database = null; + try { + InitialContext ic = new InitialContext(); + database = (UserDatabase) ic.lookup("java:comp/env/users"); + } catch (NamingException e) { + writer.println(sm.getString("managerServlet.userDatabaseError")); + log("java:comp/env/users", e); + return; + } + if (database == null) { + writer.println(sm.getString("managerServlet.userDatabaseMissing")); + return; + } + + // Enumerate the available roles + writer.println(sm.getString("managerServlet.rolesList")); + Iterator roles = database.getRoles(); + if (roles != null) { + while (roles.hasNext()) { + Role role = (Role) roles.next(); + writer.print(role.getRolename()); + writer.print(':'); + if (role.getDescription() != null) { + writer.print(role.getDescription()); + } + writer.println(); + } + } + } 1.2 +6 -1 jakarta-tomcat-4.0/webapps/manager/manager.xml Index: manager.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/manager/manager.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- manager.xml 27 Oct 2001 22:17:14 -0000 1.1 +++ manager.xml 8 Apr 2002 17:46:08 -0000 1.2 @@ -2,11 +2,16 @@ Context configuration file for the Tomcat Manager Web App - $Id: manager.xml,v 1.1 2001/10/27 22:17:14 craigmcc Exp $ + $Id: manager.xml,v 1.2 2002/04/08 17:46:08 craigmcc Exp $ --> + + + + 1.5 +14 -0 jakarta-tomcat-4.0/webapps/manager/WEB-INF/web.xml Index: web.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/manager/WEB-INF/web.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- web.xml 4 Apr 2002 20:30:34 -0000 1.4 +++ web.xml 8 Apr 2002 17:46:08 -0000 1.5 @@ -27,6 +27,20 @@ /* + + + + Link to the UserDatabase instance from which we request lists of + defined role names. Typically, this will be connected to the global + user database with a ResourceLink element in server.xml or the context + configuration file for the Manager web application. + + users + + org.apache.catalina.UserDatabase + + + -- To unsubscribe, e-mail: For additional commands, e-mail: