portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r692861 - 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/
Date Sun, 07 Sep 2008 14:05:07 GMT
Author: ate
Date: Sun Sep  7 07:05:07 2008
New Revision: 692861

URL: http://svn.apache.org/viewvc?rev=692861&view=rev
Log:
Generics Collection return type upcasting to allow returning a retrieved List<JetspeedPrincipal>
as an upcasted type, e.g. List<Role> 

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/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalManager.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=692861&r1=692860&r2=692861&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
Sun Sep  7 07:05:07 2008
@@ -126,12 +126,12 @@
         return jpam.getPrincipalNames(nameFilter, principalType);
     }
 
-    public List<JetspeedPrincipal> getPrincipals(String nameFilter)
+    public List<? extends JetspeedPrincipal> getPrincipals(String nameFilter)
     {
         return jpam.getPrincipals(nameFilter, principalType);
     }
 
-    public List<JetspeedPrincipal> getPrincipalsByAttribute(String attributeName, String
attributeValue)
+    public List<? extends JetspeedPrincipal> getPrincipalsByAttribute(String attributeName,
String attributeValue)
     {
         return jpam.getPrincipalsByAttribute(attributeName, attributeValue, principalType);
     }
@@ -144,8 +144,9 @@
             throw new PrincipalNotFoundException();
         jpsm.removePrincipal(principal);
     }
+    
 
-    public final List<JetspeedPrincipal> getAssociatedFrom(String principalFromName,
JetspeedPrincipalType from, String associationName)
+    public final List<? extends JetspeedPrincipal> getAssociatedFrom(String principalFromName,
JetspeedPrincipalType from, String associationName)
     {
         if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(),
associationName)))
         {
@@ -175,7 +176,7 @@
         return jpam.getAssociatedNamesTo(principalToName, principalType, to, associationName);
     }
 
-    public final List<JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
to, String associationName)
+    public final List<? extends JetspeedPrincipal> getAssociatedTo(String principalToName,
JetspeedPrincipalType to, String associationName)
     {
         if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(),
to.getName(), 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=692861&r1=692860&r2=692861&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 07:05:07 2008
@@ -16,8 +16,6 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -171,29 +169,19 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroupsForUser(java.lang.String)
      */
-    public Collection<Group> getGroupsForUser(String username)
+    public List<Group> getGroupsForUser(String username)
             throws SecurityException
     {
-        ArrayList<Group> groups = new ArrayList<Group>();
-        for (JetspeedPrincipal principal : super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
-        {
-            groups.add((Group)principal);
-        }
-        return groups;
+        return (List<Group>) super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF);
     }
 
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroupsInRole(java.lang.String)
      */
-    public Collection<Group> getGroupsInRole(String roleName)
+    public List<Group> getGroupsInRole(String roleName)
             throws SecurityException
     {
-        ArrayList<Group> groups = new ArrayList<Group>();
-        for (JetspeedPrincipal principal : super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_PART_OF))
-        {
-            groups.add((Group)principal);
-        }
-        return groups;
+        return (List<Group>) super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_PART_OF);
     }
 
     /**
@@ -255,17 +243,9 @@
     /**
      * @see org.apache.jetspeed.security.GroupManager#getGroups(java.lang.String)
      */
-    public Collection<Group> getGroups(String filter) throws SecurityException
+    public List<Group> getGroups(String nameFilter) throws SecurityException
     {
-        Collection<Group> groups = new ArrayList<Group>();
-        List<JetspeedPrincipal> principals = super.getPrincipals(filter);
-        
-        for (JetspeedPrincipal principal : principals)
-        {
-            groups.add((Group) principal);
-        }
-        
-        return groups;
+        return (List<Group>) super.getPrincipals(nameFilter);
     }
     
     /**

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=692861&r1=692860&r2=692861&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 07:05:07 2008
@@ -16,8 +16,6 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.prefs.Preferences;
 
@@ -178,13 +176,8 @@
      * @see org.apache.jetspeed.security.RoleManager#getRolesForUser(java.lang.String)
      */
     public List<Role> getRolesForUser(String username) throws SecurityException
