geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r816623 - in /geronimo/server/branches/2.2/plugins/console: console-base-portlets/src/main/i18n-resources/ console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/ console-base-portlets/src/main/java/org/apache/geron...
Date Fri, 18 Sep 2009 13:14:05 GMT
Author: xuhaihong
Date: Fri Sep 18 13:14:04 2009
New Revision: 816623

URL: http://svn.apache.org/viewvc?rev=816623&view=rev
Log:
GERONIMO-4603 PropertiesLoginManager is hardwired to properties-login login module

Modified:
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_en.properties
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_ja.properties
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_zh.properties
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEGroupsPortlet.java
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEUsersPortlet.java
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/RealmHelper.java
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/SERealmGroupHelper.java
    geronimo/server/branches/2.2/plugins/console/console-core/src/main/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_en.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_en.properties?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_en.properties
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_en.properties
Fri Sep 18 13:14:04 2009
@@ -130,6 +130,7 @@
 consolebase.errorMsg21 = Unable to get next serial number from CA.
 consolebase.errorMsg22 = Errors in user input while processing a CSR.
 consolebase.errorMsg23 = Errors encountered while issuing certificate.
+consolebase.errorMsg24 = Default properties-login module does not exist, it may be replaced
by a customized login module.
 consolebase.infoMsg01  = Started application
 consolebase.infoMsg02  = Stopped application
 consolebase.infoMsg03  = Restarted application

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_ja.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_ja.properties?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_ja.properties
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_ja.properties
Fri Sep 18 13:14:04 2009
@@ -130,6 +130,7 @@
 consolebase.errorMsg21 = CA から次のシリアル・ナンバーを取得できません。
 consolebase.errorMsg22 = CSR の処理中にユーザー入力エラーです。
 consolebase.errorMsg23 = 証明書の発行中のエラーが発生しました。
+consolebase.errorMsg24 = Default properties-login module does not exist, it may be replaced
by a customized login module.
 consolebase.infoMsg01  = アプリケーションを始動しました
 consolebase.infoMsg02  = アプリケーションを停止しました
 consolebase.infoMsg03  = アプリケーションを再始動しました

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_zh.properties
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_zh.properties?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_zh.properties
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/i18n-resources/portletinfo_zh.properties
Fri Sep 18 13:14:04 2009
@@ -130,6 +130,7 @@
 consolebase.errorMsg21 = 无法从CA得到下一个序列号。
 consolebase.errorMsg22 = 处理CSR时用户输入错误。
 consolebase.errorMsg23 = 颁发证书时遇到错误。
