portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r398020 - in /portals/jetspeed-2/trunk: components/security/src/java/org/apache/jetspeed/security/impl/ src/webapp/WEB-INF/assembly/
Date Fri, 28 Apr 2006 21:30:26 GMT
Author: ate
Date: Fri Apr 28 14:30:24 2006
New Revision: 398020

URL: http://svn.apache.org/viewcvs?rev=398020&view=rev
Log:
Implementing improvement JS2-527: Allow email addresses to be used for user accounts by making
hierarchical interpretation of principal names optional
See: http://issues.apache.org/jira/browse/JS2-527

Added:
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/hierarchical-principal-names.xml
Modified:
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/RolePrincipalImpl.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserPrincipalImpl.java

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java?rev=398020&r1=398019&r2=398020&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
Fri Apr 28 14:30:24 2006
@@ -99,20 +99,42 @@
      * 
      * @param name The principal name.
      * @param prefsRoot The preferences root node.
+     * @param hiearchicalNames indicator if hierarchy encoding (replacing '.' with '/') should
be done
      * @return The preferences full path / principal name.
      */
-    public static String getFullPathFromPrincipalName(String name, String prefsRoot)
+    public static String getFullPathFromPrincipalName(String name, String prefsRoot, boolean
hiearchicalNames)
     {
         String fullPath = name;
-        if (null != fullPath)
+        if (null != name )
         {
-            fullPath = prefsRoot + fullPath.replace('.', '/');
+            fullPath = prefsRoot + (hiearchicalNames ? name.replace(',','/') : name );
         }
         return fullPath;
     }
 
     /**
      * <p>
+     * Gets the principal implementation full path from the principal name.
+     * </p>
+     * <p>
+     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used
as the
+     * separator for hierarchical elements.
+     * </p>
+     * <p>
+     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
+     * </p>
+     * 
+     * @param name The principal name.
+     * @param prefsRoot The preferences root node.
+     * @return The preferences full path / principal name.
+     */
+    public static String getFullPathFromPrincipalName(String name, String prefsRoot)
+    {
+        return getFullPathFromPrincipalName(name, prefsRoot, true);
+    }
+
+    /**
+     * <p>
      * Gets the principal name from the principal implementation full path.
      * </p>
      * <p>
@@ -125,24 +147,42 @@
      * 
      * @param fullPath The principal full path.
      * @param prefsRoot The preferences root node.
+     * @param hiearchicalNames indicator if hierarchical decoding (replacing '/' with '.')
should be done
      * @return The principal name.
      */
-    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot)
+    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot,
boolean hiearchicalNames)
     {
         String name = fullPath;
         if (null != name)
         {
-            if (prefsRoot.equals(UserPrincipalImpl.PREFS_USER_ROOT))
-            {
-                name = name.substring(prefsRoot.length(), name.length());
-            }
-            else
+            name = name.substring(prefsRoot.length(), name.length());
+            if ( hiearchicalNames )
             {
-                name = name.substring(prefsRoot.length(), name.length());
+                name = name.replace('/', '.');
             }
-            name = name.replace('/', '.');
         }
         return name;
+    }
+
+    /**
+     * <p>
+     * Gets the principal name from the principal implementation full path.
+     * </p>
+     * <p>
+     * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used
as the
+     * separator for hierarchical elements.
+     * </p>
+     * <p>
+     * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
+     * </p>
+     * 
+     * @param fullPath The principal full path.
+     * @param prefsRoot The preferences root node.
+     * @return The principal name.
+     */
+    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot)
+    {
+        return getPrincipalNameFromFullPath(fullPath, prefsRoot, true);
     }
 
     private boolean enabled = true;

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java?rev=398020&r1=398019&r2=398020&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/GroupPrincipalImpl.java
Fri Apr 28 14:30:24 2006
@@ -27,6 +27,14 @@
     /** The serial version uid. */
     private static final long serialVersionUID = 6061115481776568899L;
 
