You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2001/06/27 02:31:20 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/security/db DBSecurityService.java DBUserManager.java
mpoeschl 01/06/26 17:31:20
Modified: src/java/org/apache/turbine/services/security/db
DBSecurityService.java DBUserManager.java
Log:
use generated classes
Revision Changes Path
1.9 +207 -163 jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBSecurityService.java
Index: DBSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBSecurityService.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DBSecurityService.java 2001/06/26 20:09:47 1.8
+++ DBSecurityService.java 2001/06/27 00:31:19 1.9
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -72,11 +72,11 @@
import org.apache.turbine.om.security.TurbinePermission;
import org.apache.turbine.om.security.TurbineRole;
import org.apache.turbine.om.security.User;
-import org.apache.turbine.om.security.peer.GroupPeer;
-import org.apache.turbine.om.security.peer.PermissionPeer;
-import org.apache.turbine.om.security.peer.RolePeer;
-import org.apache.turbine.om.security.peer.RolePermissionPeer;
-import org.apache.turbine.om.security.peer.UserGroupRolePeer;
+import org.apache.turbine.om.security.TurbineGroupPeer;
+import org.apache.turbine.om.security.TurbinePermissionPeer;
+import org.apache.turbine.om.security.TurbineRolePeer;
+import org.apache.turbine.om.security.TurbineRolePermissionPeer;
+import org.apache.turbine.om.security.TurbineUserGroupRolePeer;
import org.apache.turbine.om.security.peer.UserPeer;
import org.apache.turbine.services.BaseService;
import org.apache.turbine.services.security.BaseSecurityService;
@@ -92,29 +92,29 @@
import org.apache.turbine.util.security.UnknownEntityException;
/**
- * An implementation of SecurityService that uses a database as backend.
+ * An implementation of SecurityService that uses a database as backend.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @version $Id: DBSecurityService.java,v 1.8 2001/06/26 20:09:47 mpoeschl Exp $
+ * @version $Id: DBSecurityService.java,v 1.9 2001/06/27 00:31:19 mpoeschl Exp $
*/
public class DBSecurityService extends BaseSecurityService
{
- /**
- * The key within services's properties for user implementation
- * classname (user.class) - Leandro
+ /**
+ * The key within services's properties for user implementation
+ * classname (user.class) - Leandro
*/
public static final String USER_PEER_CLASS_KEY = "userPeer.class";
-
- /**
- * The default implementation of User interface
- * (org.apache.turbine.om.security.DBUser)
- */
- public static final String USER_PEER_CLASS_DEFAULT =
- "org.apache.turbine.om.security.peer.TurbineUserPeer";
-
+
+ /**
+ * The default implementation of User interface
+ * (org.apache.turbine.om.security.DBUser)
+ */
+ public static final String USER_PEER_CLASS_DEFAULT =
+ "org.apache.turbine.om.security.TurbineUserPeer";
+
/*-----------------------------------------------------------------------
Creation of AccessControlLists
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Constructs an AccessControlList for a specific user.
@@ -124,22 +124,24 @@
* into an AccessControlList object.
*
* @param user the user for whom the AccessControlList are to be retrieved
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
*/
- public AccessControlList getACL( User user )
+ public AccessControlList getACL( User user )
throws DataBackendException, UnknownEntityException
{
if(!TurbineSecurity.accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
try
{
Hashtable roles = new Hashtable();
Hashtable permissions = new Hashtable();
- // notify the state modifiers (writers) that we want to create the snapshot.
+ // notify the state modifiers (writers) that we want to create the
+ // snapshot.
lockShared();
// construct the snapshot:
@@ -150,7 +152,7 @@
{
Group group = (Group)groupsIterator.next();
// get roles of user in the group
- RoleSet groupRoles = RolePeer.retrieveSet( user, group );
+ RoleSet groupRoles = TurbineRolePeer.retrieveSet(user, group);
// put the Set into roles(group)
roles.put(group, groupRoles);
// collect all permissoins in this group
@@ -161,7 +163,8 @@
{
Role role = (Role)rolesIterator.next();
// get permissions of the role
- PermissionSet rolePermissions = PermissionPeer.retrieveSet(role);
+ PermissionSet rolePermissions =
+ TurbinePermissionPeer.retrieveSet(role);
groupPermissions.add(rolePermissions);
}
// put the Set into permissions(group)
@@ -171,7 +174,7 @@
}
catch(Exception e)
{
- throw new DataBackendException("Failed to build ACL for user '" +
+ throw new DataBackendException("Failed to build ACL for user '" +
user.getUserName() + "'" , e);
}
finally
@@ -183,16 +186,18 @@
/*-----------------------------------------------------------------------
Security management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
- /**
+ /**
* Grant an User a Role in a Group.
*
* @param User the user.
* @param Group the group.
* @param Role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
public synchronized void grant( User user, Group group, Role role )
throws DataBackendException, UnknownEntityException
@@ -209,11 +214,13 @@
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
- criteria.add(UserGroupRolePeer.USER_ID,
- ((BaseObject)user).getPrimaryKey());
- criteria.add(UserGroupRolePeer.GROUP_ID, ((BaseObject)group).getPrimaryKey());
- criteria.add(UserGroupRolePeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- UserGroupRolePeer.doInsert(criteria);
+ criteria.add(TurbineUserGroupRolePeer.USER_ID,
+ ((BaseObject)user).getPrimaryKey());
+ criteria.add(TurbineUserGroupRolePeer.GROUP_ID,
+ ((BaseObject)group).getPrimaryKey());
+ criteria.add(TurbineUserGroupRolePeer.ROLE_ID,
+ ((TurbineRole)role).getPrimaryKey());
+ TurbineUserGroupRolePeer.doInsert(criteria);
return;
}
}
@@ -223,33 +230,35 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!userExists)
{
- throw new UnknownEntityException("Unknown user '" +
+ throw new UnknownEntityException("Unknown user '" +
user.getUserName() + "'");
}
if(!groupExists)
{
- throw new UnknownEntityException("Unknown group '" +
+ throw new UnknownEntityException("Unknown group '" +
((SecurityEntity)group).getName() + "'");
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
}
- /**
+ /**
* Revoke a Role in a Group from an User.
*
* @param User the user.
* @param Group the group.
* @param Role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
public synchronized void revoke( User user, Group group, Role role )
throws DataBackendException, UnknownEntityException
@@ -266,12 +275,13 @@
if(userExists && groupExists && roleExists)
{
Criteria criteria = new Criteria();
- criteria.add(UserGroupRolePeer.USER_ID,
- ((BaseObject)user).getPrimaryKey());
- criteria.add(UserGroupRolePeer.GROUP_ID,
- ((BaseObject)group).getPrimaryKey());
- criteria.add(UserGroupRolePeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- UserGroupRolePeer.doDelete(criteria);
+ criteria.add(TurbineUserGroupRolePeer.USER_ID,
+ ((BaseObject)user).getPrimaryKey());
+ criteria.add(TurbineUserGroupRolePeer.GROUP_ID,
+ ((BaseObject)group).getPrimaryKey());
+ criteria.add(TurbineUserGroupRolePeer.ROLE_ID,
+ ((TurbineRole)role).getPrimaryKey());
+ TurbineUserGroupRolePeer.doDelete(criteria);
return;
}
}
@@ -281,22 +291,22 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!userExists)
{
- throw new UnknownEntityException("Unknown user '" +
- user.getUserName() + "'");
+ throw new UnknownEntityException("Unknown user '" +
+ user.getUserName() + "'");
}
if(!groupExists)
{
- throw new UnknownEntityException("Unknown group '" +
- ((SecurityEntity)group).getName() + "'");
+ throw new UnknownEntityException("Unknown group '" +
+ ((SecurityEntity)group).getName() + "'");
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
- role.getName() + "'");
+ throw new UnknownEntityException("Unknown role '" +
+ role.getName() + "'");
}
}
@@ -306,7 +316,8 @@
* This method is used when deleting an account.
*
* @param user the User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the account is not present.
*/
public synchronized void revokeAll( User user )
@@ -319,15 +330,20 @@
userExists=TurbineSecurity.accountExists(user);
if(userExists)
{
- // The following would not work, due to an annoying misfeature of Village.
- // Village allows only a single row to be deleted at a time. I wish that
- // it was possible to disable this behaviour!
+ // The following would not work, due to an annoying misfeature
+ // of Village.
+ // Village allows only a single row to be deleted at a time.
+ // I wish that it was possible to disable this behaviour!
// Criteria criteria = new Criteria();
- // criteria.add(UserGroupRolePeer.USER_ID, ((BaseObject)user).getPrimaryKey());
+ // criteria.add(UserGroupRolePeer.USER_ID,
+ // ((BaseObject)user).getPrimaryKey());
// UserGroupRolePeer.doDelete(criteria);
int id = ((BaseObject)user).getPrimaryKeyAsInt();
- UserGroupRolePeer.deleteAll(UserGroupRolePeer.TABLE_NAME, UserGroupRolePeer.USER_ID, id);
+ TurbineUserGroupRolePeer.deleteAll(
+ TurbineUserGroupRolePeer.TABLE_NAME,
+ TurbineUserGroupRolePeer.USER_ID,
+ id);
return;
}
}
@@ -337,9 +353,10 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
- throw new UnknownEntityException("Unknown user '"+user.getUserName()+"'");
+ throw new UnknownEntityException("Unknown user '" +
+ user.getUserName() + "'");
}
/**
@@ -347,7 +364,8 @@
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
public synchronized void grant( Role role, Permission permission )
@@ -363,10 +381,11 @@
if(roleExists && permissionExists)
{
Criteria criteria = new Criteria();
- criteria.add(RolePermissionPeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- criteria.add(RolePermissionPeer.PERMISSION_ID,
- ((BaseObject)permission).getPrimaryKey());
- UserGroupRolePeer.doInsert(criteria);
+ criteria.add(TurbineRolePermissionPeer.ROLE_ID,
+ ((TurbineRole)role).getPrimaryKey());
+ criteria.add(TurbineRolePermissionPeer.PERMISSION_ID,
+ ((BaseObject)permission).getPrimaryKey());
+ TurbineUserGroupRolePeer.doInsert(criteria);
return;
}
}
@@ -376,16 +395,16 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
if(!permissionExists)
{
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
((SecurityEntity)permission).getName() + "'");
}
}
@@ -395,7 +414,8 @@
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
public synchronized void revoke( Role role, Permission permission )
@@ -411,10 +431,11 @@
if(roleExists && permissionExists)
{
Criteria criteria = new Criteria();
- criteria.add(RolePermissionPeer.ROLE_ID, ((TurbineRole)role).getPrimaryKey());
- criteria.add(RolePermissionPeer.PERMISSION_ID,
- ((BaseObject)permission).getPrimaryKey());
- RolePermissionPeer.doDelete(criteria);
+ criteria.add(TurbineRolePermissionPeer.ROLE_ID,
+ ((TurbineRole)role).getPrimaryKey());
+ criteria.add(TurbineRolePermissionPeer.PERMISSION_ID,
+ ((BaseObject)permission).getPrimaryKey());
+ TurbineRolePermissionPeer.doDelete(criteria);
return;
}
}
@@ -424,16 +445,16 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
if(!roleExists)
{
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
if(!permissionExists)
{
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
((SecurityEntity)permission).getName() + "'");
}
}
@@ -444,7 +465,8 @@
* This method is user when deleting a Role.
*
* @param role the Role
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Role is not present.
*/
public synchronized void revokeAll( Role role )
@@ -457,7 +479,8 @@
roleExists=checkExists(role);
if(roleExists)
{
- // The following would not work, due to an annoying misfeature of Village.
+ // The following would not work, due to an annoying misfeature
+ // of Village.
// see revokeAll( user )
// Criteria criteria = new Criteria();
@@ -465,8 +488,10 @@
// RolePermissionPeer.doDelete(criteria);
int id = ((TurbineRole)role).getPrimaryKeyAsInt();
- RolePermissionPeer.deleteAll(RolePermissionPeer.TABLE_NAME,
- RolePermissionPeer.ROLE_ID, id);
+ TurbineRolePermissionPeer.deleteAll(
+ TurbineRolePermissionPeer.TABLE_NAME,
+ TurbineRolePermissionPeer.ROLE_ID,
+ id);
return;
}
}
@@ -476,14 +501,15 @@
}
finally
{
- unlockExclusive();
+ unlockExclusive();
}
- throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+ throw new UnknownEntityException("Unknown role '" +
+ role.getName() + "'");
}
/*-----------------------------------------------------------------------
Group/Role/Permission management
- -----------------------------------------------------------------------*/
+ -----------------------------------------------------------------------*/
/**
* Retrieve a set of Groups that meet the specified Criteria.
@@ -499,12 +525,13 @@
while(keys.hasNext())
{
String key = (String)keys.next();
- dbCriteria.put(GroupPeer.getColumnName(key), criteria.get(key));
+ dbCriteria.put(TurbineGroupPeer.getColumnName(key),
+ criteria.get(key));
}
Vector groups = new Vector(0);
try
{
- groups = GroupPeer.doSelect(criteria);
+ groups = TurbineGroupPeer.doSelect(criteria);
}
catch(Exception e)
{
@@ -512,7 +539,7 @@
}
return new GroupSet(groups);
}
-
+
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
@@ -527,12 +554,13 @@
while(keys.hasNext())
{
String key = (String)keys.next();
- dbCriteria.put(RolePeer.getColumnName(key), criteria.get(key));
+ dbCriteria.put(TurbineRolePeer.getColumnName(key),
+ criteria.get(key));
}
Vector roles = new Vector(0);
try
{
- roles = RolePeer.doSelect(criteria);
+ roles = TurbineRolePeer.doSelect(criteria);
}
catch(Exception e)
{
@@ -555,12 +583,13 @@
while(keys.hasNext())
{
String key = (String)keys.next();
- dbCriteria.put(PermissionPeer.getColumnName(key), criteria.get(key));
+ dbCriteria.put(TurbinePermissionPeer.getColumnName(key),
+ criteria.get(key));
}
Vector permissions = new Vector(0);
try
{
- permissions = PermissionPeer.doSelect(criteria);
+ permissions = TurbinePermissionPeer.doSelect(criteria);
}
catch(Exception e)
{
@@ -573,7 +602,8 @@
* Retrieves all permissions associated with a role.
*
* @param role the role name, for which the permissions are to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role is not present.
*/
public PermissionSet getPermissions( Role role )
@@ -586,7 +616,7 @@
roleExists = checkExists(role);
if(roleExists)
{
- return PermissionPeer.retrieveSet(role);
+ return TurbinePermissionPeer.retrieveSet(role);
}
}
catch(Exception e)
@@ -597,7 +627,7 @@
{
unlockShared();
}
- throw new UnknownEntityException("Unknown role '" +
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
}
@@ -605,7 +635,8 @@
* 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 DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public void saveGroup( Group group )
@@ -617,8 +648,8 @@
groupExists = checkExists(group);
if(groupExists)
{
- Criteria criteria = GroupPeer.buildCriteria(group);
- GroupPeer.doUpdate(criteria);
+ Criteria criteria = TurbineGroupPeer.buildCriteria(group);
+ TurbineGroupPeer.doUpdate(criteria);
}
}
catch(Exception e)
@@ -632,7 +663,8 @@
* 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 DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
public void saveRole( Role role )
@@ -644,8 +676,8 @@
roleExists = checkExists(role);
if(roleExists)
{
- Criteria criteria = RolePeer.buildCriteria(role);
- RolePeer.doUpdate(criteria);
+ Criteria criteria = TurbineRolePeer.buildCriteria(role);
+ TurbineRolePeer.doUpdate(criteria);
}
}
catch(Exception e)
@@ -656,10 +688,12 @@
}
/**
- * Stores Permission's attributes. The Permissions is required to exist in the system.
+ * 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 DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
public void savePermission( Permission permission )
@@ -671,8 +705,8 @@
permissionExists = checkExists(permission);
if(permissionExists)
{
- Criteria criteria = PermissionPeer.buildCriteria(permission);
- PermissionPeer.doUpdate(criteria);
+ Criteria criteria = TurbinePermissionPeer.buildCriteria(permission);
+ TurbinePermissionPeer.doUpdate(criteria);
}
}
catch(Exception e)
@@ -708,8 +742,8 @@
/**
* Retrieves a new Permission. It creates
- * a new Permission based on the Services Permission implementation. It does not
- * create a new Permission in the system though. Use create for that.
+ * a new Permission based on the Services Permission implementation. It does
+ * not create a new Permission in the system though. Use create for that.
*
* @param permissionName The name of the Permission to be retrieved.
*/
@@ -723,10 +757,11 @@
*
* @param group the object describing the group to be created.
* @return a new Group object that has id set up properly.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the group already exists.
*/
- public synchronized Group addGroup( Group group )
+ public synchronized Group addGroup( Group group )
throws DataBackendException, EntityExistsException
{
boolean groupExists = false;
@@ -737,16 +772,17 @@
if(!groupExists)
{
// add a row to the table
- Criteria criteria = GroupPeer.buildCriteria(group);
- GroupPeer.doInsert(criteria);
+ Criteria criteria = TurbineGroupPeer.buildCriteria(group);
+ TurbineGroupPeer.doInsert(criteria);
// try to get the object back using the name as key.
criteria = new Criteria();
- criteria.add(GroupPeer.NAME, ((SecurityEntity)group).getName());
- Vector results = GroupPeer.doSelect(criteria);
+ criteria.add(TurbineGroupPeer.NAME,
+ ((SecurityEntity)group).getName());
+ Vector results = TurbineGroupPeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Group newGroup = (Group)results.get(0);
@@ -766,7 +802,7 @@
}
// the only way we could get here without return/throw tirggered
// is that the groupExists was true.
- throw new EntityExistsException("Group '" + group +
+ throw new EntityExistsException("Group '" + group +
"' already exists");
}
@@ -775,10 +811,11 @@
*
* @param role the object describing the role to be created.
* @return a new Role object that has id set up properly.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the role already exists.
*/
- public synchronized Role addRole( Role role )
+ public synchronized Role addRole( Role role )
throws DataBackendException, EntityExistsException
{
boolean roleExists = false;
@@ -789,16 +826,16 @@
if(!roleExists)
{
// add a row to the table
- Criteria criteria = RolePeer.buildCriteria(role);
- RolePeer.doInsert(criteria);
+ Criteria criteria = TurbineRolePeer.buildCriteria(role);
+ TurbineRolePeer.doInsert(criteria);
// try to get the object back using the name as key.
criteria = new Criteria();
- criteria.add(RolePeer.NAME, role.getName());
- Vector results = RolePeer.doSelect(criteria);
+ criteria.add(TurbineRolePeer.NAME, role.getName());
+ Vector results = TurbineRolePeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Role newRole = (Role)results.get(0);
@@ -826,10 +863,11 @@
*
* @param permission the object describing the permission to be created.
* @return a new Permission object that has id set up properly.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the permission already exists.
*/
- public synchronized Permission addPermission( Permission permission )
+ public synchronized Permission addPermission( Permission permission )
throws DataBackendException, EntityExistsException
{
boolean permissionExists = false;
@@ -840,17 +878,17 @@
if(!permissionExists)
{
// add a row to the table
- Criteria criteria = PermissionPeer.buildCriteria(permission);
- PermissionPeer.doInsert(criteria);
+ Criteria criteria = TurbinePermissionPeer.buildCriteria(permission);
+ TurbinePermissionPeer.doInsert(criteria);
// try to get the object back using the name as key.
criteria = new Criteria();
- criteria.add(PermissionPeer.NAME,
+ criteria.add(TurbinePermissionPeer.NAME,
((SecurityEntity)permission).getName());
- Vector results = PermissionPeer.doSelect(criteria);
+ Vector results = TurbinePermissionPeer.doSelect(criteria);
if(results.size() != 1)
{
throw new DataBackendException(
- "Internal error - query returned " +
+ "Internal error - query returned " +
results.size() + " rows");
}
Permission newPermission = (Permission)results.get(0);
@@ -870,7 +908,7 @@
}
// the only way we could get here without return/throw tirggered
// is that the permissionExists was true.
- throw new EntityExistsException("Permission '" + permission +
+ throw new EntityExistsException("Permission '" + permission +
"' already exists");
}
@@ -878,7 +916,8 @@
* Removes a Group from the system.
*
* @param the object describing group to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public synchronized void removeGroup( Group group )
@@ -891,8 +930,8 @@
groupExists = checkExists(group);
if(groupExists)
{
- Criteria criteria = GroupPeer.buildCriteria(group);
- GroupPeer.doDelete(criteria);
+ Criteria criteria = TurbineGroupPeer.buildCriteria(group);
+ TurbineGroupPeer.doDelete(criteria);
getAllGroups().remove(group);
return;
}
@@ -914,7 +953,8 @@
* Removes a Role from the system.
*
* @param the object describing role to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @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 )
@@ -929,8 +969,8 @@
{
// revoke all permissions from the role to be deleted
revokeAll(role);
- Criteria criteria = RolePeer.buildCriteria(role);
- RolePeer.doDelete(criteria);
+ Criteria criteria = TurbineRolePeer.buildCriteria(role);
+ TurbineRolePeer.doDelete(criteria);
getAllRoles().remove(role);
return;
}
@@ -950,7 +990,8 @@
* Removes a Permission from the system.
*
* @param the object describing permission to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
public synchronized void removePermission( Permission permission )
@@ -963,8 +1004,8 @@
permissionExists = checkExists(permission);
if(permissionExists)
{
- Criteria criteria = PermissionPeer.buildCriteria(permission);
- PermissionPeer.doDelete(criteria);
+ Criteria criteria = TurbinePermissionPeer.buildCriteria(permission);
+ TurbinePermissionPeer.doDelete(criteria);
getAllPermissions().remove(permission);
return;
}
@@ -977,7 +1018,7 @@
{
unlockExclusive();
}
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
permission + "'");
}
@@ -986,7 +1027,8 @@
*
* @param the object describing the group to be renamed.
* @param name the new name for the group.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public synchronized void renameGroup( Group group, String name )
@@ -1000,8 +1042,8 @@
if(groupExists)
{
((SecurityEntity)group).setName(name);
- Criteria criteria = GroupPeer.buildCriteria(group);
- GroupPeer.doUpdate(criteria);
+ Criteria criteria = TurbineGroupPeer.buildCriteria(group);
+ TurbineGroupPeer.doUpdate(criteria);
return;
}
}
@@ -1015,13 +1057,14 @@
}
throw new UnknownEntityException("Unknown group '" + group + "'");
}
-
+
/**
* Renames an existing Role.
*
* @param the object describing the role to be renamed.
* @param name the new name for the role.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
public synchronized void renameRole( Role role, String name )
@@ -1035,8 +1078,8 @@
if(roleExists)
{
role.setName(name);
- Criteria criteria = RolePeer.buildCriteria(role);
- RolePeer.doUpdate(criteria);
+ Criteria criteria = TurbineRolePeer.buildCriteria(role);
+ TurbineRolePeer.doUpdate(criteria);
return;
}
}
@@ -1056,10 +1099,11 @@
*
* @param the object describing the permission to be renamed.
* @param name the new name for the permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
- public synchronized void renamePermission( Permission permission, String name )
+ public synchronized void renamePermission(Permission permission, String name)
throws DataBackendException, UnknownEntityException
{
boolean permissionExists = false;
@@ -1070,8 +1114,8 @@
if(permissionExists)
{
((SecurityEntity)permission).setName(name);
- Criteria criteria = PermissionPeer.buildCriteria(permission);
- PermissionPeer.doUpdate(criteria);
+ Criteria criteria = TurbinePermissionPeer.buildCriteria(permission);
+ TurbinePermissionPeer.doUpdate(criteria);
return;
}
}
@@ -1083,7 +1127,7 @@
{
unlockExclusive();
}
- throw new UnknownEntityException("Unknown permission '" +
+ throw new UnknownEntityException("Unknown permission '" +
permission + "'");
}
@@ -1142,14 +1186,14 @@
*
* @param group a <code>Group</code> value
* @return true if the group exists in the system, false otherwise
- * @throws DataBackendException when more than one Group with
+ * @throws DataBackendException when more than one Group with
* the same name exists.
* @throws Exception, a generic exception.
*/
protected boolean checkExists(Group group)
throws DataBackendException, Exception
{
- return GroupPeer.checkExists(group);
+ return TurbineGroupPeer.checkExists(group);
}
/**
@@ -1157,14 +1201,14 @@
*
* @param role a <code>Role</code> value
* @return true if the role exists in the system, false otherwise
- * @throws DataBackendException when more than one Role with
+ * @throws DataBackendException when more than one Role with
* the same name exists.
* @throws Exception, a generic exception.
*/
protected boolean checkExists(Role role)
throws DataBackendException, Exception
{
- return RolePeer.checkExists(role);
+ return TurbineRolePeer.checkExists(role);
}
/**
@@ -1172,14 +1216,14 @@
*
* @param permission a <code>Permission</code> value
* @return true if the permission exists in the system, false otherwise
- * @throws DataBackendException when more than one Permission with
+ * @throws DataBackendException when more than one Permission with
* the same name exists.
* @throws Exception, a generic exception.
*/
protected boolean checkExists(Permission permission)
throws DataBackendException, Exception
{
- return PermissionPeer.checkExists(permission);
+ return TurbinePermissionPeer.checkExists(permission);
}
}
1.8 +39 -39 jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBUserManager.java
Index: DBUserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/security/db/DBUserManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DBUserManager.java 2001/06/25 05:02:44 1.7
+++ DBUserManager.java 2001/06/27 00:31:19 1.8
@@ -25,13 +25,13 @@
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache Turbine" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache Turbine" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
@@ -60,7 +60,7 @@
import org.apache.turbine.services.db.om.BaseObject;
import org.apache.turbine.services.db.om.ObjectKey;
import org.apache.turbine.om.security.User;
-import org.apache.turbine.om.security.peer.TurbineUserPeer;
+import org.apache.turbine.om.security.TurbineUserPeer;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.UnknownEntityException;
@@ -74,12 +74,12 @@
import org.apache.turbine.services.security.TurbineSecurity;
/**
- * An UserManager performs {@link org.apache.turbine.om.security.User} objects
- * related tasks on behalf of the
+ * An UserManager performs {@link org.apache.turbine.om.security.User} objects
+ * related tasks on behalf of the
* {@link org.apache.turbine.services.security.BaseSecurityService}.
*
- * This implementation uses a relational database for storing user data. It
- * expects that the User interface implementation will be castable to
+ * This implementation uses a relational database for storing user data. It
+ * expects that the User interface implementation will be castable to
* {@link org.apache.turbine.om.BaseObject}.
*
* @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
@@ -87,7 +87,7 @@
* @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
* @author <a href="mailto:cberry@gluecode.com">Craig D. Berry</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @version $Id: DBUserManager.java,v 1.7 2001/06/25 05:02:44 jvanzyl Exp $
+ * @version $Id: DBUserManager.java,v 1.8 2001/06/27 00:31:19 mpoeschl Exp $
*/
public class DBUserManager implements UserManager
{
@@ -98,7 +98,7 @@
*
* @param user The user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
* the data backend.
*/
public boolean accountExists( User user )
@@ -114,7 +114,7 @@
*
* @param usename The name of the user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
* the data backend.
*/
public boolean accountExists( String username )
@@ -142,7 +142,7 @@
/**
* Retrieve a user from persistent storage using username as the
- * key.
+ * key.
*
* @param username the name of the user.
* @return an User object.
@@ -163,7 +163,7 @@
}
catch(Exception e)
{
- throw new DataBackendException("Failed to retrieve user '" +
+ throw new DataBackendException("Failed to retrieve user '" +
username + "'", e);
}
if ( users.size() > 1 )
@@ -205,7 +205,7 @@
for (int i=0;i<criterion.length;i++)
{
String table = criterion[i].getTable();
- if ( table == null || "".equals(table) )
+ if ( table == null || "".equals(table) )
{
criterion[i].setTable(TurbineUserPeer.getTableName());
}
@@ -232,7 +232,7 @@
* @param username the name of the user.
* @param password the user supplied password.
* @return an User object.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
@@ -240,7 +240,7 @@
* storage.
*/
public User retrieve( String username, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
User user = retrieve(username);
@@ -263,7 +263,7 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
Criteria criteria = TurbineUserPeer.buildCriteria(user);
@@ -284,7 +284,7 @@
*
* @param user an User object to authenticate.
* @param password the user supplied password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
@@ -292,12 +292,12 @@
* storage.
*/
public void authenticate( User user, String password )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
String encrypted = TurbineSecurity.encryptPassword(password);
@@ -312,22 +312,22 @@
*
* @param user an User to change password for.
* @param password the new password.
- * @exception PasswordMismatchException if the supplied password was
+ * @exception PasswordMismatchException if the supplied password was
* incorrect.
* @exception UnknownEntityException if the user's account does not
* exist in the database.
* @exception DataBackendException if there is a problem accessing the
* storage.
*/
- public void changePassword( User user, String oldPassword,
+ public void changePassword( User user, String oldPassword,
String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
+ throws PasswordMismatchException, UnknownEntityException,
DataBackendException
{
String encrypted = TurbineSecurity.encryptPassword(oldPassword);
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
if(!user.getPassword().equals(encrypted))
@@ -339,7 +339,7 @@
user.setPassword(TurbineSecurity.encryptPassword(newPassword));
// save the changes in the database imediately, to prevent the password
// being 'reverted' to the old value if the user data is lost somehow
- // before it is saved at session's expiry.
+ // before it is saved at session's expiry.
store(user);
}
@@ -347,10 +347,10 @@
* Forcibly sets new password for an User.
*
* This is supposed by the administrator to change the forgotten or
- * compromised passwords. Certain implementatations of this feature
- * would require administrative level access to the authenticating
+ * compromised passwords. Certain implementatations of this feature
+ * would require administrative level access to the authenticating
* server / program.
- *
+ *
* @param user an User to change password for.
* @param password the new password.
* @exception UnknownEntityException if the user's record does not
@@ -363,13 +363,13 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
user.setPassword(TurbineSecurity.encryptPassword(password));
- // save the changes in the database immediately, to prevent the
- // password being 'reverted' to the old value if the user data
- // is lost somehow before it is saved at session's expiry.
+ // save the changes in the database immediately, to prevent the
+ // password being 'reverted' to the old value if the user data
+ // is lost somehow before it is saved at session's expiry.
store(user);
}
@@ -377,7 +377,7 @@
* Creates new user account with specified attributes.
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
the data backend.
* @throws EntityExistsException if the user account already exists.
*/
@@ -386,7 +386,7 @@
{
if(accountExists(user))
{
- throw new EntityExistsException("The account '" +
+ throw new EntityExistsException("The account '" +
user.getUserName() + "' already exists");
}
String encrypted = TurbineSecurity.encryptPassword(initialPassword);
@@ -394,7 +394,7 @@
Criteria criteria = TurbineUserPeer.buildCriteria(user);
try
{
- // we can safely assume that BaseObject derivate is used as User
+ // we can safely assume that BaseObject derivate is used as User
// implementation with this UserManager
((BaseObject)user).setPrimaryKey(
TurbineUserPeer.doInsert(criteria));
@@ -410,7 +410,7 @@
* Removes an user account from the system.
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing
+ * @throws DataBackendException if there was an error accessing
the data backend.
* @throws UnknownEntityException if the user account is not present.
*/
@@ -419,7 +419,7 @@
{
if(!accountExists(user))
{
- throw new UnknownEntityException("The account '" +
+ throw new UnknownEntityException("The account '" +
user.getUserName() + "' does not exist");
}
Criteria criteria = new Criteria();
@@ -430,7 +430,7 @@
}
catch(Exception e)
{
- throw new DataBackendException("Failed to remove account '" +
+ throw new DataBackendException("Failed to remove account '" +
user.getUserName() + "'", e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org