+consolebase.errorMsg24 = 默认的登录模块不存在, 可能被自定义的登录模块替换。
 consolebase.infoMsg01  = 已启动应用
 consolebase.infoMsg02  = 已停止应用
 consolebase.infoMsg03  = 已重启应用

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEGroupsPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEGroupsPortlet.java?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEGroupsPortlet.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEGroupsPortlet.java
Fri Sep 18 13:14:04 2009
@@ -45,6 +45,9 @@
         if (errorMessage != null) {
             renderRequest.setAttribute("errorMessage", errorMessage);
             errorView.include(renderRequest, renderResponse);
+        } else if (!SERealmGroupHelper.isDefaultLoginModuleAvaiable()) {
+            renderRequest.setAttribute("errorMessage", getLocalizedString(renderRequest,
"consolebase.errorMsg24"));
+            errorView.include(renderRequest, renderResponse);
         } else {
             String currAction = renderRequest.getParameter("currAction");
             String message = renderRequest.getParameter("message");

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEUsersPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEUsersPortlet.java?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEUsersPortlet.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/securitymanager/SEUsersPortlet.java
Fri Sep 18 13:14:04 2009
@@ -49,6 +49,9 @@
         if (errorMessage != null) {
             renderRequest.setAttribute("errorMessage", errorMessage);
             errorView.include(renderRequest, renderResponse);
+        } else if (!SERealmGroupHelper.isDefaultLoginModuleAvaiable()) {
+            renderRequest.setAttribute("errorMessage", getLocalizedString(renderRequest,
"consolebase.errorMsg24"));
+            errorView.include(renderRequest, renderResponse);
         } else {
             try {
                 String[] users = SERealmUserHelper.getUsers();

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/RealmHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/RealmHelper.java?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/RealmHelper.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/RealmHelper.java
Fri Sep 18 13:14:04 2009
@@ -17,5 +17,19 @@
 
 package org.apache.geronimo.console.util;
 
-public abstract class RealmHelper extends KernelHelper {
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class RealmHelper extends KernelHelper {        
+    
+    private static final Logger logger = LoggerFactory.getLogger(RealmHelper.class);
+
+    public static boolean isDefaultLoginModuleAvaiable() {
+        try {
+            return (Boolean) invoke(ObjectNameConstants.SE_REALM_MBEAN_NAME, "isAvailable");
+        } catch (Exception e) {
+            logger.error("Fail to check the status of " + ObjectNameConstants.SE_REALM_MBEAN_NAME,
e);
+            return false;
+        }
+    }
 }

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/SERealmGroupHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/SERealmGroupHelper.java?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/SERealmGroupHelper.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/util/SERealmGroupHelper.java
Fri Sep 18 13:14:04 2009
@@ -37,6 +37,8 @@
     private static final String DELETE_GROUP_FUNCTION = "removeGroupPrincipal";
 
     private static final String GET_USERS_FUNCTION = "getGroupMembers";
+    
+    private static final String IS_AVAILABLE = "isAvailable";
 
     private static final String[] STRING = { "java.lang.String" };
 
@@ -115,10 +117,14 @@
         Collection users = getUsersAsCollection(groupName);
         return (users.contains(username));
     }
-
+    
     private static Collection getUsersAsCollection(String groupName)
             throws Exception {
         return getUsers(groupName);
     }
+    
+    public static boolean isAvailable() throws Exception {
+        return (Boolean) invoke(ObjectNameConstants.SE_REALM_MBEAN_NAME, IS_AVAILABLE, new
Object[0], new String[0]);
+    }
 
 }
\ No newline at end of file

Modified: geronimo/server/branches/2.2/plugins/console/console-core/src/main/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-core/src/main/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java?rev=816623&r1=816622&r2=816623&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-core/src/main/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-core/src/main/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java
Fri Sep 18 13:14:04 2009
@@ -28,6 +28,7 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -41,6 +42,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.SingleElementCollection;
 import org.apache.geronimo.security.SecurityNames;
 import org.apache.geronimo.security.jaas.LoginModuleSettings;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -55,7 +57,7 @@
 
     private ServerInfo serverInfo;
 
-    private LoginModuleSettings loginModule;
+    private SingleElementCollection<LoginModuleSettings> loginModule;
 
     private Properties users = new Properties();
 
@@ -67,11 +69,15 @@
 
     private static final String digestKey = "digest";
 
-    private final static String encodingKey = "encoding";
-
-    public PropertiesLoginModuleManager(ServerInfo serverInfo, LoginModuleSettings loginModule)
{
+    private final static String encodingKey = "encoding";    
+    
+    public PropertiesLoginModuleManager(ServerInfo serverInfo, Collection<LoginModuleSettings>
loginModule) {
         this.serverInfo = serverInfo;
-        this.loginModule = loginModule;
+        this.loginModule = new SingleElementCollection<LoginModuleSettings>(loginModule);
+    }
+
+    public boolean isAvailable() {
+        return loginModule.getElement() != null;
     }
 
     private void refreshUsers() throws GeronimoSecurityException {
@@ -132,7 +138,7 @@
         return (String[]) groups.keySet().toArray(new String[0]);
     }
 
-    public void addUserPrincipal(Hashtable properties)
+    public void addUserPrincipal(Hashtable<String, String> properties)
             throws GeronimoSecurityException {
 
         refreshUsers();
@@ -170,7 +176,7 @@
         }
     }
 
-    public void updateUserPrincipal(Hashtable properties)
+    public void updateUserPrincipal(Hashtable<String, String> properties)
             throws GeronimoSecurityException {
         refreshUsers();
         String name = (String) properties.get("UserName");
@@ -195,7 +201,7 @@
         }
     }
 
-    public void addGroupPrincipal(Hashtable properties)
+    public void addGroupPrincipal(Hashtable<String, String> properties)
             throws GeronimoSecurityException {
         refreshGroups();
         String group = (String) properties.get("GroupName");
@@ -224,7 +230,7 @@
         }
     }
 
-    public void updateGroupPrincipal(Hashtable properties)
+    public void updateGroupPrincipal(Hashtable<String, String> properties)
             throws GeronimoSecurityException {
         //same as add group principal
         refreshGroups();
@@ -268,9 +274,9 @@
         return realPassword;
     }
 
