You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/09/08 03:19:57 UTC

svn commit: r692974 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ jetspeed-api/src/main/java/org/apache/jetspeed/security/

Author: ate
Date: Sun Sep  7 18:19:57 2008
New Revision: 692974

URL: http://svn.apache.org/viewvc?rev=692974&view=rev
Log:
- adding support for creating non-mapped Role and Group
- dropped setEnabled method, replaced with update<T> method

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/GroupManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java?rev=692974&r1=692973&r2=692974&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java Sun Sep  7 18:19:57 2008
@@ -102,9 +102,17 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#addGroup(java.lang.String)
      */
-    public void addGroup(String groupName) throws SecurityException
+    public Group addGroup(String groupName) throws SecurityException
     {
-        Group group = newGroup(groupName, true);
+        return addGroup(groupName, true);
+    }
+
+    /**
+     * @see org.apache.jetspeed.security.GroupManager#addGroup(java.lang.String, boolean)
+     */
+    public Group addGroup(String groupName, boolean mapped) throws SecurityException
+    {
+        Group group = newGroup(groupName, mapped);
         
         try
         {
@@ -122,9 +130,15 @@
         {
             throw new SecurityException(e);
         }
+        catch (PrincipalNotFoundException e)
+        {
+            // cannot occurr as no associations are provided with addPrincipal
+        }
         
         if (log.isDebugEnabled())
             log.debug("Added group: " + groupName);
+        
+        return group;
     }
 
     /**
@@ -220,10 +234,6 @@
             Group group = getGroup(groupName);
             super.removeAssociation(JetspeedPrincipalAssociationType.IS_PART_OF, user, group);
         } 
-        catch (PrincipalNotFoundException e)
-        {
-            throw new SecurityException(e);
-        } 
         catch (PrincipalAssociationRequiredException e)
         {
             throw new SecurityException(e);
@@ -249,36 +259,23 @@
     }
     
     /**
-     * @see org.apache.jetspeed.security.GroupManager#setGroupEnabled(java.lang.String, boolean)
+     * @see org.apache.jetspeed.security.GroupManager#updateGroup(org.apache.jetspeed.security.Group)
      */
-    public void setGroupEnabled(String groupName, boolean enabled) throws SecurityException
+    public void updateGroup(Group group) throws SecurityException
     {
-        Group group = (Group) super.getPrincipal(groupName);
-        
-        if (null == group)
-        {
-            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(groupName));
-        }
-        
         try
         {
-            if (enabled != group.isEnabled())
-            {
-                group.setEnabled(enabled);
-                super.updatePrincipal(group);
-            }
-            
-            group.setEnabled(enabled);
+            super.updatePrincipal(group);
         }
-        catch (PrincipalReadOnlyException e)
+        catch (PrincipalNotFoundException e)
         {
-            throw new SecurityException(e);
+            throw new SecurityException(SecurityException.GROUP_DOES_NOT_EXIST.create(group.getName()));
         }
         catch (PrincipalUpdateException e)
         {
             throw new SecurityException(e);
-        } 
-        catch (PrincipalNotFoundException e)
+        }
+        catch (PrincipalReadOnlyException e)
         {
             throw new SecurityException(e);
         }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java?rev=692974&r1=692973&r2=692974&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java Sun Sep  7 18:19:57 2008
@@ -108,9 +108,17 @@
     /**
      * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String)
      */
