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 dl...@apache.org on 2004/05/08 18:17:13 UTC
cvs commit: jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl BasePrincipalImpl.java GroupManagerImpl.java PermissionManagerImpl.java RoleManagerImpl.java
dlestrat 2004/05/08 09:17:13
Modified: components/security/src/java/org/apache/jetspeed/security/impl
BasePrincipalImpl.java GroupManagerImpl.java
PermissionManagerImpl.java RoleManagerImpl.java
Log:
Modified Security service to support declarative security. Declarative security
prevents using "/" in declared security roles. To support declarative security,
hierarchical principals are now expressed as {principal}.{subprincipal}.
Revision Changes Path
1.2 +11 -10 jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java
Index: BasePrincipalImpl.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/BasePrincipalImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BasePrincipalImpl.java 10 Mar 2004 06:07:47 -0000 1.1
+++ BasePrincipalImpl.java 8 May 2004 16:17:13 -0000 1.2
@@ -63,7 +63,9 @@
/**
* <p>Gets the principal implementation full path from the principal name.</p>
- * <p>Prepends PREFS_{PRINCIPAL}_ROOT if not prepended.</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.
@@ -71,20 +73,18 @@
public static String getFullPathFromPrincipalName(String name, String prefsRoot)
{
String fullPath = name;
- if (!fullPath.startsWith(prefsRoot))
+ if (null != fullPath)
{
- if (fullPath.startsWith("/"))
- {
- fullPath = fullPath.substring(1, fullPath.length());
- }
- fullPath = prefsRoot + fullPath;
+ fullPath = prefsRoot + fullPath.replace('.', '/');
}
return fullPath;
}
/**
* <p>Gets the principal name from the principal implementation full path.</p>
- * <p>Remove prepended PREFS_{PRINCIPAL}_ROOT if present.</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.
@@ -92,7 +92,7 @@
public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot)
{
String name = fullPath;
- if (name.startsWith(prefsRoot))
+ if (null != name)
{
if (prefsRoot.equals(UserPrincipalImpl.PREFS_USER_ROOT))
{
@@ -100,8 +100,9 @@
}
else
{
- name = name.substring(prefsRoot.length() - 1, name.length());
+ name = name.substring(prefsRoot.length(), name.length());
}
+ name = name.replace('/', '.');
}
return name;
}
1.4 +3 -0 jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
Index: GroupManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GroupManagerImpl.java 25 Mar 2004 21:39:55 -0000 1.3
+++ GroupManagerImpl.java 8 May 2004 16:17:13 -0000 1.4
@@ -41,6 +41,9 @@
* <p>Group hierarchy elements are being returned as a {@link Group}
* collection. The backing implementation must appropriately map
* the group hierarchy to a preferences sub-tree.</p>
+ * <p>The convention {principal}.{subprincipal} has been chosen to name
+ * groups hierachies. Implementation follow the conventions enforced
+ * by the {@link Preferences} API.</p>
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
public class GroupManagerImpl extends BaseSecurityImpl implements GroupManager
1.2 +5 -5 jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java
Index: PermissionManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PermissionManagerImpl.java 10 Mar 2004 06:07:47 -0000 1.1
+++ PermissionManagerImpl.java 8 May 2004 16:17:13 -0000 1.2
@@ -79,7 +79,7 @@
*/
public Permissions getPermissions(Principal principal)
{
- String fullPath = SecurityHelper.getPrincipalFullPath(principal);
+ String fullPath = SecurityHelper.getPreferencesFullPath(principal);
ArgUtil.notNull(new Object[] { fullPath }, new String[] { "fullPath" }, "removePermission(java.security.Principal)");
// Remove permissions on principal.
@@ -134,7 +134,7 @@
while (principalsIterator.hasNext())
{
Principal principal = (Principal) principalsIterator.next();
- String fullPath = SecurityHelper.getPrincipalFullPath(principal);
+ String fullPath = SecurityHelper.getPreferencesFullPath(principal);
if (null != fullPath)
{
principalsFullPath.add(fullPath);
@@ -218,7 +218,7 @@
*/
public void removePermissions(Principal principal) throws SecurityException
{
- String fullPath = SecurityHelper.getPrincipalFullPath(principal);
+ String fullPath = SecurityHelper.getPreferencesFullPath(principal);
ArgUtil.notNull(new Object[] { fullPath }, new String[] { "fullPath" }, "removePermission(java.security.Principal)");
// Remove permissions on principal.
@@ -257,7 +257,7 @@
*/
public void grantPermission(Principal principal, Permission permission) throws SecurityException
{
- String fullPath = SecurityHelper.getPrincipalFullPath(principal);
+ String fullPath = SecurityHelper.getPreferencesFullPath(principal);
ArgUtil.notNull(
new Object[] { fullPath, permission },
new String[] { "fullPath", "permission" },
@@ -308,7 +308,7 @@
*/
public void revokePermission(Principal principal, Permission permission) throws SecurityException
{
- String fullPath = SecurityHelper.getPrincipalFullPath(principal);
+ String fullPath = SecurityHelper.getPreferencesFullPath(principal);
ArgUtil.notNull(
new Object[] { fullPath, permission },
new String[] { "fullPath", "permission" },
1.3 +3 -0 jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
Index: RoleManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-jetspeed-2/components/security/src/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RoleManagerImpl.java 25 Mar 2004 21:39:55 -0000 1.2
+++ RoleManagerImpl.java 8 May 2004 16:17:13 -0000 1.3
@@ -42,6 +42,9 @@
* <p>Role hierarchy elements are being returned as a {@link Role}
* collection. The backing implementation must appropriately map
* the role hierarchy to a preferences sub-tree.</p>
+ * <p>The convention {principal}.{subprincipal} has been chosen to name
+ * roles hierachies in order to support declarative security. Implementation
+ * follow the conventions enforced by the {@link Preferences} API.</p>
* @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
*/
public class RoleManagerImpl extends BaseSecurityImpl implements RoleManager
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org