geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From genspr...@apache.org
Subject svn commit: r1025609 - in /geronimo/server/trunk/plugins/console/console-portal-driver/src/main: java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java webapp/WEB-INF/themes/navigation.jsp
Date Wed, 20 Oct 2010 14:58:45 GMT
Author: genspring
Date: Wed Oct 20 14:58:44 2010
New Revision: 1025609

URL: http://svn.apache.org/viewvc?rev=1025609&view=rev
Log:
GERONIMO-5612  Filter no permission functions for built-in user "monitor"

Modified:
    geronimo/server/trunk/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
    geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp

Modified: geronimo/server/trunk/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java?rev=1025609&r1=1025608&r2=1025609&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
(original)
+++ geronimo/server/trunk/plugins/console/console-portal-driver/src/main/java/org/apache/geronimo/console/navigation/NavigationJsonGenerator.java
Wed Oct 20 14:58:44 2010
@@ -16,6 +16,8 @@
  */
 package org.apache.geronimo.console.navigation;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -23,6 +25,8 @@ import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.TreeMap;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.geronimo.pluto.impl.PageConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,6 +56,51 @@ public class NavigationJsonGenerator {
     private static  Map<String, Map<String, TreeNode>> navigationTrees=new HashMap<String,
Map<String, TreeNode>>();
     
     public static final String ALL = "all";
+    
+    private final static List<String> monitorRolePermitPages = Arrays.asList(
+            "0/Welcome",
+            "1-1-1/Application Server/System Information/Server Information",
+            "1-1-2/Application Server/System Information/Java System Info",
+            "1-1-4/Application Server/System Information/Thread Pools",
+            "1-8/Server/Monitoring"
+    );
+
+    
+    private static Map<String, List<String>> rolePagesMap=new HashMap<String,
List<String>>();
+    
+    static {
+        
+        rolePagesMap.put("monitor", monitorRolePermitPages);
+        
+    }
+    
+    public static List<PageConfig> filterPagesByRole(List<PageConfig> pageConfigList,
HttpServletRequest request){
+        
+        List<String> permitPages=null;
+        
+        if(request.isUserInRole("monitor")){
+            
+            permitPages=rolePagesMap.get("monitor"); 
+        }
+        
+        if (permitPages == null) {
+            return pageConfigList;
+        }
+
+        List<PageConfig> filteredPageConfigList = new ArrayList<PageConfig>();
+
+        for (PageConfig pc : pageConfigList) {
+
+            if (permitPages.contains(pc.getName())) {
+
+                filteredPageConfigList.add(pc);
+            }
+        }
+        
+        return filteredPageConfigList;
+        
+    };
+    
       
     private ResourceBundle navigationResourcebundle;
          

Modified: geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp?rev=1025609&r1=1025608&r2=1025609&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
(original)
+++ geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/WEB-INF/themes/navigation.jsp
Wed Oct 20 14:58:44 2010
@@ -29,6 +29,7 @@ limitations under the License.
 
 <%
     List<PageConfig> pageConfigList=new ArrayList<PageConfig>();
+
 %>
 
 <c:forEach var="page" items="${driverConfig.pages}">
@@ -38,12 +39,18 @@ limitations under the License.
 </c:forEach>
 
 <%
+	
+	List<PageConfig> filteredPageConfigList = NavigationJsonGenerator.filterPagesByRole(pageConfigList,request);
+	    
+
     NavigationJsonGenerator generator = new NavigationJsonGenerator(request.getLocale());
-    String treeJson = generator.generateTreeJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif", "all", 8);
-    String treeJsonBasic = generator.generateTreeJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif","basic", 8);
-    String listJson = generator.generateQuickLauncherJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif", "all");
-    String listJsonBasic = generator.generateQuickLauncherJSON(pageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif","basic");
-    boolean isBasicTreeHasValidItem=generator.isTreeHasValidItem(pageConfigList,"basic");
+
+
+    String treeJson = generator.generateTreeJSON(filteredPageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif", "all", 8);
+    String treeJsonBasic = generator.generateTreeJSON(filteredPageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif","basic", 8);
+    String listJson = generator.generateQuickLauncherJSON(filteredPageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif", "all");
+    String listJsonBasic = generator.generateQuickLauncherJSON(filteredPageConfigList, request.getContextPath(),
"/images/ico_doc_16x16.gif","basic");
+    boolean isBasicTreeHasValidItem=generator.isTreeHasValidItem(filteredPageConfigList,"basic");
 
 %>
 



Mime
View raw message