Author: painter
Date: Mon Nov 5 22:43:28 2018
New Revision: 1845861
URL: http://svn.apache.org/viewvc?rev=1845861&view=rev
Log:
Lots of JavaDoc updates. fulcrum-security-torque still not building on site,
see the pom for more details and where we need to figure this out for generated
classes with poor javadocs
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/PersistenceHelperDefaultImpl.java
turbine/fulcrum/trunk/security/memory/pom.xml
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryGroupManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryHelper.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryPermissionManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryRoleManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryUserManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/basic/MemoryModelManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/turbine/MemoryTurbineUserManagerImpl.java
turbine/fulcrum/trunk/security/torque/pom.xml
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractGroupManager.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractPermissionManager.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractRoleManager.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractUserManager.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicGroup.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/basic/TorqueAbstractBasicUser.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicGroup.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicPermission.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicRole.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueAbstractDynamicUser.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicGroupManagerImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicModelManagerImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicPermissionManagerImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicRoleManagerImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/dynamic/TorqueDynamicUserManagerImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/peer/PeerManager.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/peer/PeerManagerDefaultImpl.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/peer/TurbineUserGroupRoleModelPeerMapper.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/security/TorqueAbstractSecurityEntity.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/security/turbine/TorqueAbstractTurbineTurbineSecurityEntity.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/security/turbine/TorqueAbstractTurbineTurbineSecurityEntityDefault.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/DefaultAbstractTurbineGroup.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/DefaultAbstractTurbinePermission.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/DefaultAbstractTurbineRole.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/DefaultAbstractTurbineUser.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/FulcrumAbstractTurbineGroup.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/FulcrumAbstractTurbinePermission.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/FulcrumAbstractTurbineRole.java
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/FulcrumAbstractTurbineUser.java
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateGroupManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -177,8 +177,6 @@ public class HibernateGroupManagerImpl e
* @return a new Group object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the group already exists.
*/
@Override
protected synchronized Group persistNewGroup(Group group) throws
DataBackendException
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernatePermissionManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -149,8 +149,6 @@ public class HibernatePermissionManagerI
* @return a new Permission object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the permission already exists.
*/
@Override
protected synchronized Permission persistNewPermission(Permission
permission) throws DataBackendException
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateRoleManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -126,8 +126,6 @@ public class HibernateRoleManagerImpl ex
* @return a new Role object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the role already exists.
*/
@Override
protected synchronized Role persistNewRole(Role role) throws
DataBackendException
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/HibernateUserManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -146,13 +146,9 @@ public class HibernateUserManagerImpl ex
*
* @param user
* the object describing account to be created.
- * @param password
- * The password to use for the account.
*
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the user account already exists.
*/
@Override
public User persistNewUser(User user) throws DataBackendException
@@ -164,7 +160,7 @@ public class HibernateUserManagerImpl ex
/**
* Stores User attributes. The User is required to exist in the system.
*
- * @param role
+ * @param user
* The User to be stored.
* @throws DataBackendException
* if there was an error accessing the data backend.
Modified:
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/PersistenceHelperDefaultImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/PersistenceHelperDefaultImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/PersistenceHelperDefaultImpl.java
(original)
+++
turbine/fulcrum/trunk/security/hibernate/src/java/org/apache/fulcrum/security/hibernate/PersistenceHelperDefaultImpl.java
Mon Nov 5 22:43:28 2018
@@ -50,12 +50,10 @@ public class PersistenceHelperDefaultImp
/**
* Deletes an entity object
*
- * @param role
+ * @param entity
* The object to be removed
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the object does not exist.
*/
public void removeEntity(SecurityEntity entity) throws DataBackendException
{
@@ -85,12 +83,10 @@ public class PersistenceHelperDefaultImp
/**
* Stores changes made to an object
*
- * @param role
+ * @param entity
* The object to be saved
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the role does not exist.
*/
public void updateEntity(SecurityEntity entity) throws DataBackendException
{
@@ -128,12 +124,10 @@ public class PersistenceHelperDefaultImp
/**
* adds an entity
*
- * @param role
+ * @param entity
* The object to be saved
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the role does not exist.
*/
public void addEntity(SecurityEntity entity) throws DataBackendException
{
@@ -164,7 +158,7 @@ public class PersistenceHelperDefaultImp
* Returns a hibernate session, or if is null, opens one.
*
* @return An Open hibernate session.
- * @throws HibernateException
+ * @throws HibernateException generic exception
*/
public Session retrieveSession() throws HibernateException
{
@@ -176,7 +170,7 @@ public class PersistenceHelperDefaultImp
}
/**
- * Return the hibernate configuration
+ * @return the hibernate configuration
*/
public Configuration getConfiguration()
{
@@ -186,7 +180,7 @@ public class PersistenceHelperDefaultImp
/**
* In some environments we will load the session factory up and pass it in.
*
- * @param hibernateService
+ * @param sessionFactory
* The hibernateService to set.
*/
public void setSessionFactory(SessionFactory sessionFactory)
@@ -204,9 +198,7 @@ public class PersistenceHelperDefaultImp
return sessionFactory;
}
- /**
- * Avalon lifecycle method
- *
+ /* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Initializable#initialize()
*/
public void initialize() throws Exception
@@ -214,9 +206,7 @@ public class PersistenceHelperDefaultImp
sessionFactory = configuration.buildSessionFactory();
}
- /**
- * Avalon lifecycle method
- *
+ /* (non-Javadoc)
* @see org.apache.fulcrum.security.spi.AbstractManager#dispose()
*/
@Override
@@ -226,9 +216,7 @@ public class PersistenceHelperDefaultImp
super.dispose();
}
- /**
- * Avalon lifecycle method
- *
+ /* (non-Javadoc)
* @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void
configure(org.apache.avalon.framework.configuration.Configuration conf) throws
ConfigurationException
Modified: turbine/fulcrum/trunk/security/memory/pom.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/pom.xml?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
--- turbine/fulcrum/trunk/security/memory/pom.xml (original)
+++ turbine/fulcrum/trunk/security/memory/pom.xml Mon Nov 5 22:43:28 2018
@@ -67,7 +67,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.fulcrum</groupId>
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryGroupManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryGroupManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryGroupManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryGroupManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -126,13 +126,11 @@ public class MemoryGroupManagerImpl exte
/**
* Determines if the <code>Group</code> exists in the security system.
*
- * @param group
+ * @param groupName
* a <code>Group</code> value
* @return true if the group exists in the system, false otherwise
* @throws DataBackendException
* when more than one Group with the same name exists.
- * @throws Exception
- * A generic exception.
*/
public boolean checkExists(String groupName) throws DataBackendException
{
@@ -147,8 +145,6 @@ public class MemoryGroupManagerImpl exte
* @return a new Group object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the group already exists.
*/
@Override
protected synchronized <T extends Group> T persistNewGroup(T group) throws
DataBackendException
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryHelper.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryHelper.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryHelper.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryHelper.java
Mon Nov 5 22:43:28 2018
@@ -42,6 +42,11 @@ public class MemoryHelper
return new Integer(++uniqueId);
}
+ /**
+ * @param securityEntities list of security entities
+ * @param name the name
+ * @return <code>true</code> if exists
+ */
public static boolean checkExists(List<? extends SecurityEntity>
securityEntities, String name)
{
boolean exists = false;
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryPermissionManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryPermissionManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryPermissionManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryPermissionManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -92,13 +92,11 @@ public class MemoryPermissionManagerImpl
/**
* Determines if the <code>Permission</code> exists in the security system.
*
- * @param permission
+ * @param permissionName
* a <code>String</code> value
- * @return true if the permission exists in the system, false otherwise
+ * @return <code>true</code> if the permission exists in the system, false
otherwise
* @throws DataBackendException
* when more than one Permission with the same name exists.
- * @throws Exception
- * A generic exception.
*/
public boolean checkExists(String permissionName) throws
DataBackendException
{
@@ -143,8 +141,6 @@ public class MemoryPermissionManagerImpl
* @return a new Permission object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the permission already exists.
*/
@Override
protected synchronized <T extends Permission> T persistNewPermission(T
permission) throws DataBackendException
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryRoleManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryRoleManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryRoleManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryRoleManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -81,13 +81,9 @@ public class MemoryRoleManagerImpl exten
/**
* Determines if the <code>Role</code> exists in the security system.
*
- * @param permission
+ * @param roleName
* a <code>String</code> value
* @return true if the role exists in the system, false otherwise
- * @throws DataBackendException
- * when more than one Role with the same name exists.
- * @throws Exception
- * A generic exception.
*/
public boolean checkExists(String roleName)
{
@@ -114,8 +110,6 @@ public class MemoryRoleManagerImpl exten
* @return a new Role object that has id set up properly.
* @throws DataBackendException
* if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the role already exists.
*/
@Override
protected synchronized <T extends Role> T persistNewRole(T role) throws
DataBackendException
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryUserManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryUserManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryUserManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/MemoryUserManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -24,7 +24,6 @@ import java.util.List;
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.spi.AbstractUserManager;
import org.apache.fulcrum.security.util.DataBackendException;
-import org.apache.fulcrum.security.util.EntityExistsException;
import org.apache.fulcrum.security.util.UnknownEntityException;
import org.apache.fulcrum.security.util.UserSet;
@@ -32,105 +31,86 @@ import org.apache.fulcrum.security.util.
* This implementation keeps all objects in memory. This is mostly meant to
help
* with testing and prototyping of ideas.
*
- * @todo Need to load up Crypto component and actually encrypt passwords!
* @author <a href="mailto:[email protected]">Eric Pugh</a>
* @version $Id$
*/
-public class MemoryUserManagerImpl extends AbstractUserManager
-{
- private static List<User> users = new ArrayList<User>();
-
- /** Our Unique ID counter */
- // private static int uniqueId = 0;
-
- /**
- * Check whether a specified user's account exists.
- *
- * The login name is used for looking up the account.
- *
- * @param userName
- * The name of the user to be checked.
- * @return true if the specified account exists
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- */
- public boolean checkExists(String userName) throws DataBackendException
- {
- return MemoryHelper.checkExists(users, userName);
-
- }
-
- /**
- * Retrieves all users defined in the system.
- *
- * @return the names of all users defined in the system.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- */
- public UserSet getAllUsers() throws DataBackendException
- {
- return new UserSet(users);
- }
-
- /**
- * 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 the data backend.
- * @throws UnknownEntityException
- * if the user account is not present.
- */
- public void removeUser(User user) throws DataBackendException,
UnknownEntityException
- {
- users.remove(user);
- }
-
- /**
- * Creates new user account with specified attributes.
- *
- * @param user
- * the object describing account to be created.
- * @param password
- * The password to use for the account.
- *
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws EntityExistsException
- * if the user account already exists.
- */
- @Override
- protected <T extends User> T persistNewUser(T user) throws
DataBackendException
- {
- users.remove(user);
- user.setId(MemoryHelper.getUniqueId());
- users.add(user);
- return user;
- }
-
- /**
- * Stores User attributes. The User is required to exist in the system.
- *
- * @param role
- * The User to be stored.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the role does not exist.
- */
- public void saveUser(User user) throws DataBackendException,
UnknownEntityException
- {
- boolean userExists = false;
- userExists = checkExists(user);
- if (userExists)
- {
- users.remove(user);
- users.add(user);
- }
- else
- {
- throw new UnknownEntityException("Unknown user '" + user + "'");
- }
- }
+public class MemoryUserManagerImpl extends AbstractUserManager {
+
+ // TODO Need to load up Crypto component and actually encrypt passwords!
+
+ private static List<User> users = new ArrayList<User>();
+
+ /** Our Unique ID counter */
+ // private static int uniqueId = 0;
+
+ /**
+ * Check whether a specified user's account exists.
+ *
+ * The login name is used for looking up the account.
+ *
+ * @param userName The name of the user to be checked.
+ * @return true if the specified account exists
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ */
+ public boolean checkExists(String userName) throws DataBackendException
{
+ return MemoryHelper.checkExists(users, userName);
+ }
+
+ /**
+ * Retrieves all users defined in the system.
+ *
+ * @return the names of all users defined in the system.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ */
+ public UserSet getAllUsers() throws DataBackendException {
+ return new UserSet(users);
+ }
+
+ /**
+ * 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 the
data
+ * backend.
+ * @throws UnknownEntityException if the user account is not present.
+ */
+ public void removeUser(User user) throws DataBackendException,
UnknownEntityException {
+ users.remove(user);
+ }
+
+ /**
+ * Creates new user account with specified attributes.
+ *
+ * @param user the object describing account to be created.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ */
+ @Override
+ protected <T extends User> T persistNewUser(T user) throws
DataBackendException {
+ users.remove(user);
+ user.setId(MemoryHelper.getUniqueId());
+ users.add(user);
+ return user;
+ }
+
+ /**
+ * Stores User attributes. The User is required to exist in the system.
+ *
+ * @param user The User to be stored.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend
+ * @throws UnknownEntityException if the role does not exist.
+ */
+ public void saveUser(User user) throws DataBackendException,
UnknownEntityException {
+ boolean userExists = false;
+ userExists = checkExists(user);
+ if (userExists) {
+ users.remove(user);
+ users.add(user);
+ } else {
+ throw new UnknownEntityException("Unknown user '" +
user + "'");
+ }
+ }
}
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/basic/MemoryModelManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/basic/MemoryModelManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/basic/MemoryModelManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/basic/MemoryModelManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -42,8 +42,8 @@ public class MemoryModelManagerImpl exte
*
* This method is used when adding a user to a group
*
- * @param user
- * the User.
+ * @param user the User
+ * @param group the Group
* @throws DataBackendException
* if there was an error accessing the data backend.
* @throws UnknownEntityException
@@ -86,6 +86,7 @@ public class MemoryModelManagerImpl exte
*
* @param user
* the User.
+ * @param group the Group
* @throws DataBackendException
* if there was an error accessing the data backend.
* @throws UnknownEntityException
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/dynamic/MemoryModelManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -38,257 +38,200 @@ import org.apache.fulcrum.security.util.
* @author <a href="mailto:[email protected]">Eric Pugh</a>
* @version $Id$
*/
-public class MemoryModelManagerImpl extends AbstractDynamicModelManager
implements DynamicModelManager
-{
- /**
- * Puts a user in a group.
- *
- * This method is used when adding a user to a group
- *
- * @param user
- * the User.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the account is not present.
- */
- public void grant(User user, Group group) throws DataBackendException,
UnknownEntityException
- {
- boolean groupExists = false;
- boolean userExists = false;
- try
- {
- groupExists = getGroupManager().checkExists(group);
- userExists = getUserManager().checkExists(user);
- if (groupExists && userExists)
- {
- ((DynamicUser) user).addGroup(group);
- ((DynamicGroup) group).addUser(user);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("grant(Role,Permission) failed", e);
- }
-
- if (!groupExists)
- {
- throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
- }
- if (!userExists)
- {
- throw new UnknownEntityException("Unknown user '" + user.getName()
+ "'");
- }
- }
-
- /**
- * Removes a user in a group.
- *
- * This method is used when removing a user to a group
- *
- * @param user
- * the User.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the user or group is not present.
- */
- public void revoke(User user, Group group) throws DataBackendException,
UnknownEntityException
- {
- boolean groupExists = false;
- boolean userExists = false;
- try
- {
- groupExists = getGroupManager().checkExists(group);
- userExists = getUserManager().checkExists(user);
- if (groupExists && userExists)
- {
- ((DynamicUser) user).removeGroup(group);
- ((DynamicGroup) group).removeUser(user);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("grant(Role,Permission) failed", e);
- }
-
- if (!groupExists)
- {
- throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
- }
- if (!userExists)
- {
- throw new UnknownEntityException("Unknown user '" + user.getName()
+ "'");
- }
- }
-
- /**
- * Grants a Group a Role
- *
- * @param group
- * the Group.
- * @param role
- * the Role.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if group or role is not present.
- */
- public synchronized void grant(Group group, Role role) throws
DataBackendException, UnknownEntityException
- {
- boolean groupExists = false;
- boolean roleExists = false;
- try
- {
- groupExists = getGroupManager().checkExists(group);
- roleExists = getRoleManager().checkExists(role);
- if (groupExists && roleExists)
- {
- ((DynamicGroup) group).addRole(role);
- ((DynamicRole) role).addGroup(group);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("grant(Group,Role) failed", e);
- }
- if (!groupExists)
- {
- throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
- }
- if (!roleExists)
- {
- throw new UnknownEntityException("Unknown role '" + role.getName()
+ "'");
- }
- }
-
- /**
- * Revokes a Role from a Group.
- *
- * @param group
- * the Group.
- * @param role
- * the Role.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if group or role is not present.
- */
- public synchronized void revoke(Group group, Role role) throws
DataBackendException, UnknownEntityException
- {
- boolean groupExists = false;
- boolean roleExists = false;
- try
- {
- groupExists = getGroupManager().checkExists(group);
- roleExists = getRoleManager().checkExists(role);
- if (groupExists && roleExists)
- {
- ((DynamicGroup) group).removeRole(role);
- ((DynamicRole) role).removeGroup(group);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("revoke(Group,Role) failed", e);
- }
-
- if (!groupExists)
- {
- throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
- }
- if (!roleExists)
- {
- throw new UnknownEntityException("Unknown role '" + role.getName()
+ "'");
- }
- }
-
- /**
- * Grants a Role a Permission
- *
- * @param role
- * the Role.
- * @param permission
- * the Permission.
- * @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) throws
DataBackendException, UnknownEntityException
- {
- boolean roleExists = false;
- boolean permissionExists = false;
- try
- {
- roleExists = getRoleManager().checkExists(role);
- permissionExists = getPermissionManager().checkExists(permission);
- if (roleExists && permissionExists)
- {
- ((DynamicRole) role).addPermission(permission);
- ((DynamicPermission) permission).addRole(role);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("grant(Role,Permission) failed", e);
- }
-
- if (!roleExists)
- {
- throw new UnknownEntityException("Unknown role '" + role.getName()
+ "'");
- }
- if (!permissionExists)
- {
- throw new UnknownEntityException("Unknown permission '" +
permission.getName() + "'");
- }
- }
-
- /**
- * Revokes a Permission from a Role.
- *
- * @param role
- * the Role.
- * @param permission
- * the Permission.
- * @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) throws
DataBackendException, UnknownEntityException
- {
- boolean roleExists = false;
- boolean permissionExists = false;
- try
- {
- roleExists = getRoleManager().checkExists(role);
- permissionExists = getPermissionManager().checkExists(permission);
- if (roleExists && permissionExists)
- {
- ((DynamicRole) role).removePermission(permission);
- ((DynamicPermission) permission).removeRole(role);
- return;
- }
- }
- catch (Exception e)
- {
- throw new DataBackendException("revoke(Role,Permission) failed",
e);
- }
-
- if (!roleExists)
- {
- throw new UnknownEntityException("Unknown role '" + role.getName()
+ "'");
- }
- if (!permissionExists)
- {
- throw new UnknownEntityException("Unknown permission '" +
permission.getName() + "'");
- }
- }
+public class MemoryModelManagerImpl extends AbstractDynamicModelManager
implements DynamicModelManager {
+ /**
+ * Puts a user in a group.
+ *
+ * This method is used when adding a user to a group
+ *
+ * @param user the User.
+ * @param group the Group
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if the account is not present.
+ */
+ public void grant(User user, Group group) throws DataBackendException,
UnknownEntityException {
+ boolean groupExists = false;
+ boolean userExists = false;
+ try {
+ groupExists = getGroupManager().checkExists(group);
+ userExists = getUserManager().checkExists(user);
+ if (groupExists && userExists) {
+ ((DynamicUser) user).addGroup(group);
+ ((DynamicGroup) group).addUser(user);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("grant(Role,Permission)
failed", e);
+ }
+
+ if (!groupExists) {
+ throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
+ }
+ if (!userExists) {
+ throw new UnknownEntityException("Unknown user '" +
user.getName() + "'");
+ }
+ }
+
+ /**
+ * Revokes a user from a group
+ *
+ * @param user the User.
+ * @param group the Group
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend
+ * @throws UnknownEntityException if the user or group is not present.
+ */
+ public void revoke(User user, Group group) throws DataBackendException,
UnknownEntityException {
+ boolean groupExists = false;
+ boolean userExists = false;
+ try {
+ groupExists = getGroupManager().checkExists(group);
+ userExists = getUserManager().checkExists(user);
+ if (groupExists && userExists) {
+ ((DynamicUser) user).removeGroup(group);
+ ((DynamicGroup) group).removeUser(user);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("grant(Role,Permission)
failed", e);
+ }
+
+ if (!groupExists) {
+ throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
+ }
+ if (!userExists) {
+ throw new UnknownEntityException("Unknown user '" +
user.getName() + "'");
+ }
+ }
+
+ /**
+ * Grants a Role to a Group
+ *
+ * @param group the Group.
+ * @param role the Role.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if group or role is not present.
+ */
+ public synchronized void grant(Group group, Role role) throws
DataBackendException, UnknownEntityException {
+ boolean groupExists = false;
+ boolean roleExists = false;
+ try {
+ groupExists = getGroupManager().checkExists(group);
+ roleExists = getRoleManager().checkExists(role);
+ if (groupExists && roleExists) {
+ ((DynamicGroup) group).addRole(role);
+ ((DynamicRole) role).addGroup(group);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("grant(Group,Role)
failed", e);
+ }
+ if (!groupExists) {
+ throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
+ }
+ if (!roleExists) {
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
+ }
+ }
+
+ /**
+ * Revokes a Role from a Group.
+ *
+ * @param group the Group.
+ * @param role the Role.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if group or role is not present.
+ */
+ public synchronized void revoke(Group group, Role role) throws
DataBackendException, UnknownEntityException {
+ boolean groupExists = false;
+ boolean roleExists = false;
+ try {
+ groupExists = getGroupManager().checkExists(group);
+ roleExists = getRoleManager().checkExists(role);
+ if (groupExists && roleExists) {
+ ((DynamicGroup) group).removeRole(role);
+ ((DynamicRole) role).removeGroup(group);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("revoke(Group,Role)
failed", e);
+ }
+
+ if (!groupExists) {
+ throw new UnknownEntityException("Unknown group '" +
group.getName() + "'");
+ }
+ if (!roleExists) {
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
+ }
+ }
+
+ /**
+ * Grants a Role a Permission
+ *
+ * @param role the Role.
+ * @param permission the Permission.
+ * @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)
+ throws DataBackendException, UnknownEntityException {
+ boolean roleExists = false;
+ boolean permissionExists = false;
+ try {
+ roleExists = getRoleManager().checkExists(role);
+ permissionExists =
getPermissionManager().checkExists(permission);
+ if (roleExists && permissionExists) {
+ ((DynamicRole) role).addPermission(permission);
+ ((DynamicPermission) permission).addRole(role);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("grant(Role,Permission)
failed", e);
+ }
+
+ if (!roleExists) {
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
+ }
+ if (!permissionExists) {
+ throw new UnknownEntityException("Unknown permission '"
+ permission.getName() + "'");
+ }
+ }
+
+ /**
+ * Revokes a Permission from a Role.
+ *
+ * @param role the Role.
+ * @param permission the Permission.
+ * @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)
+ throws DataBackendException, UnknownEntityException {
+ boolean roleExists = false;
+ boolean permissionExists = false;
+ try {
+ roleExists = getRoleManager().checkExists(role);
+ permissionExists =
getPermissionManager().checkExists(permission);
+ if (roleExists && permissionExists) {
+ ((DynamicRole)
role).removePermission(permission);
+ ((DynamicPermission)
permission).removeRole(role);
+ return;
+ }
+ } catch (Exception e) {
+ throw new DataBackendException("revoke(Role,Permission)
failed", e);
+ }
+
+ if (!roleExists) {
+ throw new UnknownEntityException("Unknown role '" +
role.getName() + "'");
+ }
+ if (!permissionExists) {
+ throw new UnknownEntityException("Unknown permission '"
+ permission.getName() + "'");
+ }
+ }
}
Modified:
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/turbine/MemoryTurbineUserManagerImpl.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/turbine/MemoryTurbineUserManagerImpl.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/turbine/MemoryTurbineUserManagerImpl.java
(original)
+++
turbine/fulcrum/trunk/security/memory/src/java/org/apache/fulcrum/security/memory/turbine/MemoryTurbineUserManagerImpl.java
Mon Nov 5 22:43:28 2018
@@ -18,64 +18,71 @@ package org.apache.fulcrum.security.memo
* specific language governing permissions and limitations
* under the License.
*/
+
import org.apache.fulcrum.security.entity.User;
import org.apache.fulcrum.security.memory.MemoryUserManagerImpl;
import org.apache.fulcrum.security.model.turbine.TurbineUserManager;
import org.apache.fulcrum.security.util.DataBackendException;
import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.commons.lang3.StringUtils;
/**
* This implementation keeps all objects in memory. This is mostly meant to
help
* with testing and prototyping of ideas.
*
- * @todo Need to load up Crypto component and actually encrypt passwords!
* @author <a href="mailto:[email protected]">Eric Pugh</a>
* @version $Id: MemoryTurbineUserManagerImpl.java 535465 2007-05-05 06:58:06Z
* tv $
*/
-public class MemoryTurbineUserManagerImpl extends MemoryUserManagerImpl
implements TurbineUserManager
-{
- /**
- * Constructs an User object to represent an anonymous user of the
- * application.
- *
- * @return An anonymous Turbine User.
- * @throws UnknownEntityException
- * if the implementation of User interface could not be
- * determined, or does not exist.
- */
- @Override
- public <T extends User> T getAnonymousUser() throws
UnknownEntityException
- {
- T user;
- try
- {
- user = getUserInstance();
- }
- catch (DataBackendException dbe)
- {
- throw new UnknownEntityException("Could not create an anonymous
user.", dbe);
- }
-
- user.setName("");
- return user;
- }
-
- /**
- * Checks whether a passed user object matches the anonymous user pattern
- * according to the configured user manager
- *
- * @param user
- * An user object
- *
- * @return True if this is an anonymous user
- *
- */
- @Override
- public boolean isAnonymousUser(User user)
- {
- // Either just null, the name is null or the name is the empty string
- return (user == null) || user.getName() == null ||
user.getName().isEmpty();
- }
+public class MemoryTurbineUserManagerImpl extends MemoryUserManagerImpl
implements TurbineUserManager {
+
+ // TODO Need to load up Crypto component and actually encrypt passwords!
+
+ /**
+ * Constructs an User object to represent an anonymous user of the
application.
+ *
+ * @return An anonymous Turbine User.
+ * @throws UnknownEntityException if the implementation of User
interface could
+ * not be determined, or does not exist.
+ */
+ @Override
+ public <T extends User> T getAnonymousUser() throws
UnknownEntityException {
+ T user;
+ try {
+ user = getUserInstance();
+ } catch (DataBackendException dbe) {
+ throw new UnknownEntityException("Could not create an
anonymous user.", dbe);
+ }
+
+ user.setName("");
+ return user;
+ }
+
+ /**
+ * Checks whether a passed user object matches the anonymous user
pattern
+ * according to the configured user manager
+ *
+ * @param user An user object
+ * @return <code>true</code> if this is an anonymous user
+ *
+ */
+ @Override
+ public boolean isAnonymousUser(User user) {
+ // Test if we have an anonymous user obj
+ boolean isAnon = false;
+ if ( user == null ) {
+ isAnon = true;
+ } else {
+ if ( StringUtils.isEmpty( user.getName() ) )
+ isAnon = true;
+ else
+ {
+ // Turbine 4.0 and great allows for a user
stored in table called "anon"
+ if ( user.getName().equals("anon") )
+ isAnon = true;
+ }
+ }
+ return isAnon;
+ }
}
Modified: turbine/fulcrum/trunk/security/torque/pom.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/torque/pom.xml?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
--- turbine/fulcrum/trunk/security/torque/pom.xml (original)
+++ turbine/fulcrum/trunk/security/torque/pom.xml Mon Nov 5 22:43:28 2018
@@ -36,7 +36,7 @@
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
-
+
<!-- Easy update of torque libs -->
<torque.version>4.0</torque.version>
<torque.om>org.apache.fulcrum.security.torque.om</torque.om>
@@ -54,9 +54,49 @@
<forkMode>perTest</forkMode>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+
+ <!-- TODO : figure out why javadoc
warnings are not ignored
+ as this is breaking mvn site
generation
+ The only 'warnings' that remain
and are serious are coming from
+ the OM generated classes
+ -->
+
+ <!-- worked on torque, but not here?
-->
+ <doclint>none</doclint>
+
+ <!-- exclude generated sources for now
(only works when running mvn javadoc:javadoc, but not with mvn site? -->
+
<excludePackageNames>org.apache.fulcrum.security.torque.om*</excludePackageNames>
+
+ <!-- adding this did not help :( -->
+ <sourceFileExcludes>
+
<sourceFileExclude>**/torque/target/generated-sources/*.java</sourceFileExclude>
+ </sourceFileExcludes>
+
+ </configuration>
+ </plugin>
+
+
</plugins>
</build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>3.0.1</version>
+ <configuration>
+ <show>public</show>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+
<dependencies>
<dependency>
<groupId>org.apache.fulcrum</groupId>
@@ -74,25 +114,25 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <!-- broken -->
- <!-- <version>2.4.1</version> -->
- <version>1.8.0.10</version>
- <scope>test</scope>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <!-- broken -->
+ <!-- <version>2.4.1</version> -->
+ <version>1.8.0.10</version>
+ <scope>test</scope>
</dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.4</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-dbcp2</artifactId>
- <version>2.5.0</version>
- </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-dbcp2</artifactId>
+ <version>2.5.0</version>
+ </dependency>
<!-- testing dependencies -->
<dependency>
Modified:
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractGroupManager.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractGroupManager.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractGroupManager.java
(original)
+++
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractGroupManager.java
Mon Nov 5 22:43:28 2018
@@ -67,7 +67,7 @@ public abstract class TorqueAbstractGrou
*
* @return a List of Group instances
*
- * @throws TorqueException if any database error occurs
+ * @throws TorqueException if any database error occurs
*/
protected abstract <T extends Group> List<T> doSelectAllGroups(Connection
con)
throws TorqueException;
@@ -82,7 +82,7 @@ public abstract class TorqueAbstractGrou
*
* @throws NoRowsException if no such group exists
* @throws TooManyRowsException if multiple groups with the given name
exist
- * @throws TorqueException if any other database error occurs
+ * @throws TorqueException if any database error occurs if any other
database error occurs
*/
protected abstract <T extends Group> T doSelectByName(String name,
Connection con)
throws NoRowsException, TooManyRowsException, TorqueException;
@@ -97,7 +97,7 @@ public abstract class TorqueAbstractGrou
*
* @throws NoRowsException if no such group exists
* @throws TooManyRowsException if multiple groups with the given id exist
- * @throws TorqueException if any other database error occurs
+ * @throws TorqueException if any database error occurs if any other
database error occurs
*/
protected abstract <T extends Group> T doSelectById(Integer id, Connection
con)
throws NoRowsException, TooManyRowsException, TorqueException;
@@ -109,7 +109,6 @@ public abstract class TorqueAbstractGrou
* @return a new Group object that has id set up properly.
* @throws DataBackendException if there was an error accessing the data
* backend.
- * @throws EntityExistsException if the group already exists.
*/
@Override
protected synchronized <T extends Group> T persistNewGroup(T group)
throws DataBackendException
Modified:
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractPermissionManager.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractPermissionManager.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractPermissionManager.java
(original)
+++
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractPermissionManager.java
Mon Nov 5 22:43:28 2018
@@ -1,4 +1,5 @@
package org.apache.fulcrum.security.torque;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -33,363 +34,292 @@ import org.apache.torque.NoRowsException
import org.apache.torque.TooManyRowsException;
import org.apache.torque.TorqueException;
import org.apache.torque.util.Transaction;
+
/**
* This implementation persists to a database via Torque.
*
* @author <a href="mailto:[email protected]">Thomas Vandahl</a>
* @version $Id:$
*/
-public abstract class TorqueAbstractPermissionManager extends
AbstractPermissionManager
-{
-
+public abstract class TorqueAbstractPermissionManager extends
AbstractPermissionManager {
+
/** Serial version */
private static final long serialVersionUID = 194503017446833485L;
-
+
// no lazyLoading
/**
- * Avalon Service lifecycle method
- */
- @Override
- public void configure(Configuration conf) throws ConfigurationException
- {
- super.configure( conf );
-
- }
-
- /**
- * Get all specialized Permissions
- *
- * @param con a database connection
- *
- * @return a List of Permission instances
- *
- * @throws TorqueException if any database error occurs
- */
- protected abstract <T extends Permission> List<T>
doSelectAllPermissions(Connection con)
- throws TorqueException;
-
- /**
- * Get a specialized Permission by name
- *
- * @param name the name of the group
- * @param con a database connection
- *
- * @return a Permission instance
- *
- * @throws NoRowsException if no such group exists
- * @throws TooManyRowsException if multiple groups with the given name
exist
- * @throws TorqueException if any other database error occurs
- */
- protected abstract <T extends Permission> T doSelectByName(String name,
Connection con)
- throws NoRowsException, TooManyRowsException, TorqueException;
-
- /**
- * Get a specialized Permission by id
- *
- * @param id the id of the group
- * @param con a database connection
- *
- * @return a Permission instance
- *
- * @throws NoRowsException if no such group exists
- * @throws TooManyRowsException if multiple groups with the given id exist
- * @throws TorqueException if any other database error occurs
- */
- protected abstract <T extends Permission> T doSelectById(Integer id,
Connection con)
- throws NoRowsException, TooManyRowsException, TorqueException;
-
- /**
- * Renames an existing Permission.
- *
- * @param permission
- * 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 UnknownEntityException
- * if the permission does not exist.
- */
- @Override
- public synchronized void renamePermission(Permission permission, String
name) throws DataBackendException, UnknownEntityException
- {
- if (checkExists(permission))
- {
- permission.setName(name);
-
- try
- {
- TorqueAbstractSecurityEntity p =
(TorqueAbstractSecurityEntity)permission;
- p.setNew(false);
- p.save();
- }
- catch (Exception e)
- {
- throw new DataBackendException("Renaming Permission '" +
permission.getName() + "' failed", e);
- }
- }
- else
- {
- throw new UnknownEntityException("Unknown permission '" +
permission.getName() + "'");
- }
- }
-
- /**
- * Removes a Permission from the system.
- *
- * @param permission
- * The object describing the permission to be removed.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the permission does not exist.
- */
- @Override
- public synchronized void removePermission(Permission permission) throws
DataBackendException, UnknownEntityException
- {
- if (checkExists(permission))
- {
- try
- {
-
- ((TorqueAbstractSecurityEntity)permission).delete();
- }
- catch (TorqueException e)
- {
- throw new DataBackendException("Removing Permission '" +
permission.getName() + "' failed", e);
- }
- }
- else
- {
- throw new UnknownEntityException("Unknown permission '" +
permission.getName() + "'");
- }
- }
-
- /**
- * Creates a new permission with specified attributes.
- *
- * @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 EntityExistsException
- * if the permission already exists.
- */
- @Override
- protected synchronized <T extends Permission> T persistNewPermission(T
permission) throws DataBackendException
- {
- try
- {
- ((TorqueAbstractSecurityEntity)permission).save();
- }
- catch (Exception e)
- {
- throw new DataBackendException("Adding Permission '" +
permission.getName() + "' failed", e);
- }
-
- return permission;
- }
-
- /**
- * Retrieves all permissions defined in the system.
- *
- * @return the names of all roles defined in the system.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- */
- @Override
- public PermissionSet getAllPermissions() throws DataBackendException
- {
- PermissionSet permissionSet = new PermissionSet();
- Connection con = null;
-
- try
- {
- con = Transaction.begin();
-
- List<Permission> permissions = doSelectAllPermissions(con);
-
- for (Permission p : permissions)
- {
- // Add attached objects if they exist
- ((TorqueAbstractSecurityEntity)p).retrieveAttachedObjects(con,
false);
- permissionSet.add(p);
- }
-
- Transaction.commit(con);
- con = null;
- }
- catch (TorqueException e)
- {
- throw new DataBackendException("Error retrieving permission
information", e);
- }
- finally
- {
- if (con != null)
- {
- Transaction.safeRollback(con);
- }
- }
-
- return permissionSet;
- }
-
- /**
- * Determines if the <code>Permission</code> exists in the security
- * system.
- *
- * @param permissionName
- * a <code>Permission</code> value
- * @return true if the permission name exists in the system, false
otherwise
- * @throws DataBackendException
- * when more than one Permission with the same name exists.
- */
- @Override
- public boolean checkExists(String permissionName) throws
DataBackendException
- {
- boolean exists = false;
-
- Connection con = null;
-
- try
- {
- con = Transaction.begin();
-
- doSelectByName(permissionName, con);
-
- Transaction.commit(con);
- con = null;
-
- exists = true;
- }
- catch (NoRowsException e)
- {
- exists = false;
- }
- catch (TooManyRowsException e)
- {
- throw new DataBackendException("Multiple permissions with same
name '" + permissionName + "'");
- }
- catch (TorqueException e)
- {
- throw new DataBackendException("Error retrieving permission
information", e);
- }
- finally
- {
- if (con != null)
- {
- Transaction.safeRollback(con);
- }
- }
-
- return exists;
- }
-
- /**
- * Retrieve a Permission object with specified id.
- *
- * @param id
- * the id of the Permission.
- * @return an object representing the Permission with specified id.
- * @throws DataBackendException
- * if there was an error accessing the data backend.
- * @throws UnknownEntityException
- * if the permission does not exist.
- */
- @Override
- public <T extends Permission> T getPermissionById(Object id) throws
DataBackendException, UnknownEntityException
- {
- T permission;
-
- if (id != null && id instanceof Integer)
- {
- Connection con = null;
-
- try
- {
- con = Transaction.begin();
-
- permission = doSelectById((Integer)id, con);
-
- // Add attached objects if they exist
-
((TorqueAbstractSecurityEntity)permission).retrieveAttachedObjects(con, false);
-
- Transaction.commit(con);
- con = null;
- }
- catch (NoRowsException e)
- {
- throw new UnknownEntityException("Permission with id '" + id +
"' does not exist.", e);
- }
- catch (TorqueException e)
- {
- throw new DataBackendException("Error retrieving permission
information", e);
- }
- finally
- {
- if (con != null)
- {
- Transaction.safeRollback(con);
- }
- }
- }
- else
- {
- throw new UnknownEntityException("Invalid permission id '" + id +
"'");
- }
-
- return permission;
- }
-
- /**
- * Retrieve a Permission object with specified name.
- *
- * @param name the name of the Group.
- * @return an object representing the Group with specified name.
- * @throws DataBackendException if there was an error accessing the
- * data backend.
- * @throws UnknownEntityException if the group does not exist.
- */
- @Override
- public <T extends Permission> T getPermissionByName(String name) throws
DataBackendException, UnknownEntityException
- {
- T permission = null;
- Connection con = null;
-
- try
- {
- con = Transaction.begin();
-
- permission = doSelectByName(name, con);
-
- // Add attached objects if they exist
-
((TorqueAbstractSecurityEntity)permission).retrieveAttachedObjects(con, false);
-
- Transaction.commit(con);
- con = null;
- }
- catch (NoRowsException e)
- {
- throw new UnknownEntityException("Could not find permission " +
name);
- }
- catch (TooManyRowsException e)
- {
- throw new DataBackendException("Multiple Permissions with same
name '" + name + "'");
- }
- catch (TorqueException e)
- {
- throw new DataBackendException("Error retrieving permission
information", e);
- }
- finally
- {
- if (con != null)
- {
- Transaction.safeRollback(con);
- }
- }
+ * Avalon Service lifecycle method
+ */
+ @Override
+ public void configure(Configuration conf) throws ConfigurationException
{
+ super.configure(conf);
+
+ }
+
+ /**
+ * Get all specialized Permissions
+ *
+ * @param con a database connection
+ * @return a List of Permission instances
+ * @throws TorqueException if any database error occurs
+ */
+ protected abstract <T extends Permission> List<T>
doSelectAllPermissions(Connection con) throws TorqueException;
+
+ /**
+ * Get a specialized Permission by name
+ *
+ * @param name the name of the group
+ * @param con a database connection
+ *
+ * @return a Permission instance
+ *
+ * @throws NoRowsException if no such group exists
+ * @throws TooManyRowsException if multiple groups with the given name
exist
+ * @throws TorqueException if any database error occurs if any
other
+ * database error occurs
+ */
+ protected abstract <T extends Permission> T doSelectByName(String name,
Connection con)
+ throws NoRowsException, TooManyRowsException,
TorqueException;
+
+ /**
+ * Get a specialized Permission by id
+ *
+ * @param id the id of the group
+ * @param con a database connection
+ *
+ * @return a Permission instance
+ *
+ * @throws NoRowsException if no such group exists
+ * @throws TooManyRowsException if multiple groups with the given id
exist
+ * @throws TorqueException if any database error occurs if any
other
+ * database error occurs
+ */
+ protected abstract <T extends Permission> T doSelectById(Integer id,
Connection con)
+ throws NoRowsException, TooManyRowsException,
TorqueException;
+
+ /**
+ * Renames an existing Permission.
+ *
+ * @param permission 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 UnknownEntityException if the permission does not exist.
+ */
+ @Override
+ public synchronized void renamePermission(Permission permission, String
name)
+ throws DataBackendException, UnknownEntityException {
+ if (checkExists(permission)) {
+ permission.setName(name);
+
+ try {
+ TorqueAbstractSecurityEntity p =
(TorqueAbstractSecurityEntity) permission;
+ p.setNew(false);
+ p.save();
+ } catch (Exception e) {
+ throw new DataBackendException("Renaming
Permission '" + permission.getName() + "' failed", e);
+ }
+ } else {
+ throw new UnknownEntityException("Unknown permission '"
+ permission.getName() + "'");
+ }
+ }
+
+ /**
+ * Removes a Permission from the system.
+ *
+ * @param permission The object describing the permission to be removed.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if the permission does not exist.
+ */
+ @Override
+ public synchronized void removePermission(Permission permission)
+ throws DataBackendException, UnknownEntityException {
+ if (checkExists(permission)) {
+ try {
+
+ ((TorqueAbstractSecurityEntity)
permission).delete();
+ } catch (TorqueException e) {
+ throw new DataBackendException("Removing
Permission '" + permission.getName() + "' failed", e);
+ }
+ } else {
+ throw new UnknownEntityException("Unknown permission '"
+ permission.getName() + "'");
+ }
+ }
+
+ /**
+ * Creates a new permission with specified attributes.
+ *
+ * @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.
+ */
+ @Override
+ protected synchronized <T extends Permission> T persistNewPermission(T
permission) throws DataBackendException {
+ try {
+ ((TorqueAbstractSecurityEntity) permission).save();
+ } catch (Exception e) {
+ throw new DataBackendException("Adding Permission '" +
permission.getName() + "' failed", e);
+ }
+
+ return permission;
+ }
+
+ /**
+ * Retrieves all permissions defined in the system.
+ *
+ * @return the names of all roles defined in the system.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ */
+ @Override
+ public PermissionSet getAllPermissions() throws DataBackendException {
+ PermissionSet permissionSet = new PermissionSet();
+ Connection con = null;
+
+ try {
+ con = Transaction.begin();
+
+ List<Permission> permissions =
doSelectAllPermissions(con);
+
+ for (Permission p : permissions) {
+ // Add attached objects if they exist
+ ((TorqueAbstractSecurityEntity)
p).retrieveAttachedObjects(con, false);
+ permissionSet.add(p);
+ }
+
+ Transaction.commit(con);
+ con = null;
+ } catch (TorqueException e) {
+ throw new DataBackendException("Error retrieving
permission information", e);
+ } finally {
+ if (con != null) {
+ Transaction.safeRollback(con);
+ }
+ }
+
+ return permissionSet;
+ }
+
+ /**
+ * Determines if the <code>Permission</code> exists in the security
system.
+ *
+ * @param permissionName a <code>Permission</code> value
+ * @return true if the permission name exists in the system, false
otherwise
+ * @throws DataBackendException when more than one Permission with the
same name
+ * exists.
+ */
+ @Override
+ public boolean checkExists(String permissionName) throws
DataBackendException {
+ boolean exists = false;
+
+ Connection con = null;
+
+ try {
+ con = Transaction.begin();
+
+ doSelectByName(permissionName, con);
+
+ Transaction.commit(con);
+ con = null;
+
+ exists = true;
+ } catch (NoRowsException e) {
+ exists = false;
+ } catch (TooManyRowsException e) {
+ throw new DataBackendException("Multiple permissions
with same name '" + permissionName + "'");
+ } catch (TorqueException e) {
+ throw new DataBackendException("Error retrieving
permission information", e);
+ } finally {
+ if (con != null) {
+ Transaction.safeRollback(con);
+ }
+ }
+
+ return exists;
+ }
+
+ /**
+ * Retrieve a Permission object with specified id.
+ *
+ * @param id the id of the Permission.
+ * @return an object representing the Permission with specified id.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if the permission does not exist.
+ */
+ @Override
+ public <T extends Permission> T getPermissionById(Object id) throws
DataBackendException, UnknownEntityException {
+ T permission;
+
+ if (id != null && id instanceof Integer) {
+ Connection con = null;
+
+ try {
+ con = Transaction.begin();
+
+ permission = doSelectById((Integer) id, con);
+
+ // Add attached objects if they exist
+ ((TorqueAbstractSecurityEntity)
permission).retrieveAttachedObjects(con, false);
+
+ Transaction.commit(con);
+ con = null;
+ } catch (NoRowsException e) {
+ throw new UnknownEntityException("Permission
with id '" + id + "' does not exist.", e);
+ } catch (TorqueException e) {
+ throw new DataBackendException("Error
retrieving permission information", e);
+ } finally {
+ if (con != null) {
+ Transaction.safeRollback(con);
+ }
+ }
+ } else {
+ throw new UnknownEntityException("Invalid permission id
'" + id + "'");
+ }
+
+ return permission;
+ }
+
+ /**
+ * Retrieve a Permission object with specified name.
+ *
+ * @param name the name of the Group.
+ * @return an object representing the Group with specified name.
+ * @throws DataBackendException if there was an error accessing the
data
+ * backend.
+ * @throws UnknownEntityException if the group does not exist.
+ */
+ @Override
+ public <T extends Permission> T getPermissionByName(String name)
+ throws DataBackendException, UnknownEntityException {
+ T permission = null;
+ Connection con = null;
+
+ try {
+ con = Transaction.begin();
+
+ permission = doSelectByName(name, con);
+
+ // Add attached objects if they exist
+ ((TorqueAbstractSecurityEntity)
permission).retrieveAttachedObjects(con, false);
+
+ Transaction.commit(con);
+ con = null;
+ } catch (NoRowsException e) {
+ throw new UnknownEntityException("Could not find
permission " + name);
+ } catch (TooManyRowsException e) {
+ throw new DataBackendException("Multiple Permissions
with same name '" + name + "'");
+ } catch (TorqueException e) {
+ throw new DataBackendException("Error retrieving
permission information", e);
+ } finally {
+ if (con != null) {
+ Transaction.safeRollback(con);
+ }
+ }
- return permission;
- }
+ return permission;
+ }
}
Modified:
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractRoleManager.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractRoleManager.java?rev=1845861&r1=1845860&r2=1845861&view=diff
==============================================================================
---
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractRoleManager.java
(original)
+++
turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/TorqueAbstractRoleManager.java
Mon Nov 5 22:43:28 2018
@@ -67,7 +67,7 @@ public abstract class TorqueAbstractRole
*
* @return a List of Role instances
*
- * @throws TorqueException if any database error occurs
+ * @throws TorqueException if any database error occurs
*/
protected abstract <T extends Role> List<T> doSelectAllRoles(Connection
con)
throws TorqueException;
@@ -82,7 +82,7 @@ public abstract class TorqueAbstractRole
*
* @throws NoRowsException if no such group exists
* @throws TooManyRowsException if multiple groups with the given name
exist
- * @throws TorqueException if any other database error occurs
+ * @throws TorqueException if any database error occurs if any other
database error occurs
*/
protected abstract <T extends Role> T doSelectByName(String name,
Connection con)
throws NoRowsException, TooManyRowsException, TorqueException;
@@ -97,7 +97,7 @@ public abstract class TorqueAbstractRole
*
* @throws NoRowsException if no such group exists
* @throws TooManyRowsException if multiple groups with the given id exist
- * @throws TorqueException if any other database error occurs
+ * @throws TorqueException if any database error occurs if any other
database error occurs
*/
protected abstract <T extends Role> T doSelectById(Integer id, Connection
con)
throws NoRowsException, TooManyRowsException, TorqueException;
@@ -143,7 +143,6 @@ public abstract class TorqueAbstractRole
* @return a new Role object that has id set up properly.
* @throws DataBackendException if there was an error accessing the data
* backend.
- * @throws EntityExistsException if the role already exists.
*/
@Override
protected synchronized <T extends Role> T persistNewRole(T role) throws
DataBackendException