portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r692453 - 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/ jetspeed-api/src/main/java/org/apa...
Date Fri, 05 Sep 2008 14:52:41 GMT
Author: woonsan
Date: Fri Sep  5 07:52:40 2008
New Revision: 692453

URL: http://svn.apache.org/viewvc?rev=692453&view=rev
Log:
Corrected associations-retrieving.

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
    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/JetspeedPrincipalManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAccessManager.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.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/BaseJetspeedPrincipalManager.java?rev=692453&r1=692452&r2=692453&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
Fri Sep  5 07:52:40 2008
@@ -145,44 +145,44 @@
         jpsm.removePrincipal(principal);
     }
 
-    public final List<JetspeedPrincipal> getAssociatedFrom(String principalName, JetspeedPrincipalType
to, String associationName)
+    public final List<JetspeedPrincipal> getAssociatedFrom(String principalFromName,
JetspeedPrincipalType from, String associationName)
     {
-        if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(),
to.getName(), associationName)))
+        if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(),
associationName)))
         {
             // TODO: should we throw an exception here???
             return Collections.EMPTY_LIST;
         }
-        return jpam.getAssociatedFrom(principalName, principalType, to, associationName);
+        return jpam.getAssociatedFrom(principalFromName, from, principalType, associationName);
     }
 
-    public final List<String> getAssociatedNamesFrom(String principalName, JetspeedPrincipalType
to, String associationName)
+    public final List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType
 from, String associationName)
     {
-        if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(),
to.getName(), associationName)))
+        if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(),
associationName)))
         {
             // TODO: should we throw an exception here???
             return Collections.EMPTY_LIST;
         }
-        return jpam.getAssociatedNamesFrom(principalName, principalType, to, associationName);
+        return jpam.getAssociatedNamesFrom(principalFromName, from, principalType, associationName);
     }
 
-    public final List<String> getAssociatedNamesTo(String principalName, JetspeedPrincipalType
from, String associationName)
+    public final List<String> getAssociatedNamesTo(String principalToName, JetspeedPrincipalType
to, String associationName)
     {
-        if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(),
associationName)))
+        if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(),
to.getName(), associationName)))
         {
             // TODO: should we throw an exception here???
             return Collections.EMPTY_LIST;
         }
-        return jpam.getAssociatedNamesTo(principalName, principalType, from, associationName);
+        return jpam.getAssociatedNamesTo(principalToName, principalType, to, associationName);
     }
 
-    public final List<JetspeedPrincipal> getAssociatedTo(String principalName, JetspeedPrincipalType
from, String associationName)
+    public final List<JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
to, String associationName)
     {
-        if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(),
associationName)))
+        if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(),
to.getName(), associationName)))
         {
             // TODO: should we throw an exception here???
             return Collections.EMPTY_LIST;
         }
-        return jpam.getAssociatedTo(principalName, principalType, from, associationName);
+        return jpam.getAssociatedTo(principalToName, principalType, to, associationName);
     }
 
     //

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=692453&r1=692452&r2=692453&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
Fri Sep  5 07:52:40 2008
@@ -116,8 +116,11 @@
         }
         catch (PrincipalAssociationRequiredException e)
         {
-            // TODO: add SecurityException type for this?
             throw new SecurityException(SecurityException.UNEXPECTED.create("GroupManager.addGroup",
"add", e.getMessage()));
+        } 
+        catch (PrincipalAssociationNotAllowedException e)
+        {
+            throw new SecurityException(e);
         }
         
         if (log.isDebugEnabled())