-    {
-        ArrayList<Role> roles = new ArrayList<Role>();
-        for (JetspeedPrincipal principal : super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
-        {
-            roles.add((Role)principal);
-        }
-        return roles;
+    {        
+        return (List<Role>)super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF);
     }
 
     /**
@@ -192,12 +185,7 @@
      */
     public List<Role> getRolesInGroup(String groupName) throws SecurityException
     {
-        ArrayList<Role> roles = new ArrayList<Role>();
-        for (JetspeedPrincipal principal : super.getAssociatedFrom(groupName, groupType,
JetspeedPrincipalAssociationType.IS_PART_OF))
-        {
-            roles.add((Role)principal);
-        }
-        return roles;
+        return (List<Role>)super.getAssociatedFrom(groupName, groupType, JetspeedPrincipalAssociationType.IS_PART_OF);
     }
 
     /**
@@ -309,17 +297,9 @@
     /**
      * @see org.apache.jetspeed.security.RoleManager#getRoles(java.lang.String)
      */
-    public Collection<Role> getRoles(String filter) throws SecurityException
+    public List<Role> getRoles(String nameFilter) throws SecurityException
     {
-        Collection<Role> roles = new ArrayList<Role>();
-        List<JetspeedPrincipal> principals = super.getPrincipals(filter);
-        
-        for (JetspeedPrincipal principal : principals)
-        {
-            roles.add((Role) principal);
-        }
-        
-        return roles;
+        return (List<Role>)super.getPrincipals(nameFilter);
     }
 
     /** 

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.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/UserManagerImpl.java?rev=692861&r1=692860&r2=692861&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
Sun Sep  7 07:05:07 2008
@@ -62,7 +62,6 @@
 	private static final Log log = LogFactory.getLog(UserManagerImpl.class);
 
 	private String anonymousUser = "guest";
-	private String defaultPassword = "Guest123";
 	private JetspeedPrincipalType roleType;
 	private JetspeedPrincipalType groupType;
 
@@ -187,49 +186,29 @@
 		return (User) getPrincipal(username);
 	}
 
-	public List<String> getUserNames(String filter) throws SecurityException
+	public List<String> getUserNames(String nameFilter) throws SecurityException
 	{
-		return getPrincipalNames(filter);
+		return getPrincipalNames(nameFilter);
 	}
 
-	public Collection<User> getUsers(String filter) throws SecurityException
+	public List<User> getUsers(String nameFilter) throws SecurityException
 	{
-		Collection<User> users = new ArrayList<User>();
-		for (JetspeedPrincipal principal : getPrincipals(filter))
-		{
-			users.add((User) principal);
-		}
-		return users;
+		return (List<User>)getPrincipals(nameFilter);
 	}
 
-	public Collection<User> getUsersInGroup(String groupFullPathName) throws SecurityException
+	public List<User> getUsersInGroup(String groupFullPathName) throws SecurityException
 	{
-		ArrayList<User> groupUsers = new ArrayList<User>();
-		for (JetspeedPrincipal principal : super.getAssociatedFrom(groupFullPathName, groupType,
JetspeedPrincipalAssociationType.IS_PART_OF))
-		{
-			groupUsers.add((User) principal);
-		}
-		return groupUsers;
+		return (List<User>) super.getAssociatedFrom(groupFullPathName, groupType, JetspeedPrincipalAssociationType.IS_PART_OF);
 	}
 
-	public Collection<User> getUsersInRole(String roleFullPathName) throws SecurityException
+	public List<User> getUsersInRole(String roleFullPathName) throws SecurityException
 	{
-		ArrayList<User> groupUsers = new ArrayList<User>();
-		for (JetspeedPrincipal principal : super.getAssociatedFrom(roleFullPathName, roleType,
JetspeedPrincipalAssociationType.IS_PART_OF))
-		{
-			groupUsers.add((User) principal);
-		}
-		return groupUsers;
+		return (List<User>) super.getAssociatedFrom(roleFullPathName, roleType, JetspeedPrincipalAssociationType.IS_PART_OF);
 	}
 
 	public List<User> lookupUsers(String attributeName, String attributeValue) throws
SecurityException
 	{
-		List<User> users = new ArrayList<User>();
-		for (JetspeedPrincipal user : super.getPrincipalsByAttribute(attributeName, attributeValue))
-		{
-			users.add((User) user);
-		}
-		return users;
+		return (List<User>) super.getPrincipalsByAttribute(attributeName, attributeValue);
 	}
 
 	/**

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=692861&r1=692860&r2=692861&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
Sun Sep  7 07:05:07 2008
@@ -34,9 +34,9 @@
 
     List<String> getPrincipalNames(String nameFilter);
 
-    List<JetspeedPrincipal> getPrincipals(String nameFilter);
+    List<? extends JetspeedPrincipal> getPrincipals(String nameFilter);
     
-    List<JetspeedPrincipal> getPrincipalsByAttribute(String attributeName, String attributeValue);
+    List<? extends JetspeedPrincipal> getPrincipalsByAttribute(String attributeName,
String attributeValue);
     
     JetspeedPrincipal newPrincipal(String name, boolean mapped);
 
@@ -44,9 +44,9 @@
     
     void removePrincipal(String name) throws PrincipalNotFoundException, PrincipalNotRemovableException,
DependentPrincipalException;
 
-    List<JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType
from, String associationName);
+    List<? extends JetspeedPrincipal> getAssociatedFrom(String principalFromName, JetspeedPrincipalType
from, String associationName);
 
-    List<JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
to, String associationName);
+    List<? extends JetspeedPrincipal> getAssociatedTo(String principalToName, JetspeedPrincipalType
to, String associationName);
 
     List<String> getAssociatedNamesFrom(String principalFromName, JetspeedPrincipalType
from, String associationName);
 



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