portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r742172 [2/7] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-page-manager/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/ components/jetspeed-profiler/ components/jetspeed-profiler/...
Date Sun, 08 Feb 2009 21:28:38 GMT
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -16,62 +16,28 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
 
 /**
- * <p>
  * Implements the service interface for managing Jetsped Security Groups.
- * </p>
- * <p>
- * Group hierarchy elements are being returned as a {@link Group}collection.
- * The backing implementation must appropriately map the group hierarchy to a
- * preferences sub-tree.
- * </p>
- * <p>
- * The convention {principal}.{subprincipal} has been chosen to name groups hierarchies. 
- * </p>
- * <p>Modified 2008-08-05 - DST - decoupled java preferences</p> 
+ *
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id$
  */
-public class GroupManagerImpl extends BaseJetspeedPrincipalManager implements GroupManager
+public class GroupManagerImpl extends AbstractGroupManagerImpl implements GroupManager
 {
+    private static final long serialVersionUID = 8645807335279079200L;
 
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(GroupManagerImpl.class);
-
-    private JetspeedPrincipalType userType;
-    private JetspeedPrincipalType roleType;
-    private UserManager userManager;
-    
-    public GroupManagerImpl(JetspeedPrincipalType principalType,JetspeedPrincipalType userType,JetspeedPrincipalType roleType, 
-                           JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
+    public GroupManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType roleType, 
+                            JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
     {
-        super(principalType, jpam, jpsm);
-        this.userType = userType;
-        this.roleType = roleType;
+        super(principalType, userType, roleType, jpam, jpsm);
     }
-    public void checkInitialized()
-    {    	
-    	if (userManager == null)
-    	{
-        	userManager = (UserManager)getPrincipalManagerProvider().getManager(userType);
-    	}
-    }      
     
     /* (non-Javadoc)
      * @see org.apache.jetspeed.security.GroupManager#newGroup(java.lang.String, boolean)
@@ -81,206 +47,5 @@
         GroupImpl group = new GroupImpl(name);
         group.setMapped(mapped);
         return group;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.GroupManager#newTransientGroup(java.lang.String)
-     */
-    public Group newTransientGroup(String name)
-    {
-        TransientGroup group = new TransientGroup(name);
-        return group;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#addGroup(java.lang.String)
-     */
-    public Group addGroup(String groupName) throws SecurityException
-    {
-        return addGroup(groupName, true);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#addGroup(java.lang.String, boolean)
-     */
-    public Group addGroup(String groupName, boolean mapped) throws SecurityException
-    {
-        Group group = newGroup(groupName, mapped);
-        
-        super.addPrincipal(group, null);
-            
-        if (log.isDebugEnabled())
-            log.debug("Added group: " + groupName);
-        
-        return group;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#removeGroup(java.lang.String)
-     */
-    public void removeGroup(String groupName) throws SecurityException
-    {
-       super.removePrincipal(groupName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#groupExists(java.lang.String)
-     */
-    public boolean groupExists(String groupName)
-    {
-        return super.principalExists(groupName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#getGroup(java.lang.String)
-     */
-    public Group getGroup(String groupName) throws SecurityException
-    {
-        Group group = (Group) super.getPrincipal(groupName);
-        
-        if (null == group) 
-        { 
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
-        }
-
-        return group;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#getGroupsForUser(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Group> getGroupsForUser(String username)
-            throws SecurityException
-    {
-        return (List<Group>) super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#getGroupsInRole(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Group> getGroupsInRole(String roleName)
-            throws SecurityException
-    {
-        return (List<Group>) super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#addUserToGroup(java.lang.String,
-     *      java.lang.String)
-     */
-    public void addUserToGroup(String username, String groupName)
-            throws SecurityException
-    {
-       	checkInitialized();
-       	User user = userManager.getUser(username);
-        if (user == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
-        }
-        Group group = getGroup(groupName);
-        if (group == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
-        }
-        super.addAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#removeUserFromGroup(java.lang.String,
-     *      java.lang.String)
-     */
-    public void removeUserFromGroup(String username, String groupName)
-            throws SecurityException
-    {
-    	checkInitialized();
-        User user = userManager.getUser(username);
-        if (user == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
-        }
-        Group group = getGroup(groupName);
-        if (group == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
-        }
-        super.removeAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#isUserInGroup(java.lang.String,
-     *      java.lang.String)
-     */
-    public boolean isUserInGroup(String username, String groupName)
-            throws SecurityException
-    {
-        return getAssociatedNamesFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF).contains(groupName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#getGroups(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Group> getGroups(String nameFilter) throws SecurityException
-    {
-        return (List<Group>) super.getPrincipals(nameFilter);
-    }
-    
-    public List<String> getGroupNames(String nameFilter) throws SecurityException
-    {
-        return getPrincipalNames(nameFilter);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.GroupManager#updateGroup(org.apache.jetspeed.security.Group)
-     */
-    public void updateGroup(Group group) throws SecurityException
-    {
-        super.updatePrincipal(group);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.GroupManager#addGroupToGroup(org.apache.jetspeed.security.Group, org.apache.jetspeed.security.Group, java.lang.String)
-     */
-    public void addGroupToGroup(Group from, Group to, String associationName) throws SecurityException
-    {
-        this.addAssociation(from, to, associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.GroupManager#removeGroupFromGroup(org.apache.jetspeed.security.Group, org.apache.jetspeed.security.Group, java.lang.String)
-     */
-    public void removeGroupFromGroup(Group from, Group to, String associationName) throws SecurityException
-    {
-        removeAssociation(from, to, associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.GroupManager#getGroupsAssociatedFrom(org.apache.jetspeed.security.Group, java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Group> getGroupsAssociatedFrom(Group from, String associationName)
-    {
-        return (List<Group>)getAssociatedFrom(from.getName(), from.getType(), associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.GroupManager#getGroupsAssociatedTo(org.apache.jetspeed.security.Group, java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Group> getGroupsAssociatedTo(Group to, String associationName)
-    {
-        return (List<Group>)getAssociatedFrom(to.getName(), to.getType(), associationName);
-    }
-    
-    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
-    {
-        return newGroup(name, mapped);
-    }
-
-    public JetspeedPrincipal newTransientPrincipal(String name)
-    {
-        return newTransientGroup(name);
-    }
+    }    
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LoginModuleProxyImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LoginModuleProxyImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LoginModuleProxyImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LoginModuleProxyImpl.java Sun Feb  8 21:28:35 2009
@@ -18,6 +18,7 @@
 
 import org.apache.jetspeed.security.AuthenticationProvider;
 import org.apache.jetspeed.security.LoginModuleProxy;
+import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.UserManager;
 
 /**
@@ -35,6 +36,9 @@
     /** The {@link UserManager}. */
     private UserManager userMgr;
     
+    /** The {@link RoleManager}. */
+    private RoleManager roleMgr;
+    
     /** The portal user role. */
     private String portalUserRole;
 
@@ -46,12 +50,13 @@
      * 
      * @param authProvider The authentication provider
      * @param userMgr The user manager.
+     * @param roleMgr The role manager.
      * @param portalUserRole The portal user role shared by all portal users: used
      *                       in web.xml authorization to detect authenticated portal
      *                       users.
      *  
      */
-    public LoginModuleProxyImpl(AuthenticationProvider authProvider, UserManager userMgr, String portalUserRole)
+    public LoginModuleProxyImpl(AuthenticationProvider authProvider, UserManager userMgr, RoleManager roleMgr, String portalUserRole)
     {
         // The authentication provider
         this.authProvider = authProvider;
@@ -59,6 +64,9 @@
         // The user manager.
         this.userMgr = userMgr;
         
+        // The role manager.
+        this.roleMgr = roleMgr;
+        
         // The portal user role
         this.portalUserRole = (portalUserRole != null ? portalUserRole : DEFAULT_PORTAL_USER_ROLE_NAME);
 
@@ -66,9 +74,17 @@
         // TODO Can we fix this?
         LoginModuleProxyImpl.loginModuleProxy = this;
     }
-    public LoginModuleProxyImpl(AuthenticationProvider authProvider, UserManager userMgr)
+    public LoginModuleProxyImpl(AuthenticationProvider authProvider, UserManager userMgr, RoleManager roleMgr)
+    {
+        this(authProvider, userMgr, roleMgr, DEFAULT_PORTAL_USER_ROLE_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.security.LoginModuleProxy#getRoleManager()
+     */
+    public RoleManager getRoleManager()
     {
-        this(authProvider, userMgr, DEFAULT_PORTAL_USER_ROLE_NAME);
+        return this.roleMgr;
     }
 
     /**

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -24,76 +24,44 @@
 import java.util.HashMap;
 import java.util.List;
 
-import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.security.JetspeedPermission;
 import org.apache.jetspeed.security.PermissionManager;
+import org.apache.jetspeed.security.JetspeedPermission;
 import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.JetspeedPermissionAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPermissionStorageManager;
 import org.apache.jetspeed.security.spi.PersistentJetspeedPermission;
-import org.apache.jetspeed.security.spi.impl.BaseJetspeedPermission;
 import org.apache.jetspeed.security.spi.impl.JetspeedPermissionFactory;
+import org.apache.jetspeed.security.spi.impl.PersistentJetspeedPermissionImpl;
 
 /**
  * @version $Id$
- *
  */
-public class PermissionManagerImpl implements PermissionManager
+public class PermissionManagerImpl extends AbstractPermissionManagerImpl implements PermissionManager
 {
-    private HashMap<String, JetspeedPermissionFactory> factoryMap = new HashMap<String, JetspeedPermissionFactory>();
-    private JetspeedPermissionAccessManager jpam;
-    private JetspeedPermissionStorageManager jpsm;
-    private static ThreadLocal<HashMap<Long,Permissions>> permissionsCache = new ThreadLocal<HashMap<Long,Permissions>>();
-    
     public PermissionManagerImpl(List<JetspeedPermissionFactory> factories, JetspeedPermissionAccessManager jpam, JetspeedPermissionStorageManager jpsm)
     {
-        for (JetspeedPermissionFactory pf : factories)
-        {
-            factoryMap.put(pf.getType(), pf);
-        }
-        this.jpam = jpam;
-        this.jpsm = jpsm;
-    }
-    
-    private HashMap<Long,Permissions> getPermissionsMap()
-    {
-        HashMap<Long,Permissions> map = permissionsCache.get();
-        if (map == null)
-        {
-            map = new HashMap<Long,Permissions>();
-            permissionsCache.set(map);
-        }
-        return map;
-    }
-    
-    protected PersistentJetspeedPermission getPersistentJetspeedPermission(JetspeedPermission permission)
-    {
-        if (permission instanceof PersistentJetspeedPermission)
-        {
-            return (PersistentJetspeedPermission)permission;
-        }
-        else
-        {
-            return ((BaseJetspeedPermission)permission).getPermission();
-        }
+        super(factories, jpam, jpsm);
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionFactory#newPermission(java.lang.String, java.lang.String, java.lang.String)
+     */
     public JetspeedPermission newPermission(String type, String name, String actions)
     {
-        return factoryMap.get(type).newPermission(name, actions);
+        return factoryMap.get(type).newPermission(new PersistentJetspeedPermissionImpl(type, name), actions);
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionFactory#newPermission(java.lang.String, java.lang.String, int)
+     */
     public JetspeedPermission newPermission(String type, String name, int mask)
     {
-        return factoryMap.get(type).newPermission(name, mask);
+        return factoryMap.get(type).newPermission(new PersistentJetspeedPermissionImpl(type, name), mask);
     }
 
-    public int parseActions(String actions)
-    {
-        return JetspeedActions.getContainerActionsMask(actions);
-    }
-    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionManager#getPermissions(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
     @SuppressWarnings("unchecked") 
     public Permissions getPermissions(JetspeedPrincipal principal)
     {
@@ -121,6 +89,9 @@
         return permissions;
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionManager#getPermissions(java.security.Principal[])
+     */
     @SuppressWarnings("unchecked") 
     public Permissions getPermissions(Principal[] principals)
     {
@@ -154,84 +125,4 @@
         }
         return allPermissions;
     }
-
-    @SuppressWarnings("unchecked") 
-    public List<JetspeedPermission> getPermissions()
-    {
-        return (List<JetspeedPermission>)jpam.getPermissions();
-    }
-
-    @SuppressWarnings("unchecked") 
-    public List<JetspeedPermission> getPermissions(String typeName)
-    {
-        return (List<JetspeedPermission>)jpam.getPermissions(typeName);
-    }
-
-    @SuppressWarnings("unchecked") 
-    public List<JetspeedPermission> getPermissions(String typeName, String nameFilter)
-    {
-        return (List<JetspeedPermission>)jpam.getPermissions(typeName, nameFilter);
-    }
-
-    public List<JetspeedPrincipal> getPrincipals(JetspeedPermission permission)
-    {
-        return jpam.getPrincipals(getPersistentJetspeedPermission(permission), null);
-    }
-
-    public List<JetspeedPrincipal> getPrincipals(JetspeedPermission permission, String principalType)
-    {
-        return jpam.getPrincipals(getPersistentJetspeedPermission(permission), principalType);
-    }
-
-    public boolean permissionExists(JetspeedPermission permission)
-    {
-        return jpam.permissionExists(permission);
-    }
-
-    public void addPermission(JetspeedPermission permission) throws SecurityException
-    {
-        jpsm.addPermission(getPersistentJetspeedPermission(permission));
-    }
-
-    public void updatePermission(JetspeedPermission permission) throws SecurityException
-    {
-        jpsm.updatePermission(getPersistentJetspeedPermission(permission));
-        permissionsCache.remove();
-    }
-
-    public void removePermission(JetspeedPermission permission) throws SecurityException
-    {
-        jpsm.removePermission(getPersistentJetspeedPermission(permission));
-        permissionsCache.remove();
-    }
-
-    public void grantPermission(JetspeedPermission permission, JetspeedPrincipal principal) throws SecurityException
-    {
-        jpsm.grantPermission(getPersistentJetspeedPermission(permission), principal);
-        permissionsCache.remove();
-    }
-
-    public void grantPermissionOnlyTo(JetspeedPermission permission, List<JetspeedPrincipal> principals) throws SecurityException
-    {
-        jpsm.grantPermissionOnlyTo(getPersistentJetspeedPermission(permission), null, principals);
-        permissionsCache.remove();
-    }
-
-    public void grantPermissionOnlyTo(JetspeedPermission permission, String principalType, List<JetspeedPrincipal> principals) throws SecurityException
-    {
-        jpsm.grantPermissionOnlyTo(getPersistentJetspeedPermission(permission), principalType, principals);
-        permissionsCache.remove();
-    }
-
-    public void revokePermission(JetspeedPermission permission, JetspeedPrincipal principal) throws SecurityException
-    {
-        jpsm.revokePermission(getPersistentJetspeedPermission(permission), principal);
-        permissionsCache.remove();
-    }
-
-    public void revokeAllPermissions(JetspeedPrincipal principal) throws SecurityException
-    {
-        jpsm.revokeAllPermissions(principal);
-        permissionsCache.remove();
-    }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java Sun Feb  8 21:28:35 2009
@@ -37,6 +37,7 @@
 public abstract class PersistentJetspeedPrincipal extends TransientJetspeedPrincipal implements PersistenceBrokerAware, Serializable
 {
     private Long id;
+    private String name;
     private Timestamp creationDate;
     private Timestamp modifiedDate;
     private boolean enabled = true;
@@ -44,6 +45,7 @@
     private boolean readOnly;
     private boolean removable = true;
     private boolean extendable = true;
+    private Long domainId;
 
     @SuppressWarnings("unchecked")
     protected Collection attributes;
@@ -55,7 +57,8 @@
       
     public PersistentJetspeedPrincipal(String name)
     {   
-    	super(name);
+    	super();
+    	this.name = name;
     }
     
     public Long getId()
@@ -63,6 +66,11 @@
         return id;
     }
 
+    public String getName()
+    {
+        return name;
+    }   
+
     public void setName(String name)
     {
         this.name = name;
@@ -145,7 +153,7 @@
             {
                 attributes = new ArrayList<SecurityAttributeValue>();
             }
-            sa = new SecurityAttributesImpl(this, attributes, isReadOnly(), isExtendable());
+            sa = new SecurityAttributesImpl(this, attributes, SecurityAttributeValueImpl.class, isReadOnly(), isExtendable());
         }
         return sa;
     }
@@ -189,8 +197,18 @@
         this.modifiedDate = new Timestamp(System.currentTimeMillis());
     }
     
-    protected boolean isSynchronizing(){
+    protected boolean isSynchronizing()
+    {
         return SynchronizationStateAccess.isSynchronizing();
     }
 
+    public Long getDomainId()
+    {
+        return domainId;
+    }
+
+    public void setDomainId(Long domainId)
+    {
+        this.domainId = domainId;
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -16,69 +16,27 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.Group;
-import org.apache.jetspeed.security.GroupManager;
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
 import org.apache.jetspeed.security.Role;
 import org.apache.jetspeed.security.RoleManager;
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
 
 /**
- * <p>
  * Implementation for managing roles.
- * </p>
- * <p>
- * Role hierarchy elements are being returned as a {@link Role}collection. The
- * backing implementation must appropriately map the role hierarchy to a
- * preferences sub-tree.
- * </p>
- * <p>
- * The convention {principal}.{subprincipal} has been chosen to name roles
- * hierachies in order to support declarative security. Implementation follow
- * the conventions enforced by the {@link Preferences}API.
- * </p>
  * 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id$
  */
-public class RoleManagerImpl extends BaseJetspeedPrincipalManager implements RoleManager
+public class RoleManagerImpl extends AbstractRoleManagerImpl implements RoleManager
 {
-    /** The logger. */
-    private static final Log log = LogFactory.getLog(RoleManagerImpl.class);
-    
-    private JetspeedPrincipalType userType;
-    private JetspeedPrincipalType groupType;
-    private UserManager userManager;
-    private GroupManager groupManager;
-    
-    public RoleManagerImpl(JetspeedPrincipalType principalType,JetspeedPrincipalType userType,JetspeedPrincipalType groupType,
+    private static final long serialVersionUID = 1283277153286868126L;
+
+    public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType groupType,
                            JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
     {
-        super(principalType, jpam, jpsm);
-        this.userType = userType;
-        this.groupType = groupType;
-    }
-    public void checkInitialized()
-    {    	
-    	if (userManager == null)
-    	{
-    		userManager = (UserManager)getPrincipalManagerProvider().getManager(userType);
-    	}
-    	if (groupManager == null)
-    	{
-    		groupManager = (GroupManager)getPrincipalManagerProvider().getManager(groupType);
-    	}
+        super(principalType, userType, groupType, jpam, jpsm);
     }
     
     /* (non-Javadoc)
@@ -90,255 +48,4 @@
         role.setMapped(mapped);
         return role;
     }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.RoleManager#newTransientRole(java.lang.String)
-     */
-    public Role newTransientRole(String name)
-    {
-        TransientRole role = new TransientRole(name);
-        return role;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String)
-     */
-    public Role addRole(String roleName) throws SecurityException
-    {
-        return addRole(roleName, true);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#addRole(java.lang.String, boolean)
-     */
-    public Role addRole(String roleName, boolean mapped) throws SecurityException
-    {
-        Role role = newRole(roleName, mapped);
-
-        super.addPrincipal(role, null);        
-        
-        if (log.isDebugEnabled())
-            log.debug("Added role: " + roleName);
-        
-        return role;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#removeRole(java.lang.String)
-     */
-    public void removeRole(String roleName) throws SecurityException
-    {
-        super.removePrincipal(roleName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#roleExists(java.lang.String)
-     */
-    public boolean roleExists(String roleName)
-    {
-        return super.principalExists(roleName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#getRole(java.lang.String)
-     */
-    public Role getRole(String roleName) throws SecurityException
-    {
-        Role role = (Role) super.getPrincipal(roleName);
-        
-        if (null == role) 
-        { 
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName)); 
-        }
-
-        return role;
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#getRolesForUser(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Role> getRolesForUser(String username) throws SecurityException
-    {        
-        return (List<Role>)super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#getRolesInGroup(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Role> getRolesInGroup(String groupName) throws SecurityException
-    {
-        return (List<Role>)super.getAssociatedFrom(groupName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#addRoleToUser(java.lang.String,
-     *      java.lang.String)
-     */
-    public void addRoleToUser(String username, String roleName) throws SecurityException
-    {
-        checkInitialized();
-    	User user = userManager.getUser(username);
-        if (user == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
-        }
-        Role role = getRole(roleName);
-        if (role == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
-        }
-        super.addAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#removeRoleFromUser(java.lang.String,
-     *      java.lang.String)
-     */
-    public void removeRoleFromUser(String username, String roleName) throws SecurityException
-    {
-    	checkInitialized();
-    	User user = userManager.getUser(username);
-        if (user == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
-        }
-        Role role = getRole(roleName);
-        if (role == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
-        }
-        super.removeAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#isUserInRole(java.lang.String,
-     *      java.lang.String)
-     */
-    public boolean isUserInRole(String username, String roleName) throws SecurityException
-    {
-        return getAssociatedNamesFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF).contains(roleName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#addRoleToGroup(java.lang.String,
-     *      java.lang.String)
-     */
-    public void addRoleToGroup(String roleName, String groupName) throws SecurityException
-    {
-        checkInitialized();
-    	Group group = groupManager.getGroup(groupName);
-        if (group == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
-        }
-        Role role = getRole(roleName);
-        if (role == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
-        }
-        super.addAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#removeRoleFromGroup(java.lang.String,
-     *      java.lang.String)
-     */
-    public void removeRoleFromGroup(String roleName, String groupName) throws SecurityException
-    {
-    	checkInitialized();
-    	Group group = groupManager.getGroup(groupName);
-        if (group == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
-        }
-        Role role = getRole(roleName);
-        if (role == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
-        }
-        super.removeAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#isGroupInRole(java.lang.String,
-     *      java.lang.String)
-     */
-    public boolean isGroupInRole(String groupName, String roleName) throws SecurityException
-    {
-        return getAssociatedNamesFrom(groupName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF).contains(roleName);
-    }
-
-    /**
-     * @see org.apache.jetspeed.security.RoleManager#getRoles(java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Role> getRoles(String nameFilter) throws SecurityException
-    {
-        return (List<Role>)super.getPrincipals(nameFilter);
-    }
-
-    public List<String> getRoleNames(String nameFilter) throws SecurityException
-    {
-        return getPrincipalNames(nameFilter);
-    }
-
-    /** 
-     * @see org.apache.jetspeed.security.RoleManager#updateRole(org.apache.jetspeed.security.Role)
-     */
-    public void updateRole(Role role) throws SecurityException
-    {
-         super.updatePrincipal(role);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.RoleManager#addRoleToRole(org.apache.jetspeed.security.Role, org.apache.jetspeed.security.Role, java.lang.String)
-     */
-    public void addRoleToRole(Role from, Role to, String associationName) throws SecurityException
-    {
-        this.addAssociation(from, to, associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.RoleManager#removeRoleFromRole(org.apache.jetspeed.security.Role, org.apache.jetspeed.security.Role, java.lang.String)
-     */
-    public void removeRoleFromRole(Role from, Role to, String associationName) throws SecurityException
-    {
-        removeAssociation(from, to, associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.RoleManager#getRolesAssociatedFrom(org.apache.jetspeed.security.Role, java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Role> getRolesAssociatedFrom(Role from, String associationName)
-    {
-        return (List<Role>)getAssociatedFrom(from.getName(), from.getType(), associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.RoleManager#getRolesAssociatedTo(org.apache.jetspeed.security.Role, java.lang.String)
-     */
-    @SuppressWarnings("unchecked")
-    public List<Role> getRolesAssociatedTo(Role to, String associationName)
-    {
-        return (List<Role>)getAssociatedFrom(to.getName(), to.getType(), associationName);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#newPrincipal(java.lang.String, boolean)
-     */
-    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
-    {
-        return newRole(name, mapped);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#newTransientPrincipal(java.lang.String)
-     */
-    public JetspeedPrincipal newTransientPrincipal(String name)
-    {
-        return newTransientRole(name);
-    }
 }
\ No newline at end of file

Copied: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValueImpl.java (from r736476, portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValueImpl.java?p2=portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValueImpl.java&p1=portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java&r1=736476&r2=742172&rev=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValueImpl.java Sun Feb  8 21:28:35 2009
@@ -23,7 +23,7 @@
  * @version $Id$
  *
  */
-public class SecurityAttributeValue implements Serializable
+public class SecurityAttributeValueImpl implements SecurityAttributeValue, Serializable
 {
     private static final long serialVersionUID = -5305625934872996140L;
 
@@ -33,13 +33,11 @@
     private String name;
     private String value;
     
-    /*
-     * default constructor required for persistence engine
-     */
-    public SecurityAttributeValue()
-    {}
+    public SecurityAttributeValueImpl()
+    {        
+    }
     
-    public SecurityAttributeValue(String name)
+    public void setName(String name)
     {
         this.name = name;
     }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java Sun Feb  8 21:28:35 2009
@@ -45,6 +45,7 @@
      * unchecked collection to allow using default OJB managed collections which are not Generics extendable
      */
     private Collection avColl;
+    private Class<?> avClass;
     private boolean readOnly;
     private boolean extendable;
     private boolean persistent;
@@ -60,16 +61,18 @@
             throw new IllegalArgumentException("Provided JetspeedPrincipal is not transient");
         }
         this.avColl =  new ArrayList<SecurityAttributeValue>();
+        this.avClass = null;
         this.persistent = false;
         this.readOnly = false;
         this.extendable = false;
     }
 
     @SuppressWarnings("unchecked")
-    public SecurityAttributesImpl(JetspeedPrincipal jp, Collection avColl, boolean readOnly, boolean extendable)
+    public SecurityAttributesImpl(JetspeedPrincipal jp, Collection avColl, Class<?> avClass, boolean readOnly, boolean extendable)
     {
         this.jp = jp;
         this.avColl = avColl;
+        this.avClass = avClass;
         this.persistent = true;
         this.readOnly = jp.getType().getAttributeTypes().isReadOnly() ? true : readOnly;
         this.extendable = jp.getType().getAttributeTypes().isExtendable() ? true : extendable;
@@ -200,14 +203,35 @@
                 throw new SecurityException(SecurityException.ATTRIBUTES_NOT_EXTENDABLE.createScoped(getPrincipal().getType().getName()));
             }
             // New INFO_CATEGORY attribute, always of type STRING
-            SecurityAttributeValue value = new SecurityAttributeValue(name);
+            SecurityAttributeValue value = null;
+            try
+            {
+                value = (SecurityAttributeValue)avClass.newInstance();
+            }
+            catch (InstantiationException ie)
+            {                
+            }
+            catch (IllegalAccessException ie)
+            {                
+            }
+            value.setName(name);
             avColl.add(value);
-            sa = new SecurityAttributeImpl(new SecurityAttributeTypeImpl(name), value, persistent);
-            
+            sa = new SecurityAttributeImpl(new SecurityAttributeTypeImpl(name), value, persistent);            
         }
         else
         {
-            SecurityAttributeValue value = new SecurityAttributeValue(name);
+            SecurityAttributeValue value = null;
+            try
+            {
+                value = (SecurityAttributeValue)avClass.newInstance();
+            }
+            catch (InstantiationException ie)
+            {                
+            }
+            catch (IllegalAccessException ie)
+            {                
+            }
+            value.setName(name);
             avColl.add(value);
             sa = new SecurityAttributeImpl(sat, value, persistent);
         }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java Sun Feb  8 21:28:35 2009
@@ -17,163 +17,59 @@
 
 package org.apache.jetspeed.security.impl;
 
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.util.Map;
-
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalManagerProvider;
-import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.SecurityAttributes;
-import org.apache.jetspeed.security.SecurityException;
-
 /**
- * @$
+ * TransientJetspeedPrincipal
  *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
  */
-public abstract class TransientJetspeedPrincipal implements JetspeedPrincipal, Serializable
+public class TransientJetspeedPrincipal extends AbstractTransientJetspeedPrincipal
 {
-    protected static JetspeedPrincipalManagerProvider jpmp;
-    
+    private static final long serialVersionUID = 5038976589776864304L;
+
+    protected String type;
     protected String name;
-    @SuppressWarnings("unused")
-    private String type;
-    
-    protected transient JetspeedPrincipalType jpt;
-    protected transient SecurityAttributes sa;
     private Long domainId;
     
-    public static void setJetspeedPrincipalManagerProvider(JetspeedPrincipalManagerProvider jpmp)
-    {
-        TransientJetspeedPrincipal.jpmp = jpmp;
-    }
-    
     protected TransientJetspeedPrincipal()
     {
-        type = jpmp.getPrincipalTypeByClassName(getClass().getName()).getName();
+        super();
     }
     
     protected TransientJetspeedPrincipal(String type, String name)
     {
+        super(type);
         this.name = name;
-        this.type = type;
     }
     
-    public TransientJetspeedPrincipal(String name)
+    protected TransientJetspeedPrincipal(String name)
     {
-        this();
-    	this.name = name;
-    }
-    
-    public Long getId()
-    {
-        return null;
-    }
-
-    public String getName()
-    {
-        return name;
-    }   
-
-    public synchronized JetspeedPrincipalType getType()
-    {
-        if (jpt == null)
-        {
-            jpt = jpmp.getPrincipalType(type);
-        }
-        return jpt;
-    }
-
-    public Timestamp getCreationDate()
-    {
-        return null;
-    }
-    
-    public Timestamp getModifiedDate()
-    {
-        return null;
-    }
-    
-    public boolean isTransient()
-    {
-        return true;
-    }
-    
-    public boolean isEnabled()
-    {
-        return true;
-    }
-
-    public void setEnabled(boolean enabled) throws SecurityException
-    {
-        throw new UnsupportedOperationException();
-    }
-    
-    public boolean isMapped()
-    {
-        return false;
-    }
-    
-    public void setMapped(boolean mapped)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    public boolean isReadOnly()
-    {
-        return false;
-    }
-    
-    public void setReadOnly(boolean readOnly)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-    public boolean isRemovable()
-    {
-        return false;
+        super();
+        this.name = name;
     }
     
-    public void setRemovable(boolean removable)
+    public String getTypeName()
     {
-        throw new UnsupportedOperationException();
+        return type;
     }
 
-    public boolean isExtendable()
-    {
-        return true;
-    }
-    
-    public void setExtendable(boolean extendable)
+    public void setTypeName(String type)
     {
-        throw new UnsupportedOperationException();
-    }
-    
-    public synchronized SecurityAttributes getSecurityAttributes()
-    {
-        if (sa == null)
-        {
-            sa = new SecurityAttributesImpl(this);
-        }
-        return sa;
+        this.type = type;
     }
     
-    public Map<String, String> getInfoMap()
+    public String getName()
     {
-        return getSecurityAttributes().getInfoMap();
+        return name;
     }
 
-    public String toString()
-    {
-        return getType().getName()+": "+getName()+" (id: "+(getId())+", transient: "+isTransient()+", mapped: "+isMapped()+")";
-    }
-    
     public Long getDomainId()
     {
         return domainId;
     }
-
-    public void setDomainId(Long domainId){
-        this.domainId=domainId;
+    
+    public void setDomainId(Long domainId)
+    {
+        this.domainId = domainId;
     }
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -16,257 +16,47 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.AuthenticatedUser;
-import org.apache.jetspeed.security.AuthenticatedUserImpl;
-import org.apache.jetspeed.security.GroupManager;
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.JetspeedSubjectFactory;
-import org.apache.jetspeed.security.PasswordCredential;
-import org.apache.jetspeed.security.PrincipalsSet;
-import org.apache.jetspeed.security.RoleManager;
-import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.UserCredential;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
 import org.apache.jetspeed.security.spi.UserPasswordCredentialManager;
 import org.apache.jetspeed.security.spi.UserSubjectPrincipalsProvider;
-import org.apache.jetspeed.security.spi.UserSubjectPrincipalsResolver;
 
 /**
- * <p>
  * Implementation for managing users and provides access to the {@link User}.
- * </p>
  * 
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
  * @author <a href="mailto:vkumar@apache.org">Vivek Kumar </a>
  * @version $Id$
  */
-public class UserManagerImpl extends BaseJetspeedPrincipalManager implements UserManager, UserSubjectPrincipalsProvider
+public class UserManagerImpl extends AbstractUserManagerImpl implements UserManager, UserSubjectPrincipalsProvider
 {
-	private static final Log log = LogFactory.getLog(UserManagerImpl.class);
-
-	private String anonymousUser = "guest";
-	private JetspeedPrincipalType roleType;
-	private JetspeedPrincipalType groupType;
-
-	private UserPasswordCredentialManager credentialManager;
-	private RoleManager roleManager;
-	private GroupManager groupManager;
-	private Map<String, UserSubjectPrincipalsResolver> usprMap = new HashMap<String, UserSubjectPrincipalsResolver>();
+    private static final long serialVersionUID = 9190153823246723079L;
 
 	public UserManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType roleType, JetspeedPrincipalType groupType,
-			JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialManager credentialManager)
-	{
-		super(principalType, jpam, jpsm);
-		this.credentialManager = credentialManager;
-		this.roleType = roleType;
-		this.groupType = groupType;
-	}
-
-	public void checkInitialized()
-	{
-		if (groupManager == null)
-		{
-			groupManager = (GroupManager) getPrincipalManagerProvider().getManager(groupType);
-		}
-		if (roleManager == null)
-		{
-			roleManager = (RoleManager) getPrincipalManagerProvider().getManager(roleType);
-		}
-	}
-
-	public User addUser(String username) throws SecurityException
-	{
-		return addUser(username, true);
-	}
-
-	public User addUser(String username, boolean mapped) throws SecurityException
-	{
-		User user = newUser(username, mapped);
-		
-		super.addPrincipal(user, null);
-
-		if (log.isDebugEnabled())
-			log.debug("Added user: " + username);
-
-		return user;
-	}
-
-	public String getAnonymousUser()
-	{
-		return anonymousUser;
-	}
-
-	public PasswordCredential getPasswordCredential(User user) throws SecurityException
-	{
-		if (credentialManager != null)
-		{
-			return credentialManager.getPasswordCredential(user);
-		}
-		return null;
-	}
-
-	public Subject getSubject(User user) throws SecurityException
-	{
-		if (credentialManager != null)
-		{
-			PasswordCredential pwc = getPasswordCredential(user);
-			if (pwc != null)
-			{
-				UserCredential credential = new UserCredentialImpl(pwc);
-				HashSet<Object> privateCred = new HashSet<Object>();
-				privateCred.add(credential);
-				return getSubject(new AuthenticatedUserImpl(user, null, privateCred));
-			}
-		}
-		return getSubject(new AuthenticatedUserImpl(user, null, null));
-	}
-
-	public Subject getSubject(AuthenticatedUser user) throws SecurityException
-	{
-		Set<Principal> principals = new PrincipalsSet();
-		resolveSubjectPrincipals(user, principals);
-		return JetspeedSubjectFactory.createSubject(user.getUser(), getPublicCredentialsForSubject(user), getPrivateCredentialsForSubject(user), principals);
-	}
-
-	protected Set<Object> getPublicCredentialsForSubject(AuthenticatedUser user)
-	{
-		HashSet<Object> credentials = new HashSet<Object>();
-		if (user.getPublicCredentials() != null)
-		{
-			credentials.addAll(user.getPublicCredentials());
-		}
-		return credentials;
-	}
-
-	protected Set<Object> getPrivateCredentialsForSubject(AuthenticatedUser user)
-	{
-		HashSet<Object> credentials = new HashSet<Object>();
-		if (user.getPrivateCredentials() != null)
-		{
-			credentials.addAll(user.getPrivateCredentials());
-		}
-		return credentials;
-	}
-
-	protected void resolveSubjectPrincipals(AuthenticatedUser user, Set<Principal> principals) throws SecurityException
-	{
-		checkInitialized();
-		HashSet<Long> resolvedIds = new HashSet<Long>();
-		for (UserSubjectPrincipalsResolver resolver : usprMap.values())
-		{
-		    resolver.resolve(user.getUser(), resolvedIds, principals, usprMap);
-		}
-	}
-
-	public User getUser(String username) throws SecurityException
-	{
-	    User user = (User)getPrincipal(username);
-	    if (null == user)
-	    {
-	        throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
-	    }
-	    return user;
-	}
-
-	public List<String> getUserNames(String nameFilter) throws SecurityException
-	{
-		return getPrincipalNames(nameFilter);
-	}
-
-	public List<User> getUsers(String nameFilter) throws SecurityException
-	{
-		return (List<User>) getPrincipals(nameFilter);
-	}
-
-	public List<User> getUsersInGroup(String groupFullPathName) throws SecurityException
+                           JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialManager credentialManager)
 	{
-		return (List<User>) super.getAssociatedTo(groupFullPathName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-	}
-
-	public List<User> getUsersInRole(String roleFullPathName) throws SecurityException
-	{
-		return (List<User>) super.getAssociatedTo(roleFullPathName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
-	}
-
-	public List<User> lookupUsers(String attributeName, String attributeValue) throws SecurityException
-	{
-		return (List<User>) super.getPrincipalsByAttribute(attributeName, attributeValue);
-	}
-
-	public User newTransientUser(String name)
-	{
-		TransientUser user = new TransientUser(name);
-		return user;
+		super(principalType, roleType, groupType, jpam, jpsm, credentialManager);
 	}
 
+	/* (non-Javadoc)
+	 * @see org.apache.jetspeed.security.UserManager#newUser(java.lang.String)
+	 */
 	public User newUser(String name)
 	{
 		UserImpl user = new UserImpl(name);
 		return user;
 	}
 
+	/* (non-Javadoc)
+	 * @see org.apache.jetspeed.security.UserManager#newUser(java.lang.String, boolean)
+	 */
 	public User newUser(String name, boolean mapped)
 	{
 		UserImpl user = new UserImpl(name);
 		user.setMapped(mapped);
 		return user;
 	}
-
-	public void removeUser(String username) throws SecurityException
-	{
-		JetspeedPrincipal user;
-		
-		user = getUser(username);
-		super.removePrincipal(user);
-	}
-
-	public void storePasswordCredential(PasswordCredential credential) throws SecurityException
-	{
-		if (credentialManager == null)
-		{
-			throw new UnsupportedOperationException();
-		}
-		credentialManager.storePasswordCredential(credential);
-	}
-
-	public void updateUser(User user) throws SecurityException
-	{
-		super.updatePrincipal(user);
-	}
-
-	public boolean userExists(String username)
-	{
-		return super.principalExists(username);
-	}
-
-	public JetspeedPrincipal newPrincipal(String name, boolean mapped)
-	{
-		return newUser(name, mapped);
-	}
-
-	public JetspeedPrincipal newTransientPrincipal(String name)
-	{
-		return newTransientUser(name);
-	}
-
-    public void addSubjectPrincipalsResolver(UserSubjectPrincipalsResolver resolver)
-    {
-        this.usprMap.put(resolver.getPrincipalType().getName(), resolver);
-    }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ext/JBossLoginModule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ext/JBossLoginModule.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ext/JBossLoginModule.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ext/JBossLoginModule.java Sun Feb  8 21:28:35 2009
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.List;
 
 import javax.security.auth.Subject;
 
@@ -29,11 +28,10 @@
 import org.apache.jetspeed.security.AuthenticationProvider;
 import org.apache.jetspeed.security.Role;
 import org.apache.jetspeed.security.SubjectHelper;
-import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.UserSubjectPrincipal;
 import org.apache.jetspeed.security.impl.DefaultLoginModule;
-import org.apache.jetspeed.security.impl.RoleImpl;
 
 /**
  * <p>Configures Subject principals for JBoss JAAS implementation
@@ -92,16 +90,17 @@
     /**
      * Create a new JBoss login module that uses the given user manager.
      * @param userManager
+     * @param roleManager
      * @see DefaultLoginModule#DefaultLoginModule(UserManager)
      */
-    protected JBossLoginModule (AuthenticationProvider authProvider, UserManager userManager)
+    protected JBossLoginModule (AuthenticationProvider authProvider, UserManager userManager, RoleManager roleManager)
     {
-        super (authProvider, userManager);
+        super (authProvider, userManager, roleManager);
     }
         
-    public JBossLoginModule(AuthenticationProvider authProvider, UserManager userManager, String portalUserRole)
+    public JBossLoginModule(AuthenticationProvider authProvider, UserManager userManager, RoleManager roleManager, String portalUserRole)
     {
-        super(authProvider, userManager, portalUserRole);
+        super(authProvider, userManager, roleManager, portalUserRole);
     }
 
     protected void commitSubject(Subject containerSubject, Subject jetspeedSubject, AuthenticatedUser user)
@@ -124,7 +123,7 @@
         {
             // add portal user role: used in web.xml authorization to
             // detect authenticated portal users
-            roles.addMember(new RoleImpl(portalUserRole));        
+            roles.addMember(rms.newRole(portalUserRole, false));        
         }
         subject.getPrincipals().add(roles);
     }

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,51 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.security.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+
+/**
+ * <p>Represents a security 'group' extending BaseJetspeedPrincipal.</p>
+ * @version $Id: GroupImpl.java 695798 2008-09-16 09:48:31Z ate $
+ */
+@Entity (name="Group")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="SECURITY_PRINCIPAL")
+@DiscriminatorColumn (name="PRINCIPAL_TYPE")
+@DiscriminatorValue (value=JetspeedPrincipalType.GROUP)
+public class GroupImpl extends PersistentJetspeedPrincipal implements Group
+{
+	private static final long serialVersionUID = 5484179899807809619L;
+
+    public GroupImpl()
+    {
+        super();
+    }
+    
+	public GroupImpl(String name)
+	{
+		super(name);
+	}
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,211 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.security.jpa;
+
+import java.util.List;
+
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.GroupManager;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.AbstractGroupManagerImpl;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Implements the service interface for managing Jetsped Security Groups.
+ *
+ * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: GroupManagerImpl.java 702099 2008-10-06 11:13:38Z ate $
+ */
+@Repository
+public class GroupManagerImpl extends AbstractGroupManagerImpl implements GroupManager
+{
+    private static final long serialVersionUID = -438359072678093276L;
+
+    public GroupManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType roleType, 
+                            JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
+    {
+        super(principalType, userType, roleType, jpam, jpsm);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.GroupManager#newGroup(java.lang.String, boolean)
+     */
+    public Group newGroup(String name, boolean mapped)
+    {
+        GroupImpl group = new GroupImpl(name);
+        group.setMapped(mapped);
+        return group;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#addGroup(java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public Group addGroup(String groupName) throws SecurityException
+    {
+        return super.addGroup(groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#addGroup(java.lang.String, boolean)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public Group addGroup(String groupName, boolean mapped) throws SecurityException
+    {
+        return super.addGroup(groupName, mapped);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#removeGroup(java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void removeGroup(String groupName) throws SecurityException
+    {
+        super.removeGroup(groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#groupExists(java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public boolean groupExists(String groupName)
+    {
+        return super.groupExists(groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroup(java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public Group getGroup(String groupName) throws SecurityException
+    {
+        return super.getGroup(groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroupsForUser(java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public List<Group> getGroupsForUser(String username) throws SecurityException
+    {
+        return super.getGroupsForUser(username);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroupsInRole(java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public List<Group> getGroupsInRole(String roleName) throws SecurityException
+    {
+        return super.getGroupsInRole(roleName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#addUserToGroup(java.lang.String, java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void addUserToGroup(String username, String groupName) throws SecurityException
+    {
+        super.addUserToGroup(username, groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#removeUserFromGroup(java.lang.String, java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void removeUserFromGroup(String username, String groupName) throws SecurityException
+    {
+        super.removeUserFromGroup(username, groupName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#isUserInGroup(java.lang.String, java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public boolean isUserInGroup(String username, String groupName) throws SecurityException
+    {
+        return super.isUserInGroup(username, groupName);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroups(java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public List<Group> getGroups(String nameFilter) throws SecurityException
+    {
+        return super.getGroups(nameFilter);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroupNames(java.lang.String)
+     */
+    @Transactional (readOnly=true, rollbackFor=SecurityException.class)
+    public List<String> getGroupNames(String nameFilter) throws SecurityException
+    {
+        return super.getGroupNames(nameFilter);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#updateGroup(org.apache.jetspeed.security.Group)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void updateGroup(Group group) throws SecurityException
+    {
+        super.updateGroup(group);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#addGroupToGroup(org.apache.jetspeed.security.Group, org.apache.jetspeed.security.Group, java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void addGroupToGroup(Group from, Group to, String associationName) throws SecurityException
+    {
+        super.addGroupToGroup(from, to, associationName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#removeGroupFromGroup(org.apache.jetspeed.security.Group, org.apache.jetspeed.security.Group, java.lang.String)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void removeGroupFromGroup(Group from, Group to, String associationName) throws SecurityException
+    {
+        super.removeGroupFromGroup(from, to, associationName);
+    }
+   
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroupsAssociatedTo(org.apache.jetspeed.security.Group, java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public List<Group> getGroupsAssociatedTo(Group to, String associationName)
+    {
+        return super.getGroupsAssociatedTo(to, associationName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractGroupManagerImpl#getGroupsAssociatedFrom(org.apache.jetspeed.security.Group, java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public List<Group> getGroupsAssociatedFrom(Group from, String associationName)
+    {
+        return super.getGroupsAssociatedFrom(from, associationName);
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PermissionManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PermissionManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PermissionManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PermissionManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package org.apache.jetspeed.security.jpa;
+
+import java.security.Permissions;
+import java.security.Principal;
+import java.security.Permission;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.jetspeed.security.PermissionManager;
+import org.apache.jetspeed.security.JetspeedPermission;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl;
+import org.apache.jetspeed.security.spi.JetspeedPermissionAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPermissionStorageManager;
+import org.apache.jetspeed.security.spi.PersistentJetspeedPermission;
+import org.apache.jetspeed.security.spi.impl.JetspeedPermissionFactory;
+import org.apache.jetspeed.security.spi.jpa.PersistentJetspeedPermissionImpl;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @version $Id: PermissionManagerImpl.java 700986 2008-10-02 02:00:17Z ate $
+ *
+ */
+@Repository
+public class PermissionManagerImpl extends AbstractPermissionManagerImpl implements PermissionManager
+{
+    public PermissionManagerImpl(List<JetspeedPermissionFactory> factories, JetspeedPermissionAccessManager jpam, JetspeedPermissionStorageManager jpsm)
+    {
+        super(factories, jpam, jpsm);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionFactory#newPermission(java.lang.String, java.lang.String, java.lang.String)
+     */
+    public JetspeedPermission newPermission(String type, String name, String actions)
+    {
+        return factoryMap.get(type).newPermission(new PersistentJetspeedPermissionImpl(type, name), actions);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionFactory#newPermission(java.lang.String, java.lang.String, int)
+     */
+    public JetspeedPermission newPermission(String type, String name, int mask)
+    {
+        return factoryMap.get(type).newPermission(new PersistentJetspeedPermissionImpl(type, name), mask);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionManager#getPermissions(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @SuppressWarnings("unchecked") 
+    @Transactional (readOnly=true)
+    public Permissions getPermissions(JetspeedPrincipal principal)
+    {
+        Permissions permissions = null;
+        if (principal instanceof PersistentJetspeedPrincipal && ((PersistentJetspeedPrincipal)principal).getId() != null)
+        {
+            HashMap<Long,Permissions> permissionsMap = getPermissionsMap();
+            Long id = ((PersistentJetspeedPrincipal)principal).getId();
+            permissions = permissionsMap.get(id);
+            if (permissions == null)
+            {
+                permissions = new Permissions();
+                List<PersistentJetspeedPermission> permList = (List<PersistentJetspeedPermission>)jpam.getPermissions((PersistentJetspeedPrincipal)principal);        
+                for (PersistentJetspeedPermission p : permList)
+                {
+                    permissions.add(factoryMap.get(p.getType()).newPermission(p));
+                }
+                permissionsMap.put(id, permissions);
+            }
+        }
+        else
+        {
+            permissions = new Permissions();
+        }
+        return permissions;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.PermissionManager#getPermissions(java.security.Principal[])
+     */
+    @SuppressWarnings("unchecked") 
+    @Transactional (readOnly=true)
+    public Permissions getPermissions(Principal[] principals)
+    {
+        Permissions allPermissions = new Permissions();
+        HashMap<Long,Permissions> permissionsMap = null;
+        for (Principal principal : principals)
+        {
+            if (principal instanceof PersistentJetspeedPrincipal && ((PersistentJetspeedPrincipal)principal).getId() != null)
+            {
+                if (permissionsMap == null)
+                {
+                    permissionsMap = getPermissionsMap();
+                }
+                Long id = ((PersistentJetspeedPrincipal)principal).getId();
+                Permissions permissions = permissionsMap.get(id);
+                if (permissions == null)
+                {
+                    permissions = new Permissions();
+                    List<PersistentJetspeedPermission> permList = (List<PersistentJetspeedPermission>)jpam.getPermissions((PersistentJetspeedPrincipal)principal);        
+                    for (PersistentJetspeedPermission p : permList)
+                    {
+                        permissions.add(factoryMap.get(p.getType()).newPermission(p));
+                    }
+                    permissionsMap.put(id, permissions);
+                }
+                for (Enumeration<Permission> e = permissions.elements(); e.hasMoreElements(); )
+                {
+                    allPermissions.add(e.nextElement());
+                }
+            }
+        }
+        return allPermissions;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#permissionExists(org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Transactional (readOnly=true)
+    public boolean permissionExists(JetspeedPermission permission)
+    {
+        return super.permissionExists(permission);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#getPermissions()
+     */
+    @Transactional (readOnly=true)
+    public List<JetspeedPermission> getPermissions()
+    {
+        return super.getPermissions();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#getPermissions(java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public List<JetspeedPermission> getPermissions(String typeName)
+    {
+        return super.getPermissions(typeName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#getPermissions(java.lang.String, java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public List<JetspeedPermission> getPermissions(String typeName, String nameFilter)
+    {
+        return super.getPermissions(typeName, nameFilter);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#getPrincipals(org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Transactional (readOnly=true)
+    public List<JetspeedPrincipal> getPrincipals(JetspeedPermission permission)
+    {
+        return super.getPrincipals(permission);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#getPrincipals(org.apache.jetspeed.security.JetspeedPermission, java.lang.String)
+     */
+    @Transactional (readOnly=true)
+    public List<JetspeedPrincipal> getPrincipals(JetspeedPermission permission, String principalType)
+    {
+        return super.getPrincipals(permission, principalType);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#addPermission(org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void addPermission(JetspeedPermission permission) throws SecurityException
+    {
+        super.addPermission(permission);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#removePermission(org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void removePermission(JetspeedPermission permission) throws SecurityException
+    {
+        super.removePermission(permission);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#updatePermission(org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void updatePermission(JetspeedPermission permission) throws SecurityException
+    {
+        super.updatePermission(permission);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#grantPermission(org.apache.jetspeed.security.JetspeedPermission, org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void grantPermission(JetspeedPermission permission, JetspeedPrincipal principal) throws SecurityException
+    {
+        super.grantPermission(permission, principal);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#revokePermission(org.apache.jetspeed.security.JetspeedPermission, org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void revokePermission(JetspeedPermission permission, JetspeedPrincipal principal) throws SecurityException
+    {
+        super.revokePermission(permission, principal);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#grantPermissionOnlyTo(org.apache.jetspeed.security.JetspeedPermission, java.util.List)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void grantPermissionOnlyTo(JetspeedPermission permission, List<JetspeedPrincipal> principals) throws SecurityException
+    {
+        super.grantPermissionOnlyTo(permission, principals);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#grantPermissionOnlyTo(org.apache.jetspeed.security.JetspeedPermission, java.lang.String, java.util.List)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void grantPermissionOnlyTo(JetspeedPermission permission, String principalType, List<JetspeedPrincipal> principals) throws SecurityException
+    {
+        super.grantPermissionOnlyTo(permission, principalType, principals);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.AbstractPermissionManagerImpl#revokeAllPermissions(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Transactional (readOnly=false, rollbackFor=SecurityException.class)
+    public void revokeAllPermissions(JetspeedPrincipal principal) throws SecurityException
+    {
+        super.revokeAllPermissions(principal);
+    }
+}



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


Mime
View raw message