You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/08/24 21:42:29 UTC
cvs commit: jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple MemoryPermissionManagerImpl.java MemoryRoleManagerImpl.java MemoryGroupManagerImpl.java
epugh 2003/08/24 12:42:29
Modified: security/src/java/org/apache/fulcrum/security/spi/memory/simple
MemoryPermissionManagerImpl.java
MemoryRoleManagerImpl.java
MemoryGroupManagerImpl.java
Log:
Now the memory SPI is working.
Revision Changes Path
1.2 +5 -33 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryPermissionManagerImpl.java
Index: MemoryPermissionManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryPermissionManagerImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MemoryPermissionManagerImpl.java 23 Aug 2003 22:02:04 -0000 1.1
+++ MemoryPermissionManagerImpl.java 24 Aug 2003 19:42:29 -0000 1.2
@@ -68,6 +68,7 @@
import org.apache.fulcrum.security.entity.Permission;
import org.apache.fulcrum.security.entity.Role;
import org.apache.fulcrum.security.model.simple.entity.SimplePermission;
+import org.apache.fulcrum.security.model.simple.entity.SimpleRole;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.EntityExistsException;
import org.apache.fulcrum.security.util.PermissionSet;
@@ -168,7 +169,7 @@
* @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public Permission getPermissionById(int id) throws DataBackendException, UnknownEntityException
+ public Permission getPermissionById(long id) throws DataBackendException, UnknownEntityException
{
Permission permission = getAllPermissions().getPermissionById(id);
if (permission == null)
@@ -243,36 +244,7 @@
}
return exists;
}
- /**
- * Stores Permission's attributes. The Permissions is required to exist in
- * the system.
- *
- * @param permission The Permission to be stored.
- * @throws DataBackendException if there was an error accessing the data
- * backend.
- * @throws UnknownEntityException if the permission does not exist.
- */
- public void savePermission(Permission permission) throws DataBackendException, UnknownEntityException
- {
- boolean permissionExists = false;
- try
- {
- permissionExists = checkExists(permission);
- if (permissionExists)
- {
- permissions.remove(permission);
- permissions.add(permission);
- }
- else
- {
- throw new UnknownEntityException("Unknown permission '" + permission + "'");
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("savePermission(Permission) failed", e);
- }
- }
+
/**
* Removes a Permission from the system.
*
@@ -364,7 +336,7 @@
roleExists = checkExists(role);
if (roleExists)
{
- return role.getPermissions();
+ return ((SimpleRole)role).getPermissions();
}
}
catch (Exception e)
1.2 +12 -34 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryRoleManagerImpl.java
Index: MemoryRoleManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryRoleManagerImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MemoryRoleManagerImpl.java 23 Aug 2003 22:02:04 -0000 1.1
+++ MemoryRoleManagerImpl.java 24 Aug 2003 19:42:29 -0000 1.2
@@ -160,7 +160,6 @@
{
throw new UnknownEntityException("The specified role does not exist");
}
- role.setPermissions(getPermissions(role));
return role;
}
/**
@@ -175,14 +174,13 @@
* @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public Role getRoleById(int id) throws DataBackendException, UnknownEntityException
+ public Role getRoleById(long id) throws DataBackendException, UnknownEntityException
{
Role role = getAllRoles().getRoleById(id);
if (role == null)
{
throw new UnknownEntityException("The specified role does not exist");
- }
- role.setPermissions(getPermissions(role));
+ }
return role;
}
/**
@@ -281,7 +279,7 @@
roleExists = checkExists(role);
if (roleExists)
{
- role.setPermissions(new PermissionSet());
+ ((SimpleRole)role).setPermissions(new PermissionSet());
return;
}
}
@@ -452,35 +450,15 @@
// is that the roleExists was true.
throw new EntityExistsException("Role '" + role + "' already exists");
}
+
/**
- * Stores Role's attributes. The Roles is required to exist in the system.
- *
- * @param role The Role to be stored.
- * @throws DataBackendException if there was an error accessing the data
- * backend.
- * @throws UnknownEntityException if the role does not exist.
- */
- public void saveRole(Role role) throws DataBackendException, UnknownEntityException
- {
- boolean roleExists = false;
- roleExists = checkExists(role);
- if (roleExists)
- {
- roles.add(role);
- }
- else
- {
- throw new UnknownEntityException("Unknown role '" + role + "'");
- }
- }
- /**
- * Removes a Role from the system.
- *
- * @param role The object describing the role to be removed.
- * @throws DataBackendException if there was an error accessing the data
- * backend.
- * @throws UnknownEntityException if the role does not exist.
- */
+ * Removes a Role from the system.
+ *
+ * @param role The object describing the role to be removed.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if the role does not exist.
+ */
public synchronized void removeRole(Role role) throws DataBackendException, UnknownEntityException
{
boolean roleExists = false;
1.2 +3 -31 jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryGroupManagerImpl.java
Index: MemoryGroupManagerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/spi/memory/simple/MemoryGroupManagerImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MemoryGroupManagerImpl.java 23 Aug 2003 22:02:04 -0000 1.1
+++ MemoryGroupManagerImpl.java 24 Aug 2003 19:42:29 -0000 1.2
@@ -184,7 +184,7 @@
* @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public Group getGroupById(int id) throws DataBackendException, UnknownEntityException
+ public Group getGroupById(long id) throws DataBackendException, UnknownEntityException
{
Group group = getAllGroups().getGroupById(id);
if (group == null)
@@ -272,35 +272,7 @@
{
}
}
- /**
- * Stores Group's attributes. The Groups is required to exist in the system.
- *
- * @param group The Group to be stored.
- * @throws DataBackendException if there was an error accessing the data
- * backend.
- * @throws UnknownEntityException if the group does not exist.
- */
- public void saveGroup(Group group) throws DataBackendException, UnknownEntityException
- {
- boolean groupExists = false;
- try
- {
- groupExists = checkExists(group);
- if (groupExists)
- {
- groups.remove(group);
- groups.add(group);
- }
- else
- {
- throw new UnknownEntityException("Unknown group '" + group + "'");
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("saveGroup(Group) failed", e);
- }
- }
+
/**
* Determines if the <code>Group</code> exists in the security system.
*