@@ -170,7 +173,7 @@
             throws SecurityException
     {
         ArrayList<Group> groups = new ArrayList<Group>();
-        for (JetspeedPrincipal principal : super.getAssociatedTo(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
+        for (JetspeedPrincipal principal : super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
         {
             groups.add((Group)principal);
         }
@@ -184,7 +187,7 @@
             throws SecurityException
     {
         ArrayList<Group> groups = new ArrayList<Group>();
-        for (JetspeedPrincipal principal : super.getAssociatedFrom(roleName, roleType, JetspeedPrincipalAssociationType.IS_PART_OF))
+        for (JetspeedPrincipal principal : super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_PART_OF))
         {
             groups.add((Group)principal);
         }

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=692453&r1=692452&r2=692453&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
Fri Sep  5 07:52:40 2008
@@ -27,6 +27,7 @@
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
+import org.apache.jetspeed.security.JetspeedPrincipalManager;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
 import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
 import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
@@ -72,14 +73,14 @@
     private UserManager userManager;
     private GroupManager groupManager;
     
-    public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType,
JetspeedPrincipalType groupType, 
+    public RoleManagerImpl(JetspeedPrincipalType principalType, 
                            JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager
jpsm,
                            JetspeedPrincipalPermissionStorageManager jppsm,
                            UserManager userManager, GroupManager groupManager)
     {
         super(principalType, jpam, jpsm, jppsm);
-        this.userType = userType;
-        this.groupType = groupType;
+        this.userType = ((JetspeedPrincipalManager) userManager).getPrincipalType();
+        this.groupType = ((JetspeedPrincipalManager) groupManager).getPrincipalType();;
         this.userManager = userManager;
         this.groupManager = groupManager;
     }
@@ -112,6 +113,7 @@
     public void addRole(String roleName) throws SecurityException
     {
         Role role = newRole(roleName, true);
+        
         try
         {
             super.addPrincipal(role, null);
@@ -122,9 +124,13 @@
         }
         catch (PrincipalAssociationRequiredException e)
         {
-            // TODO: add SecurityException type for this?
             throw new SecurityException(SecurityException.UNEXPECTED.create("RoleManager.addRole",
"add", e.getMessage()));
+        } 
+        catch (PrincipalAssociationNotAllowedException e)
+        {
+            throw new SecurityException(e);
         }
+        
         if (log.isDebugEnabled())
             log.debug("Added role: " + roleName);
     }
@@ -174,7 +180,7 @@
     public List<Role> getRolesForUser(String username) throws SecurityException
     {
         ArrayList<Role> roles = new ArrayList<Role>();
-        for (JetspeedPrincipal principal : super.getAssociatedTo(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
+        for (JetspeedPrincipal principal : super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
         {
             roles.add((Role)principal);
         }
@@ -187,7 +193,7 @@
     public List<Role> getRolesInGroup(String groupName) throws SecurityException
     {
         ArrayList<Role> roles = new ArrayList<Role>();
-        for (JetspeedPrincipal principal : super.getAssociatedTo(groupName, groupType, JetspeedPrincipalAssociationType.IS_PART_OF))
+        for (JetspeedPrincipal principal : super.getAssociatedFrom(groupName, groupType,
JetspeedPrincipalAssociationType.IS_PART_OF))
         {
             roles.add((Role)principal);
         }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalManager.java?rev=692453&r1=692452&r2=692453&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalManager.java
Fri Sep  5 07:52:40 2008
@@ -44,11 +44,11 @@
     
     void removePrincipal(String name) throws PrincipalNotFoundException, PrincipalNotRemovableException,
DependentPrincipalException;
 
-    List<JetspeedPrincipal> getAssociatedFrom(String principalName, JetspeedPrincipalType
to, String associationName);
+    List<JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType
from, String associationName);
 
-    List<JetspeedPrincipal> getAssociatedTo(String principalName, JetspeedPrincipalType
from, String associationName);
+    List<JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
to, String associationName);
 
-    List<String> getAssociatedNamesFrom(String principalName, JetspeedPrincipalType
to, String associationName);
+    List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType
from, String associationName);
 
-    List<String> getAssociatedNamesTo(String principalName, JetspeedPrincipalType from,
String associationName);
+    List<String> getAssociatedNamesTo(String principalToName, JetspeedPrincipalType
to, String associationName);
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAccessManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAccessManager.java?rev=692453&r1=692452&r2=692453&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAccessManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAccessManager.java
Fri Sep  5 07:52:40 2008
@@ -39,21 +39,21 @@
 
     List<String> getPrincipalNames(String nameFilter, JetspeedPrincipalType type);
 
-    List<JetspeedPrincipal> getAssociatedFrom(String principalName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
+    List<JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<JetspeedPrincipal> getAssociatedFrom(Long principalId, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
+    List<JetspeedPrincipal> getAssociatedFrom(Long principalFromId, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<JetspeedPrincipal> getAssociatedTo(String principalName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
+    List<JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<JetspeedPrincipal> getAssociatedTo(Long principalId, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
+    List<JetspeedPrincipal> getAssociatedTo(Long principalToId, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<String> getAssociatedNamesFrom(String principalName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
+    List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<String> getAssociatedNamesFrom(Long principalId, JetspeedPrincipalType from,
JetspeedPrincipalType to, String associationName);
+    List<String> getAssociatedNamesFrom(Long principalFromId, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<String> getAssociatedNamesTo(String principalName, JetspeedPrincipalType from,
JetspeedPrincipalType to, String associationName);
+    List<String> getAssociatedNamesTo(String principalToName, JetspeedPrincipalType
from, JetspeedPrincipalType to, String associationName);
 
-    List<String> getAssociatedNamesTo(Long principalId, JetspeedPrincipalType from,
JetspeedPrincipalType to, String associationName);
+    List<String> getAssociatedNamesTo(Long principalToId, JetspeedPrincipalType from,
JetspeedPrincipalType to, String associationName);
 
     List<String> getPrincipals(JetspeedPermission permission);
 



---------------------------------------------------------------------
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