You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2006/09/21 22:56:38 UTC

svn commit: r448680 [3/4] - in /jakarta/turbine/fulcrum/trunk/security/torque: ./ schema/ src/java/org/apache/fulcrum/security/torque/basic/ src/java/org/apache/fulcrum/security/torque/dynamic/ src/java/org/apache/fulcrum/security/torque/om/map/ src/ja...

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueUserMapBuilder.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueUserMapBuilder.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueUserMapBuilder.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/om/map/TorqueUserMapBuilder.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,72 @@
+package org.apache.fulcrum.security.torque.om.map;
+
+import java.util.Date;
+import java.math.BigDecimal;
+
+import org.apache.torque.Torque;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.MapBuilder;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
+
+/**
+  *  This class was autogenerated by Torque on:
+  *
+  * [Sun Aug 27 22:32:46 CEST 2006]
+  *
+  */
+public class TorqueUserMapBuilder implements MapBuilder
+{
+    /**
+     * The name of this class
+     */
+    public static final String CLASS_NAME =
+        "org.apache.fulcrum.security.torque.om.map.TorqueUserMapBuilder";
+
+    /**
+     * The database map.
+     */
+    private DatabaseMap dbMap = null;
+
+    /**
+     * Tells us if this DatabaseMapBuilder is built so that we
+     * don't have to re-build it every time.
+     *
+     * @return true if this DatabaseMapBuilder is built
+     */
+    public boolean isBuilt()
+    {
+        return (dbMap != null);
+    }
+
+    /**
+     * Gets the databasemap this map builder built.
+     *
+     * @return the databasemap
+     */
+    public DatabaseMap getDatabaseMap()
+    {
+        return this.dbMap;
+    }
+
+    /**
+     * The doBuild() method builds the DatabaseMap
+     *
+     * @throws TorqueException
+     */
+    public void doBuild() throws TorqueException
+    {
+        dbMap = Torque.getDatabaseMap("fulcrum");
+
+        dbMap.addTable("FULCRUM_USER");
+        TableMap tMap = dbMap.getTable("FULCRUM_USER");
+
+        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
+
+        tMap.setPrimaryKeyMethodInfo(tMap.getName());
+
+              tMap.addPrimaryKey("FULCRUM_USER.USER_ID", new Integer(0) );
+                        	          tMap.addColumn("FULCRUM_USER.LOGIN_NAME", "", 64 );
+                                      	          tMap.addColumn("FULCRUM_USER.PASSWORD_VALUE", "", 16 );
+                        }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,369 @@
+package org.apache.fulcrum.security.torque.turbine;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.RoleManager;
+import org.apache.fulcrum.security.UserManager;
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineGroup;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.spi.AbstractGroupManager;
+import org.apache.fulcrum.security.torque.om.TorqueGroup;
+import org.apache.fulcrum.security.torque.om.TorqueGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueUser;
+import org.apache.fulcrum.security.torque.om.TorqueUserPeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.GroupSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineGroupManagerImpl extends AbstractGroupManager
+{
+    /**
+     * Retrieve a Group 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.
+     */
+    public Group getGroupByName(String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        Group group = getGroupInstance();
+        List groups = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueGroupPeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueGroupPeer.GROUP_NAME, name);
+
+            groups = TorqueGroupPeer.doSelect(criteria, con);
+
+            if (groups.size() == 1)
+            {
+                TorqueGroup g = (TorqueGroup) groups.get(0);
+                
+                group.setId(g.getId());
+                group.setName(g.getName());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineGroup)group).setUserGroupRoleSet(getUgrForGroup(group, con));
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving group information", e);
+        }
+
+        if (groups.size() == 0)
+        {
+            throw new UnknownEntityException("Could not find group" + name);
+        }
+
+        if (groups.size() > 1)
+        {
+            throw new DataBackendException("Multiple Groups with same name '" + name + "'");
+        }
+
+        return group;
+    }
+
+    /**
+     * Retrieves all groups defined in the system.
+     *
+     * @return the names of all groups defined in the system.
+     * @throws DataBackendException if there was an error accessing the
+     *         data backend.
+     */
+    public GroupSet getAllGroups() throws DataBackendException
+    {
+        GroupSet groupSet = new GroupSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueGroupPeer.DATABASE_NAME);
+
+            List groups = TorqueGroupPeer.doSelect(new Criteria(), con);
+            
+            for (Iterator i = groups.iterator(); i.hasNext();)
+            {
+                Group group = getGroupInstance();
+                TorqueGroup g = (TorqueGroup)i.next();
+                group.setId(g.getId());
+                group.setName(g.getName());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineGroup)group).setUserGroupRoleSet(getUgrForGroup(group, con));
+
+                groupSet.add(group);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving group information", e);
+        }
+
+        return groupSet;
+    }
+
+    /**
+        * Removes a Group from the system.
+        *
+        * @param group The object describing the group to be removed.
+        * @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)
+        throws DataBackendException, UnknownEntityException
+    {
+        try
+        {
+            TorqueGroupPeer.doDelete(SimpleKey.keyFor((Integer)group.getId()));
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Removing Group '" + group + "' failed", e);
+        }
+    }
+
+    /**
+        * Renames an existing Group.
+        *
+        * @param group 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 UnknownEntityException if the group does not exist.
+        */
+    public synchronized void renameGroup(Group group, String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(group))
+        {
+            group.setName(name);
+
+            try
+            {
+                TorqueGroup g = new TorqueGroup();
+                g.setId((Integer)group.getId());
+                g.setName(name);
+                g.setNew(false);
+                g.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Renaming Group '" + group + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown group '" + group + "'");
+        }
+    }
+
+    /**
+     * Determines if the <code>Group</code> exists in the security system.
+     *
+     * @param groupName a <code>Group</code> value
+     * @return true if the group name exists in the system, false otherwise
+     * @throws DataBackendException when more than one Group with
+     *         the same name exists.
+     */
+    public boolean checkExists(String groupName) throws DataBackendException
+    {
+        List groups;
+
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueGroupPeer.GROUP_NAME, groupName);
+
+            groups = TorqueGroupPeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving group information", e);
+        }
+
+        if (groups.size() > 1)
+        {
+            throw new DataBackendException(
+                    "Multiple groups with same name '" + groupName + "'");
+        }
+
+        return (groups.size() == 1);
+    }
+
+    /**
+    * Creates a new group with specified attributes.
+    *
+    * @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 EntityExistsException if the group already exists.
+    */
+    protected synchronized Group persistNewGroup(Group group)
+        throws DataBackendException
+    {
+        try
+        {
+            TorqueGroup g = new TorqueGroup();
+            g.setName(group.getName());
+            g.save();
+            
+            group.setId(g.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding Group '" + group + "' failed", e);
+        }
+        
+        return group;
+    }
+
+    /**
+     * Retrieve a Group object with specified id.
+     *
+     * @param id
+     *            the id of the Group.
+     * @return an object representing the Group with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the group does not exist.
+     */
+    public Group getGroupById(Object id)
+        throws DataBackendException, UnknownEntityException
+    {
+        Group group = getGroupInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(TorqueGroupPeer.DATABASE_NAME);
+                
+                TorqueGroup g = TorqueGroupPeer.retrieveByPK((Integer)id, con);
+                
+                group.setId(g.getId());
+                group.setName(g.getName());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineGroup)group).setUserGroupRoleSet(getUgrForGroup(group, con));
+
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("Group with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving group information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid group id '" + group.getId() + "'");
+        }
+
+        return group;
+    }
+
+    /**
+     * Provides the user/group/role-relations for the given group
+     *  
+     * @param group the group for which the relations should be retrieved  
+     * @param con a database connection
+     */
+    private Set getUgrForGroup(Group group, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        Set ugrSet = new HashSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.add(TorqueTurbineUserGroupRolePeer.GROUP_ID, (Integer)group.getId());
+        
+        List ugrs = TorqueTurbineUserGroupRolePeer.doSelect(criteria, con);
+        UserManager userManager = getUserManager();
+        RoleManager roleManager = getRoleManager();
+        
+        for (Iterator i = ugrs.iterator(); i.hasNext();)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setGroup(group);
+            
+            TorqueTurbineUserGroupRole tugr = (TorqueTurbineUserGroupRole)i.next();
+
+            User user = userManager.getUserInstance();
+            TorqueUser u = TorqueUserPeer.retrieveByPK(tugr.getUserId(), con);
+            user.setId(u.getId());
+            user.setName(u.getName());
+            user.setPassword(u.getPassword());
+            ugr.setUser(user);
+
+            Role role = roleManager.getRoleInstance();
+            TorqueRole r = TorqueRolePeer.retrieveByPK(tugr.getRoleId(), con);
+            role.setId(r.getId());
+            role.setName(r.getName());
+            ugr.setRole(role);
+            
+            ugrSet.add(ugr);
+        }
+        
+        return ugrSet;
+    }
+}
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineModelManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineModelManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineModelManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineModelManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,257 @@
+package org.apache.fulcrum.security.torque.turbine;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.util.Iterator;
+
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.turbine.AbstractTurbineModelManager;
+import org.apache.fulcrum.security.model.turbine.TurbineModelManager;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineGroup;
+import org.apache.fulcrum.security.model.turbine.entity.TurbinePermission;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineRole;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermission;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRolePeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.util.Criteria;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineModelManagerImpl extends AbstractTurbineModelManager implements TurbineModelManager
+{
+    /**
+     * 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)
+            {
+                ((TurbineRole) role).addPermission(permission);
+                ((TurbinePermission) permission).addRole(role);
+
+                TorqueTurbineRolePermission rp = new TorqueTurbineRolePermission();
+                rp.setPermissionId((Integer)permission.getId());
+                rp.setRoleId((Integer)role.getId());
+                rp.save();
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("grant('" + role.getName() + "', '" + permission.getName() + "') 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)
+            {
+                ((TurbineRole) role).removePermission(permission);
+                ((TurbinePermission) permission).removeRole(role);
+
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueTurbineRolePermissionPeer.ROLE_ID, (Integer)role.getId());
+                criteria.add(TorqueTurbineRolePermissionPeer.PERMISSION_ID, (Integer)permission.getId());
+                TorqueTurbineRolePermissionPeer.doDelete(criteria);
+            }
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("revoke('" + role.getName() + "', '" + permission.getName() + "') failed", e);
+        }
+        
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+        
+        if (!permissionExists)
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
+        }
+    }
+
+    public synchronized void grant(User user, Group group, Role role) throws DataBackendException, UnknownEntityException
+    {
+        boolean roleExists = false;
+        boolean userExists = false;
+        boolean groupExists = false;
+        
+        try
+        {
+            roleExists = getRoleManager().checkExists(role);
+            userExists = getUserManager().checkExists(user);
+            groupExists = getGroupManager().checkExists(group);
+            if (roleExists && groupExists && userExists)
+            {
+                TurbineUserGroupRole user_group_role = new TurbineUserGroupRole();
+                user_group_role.setUser(user);
+                user_group_role.setGroup(group);
+                user_group_role.setRole(role);
+                ((TurbineUser) user).addUserGroupRole(user_group_role);
+                ((TurbineGroup) group).addUserGroupRole(user_group_role);
+                ((TurbineRole) role).addUserGroupRole(user_group_role);
+
+                TorqueTurbineUserGroupRole ugr = new TorqueTurbineUserGroupRole();
+                ugr.setUserId((Integer)user.getId());
+                ugr.setGroupId((Integer)group.getId());
+                ugr.setRoleId((Integer)role.getId());
+                ugr.save();
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("grant('" 
+                    + (user != null ? user.getName() : "null") + "', '" 
+                    + (group != null ? group.getName() : "null") + "', '"
+                    + (role != null ? role.getName() : "null") + "') failed", e);
+        }
+
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+
+        if (!userExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
+        }
+    }
+
+    public synchronized void revoke(User user, Group group, Role role)
+        throws DataBackendException, UnknownEntityException
+    {
+        boolean roleExists = false;
+        boolean userExists = false;
+        boolean groupExists = false;
+        try
+        {
+            roleExists = getRoleManager().checkExists(role);
+            userExists = getUserManager().checkExists(user);
+            groupExists = getGroupManager().checkExists(group);
+
+            if (roleExists && groupExists && userExists)
+            {
+                boolean ugrFound = false;
+                TurbineUserGroupRole user_group_role = null;
+
+                for (Iterator i = ((TurbineUser) user).getUserGroupRoleSet()
+                        .iterator(); i.hasNext();)
+                {
+                    user_group_role = (TurbineUserGroupRole) i.next();
+                    if (user_group_role.getUser().equals(user)
+                        && user_group_role.getGroup().equals(group)
+                        && user_group_role.getRole().equals(role))
+                    {
+                        ugrFound = true;
+                        break;
+                    }
+                }
+
+                if (!ugrFound)
+                {
+                    throw new UnknownEntityException("Could not find User/Group/Role");
+                }
+
+                ((TurbineUser) user).removeUserGroupRole(user_group_role);
+                ((TurbineGroup) group).removeUserGroupRole(user_group_role);
+                ((TurbineRole) role).removeUserGroupRole(user_group_role);
+
+                Criteria criteria = new Criteria();
+                criteria.add(TorqueTurbineUserGroupRolePeer.USER_ID, (Integer)user.getId());
+                criteria.add(TorqueTurbineUserGroupRolePeer.GROUP_ID, (Integer)group.getId());
+                criteria.add(TorqueTurbineUserGroupRolePeer.ROLE_ID, (Integer)role.getId());
+                TorqueTurbineUserGroupRolePeer.doDelete(criteria);
+            }
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("revoke('" 
+                    + (user != null ? user.getName() : "null") + "', '" 
+                    + (group != null ? group.getName() : "null") + "', '"
+                    + (role != null ? role.getName() : "null") + "') failed", e);
+        }
+
+        if (!roleExists)
+        {
+            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
+        }
+        if (!groupExists)
+        {
+            throw new UnknownEntityException("Unknown group '" + group.getName() + "'");
+        }
+        if (!userExists)
+        {
+            throw new UnknownEntityException("Unknown user '" + user.getName() + "'");
+        }
+    }
+}
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,366 @@
+package org.apache.fulcrum.security.torque.turbine;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fulcrum.security.RoleManager;
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.model.turbine.entity.TurbinePermission;
+import org.apache.fulcrum.security.spi.AbstractPermissionManager;
+import org.apache.fulcrum.security.torque.om.TorquePermission;
+import org.apache.fulcrum.security.torque.om.TorquePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.PermissionSet;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbinePermissionManagerImpl extends AbstractPermissionManager
+{
+    /**
+     * 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.
+     */
+    public PermissionSet getAllPermissions() throws DataBackendException
+    {
+        PermissionSet permissionSet = new PermissionSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+            
+            List permissions = TorquePermissionPeer.doSelect(new Criteria(), con);
+            
+            for (Iterator i = permissions.iterator(); i.hasNext();)
+            {
+                TorquePermission p = (TorquePermission)i.next();
+
+                // TODO: This throws UnknownEntityException.
+                Permission permission = getPermissionInstance();
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+
+                // Add roles if they exist
+                ((TurbinePermission)permission).setRoles(getRolesForPermission(permission, con));
+
+                permissionSet.add(permission);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (Exception e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        return permissionSet;
+    }
+
+    /**
+     * 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.
+     */
+    public synchronized void renamePermission(Permission permission, String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(permission))
+        {
+            permission.setName(name);
+            
+            try
+            {
+                TorquePermission p = new TorquePermission();
+                p.setId((Integer)permission.getId());
+                p.setName(name);
+                p.setNew(false);
+                p.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Renaming Permission '" + permission + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission + "'");
+        }
+    }
+
+    /**
+     * 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.
+     */
+    public boolean checkExists(String permissionName) throws DataBackendException
+    {
+        List permissions;
+        
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorquePermissionPeer.PERMISSION_NAME, permissionName);
+
+            permissions = TorquePermissionPeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        if (permissions.size() > 1)
+        {
+            throw new DataBackendException("Multiple permissions with same name '" + permissionName + "'");
+        }
+
+        return (permissions.size() == 1);
+    }
+
+    /**
+     * 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.
+     */
+    public synchronized void removePermission(Permission permission)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(permission))
+        {
+            try
+            {
+                TorquePermissionPeer.doDelete(SimpleKey.keyFor((Integer)permission.getId()));
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("Removing Permission '" + permission + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown permission '" + permission + "'");
+        }
+    }
+
+    /**
+     * 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.
+     */
+    protected synchronized Permission persistNewPermission(Permission permission)
+        throws DataBackendException
+    {
+        try
+        {
+            TorquePermission p = new TorquePermission();
+            p.setName(permission.getName());
+            p.save();
+            
+            permission.setId(p.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding Permission '" + permission + "' failed", e);
+        }
+
+        return permission;
+    }
+
+    /**
+     * 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.
+     */
+    public Permission getPermissionById(Object id)
+        throws DataBackendException, UnknownEntityException
+    {
+        Permission permission = getPermissionInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+                
+                TorquePermission p = 
+                    TorquePermissionPeer.retrieveByPK((Integer)id, con);
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+
+                // Add roles if they exist
+                ((TurbinePermission)permission).setRoles(getRolesForPermission(permission, con));
+
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("Permission with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving permission information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid permission id '" + permission.getId() + "'");
+        }
+
+        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.
+     */
+    public Permission getPermissionByName(String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        Permission permission = getPermissionInstance();
+        List permissions = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorquePermissionPeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorquePermissionPeer.PERMISSION_NAME, name);
+
+            permissions = TorquePermissionPeer.doSelect(criteria, con);
+
+            if (permissions.size() == 1)
+            {
+                TorquePermission p = (TorquePermission) permissions.get(0);
+                
+                permission.setId(p.getId());
+                permission.setName(p.getName());
+                
+                // Add roles if they exist
+                ((TurbinePermission)permission).setRoles(getRolesForPermission(permission, con));
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving permission information", e);
+        }
+
+        if (permissions.size() == 0)
+        {
+            throw new UnknownEntityException("Could not find permission " + name);
+        }
+
+        if (permissions.size() > 1)
+        {
+            throw new DataBackendException("Multiple Permissions with same name '" + name + "'");
+        }
+
+        return permission;
+    }
+
+    /**
+     * Provides the roles for the given permission
+     *  
+     * @param permission the permission for which the roles should be retrieved  
+     * @param con a database connection
+     */
+    private RoleSet getRolesForPermission(Permission permission, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        RoleSet roleSet = new RoleSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueTurbineRolePermissionPeer.ROLE_ID, TorqueRolePeer.ROLE_ID);
+        criteria.add(TorqueTurbineRolePermissionPeer.PERMISSION_ID, (Integer)permission.getId());
+        
+        List roles = TorqueRolePeer.doSelect(criteria, con);
+        RoleManager roleManager = getRoleManager();
+        
+        for (Iterator i = roles.iterator(); i.hasNext();)
+        {
+            TorqueRole r = (TorqueRole)i.next();
+            Role role = roleManager.getRoleInstance();
+            
+            role.setId(r.getId());
+            role.setName(r.getName());
+            roleSet.add(role);
+        }
+        
+        return roleSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,424 @@
+package org.apache.fulcrum.security.torque.turbine;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.GroupManager;
+import org.apache.fulcrum.security.PermissionManager;
+import org.apache.fulcrum.security.UserManager;
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.Permission;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineRole;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.spi.AbstractRoleManager;
+import org.apache.fulcrum.security.torque.om.TorqueGroup;
+import org.apache.fulcrum.security.torque.om.TorqueGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorquePermission;
+import org.apache.fulcrum.security.torque.om.TorquePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineRolePermissionPeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueUser;
+import org.apache.fulcrum.security.torque.om.TorqueUserPeer;
+import org.apache.fulcrum.security.util.DataBackendException;
+import org.apache.fulcrum.security.util.EntityExistsException;
+import org.apache.fulcrum.security.util.PermissionSet;
+import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineRoleManagerImpl extends AbstractRoleManager
+{
+    /**
+    * Renames an existing Role.
+    *
+    * @param role 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 UnknownEntityException if the role does not exist.
+    */
+    public synchronized void renameRole(Role role, String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(role))
+        {
+            role.setName(name);
+            
+            try
+            {
+                TorqueRole r = new TorqueRole();
+                r.setId((Integer)role.getId());
+                r.setName(name);
+                r.setNew(false);
+                r.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Renaming Role '" + role + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown Role '" + role + "'");
+        }
+    }
+
+    /**
+      * Determines if the <code>Role</code> exists in the security system.
+      *
+      * @param roleName a <code>Role</code> value
+      * @return true if the role name exists in the system, false otherwise
+      * @throws DataBackendException when more than one Role with
+      *         the same name exists.
+      */
+    public boolean checkExists(String roleName) throws DataBackendException
+    {
+        List roles;
+
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueRolePeer.ROLE_NAME, roleName);
+
+            roles = TorqueRolePeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+
+        if (roles.size() > 1)
+        {
+            throw new DataBackendException("Multiple roles with same name '" + roleName + "'");
+        }
+        
+        return (roles.size() == 1);
+    }
+
+    /**
+     * Retrieves all roles 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.
+     */
+    public RoleSet getAllRoles() throws DataBackendException
+    {
+        RoleSet roleSet = new RoleSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+            
+            List roles = TorqueRolePeer.doSelect(new Criteria(), con);
+            
+            for (Iterator i = roles.iterator(); i.hasNext();)
+            {
+                Role role = getRoleInstance();
+                TorqueRole r = (TorqueRole)i.next();
+                role.setId(r.getId());
+                role.setName(r.getName());
+
+                // Add user/group/role-relations if they exist
+                ((TurbineRole)role).setUserGroupRoleSet(getUgrForRole(role, con));
+
+                // Add permissions if they exist
+                ((TurbineRole)role).setPermissions(getPermissionsForRole(role, con));
+
+                roleSet.add(role);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+        catch (UnknownEntityException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error creating permission instance", e);
+        }
+        
+        return roleSet;
+    }
+
+    /**
+    * Creates a new role with specified attributes.
+    *
+    * @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 EntityExistsException if the role already exists.
+    */
+    protected synchronized Role persistNewRole(Role role) throws DataBackendException
+    {
+        try
+        {
+            TorqueRole r = new TorqueRole();
+            r.setName(role.getName());
+            r.save();
+            
+            role.setId(r.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding Role '" + role + "' failed", e);
+        }
+        
+        return role;
+    }
+
+    /**
+    * Removes a Role from the system.
+    *
+    * @param role The object describing the role to be removed.
+    * @throws DataBackendException if there was an error accessing the data
+    *         backend.
+    * @throws UnknownEntityException if the role does not exist.
+    */
+    public synchronized void removeRole(Role role) throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(role))
+        {
+            try
+            {
+                TorqueRolePeer.doDelete(SimpleKey.keyFor((Integer)role.getId()));
+            }
+            catch (TorqueException e)
+            {
+                throw new DataBackendException("Removing Role '" + role + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown role '" + role + "'");
+        }
+    }
+
+    /**
+     * Retrieve a Role object with specified id.
+     *
+     * @param id
+     *            the id of the Role.
+     * @return an object representing the Role with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the role does not exist.
+     */
+    public Role getRoleById(Object id)
+        throws DataBackendException, UnknownEntityException 
+    {
+        Role role = getRoleInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+
+            try
+            {
+                con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+                
+                TorqueRole r = 
+                    TorqueRolePeer.retrieveByPK((Integer)id, con);
+                role.setId(r.getId());
+                role.setName(r.getName());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineRole)role).setUserGroupRoleSet(getUgrForRole(role, con));
+
+                // Add permissions if they exist
+                ((TurbineRole)role).setPermissions(getPermissionsForRole(role, con));
+
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("Role with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving role information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid role id '" + role.getId() + "'");
+        }
+
+        return role;
+    }
+
+    /**
+     * Retrieve a Role object with specified name.
+     *
+     * @param name the name of the Role.
+     * @return an object representing the Role with specified name.
+     * @throws DataBackendException if there was an error accessing the
+     *         data backend.
+     * @throws UnknownEntityException if the role does not exist.
+     */
+    public Role getRoleByName(String name)
+        throws DataBackendException, UnknownEntityException
+    {
+        Role role = getRoleInstance();
+        List roles = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueRolePeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueRolePeer.ROLE_NAME, name);
+
+            roles = TorqueRolePeer.doSelect(criteria, con);
+
+            if (roles.size() == 1)
+            {
+                TorqueRole r = (TorqueRole) roles.get(0);
+                
+                role.setId(r.getId());
+                role.setName(r.getName());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineRole)role).setUserGroupRoleSet(getUgrForRole(role, con));
+
+                // Add permissions if they exist
+                ((TurbineRole)role).setPermissions(getPermissionsForRole(role, con));
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving role information", e);
+        }
+
+        if (roles.size() == 0)
+        {
+            throw new UnknownEntityException("Could not find role" + name);
+        }
+
+        if (roles.size() > 1)
+        {
+            throw new DataBackendException("Multiple Roles with same name '" + name + "'");
+        }
+
+        return role;
+    }
+
+    /**
+     * Provides the user/group/role-relations for the given role
+     *  
+     * @param role the role for which the relations should be retrieved  
+     * @param con a database connection
+     */
+    private Set getUgrForRole(Role role, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        Set ugrSet = new HashSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.add(TorqueTurbineUserGroupRolePeer.ROLE_ID, (Integer)role.getId());
+        
+        List ugrs = TorqueTurbineUserGroupRolePeer.doSelect(criteria, con);
+        UserManager userManager = getUserManager();
+        GroupManager groupManager = getGroupManager();
+        
+        for (Iterator i = ugrs.iterator(); i.hasNext();)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setRole(role);
+            
+            TorqueTurbineUserGroupRole tugr = (TorqueTurbineUserGroupRole)i.next();
+
+            User user = userManager.getUserInstance();
+            TorqueUser u = TorqueUserPeer.retrieveByPK(tugr.getUserId(), con);
+            user.setId(u.getId());
+            user.setName(u.getName());
+            user.setPassword(u.getPassword());
+            ugr.setUser(user);
+
+            Group group = groupManager.getGroupInstance();
+            TorqueGroup g = TorqueGroupPeer.retrieveByPK(tugr.getGroupId(), con);
+            group.setId(g.getId());
+            group.setName(g.getName());
+            ugr.setGroup(group);
+            
+            ugrSet.add(ugr);
+        }
+        
+        return ugrSet;
+    }
+
+    /**
+     * Provides the permissions for the given role
+     *  
+     * @param role the role for which the permissions should be retrieved  
+     * @param con a database connection
+     */
+    private PermissionSet getPermissionsForRole(Role role, Connection con)
+        throws TorqueException, DataBackendException, UnknownEntityException
+    {
+        PermissionSet permissionSet = new PermissionSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.addJoin(TorqueTurbineRolePermissionPeer.PERMISSION_ID, TorquePermissionPeer.PERMISSION_ID);
+        criteria.add(TorqueTurbineRolePermissionPeer.ROLE_ID, (Integer)role.getId());
+        
+        List permissions = TorquePermissionPeer.doSelect(criteria, con);
+        PermissionManager permissionManager = getPermissionManager();
+        
+        for (Iterator i = permissions.iterator(); i.hasNext();)
+        {
+            TorquePermission p = (TorquePermission)i.next();
+            Permission permission = permissionManager.getPermissionInstance();
+            
+            permission.setId(p.getId());
+            permission.setName(p.getName());
+            permissionSet.add(permission);
+        }
+        
+        return permissionSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java Thu Sep 21 13:56:36 2006
@@ -0,0 +1,372 @@
+package org.apache.fulcrum.security.torque.turbine;
+/*
+ *  Copyright 2001-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import java.sql.Connection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.fulcrum.security.GroupManager;
+import org.apache.fulcrum.security.RoleManager;
+import org.apache.fulcrum.security.entity.Group;
+import org.apache.fulcrum.security.entity.Role;
+import org.apache.fulcrum.security.entity.User;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUser;
+import org.apache.fulcrum.security.model.turbine.entity.TurbineUserGroupRole;
+import org.apache.fulcrum.security.spi.AbstractUserManager;
+import org.apache.fulcrum.security.torque.om.TorqueGroup;
+import org.apache.fulcrum.security.torque.om.TorqueGroupPeer;
+import org.apache.fulcrum.security.torque.om.TorqueRole;
+import org.apache.fulcrum.security.torque.om.TorqueRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRole;
+import org.apache.fulcrum.security.torque.om.TorqueTurbineUserGroupRolePeer;
+import org.apache.fulcrum.security.torque.om.TorqueUser;
+import org.apache.fulcrum.security.torque.om.TorqueUserPeer;
+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;
+import org.apache.torque.NoRowsException;
+import org.apache.torque.TorqueException;
+import org.apache.torque.om.SimpleKey;
+import org.apache.torque.util.Criteria;
+import org.apache.torque.util.Transaction;
+/**
+ * This implementation persists to a database via Torque.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class TorqueTurbineUserManagerImpl extends AbstractUserManager
+{
+    /**
+     * 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
+    {
+        List users;
+
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueUserPeer.LOGIN_NAME, userName.toLowerCase());
+
+            users = TorqueUserPeer.doSelect(criteria);
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Error retrieving user information", e);
+        }
+
+        if (users.size() > 1)
+        {
+            throw new DataBackendException("Multiple Users with same username '" + userName + "'");
+        }
+        
+        return (users.size() == 1);
+    }
+
+    /**
+     * Retrieve a user from persistent storage using username as the
+     * key.
+     *
+     * @param userName the name of the user.
+     * @return an User object.
+     * @exception UnknownEntityException if the user's account does not
+     *            exist in the database.
+     * @exception DataBackendException if there is a problem accessing the
+     *            storage.
+     */
+    public User getUser(String userName) throws UnknownEntityException, DataBackendException
+    {
+        User user = getUserInstance();
+        List users = Collections.EMPTY_LIST;
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+            
+            Criteria criteria = new Criteria();
+            criteria.add(TorqueUserPeer.LOGIN_NAME, userName.toLowerCase());
+
+            users = TorqueUserPeer.doSelect(criteria, con);
+
+            if (users.size() == 1)
+            {
+                TorqueUser u = (TorqueUser) users.get(0);
+                
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+                
+                // Add user/group/role-relations if they exist
+                ((TurbineUser)user).setUserGroupRoleSet(getUgrForUser(user, con));
+            }
+            
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving user information", e);
+        }
+
+        if (users.size() == 0)
+        {
+            throw new UnknownEntityException("Unknown user '" + userName + "'");
+        }
+
+        if (users.size() > 1)
+        {
+            throw new DataBackendException("Multiple Users with same username '" + userName + "'");
+        }
+
+        return user;
+    }
+
+    /**
+       * 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
+    {
+        UserSet userSet = new UserSet();
+        Connection con = null;
+
+        try
+        {
+            con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+            
+            List users = TorqueUserPeer.doSelect(new Criteria(), con);
+
+            for (Iterator i = users.iterator(); i.hasNext();)
+            {
+                User user = getUserInstance();
+                TorqueUser u = (TorqueUser)i.next();
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+
+                // Add user/group/role-relations if they exist
+                ((TurbineUser)user).setUserGroupRoleSet(getUgrForUser(user, con));
+                
+                userSet.add(user);
+            }
+
+            Transaction.commit(con);
+        }
+        catch (TorqueException e)
+        {
+            Transaction.safeRollback(con);
+            throw new DataBackendException("Error retrieving all users", e);
+        }
+        
+        return userSet;
+    }
+
+    /**
+    * 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 synchronized void removeUser(User user) throws DataBackendException, UnknownEntityException
+    {
+        try
+        {
+            TorqueUserPeer.doDelete(SimpleKey.keyFor((Integer)user.getId()));
+        }
+        catch (TorqueException e)
+        {
+            throw new DataBackendException("Removing User '" + user + "' failed", e);
+        }
+    }
+
+    /**
+       * 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.
+       */
+    protected synchronized User persistNewUser(User user) throws DataBackendException
+    {
+        try
+        {
+            TorqueUser u = new TorqueUser();
+            
+            u.setName(user.getName());
+            u.setPassword(user.getPassword());
+            u.save();
+
+            user.setId(u.getId());
+        }
+        catch (Exception e)
+        {
+            throw new DataBackendException("Adding User '" + user + "' failed", e);
+        }
+        
+        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 synchronized void saveUser(User user) throws DataBackendException, UnknownEntityException
+    {
+        if (checkExists(user))
+        {
+            try
+            {
+                TorqueUser u = new TorqueUser();
+                
+                u.setId((Integer)user.getId());
+                u.setName(user.getName());
+                u.setPassword(user.getPassword());
+                u.setNew(false);
+                u.save();
+            }
+            catch (Exception e)
+            {
+                throw new DataBackendException("Saving User '" + user + "' failed", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Unknown user '" + user + "'");
+        }
+    }
+
+    /**
+     * Retrieve a User object with specified id.
+     *
+     * @param id
+     *            the id of the User.
+     * @return an object representing the User with specified id.
+     * @throws DataBackendException
+     *             if there was an error accessing the data backend.
+     * @throws UnknownEntityException
+     *             if the user does not exist.
+     */
+    public User getUserById(Object id)
+        throws DataBackendException, UnknownEntityException
+    {
+        User user = getUserInstance();
+
+        if (id != null && id instanceof Integer)
+        {
+            Connection con = null;
+            
+            try
+            {
+                con = Transaction.begin(TorqueUserPeer.DATABASE_NAME);
+                
+                TorqueUser u = TorqueUserPeer.retrieveByPK((Integer)id, con);
+
+                user.setId(u.getId());
+                user.setName(u.getName());
+                user.setPassword(u.getPassword());
+
+                // Add user/group/role-relations if they exist
+                ((TurbineUser)user).setUserGroupRoleSet(getUgrForUser(user, con));
+                
+                Transaction.commit(con);
+            }
+            catch (NoRowsException e)
+            {
+                Transaction.safeRollback(con);
+                throw new UnknownEntityException("User with id '" + id + "' does not exist.", e);
+            }
+            catch (TorqueException e)
+            {
+                Transaction.safeRollback(con);
+                throw new DataBackendException("Error retrieving user information", e);
+            }
+        }
+        else
+        {
+            throw new UnknownEntityException("Invalid user id '" + user.getId() + "'");
+        }
+
+        return user;
+    }
+    
+    /**
+     * Provides the user/group/role-relations for the given user
+     *  
+     * @param user the user for which the relations should be retrieved  
+     * @param con a database connection
+     */
+    private Set getUgrForUser(User user, Connection con)
+        throws TorqueException, DataBackendException
+    {
+        Set ugrSet = new HashSet();
+        
+        Criteria criteria = new Criteria();
+        criteria.add(TorqueTurbineUserGroupRolePeer.USER_ID, (Integer)user.getId());
+        
+        List ugrs = TorqueTurbineUserGroupRolePeer.doSelect(criteria, con);
+        RoleManager userManager = getRoleManager();
+        GroupManager groupManager = getGroupManager();
+        
+        for (Iterator i = ugrs.iterator(); i.hasNext();)
+        {
+            TurbineUserGroupRole ugr = new TurbineUserGroupRole();
+            ugr.setUser(user);
+            
+            TorqueTurbineUserGroupRole tugr = (TorqueTurbineUserGroupRole)i.next();
+
+            Role role = userManager.getRoleInstance();
+            TorqueRole r = TorqueRolePeer.retrieveByPK(tugr.getRoleId(), con);
+            role.setId(r.getId());
+            role.setName(r.getName());
+            ugr.setRole(role);
+
+            Group group = groupManager.getGroupInstance();
+            TorqueGroup g = TorqueGroupPeer.retrieveByPK(tugr.getGroupId(), con);
+            group.setId(g.getId());
+            group.setName(g.getName());
+            ugr.setGroup(group);
+            
+            ugrSet.add(ugr);
+        }
+        
+        return ugrSet;
+    }
+}

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueComponentConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueComponentConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueComponentConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,17 @@
+<my-system>
+    <securityService/>
+    <authenticator/>
+    <modelManager/>
+    <aclFactory/>
+    
+    <userManager>
+      	<className>org.apache.fulcrum.security.model.basic.entity.BasicUser</className>
+    </userManager> 
+    <groupManager>
+      	<className>org.apache.fulcrum.security.model.basic.entity.BasicGroup</className>
+    </groupManager>    
+  
+    <torqueService>
+        <configfile>/src/test/Torque.properties</configfile>
+    </torqueService>
+</my-system>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueRoleConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueRoleConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueRoleConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/BasicTorqueRoleConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,33 @@
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+    <role
+        name="org.apache.fulcrum.security.SecurityService"
+        shorthand="securityService"
+        default-class="org.apache.fulcrum.security.BaseSecurityService"/>
+    <role
+        name="org.apache.fulcrum.security.UserManager"
+        shorthand="userManager"
+        early-init="true"
+        default-class="org.apache.fulcrum.security.torque.basic.TorqueBasicUserManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.GroupManager"
+        shorthand="groupManager"
+        default-class="org.apache.fulcrum.security.torque.basic.TorqueBasicGroupManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.ModelManager"
+        shorthand="modelManager"
+        default-class="org.apache.fulcrum.security.torque.basic.TorqueBasicModelManagerImpl"/>                                
+    <role
+        name="org.apache.fulcrum.security.authenticator.Authenticator"
+        shorthand="authenticator"
+        default-class="org.apache.fulcrum.security.authenticator.TextMatchAuthenticator"/>                                
+    <role
+        name="org.apache.fulcrum.security.model.ACLFactory"
+        shorthand="aclFactory"
+        default-class="org.apache.fulcrum.security.model.basic.BasicACLFactory"/>                                
+    <role
+        name="org.apache.torque.avalon.Torque"
+        shorthand="torqueService"
+        default-class="org.apache.torque.avalon.TorqueComponent"/>                                
+</role-list>
+ 
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueComponentConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueComponentConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueComponentConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,23 @@
+<my-system>
+    <securityService/>
+    <authenticator/>
+    <modelManager/>
+    <aclFactory/>
+    
+    <userManager>
+        <className>org.apache.fulcrum.security.model.dynamic.entity.DynamicUser</className>
+    </userManager> 
+    <groupManager>
+        <className>org.apache.fulcrum.security.model.dynamic.entity.DynamicGroup</className>
+    </groupManager>    
+    <roleManager>
+        <className>org.apache.fulcrum.security.model.dynamic.entity.DynamicRole</className>
+    </roleManager>   
+    <permissionManager>
+        <className>org.apache.fulcrum.security.model.dynamic.entity.DynamicPermission</className>
+    </permissionManager> 
+ 
+    <torqueService>
+        <configfile>/src/test/Torque.properties</configfile>
+    </torqueService>
+</my-system>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueRoleConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueRoleConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueRoleConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/DynamicTorqueRoleConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,41 @@
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+    <role
+        name="org.apache.fulcrum.security.SecurityService"
+        shorthand="securityService"
+        default-class="org.apache.fulcrum.security.BaseSecurityService"/>
+    <role
+        name="org.apache.fulcrum.security.UserManager"
+        shorthand="userManager"
+        early-init="true"
+        default-class="org.apache.fulcrum.security.torque.dynamic.TorqueDynamicUserManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.GroupManager"
+        shorthand="groupManager"
+        default-class="org.apache.fulcrum.security.torque.dynamic.TorqueDynamicGroupManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.RoleManager"
+        shorthand="roleManager"
+        default-class="org.apache.fulcrum.security.torque.dynamic.TorqueDynamicRoleManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.PermissionManager"
+        shorthand="permissionManager"
+        default-class="org.apache.fulcrum.security.torque.dynamic.TorqueDynamicPermissionManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.ModelManager"
+        shorthand="modelManager"
+        default-class="org.apache.fulcrum.security.torque.dynamic.TorqueDynamicModelManagerImpl"/>                                
+    <role
+        name="org.apache.fulcrum.security.authenticator.Authenticator"
+        shorthand="authenticator"
+        default-class="org.apache.fulcrum.security.authenticator.TextMatchAuthenticator"/>                                
+    <role
+        name="org.apache.fulcrum.security.model.ACLFactory"
+        shorthand="aclFactory"
+        default-class="org.apache.fulcrum.security.model.dynamic.DynamicACLFactory"/>                                
+    <role
+        name="org.apache.torque.avalon.Torque"
+        shorthand="torqueService"
+        default-class="org.apache.torque.avalon.TorqueComponent"/>                                
+</role-list>
+ 
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/Torque.properties
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/Torque.properties?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/Torque.properties (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/Torque.properties Thu Sep 21 13:56:36 2006
@@ -0,0 +1,36 @@
+# Copyright 2005 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License")
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Runtime settings for the fulcrum security test profile
+#
+# $Id: Torque.properties 279964 2005-09-10 07:07:23Z tfischer $
+#
+
+torque.database.default = fulcrum
+torque.database.fulcrum.adapter = mysql
+
+#Using commons-dbcp
+torque.dsfactory.fulcrum.factory = org.apache.torque.dsfactory.SharedPoolDataSourceFactory
+torque.dsfactory.fulcrum.connection.driver = org.gjt.mm.mysql.Driver
+torque.dsfactory.fulcrum.connection.url = jdbc:mysql://localhost:3306/fulcrum
+torque.dsfactory.fulcrum.connection.user = root
+torque.dsfactory.fulcrum.connection.password =
+
+torque.dsfactory.bookstore.pool.validationQuery = SELECT 1
+
+# Determines whether the managers cache instances of the business objects.
+# And also whether the MethodResultCache will really cache results.
+
+torque.manager.useCache = true

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueComponentConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueComponentConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueComponentConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,23 @@
+<my-system>
+    <securityService/>
+    <authenticator/>
+    <modelManager/>
+    <aclFactory/>
+    
+    <userManager>
+        <className>org.apache.fulcrum.security.model.turbine.entity.TurbineUser</className>
+    </userManager> 
+    <groupManager>
+        <className>org.apache.fulcrum.security.model.turbine.entity.TurbineGroup</className>
+    </groupManager>    
+    <roleManager>
+        <className>org.apache.fulcrum.security.model.turbine.entity.TurbineRole</className>
+    </roleManager>   
+    <permissionManager>
+        <className>org.apache.fulcrum.security.model.turbine.entity.TurbinePermission</className>
+    </permissionManager> 
+  
+    <torqueService>
+        <configfile>/src/test/Torque.properties</configfile>
+    </torqueService>
+</my-system>
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueRoleConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueRoleConfig.xml?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueRoleConfig.xml (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/TurbineTorqueRoleConfig.xml Thu Sep 21 13:56:36 2006
@@ -0,0 +1,42 @@
+<!-- This configuration file for Avalon components is used for testing the TestComponent -->
+<role-list>
+    <role
+        name="org.apache.fulcrum.security.SecurityService"
+        shorthand="securityService"
+        default-class="org.apache.fulcrum.security.BaseSecurityService"/>
+    <role
+        name="org.apache.fulcrum.security.UserManager"
+        shorthand="userManager"
+        early-init="true"
+        default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineUserManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.GroupManager"
+        shorthand="groupManager"
+        default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineGroupManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.RoleManager"
+        shorthand="roleManager"
+        default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineRoleManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.PermissionManager"
+        shorthand="permissionManager"
+        default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbinePermissionManagerImpl"/>
+    <role
+        name="org.apache.fulcrum.security.ModelManager"
+        shorthand="modelManager"
+        default-class="org.apache.fulcrum.security.torque.turbine.TorqueTurbineModelManagerImpl"/>                                
+    <role
+        name="org.apache.fulcrum.security.authenticator.Authenticator"
+        shorthand="authenticator"
+        default-class="org.apache.fulcrum.security.authenticator.TextMatchAuthenticator"/>                                
+    <role
+        name="org.apache.fulcrum.security.model.ACLFactory"
+        shorthand="aclFactory"
+        default-class="org.apache.fulcrum.security.model.dynamic.DynamicACLFactory"/>                                
+
+    <role
+        name="org.apache.torque.avalon.Torque"
+        shorthand="torqueService"
+        default-class="org.apache.torque.avalon.TorqueComponent"/>                                
+</role-list>
+ 
\ No newline at end of file

Added: jakarta/turbine/fulcrum/trunk/security/torque/src/test/log4j.properties
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/security/torque/src/test/log4j.properties?view=auto&rev=448680
==============================================================================
--- jakarta/turbine/fulcrum/trunk/security/torque/src/test/log4j.properties (added)
+++ jakarta/turbine/fulcrum/trunk/security/torque/src/test/log4j.properties Thu Sep 21 13:56:36 2006
@@ -0,0 +1,70 @@
+# ------------------------------------------------------------------------
+#
+# Logging Configuration
+#
+# Mix of Turbine logging configuration and Hibernate configuration
+#
+# ------------------------------------------------------------------------
+
+#
+# If we don't know the logging facility, put it into the
+# turbine.log
+#
+log4j.rootLogger = DEBUG, turbine
+
+#
+# Turbine goes into Turbine Log
+#
+log4j.category.org.apache.turbine = INFO, turbine
+log4j.additivity.org.apache.turbine = false
+
+#
+# Torque Logfile
+#
+log4j.category.org.apache.torque = DEBUG, torque
+log4j.additivity.org.apache.torque = false
+
+#
+# Avalon Logfile
+#
+log4j.category.avalon = INFO, avalon
+log4j.additivity.avalon = false
+
+########################################################################
+#
+# Logfile definitions
+#
+########################################################################
+
+#
+# turbine.log
+#
+log4j.appender.turbine = org.apache.log4j.FileAppender
+log4j.appender.turbine.file = turbine.log
+log4j.appender.turbine.layout = org.apache.log4j.PatternLayout
+log4j.appender.turbine.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.turbine.append = false
+
+#
+# torque.log
+# 
+log4j.appender.torque = org.apache.log4j.FileAppender
+log4j.appender.torque.file = target/torque.log
+log4j.appender.torque.layout = org.apache.log4j.PatternLayout
+log4j.appender.torque.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.torque.append = false
+
+#
+# Avalon gets configured to write its output onto the avalon
+# category.
+#
+log4j.appender.avalon = org.apache.log4j.FileAppender
+log4j.appender.avalon.file = target/avalon.log
+log4j.appender.avalon.layout = org.apache.log4j.PatternLayout
+log4j.appender.avalon.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.avalon.append = false
+
+
+### set log levels - for more verbose logging change 'info' to 'debug' ##
+
+#log4j.rootLogger=debug, stdout



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org