-    public void addRole(String roleName) throws SecurityException
+    public Role addRole(String roleName) throws SecurityException
     {
-        Role role = newRole(roleName, true);
+        return addRole(roleName, true);
+    }
+
+    /**
+     * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String, boolean)
+     */
+    public Role addRole(String roleName, boolean mapped) throws SecurityException
+    {
+        Role role = newRole(roleName, mapped);
         
         try
         {
@@ -128,9 +136,15 @@
         {
             throw new SecurityException(e);
         }
+        catch (PrincipalNotFoundException e)
+        {
+            // cannot occurr as no associations are provided with addPrincipal
+        }
         
         if (log.isDebugEnabled())
             log.debug("Added role: " + roleName);
+        
+        return role;
     }
 
     /**
@@ -222,10 +236,6 @@
             Role role = getRole(roleName);
             super.removeAssociation(JetspeedPrincipalAssociationType.IS_PART_OF, user, role);
         } 
-        catch (PrincipalNotFoundException e)
-        {
-            throw new SecurityException(e);
-        } 
         catch (PrincipalAssociationRequiredException e)
         {
             throw new SecurityException(e);
@@ -275,10 +285,6 @@
             Role role = getRole(roleName);
             super.removeAssociation(JetspeedPrincipalAssociationType.IS_PART_OF, group, role);
         } 
-        catch (PrincipalNotFoundException e)
-        {
-            throw new SecurityException(e);
-        } 
         catch (PrincipalAssociationRequiredException e)
         {
             throw new SecurityException(e);
@@ -303,36 +309,23 @@
     }
 
     /** 
-     * @see org.apache.jetspeed.security.RoleManager#setRoleEnabled(java.lang.String, boolean)
+     * @see org.apache.jetspeed.security.RoleManager#updateRole(org.apache.jetspeed.security.Role)
      */
-    public void setRoleEnabled(String roleName, boolean enabled) throws SecurityException
+    public void updateRole(Role role) throws SecurityException
     {
-        Role role = (Role) super.getPrincipal(roleName);
-        
-        if (null == role)
-        {
-            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(roleName));
-        }
-        
         try
         {
-            if (enabled != role.isEnabled())
-            {
-                role.setEnabled(enabled);
-                super.updatePrincipal(role);
-            }
-            
-            role.setEnabled(enabled);
+            super.updatePrincipal(role);
         }
-        catch (PrincipalReadOnlyException e)
+        catch (PrincipalNotFoundException e)
         {
-            throw new SecurityException(e);
+            throw new SecurityException(SecurityException.ROLE_DOES_NOT_EXIST.create(role.getName()));
         }
         catch (PrincipalUpdateException e)
         {
             throw new SecurityException(e);
         } 
-        catch (PrincipalNotFoundException e)
+        catch (PrincipalReadOnlyException e)
         {
             throw new SecurityException(e);
         }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/GroupManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/GroupManager.java?rev=692974&r1=692973&r2=692974&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/GroupManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/GroupManager.java Sun Sep  7 18:19:57 2008
@@ -35,10 +35,25 @@
      * <p>
      * Add a new group.
      * </p>
+     * <p>
+     * If an external security storage manager is used, the group will be mapped/replicated to it as well.
+     * </p>
+     * @param groupName The group name
+     * @return the new {@link Group}
+     * @throws Throws a security exception.
+     */
+    Group addGroup(String groupName) throws SecurityException;
+
+    /**
+     * <p>
+     * Add a new group and optionally map/replicate it to an external storage manager (if configured).
+     * </p>
      * @param groupName The group name
+     * @param mapped if the new Group should be mapped/replicated to an external security storage manager (if used) or not.
+     * @return the new {@link Group}
      * @throws Throws a security exception.
      */
-    void addGroup(String groupName) throws SecurityException;
+    Group addGroup(String groupName, boolean mapped) throws SecurityException;
 
     /**
      * <p>
@@ -136,9 +151,9 @@
    List<Group> getGroups(String nameFilter) throws SecurityException;
     
    /**
-    * Enable or disable a group.
-    * @param groupName The group name
-    * @param enabled enabled flag for the group
+    * Updates a group and all its attributes
+    * @param group
+    * @throws SecurityException
     */
-   void setGroupEnabled(String groupName, boolean enabled) throws SecurityException;
+   void updateGroup(Group group) throws SecurityException;
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java?rev=692974&r1=692973&r2=692974&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java Sun Sep  7 18:19:57 2008
@@ -29,11 +29,29 @@
     Role newTransientRole(String name);
     
     /**
-     * <p>Add a new role.</p>
+     * <p>
+     * Add a new role
+     * </p>
+     * <p>
+     * If an external security storage manager is used, the role will be mapped/replicated to it as well.
+     * </p>
      * @param roleName The role name
+     * @return the new {@link Role}
+     * @throws Throws a security exception if the role already exists.
+     */
+    Role addRole(String roleName) throws SecurityException;
+
+    /**
+     * <p>
+     * Add a new role and optionally map/replicate it to an external storage manager (if configured).
+     * </p>
+     * 
+     * @param roleName The role name.
+     * @param mapped if the new Role should be mapped/replicated to an external security storage manager (if used) or not.
+     * @return the new {@link Role}
      * @throws Throws a security exception if the role already exists.
      */
-    void addRole(String roleName) throws SecurityException;
+    Role addRole(String roleName, boolean mapped) throws SecurityException;
 
     /**
      * <p>Remove a given role</p>
@@ -136,9 +154,9 @@
     List<Role> getRoles(String nameFilter) throws SecurityException;
     
     /**
-     * Enable or disable a role.
-     * @param roleName.
-     * @param enabled enabled flag for the role
+     * Updates a role and all its attributes
+     * @param role
+     * @throws SecurityException
      */
-    void setRoleEnabled(String roleName, boolean enabled) throws SecurityException;
+    void updateRole(Role role) throws SecurityException;
 }



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