+    private static boolean hiearchicalNames = true;
+
+    public static final Object useHierarchicalNames(boolean hierarchicalNames)
+    {
+        GroupPrincipalImpl.hiearchicalNames = hierarchicalNames;
+        return null;
+    }
+    
     /**
      * <p>The group principal constructor.</p>
      * @param groupName The group principal name.
@@ -61,7 +69,7 @@
      */
     public static String getFullPathFromPrincipalName(String name)
     {
-        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_GROUP_ROOT);
+        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_GROUP_ROOT, hiearchicalNames);
     }
 
     /**
@@ -72,7 +80,7 @@
      */
     public static String getPrincipalNameFromFullPath(String fullPath)
     {
-        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_GROUP_ROOT);
+        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_GROUP_ROOT,
hiearchicalNames);
     }
     
 }

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/RolePrincipalImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/RolePrincipalImpl.java?rev=398020&r1=398019&r2=398020&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/RolePrincipalImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/RolePrincipalImpl.java
Fri Apr 28 14:30:24 2006
@@ -27,6 +27,14 @@
     /** The serial version uid. */
     private static final long serialVersionUID = -3521731040045006314L;
 
+    private static boolean hiearchicalNames = true;
+
+    public static final Object useHierarchicalNames(boolean hierarchicalNames)
+    {
+        RolePrincipalImpl.hiearchicalNames = hierarchicalNames;
+        return null;
+    }
+    
     /**
      * <p>The role principal constructor.</p>
      * @param roleName The role principal name.
@@ -62,7 +70,7 @@
      */
     public static String getFullPathFromPrincipalName(String name)
     {
-        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_ROLE_ROOT);
+        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_ROLE_ROOT, hiearchicalNames);
     }
 
     /**
@@ -73,6 +81,6 @@
      */
     public static String getPrincipalNameFromFullPath(String fullPath)
     {
-        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_ROLE_ROOT);
+        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_ROLE_ROOT,
hiearchicalNames);
     }
 }

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserPrincipalImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserPrincipalImpl.java?rev=398020&r1=398019&r2=398020&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserPrincipalImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/impl/UserPrincipalImpl.java
Fri Apr 28 14:30:24 2006
@@ -26,7 +26,16 @@
 
     /** The serial version uid. */
     private static final long serialVersionUID = 4134905654850335230L;
+    
+    private static boolean hiearchicalNames = true;
 
+    
+    public static final Object useHierarchicalNames(boolean hierarchicalNames)
+    {
+        UserPrincipalImpl.hiearchicalNames = hierarchicalNames;
+        return null;
+    }
+    
     /**
      * <p>The user principal constructor.</p>
      * @param userName The user principal name.
@@ -61,7 +70,7 @@
      */
     public static String getFullPathFromPrincipalName(String name)
     {
-        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_USER_ROOT);
+        return BasePrincipalImpl.getFullPathFromPrincipalName(name, PREFS_USER_ROOT, hiearchicalNames);
     }
 
     /**
@@ -72,6 +81,6 @@
      */
     public static String getPrincipalNameFromFullPath(String fullPath)
     {
-        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_USER_ROOT);
+        return BasePrincipalImpl.getPrincipalNameFromFullPath(fullPath, PREFS_USER_ROOT,
hiearchicalNames);
     }
 }

Added: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/hierarchical-principal-names.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/hierarchical-principal-names.xml?rev=398020&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/hierarchical-principal-names.xml
(added)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/hierarchical-principal-names.xml
Fri Apr 28 14:30:24 2006
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+    
+  <!-- http://issues.apache.org/jira/browse/JS2-527
+  
+       By default, Jetspeed supports hierarchical names for role, group and user principal
names. 
+       To make use of that, separate the elements using a dot '.'.
+       Internally, Jetspeed will translate these '.' to '/' to be able to map it on its preference
store structure.
+       But, sometimes this isn't wanted, especially with user principal names, as it prohibits
using email adresses for instance. 
+       
+       If you don't want hierarchical names support for role, group and/or user principal
names, you can disable the default
+       by moving the related MethodInvokatingFactoryBean definition below outside this comment.
+       
+    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+      <property name="staticMethod">
+        <value>org.apache.jetspeed.security.impl.UserPrincipalImpl.useHierarchicalNames</value>
+      </property>
+      <property name="arguments">
+        <value>false</value>
+      </property>
+    </bean>
+
+    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+      <property name="staticMethod">
+        <value>org.apache.jetspeed.security.impl.RolePrincipalImpl.useHierarchicalNames</value>
+      </property>
+      <property name="arguments">
+        <value>false</value>
+      </property>
+    </bean>
+
+    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+      <property name="staticMethod">
+        <value>org.apache.jetspeed.security.impl.GroupPrincipalImpl.useHierarchicalNames</value>
+      </property>
+      <property name="arguments">
+        <value>false</value>
+      </property>
+    </bean>
+    
+  -->
+
+</beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message