geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r559950 - in /geronimo/server/trunk/applications/console/geronimo-console-standard/src/main: java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java webapp/WEB-INF/view/realmwizard/selectType.jsp
Date Thu, 26 Jul 2007 19:33:13 GMT
Author: dwoods
Date: Thu Jul 26 12:33:12 2007
New Revision: 559950

URL: http://svn.apache.org/viewvc?view=rev&rev=559950
Log:
GERONIMO-2534 Security realms portlet should validate the realm-name for duplicate name. 
Patch from Don Hill.

Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/realmwizard/selectType.jsp

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java?view=diff&rev=559950&r1=559949&r2=559950
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/securitymanager/realm/SecurityRealmPortlet.java
Thu Jul 26 12:33:12 2007
@@ -189,10 +189,15 @@
         } else if (mode.equals("process-" + SELECT_TYPE_MODE)) {
             if (data.getName() != null && !data.getName().trim().equals("")) {
                 // Config properties have to be set in render since they have values of null
-                if (data.getRealmType().equals("Other")) {
-                    actionResponse.setRenderParameter(MODE_KEY, CUSTOM_MODE);
+                if( doesRealmExist(actionRequest, data.getName())) {
+                    actionResponse.setRenderParameter("SecurityRealmNamingError", "Please
provide a unique Security Realm Name, " + data.getName() + " is already in use");
+                    actionResponse.setRenderParameter(MODE_KEY, SELECT_TYPE_MODE);
                 } else {
-                    actionResponse.setRenderParameter(MODE_KEY, CONFIGURE_MODE);
+                    if (data.getRealmType().equals("Other")) {
+                        actionResponse.setRenderParameter(MODE_KEY, CUSTOM_MODE);
+                    } else {
+                        actionResponse.setRenderParameter(MODE_KEY, CONFIGURE_MODE);
+                    }
                 }
             } else {
                 actionResponse.setRenderParameter(MODE_KEY, SELECT_TYPE_MODE);
@@ -584,6 +589,9 @@
 
     private void renderSelectType(RenderRequest request, RenderResponse response) throws
IOException, PortletException {
         request.setAttribute("moduleTypes", MasterLoginModuleInfo.getAllModules());
+        if (request.getParameter("SecurityRealmNamingError") != null) {
+            request.setAttribute("SecurityRealmNamingError", request.getParameter("SecurityRealmNamingError"));
+        }
         selectTypeView.include(request, response);
     }
 
@@ -1149,4 +1157,27 @@
             }
         }
     }
-}
\ No newline at end of file
+
+    /**
+     * When adding a new security determine if the realm name is already registered.
+     *
+     * @param request - the request associated with the current user
+     * @param realmName -  the realm name to check and see if it already exists
+     *
+     * @return boolean - if the relam name already exists.
+     */
+    private boolean doesRealmExist(PortletRequest request, String realmName) {
+        org.apache.geronimo.management.geronimo.SecurityRealm[] realms = PortletManager.getCurrentServer(request).getSecurityRealms();
+        boolean exist = false;
+        for (int i = 0; i < realms.length; i++) {
+            org.apache.geronimo.management.geronimo.SecurityRealm result = realms[i];
+
+            if( result.getRealmName().equalsIgnoreCase(realmName)){
+                exist = true;
+                break;
+            }
+        }
+        return exist;
+    }
+}
+

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/realmwizard/selectType.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/realmwizard/selectType.jsp?view=diff&rev=559950&r1=559949&r2=559950
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/realmwizard/selectType.jsp
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/webapp/WEB-INF/view/realmwizard/selectType.jsp
Thu Jul 26 12:33:12 2007
@@ -30,6 +30,7 @@
 </script>
 
 <p><b>Create Security Realm</b> -- Step 1: Select Name and Type</p>
+<c:if test="${!(empty SecurityRealmNamingError)}"><p><font color="red"><b>Naming
Error: ${SecurityRealmNamingError}</b></font></p></c:if>
 
 <!--   FORM TO COLLECT DATA FOR THIS PAGE   -->
 <form name="<portlet:namespace/>RealmForm" action="<portlet:actionURL/>">



Mime
View raw message