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/05 09:55:21 UTC
svn commit: r692373 - 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: Fri Sep 5 00:55:20 2008
New Revision: 692373
URL: http://svn.apache.org/viewvc?rev=692373&view=rev
Log:
More fixes and implementation of association relationship handling
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/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/RoleManager.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=692373&r1=692372&r2=692373&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 00:55:20 2008
@@ -16,6 +16,7 @@
*/
package org.apache.jetspeed.security.impl;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -136,24 +137,44 @@
jpsm.removePrincipal(principal);
}
- public List<JetspeedPrincipal> getAssociatedFrom(String principalName, String associationName)
+ public final List<JetspeedPrincipal> getAssociatedFrom(String principalName, JetspeedPrincipalType to, String associationName)
{
- return jpam.getAssociatedFrom(principalName, principalType, associationName);
+ if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(), to.getName(), associationName)))
+ {
+ // TODO: should we throw an exception here???
+ return Collections.EMPTY_LIST;
+ }
+ return jpam.getAssociatedFrom(principalName, principalType, to, associationName);
}
- public List<String> getAssociatedNamesFrom(String principalName, String associationName)
+ public final List<String> getAssociatedNamesFrom(String principalName, JetspeedPrincipalType to, String associationName)
{
- return jpam.getAssociatedNamesFrom(principalName, principalType, associationName);
+ if ( !assHandlers.containsKey(new AssociationHandlerKey(principalType.getName(), to.getName(), associationName)))
+ {
+ // TODO: should we throw an exception here???
+ return Collections.EMPTY_LIST;
+ }
+ return jpam.getAssociatedNamesFrom(principalName, principalType, to, associationName);
}
- public List<String> getAssociatedNamesTo(String principalName, String associationName)
+ public final List<String> getAssociatedNamesTo(String principalName, JetspeedPrincipalType from, String associationName)
{
- return jpam.getAssociatedNamesTo(principalName, principalType, associationName);
+ if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(), associationName)))
+ {
+ // TODO: should we throw an exception here???
+ return Collections.EMPTY_LIST;
+ }
+ return jpam.getAssociatedNamesTo(principalName, principalType, from, associationName);
}
- public List<JetspeedPrincipal> getAssociatedTo(String principalName, String associationName)
+ public final List<JetspeedPrincipal> getAssociatedTo(String principalName, JetspeedPrincipalType from, String associationName)
{
- return jpam.getAssociatedTo(principalName, principalType, associationName);
+ if ( !assHandlers.containsKey(new AssociationHandlerKey(from.getName(), principalType.getName(), associationName)))
+ {
+ // TODO: should we throw an exception here???
+ return Collections.EMPTY_LIST;
+ }
+ return jpam.getAssociatedTo(principalName, principalType, from, associationName);
}
//
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=692373&r1=692372&r2=692373&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 00:55:20 2008
@@ -46,6 +46,7 @@
import org.apache.jetspeed.security.RolePrincipal;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.SecurityProvider;
+import org.apache.jetspeed.security.UserManager;
import org.apache.jetspeed.security.attributes.SecurityAttributes;
import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
@@ -78,9 +79,12 @@
/** The logger. */
private static final Log log = LogFactory.getLog(RoleManagerImpl.class);
- public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalAccessManager jpam,
- JetspeedPrincipalStorageManager jpsm,
- JetspeedPrincipalPermissionStorageManager jppsm)
+ private JetspeedPrincipalType userType;
+ private JetspeedPrincipalType groupType;
+
+ public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType groupType,
+ JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm,
+ JetspeedPrincipalPermissionStorageManager jppsm)
{
super(principalType, jpam, jpsm, jppsm);
}
@@ -172,42 +176,26 @@
/**
* @see org.apache.jetspeed.security.RoleManager#getRolesForUser(java.lang.String)
*/
- public Collection<Role> getRolesForUser(String username) throws SecurityException
+ public List<Role> getRolesForUser(String username) throws SecurityException
{
- Collection<Role> roles = new ArrayList<Role>();
- // retrieve associated principals of which the user is the part
- List<JetspeedPrincipal> principals = super.getAssociatedFrom(username, JetspeedPrincipalAssociationType.IS_PART_OF);
-
- for (JetspeedPrincipal principal : principals)
+ ArrayList<Role> roles = new ArrayList<Role>();
+ for (JetspeedPrincipal principal : super.getAssociatedTo(username, userType, JetspeedPrincipalAssociationType.IS_PART_OF))
{
- // TODO: the next literal should be defined as a constant in somewhere.
- if ("org.apache.jetspeed.security.role".equals(principal.getType().getName()))
- {
- roles.add((Role) principal);
- }
+ roles.add((Role)principal);
}
-
return roles;
}
/**
* @see org.apache.jetspeed.security.RoleManager#getRolesInGroup(java.lang.String)
*/
- public Collection<Role> getRolesInGroup(String groupName) throws SecurityException
+ public List<Role> getRolesInGroup(String groupName) throws SecurityException
{
- Collection<Role> roles = new ArrayList<Role>();
- // retrieve associated principals which are part of the group
- List<JetspeedPrincipal> principals = super.getAssociatedTo(groupName, JetspeedPrincipalAssociationType.IS_PART_OF);
-
- for (JetspeedPrincipal principal : principals)
+ ArrayList<Role> roles = new ArrayList<Role>();
+ for (JetspeedPrincipal principal : super.getAssociatedTo(groupName, groupType, JetspeedPrincipalAssociationType.IS_PART_OF))
{
- // TODO: the next literal should be defined as a constant in somewhere.
- if ("org.apache.jetspeed.security.role".equals(principal.getType().getName()))
- {
- roles.add((Role) principal);
- }
+ roles.add((Role)principal);
}
-
return roles;
}
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=692373&r1=692372&r2=692373&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 00:55:20 2008
@@ -42,11 +42,11 @@
void removePrincipal(String name) throws PrincipalNotFoundException, PrincipalNotRemovableException, DependentPrincipalException;
- List<JetspeedPrincipal> getAssociatedFrom(String principalName, String associationName);
+ List<JetspeedPrincipal> getAssociatedFrom(String principalName, JetspeedPrincipalType to, String associationName);
- List<JetspeedPrincipal> getAssociatedTo(String principalName, String associationName);
+ List<JetspeedPrincipal> getAssociatedTo(String principalName, JetspeedPrincipalType from, String associationName);
- List<String> getAssociatedNamesFrom(String principalName, String associationName);
+ List<String> getAssociatedNamesFrom(String principalName, JetspeedPrincipalType to, String associationName);
- List<String> getAssociatedNamesTo(String principalName, String associationName);
+ List<String> getAssociatedNamesTo(String principalName, JetspeedPrincipalType from, String associationName);
}
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=692373&r1=692372&r2=692373&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 Fri Sep 5 00:55:20 2008
@@ -17,6 +17,7 @@
package org.apache.jetspeed.security;
import java.util.Collection;
+import java.util.List;
import java.util.prefs.Preferences;
/**
@@ -78,23 +79,23 @@
Role getRole(String roleFullPathName) throws SecurityException;
/**
- * <p>A collection of {@link Role} for all the roles
+ * <p>A list of {@link Role} for all the roles
* associated to a specific user.</p>
* @param username The user name.
* @return A Collection of {@link Role}.
* @throws Throws a security exception if the user does not exist.
*/
- Collection<Role> getRolesForUser(String username) throws SecurityException;
+ List<Role> getRolesForUser(String username) throws SecurityException;
/**
- * <p>A collection of {@link Role} for all the roles
+ * <p>A list of {@link Role} for all the roles
* associated to a specific group.</p>
* @param groupFullPathName The group full path
* (e.g. theGroupName.theGroupChildName).
* @return A Collection of {@link Role}.
* @throws Throws a security exception if the group does not exist.
*/
- Collection<Role> getRolesInGroup(String groupFullPathName) throws SecurityException;
+ List<Role> getRolesInGroup(String groupFullPathName) throws SecurityException;
/**
* <p>Add a role to a user.</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org