-    public Set getGroupMembers(String groupPrincipal)
+    public Set<String> getGroupMembers(String groupPrincipal)
             throws GeronimoSecurityException {
-        Set memberSet = new HashSet();
+        Set<String> memberSet = new HashSet<String>();
         // return nothing when the groupPrincipal is null or empty
         if (groupPrincipal == null || groupPrincipal.equals("")) {
             return memberSet;
@@ -287,19 +293,19 @@
     }
 
     private String getUsersURI() {
-        return (String) loginModule.getOptions().get(usersKey);
+        return (String) loginModule.getElement().getOptions().get(usersKey);
     }
 
     private String getGroupsURI() {
-        return (String) loginModule.getOptions().get(groupsKey);
+        return (String) loginModule.getElement().getOptions().get(groupsKey);
     }
 
     private String getDigest() {
-        return (String) loginModule.getOptions().get(digestKey);
+        return (String) loginModule.getElement().getOptions().get(digestKey);
     }
 
     private String getEncoding() {
-        return (String) loginModule.getOptions().get(encodingKey);
+        return (String) loginModule.getElement().getOptions().get(encodingKey);
     }
 
     /**
@@ -394,6 +400,10 @@
 
     public void doStart() throws Exception {
         log.debug("Starting gbean");
+        if (!isAvailable()) {
+            log.warn("Could not find the default properties-login login module");
+            return;
+        }
         encryptAllPasswords();
         log.debug("Started gbean");
     }
@@ -409,23 +419,24 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("PropertiesLoginModuleManager",
PropertiesLoginModuleManager.class);
 
-        infoFactory.addOperation("addUserPrincipal", new Class[]{Hashtable.class});
-        infoFactory.addOperation("removeUserPrincipal", new Class[]{String.class});
-        infoFactory.addOperation("updateUserPrincipal", new Class[]{Hashtable.class});
-        infoFactory.addOperation("getGroups");
-        infoFactory.addOperation("getUsers");
-        infoFactory.addOperation("refreshAll");
-
-        infoFactory.addOperation("updateUserPrincipal", new Class[]{Hashtable.class});
-
-        infoFactory.addOperation("getPassword", new Class[]{String.class});
-        infoFactory.addOperation("getGroupMembers", new Class[]{String.class});
-        infoFactory.addOperation("addGroupPrincipal", new Class[]{Hashtable.class});
-        infoFactory.addOperation("removeGroupPrincipal", new Class[]{String.class});
-        infoFactory.addOperation("updateGroupPrincipal", new Class[]{Hashtable.class});
-        infoFactory.addOperation("addToGroup", new Class[]{String.class, String.class});
-        infoFactory.addOperation("removeFromGroup", new Class[]{String.class, String.class});
-
+        infoFactory.addOperation("addUserPrincipal", new Class[] { Hashtable.class }, void.class.getName());
+        infoFactory.addOperation("removeUserPrincipal", new Class[] { String.class }, void.class.getName());
+        infoFactory.addOperation("updateUserPrincipal", new Class[] { Hashtable.class },
void.class.getName());
+        infoFactory.addOperation("getGroups", String[].class.getName());
+        infoFactory.addOperation("getUsers", String[].class.getName());
+        infoFactory.addOperation("refreshAll", void.class.getName());
+
+        infoFactory.addOperation("updateUserPrincipal", new Class[] { Hashtable.class },
void.class.getName());
+
+        infoFactory.addOperation("getPassword", new Class[] { String.class }, void.class.getName());
+        infoFactory.addOperation("getGroupMembers", new Class[] { String.class }, void.class.getName());
+        infoFactory.addOperation("addGroupPrincipal", new Class[] { Hashtable.class }, void.class.getName());
+        infoFactory.addOperation("removeGroupPrincipal", new Class[] { String.class }, void.class.getName());
+        infoFactory.addOperation("updateGroupPrincipal", new Class[] { Hashtable.class },
void.class.getName());
+        infoFactory.addOperation("addToGroup", new Class[] { String.class, String.class },
void.class.getName());
+        infoFactory.addOperation("removeFromGroup", new Class[] { String.class, String.class
}, void.class.getName());
+        infoFactory.addOperation("isAvailable", boolean.class.getName());
+        
         infoFactory.addReference("ServerInfo", ServerInfo.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
         infoFactory.addReference("LoginModule", LoginModuleSettings.class, SecurityNames.LOGIN_MODULE);
 



Mime
View raw message