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 [1/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
Author: rwatler
Date: Sun Feb  8 21:28:35 2009
New Revision: 742172

URL: http://svn.apache.org/viewvc?rev=742172&view=rev
Log:
JPA/OpenJPA Implementation of Security Component Persistence
------------------------------------------------------------
- add support for JPA/OpenJPA persistence using same approaches used with other component projects
- upgrade to Spring Framework 2.5.3 to correct bean cyclic reference bug with transactional proxy injection
- abstract various permissions and principal managers classes to aggregate adn reuse common persistence layer code between OJB and JPA impls
- construct portal roles for subject population in default and JBoss login modules using role manager to insulate it from OJB and JPA impls
- update security schema by adding conventional JPA_VERSION fields to tables
- fix minor bugs in other JPA component impls


Added:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractGroupManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractPermissionManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractRoleManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractTransientJetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractUserManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValueImpl.java
      - copied, changed from r736476, portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/GroupManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PermissionManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/PersistentJetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/RoleManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueCollection.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityAttributeValueImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/SecurityDomainImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/jpa/UserManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialPolicyManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedPrincipalAssociation.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedPrincipalPermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/OpenJPAJetspeedSecurityPersistenceManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/PasswordCredentialImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/PersistentJetspeedPermissionImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/SecurityManagerContext.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/UserPasswordCredentialManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/UserPasswordCredentialPolicyManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/resources/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/resources/META-INF/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/resources/META-INF/persistence.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPAGroupManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPALoginModule.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPAPermissionManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPARdbmsPolicy.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPARdbmsPolicyFolder.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPARoleManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestOpenJPAUserManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jndi.properties
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jpa-security.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/log4j.properties
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/openjpa-security.xml
Removed:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java
Modified:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/pom.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/OpenJPADatabasePageManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/pom.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/util/DatasourceEnabledSpringTestCase.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/pom.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/jpa/PortletPreferencesProviderImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/pom.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/JETSPEED-INF/ojb/security_repository.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/DefaultLoginModule.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LoginModuleProxyImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PermissionManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ext/JBossLoginModule.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPermissionAccessManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FolderPermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/FragmentPermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPermissionFactory.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PagePermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/PortletPermission.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialPolicyManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/TestRdbmsPolicyFolder.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/security/LoginModuleProxy.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/ddl-schema/security-schema.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/resources/assembly/security-atn.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/resources/ddl/mssql/create-schema.sql
    portals/jetspeed-2/portal/branches/JPA_BRANCH/pom.xml

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/pom.xml?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/pom.xml Sun Feb  8 21:28:35 2009
@@ -197,7 +197,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.om.page.jpa</id>
@@ -217,7 +217,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.page.document.jpa</id>
@@ -237,7 +237,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.page.jpa</id>
@@ -257,7 +257,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/OpenJPADatabasePageManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/OpenJPADatabasePageManagerImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/OpenJPADatabasePageManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/OpenJPADatabasePageManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -117,6 +117,10 @@
         {
             openJPAEventManager.removeListener(listener);
         }
+        // terminate access to OpenJPA components
+        openJPAEventManager = null;
+        openJPASystemDataCache = null;
+        listener = null;
     }    
 
     // Implementation

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/pom.xml?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/pom.xml Sun Feb  8 21:28:35 2009
@@ -163,7 +163,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.profiler.jpa</id>
@@ -183,7 +183,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java Sun Feb  8 21:28:35 2009
@@ -32,6 +32,12 @@
     private AbstractProfilingRule profilingRule;
     private List<RuleCriterion> criterionList;
 
+    /**
+     * Construct list to maintain JPA inverse relationship.
+     *
+     * @param profilingRule owning profile rule.
+     * @param criterionList managed criterion list.
+     */
     RuleCriterionList(AbstractProfilingRule profilingRule, List<RuleCriterion> criterionList)
     {
         super();

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/util/DatasourceEnabledSpringTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/util/DatasourceEnabledSpringTestCase.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/util/DatasourceEnabledSpringTestCase.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/util/DatasourceEnabledSpringTestCase.java Sun Feb  8 21:28:35 2009
@@ -67,7 +67,7 @@
         {
             super.tearDown();
         }
-        catch (Exception e)
+        finally
         {
             try
             {
@@ -76,8 +76,7 @@
             catch (Exception ignore)
             {                
             }
-            throw e;
-        }        
+        }
     }
 
     protected String[] getBootConfigurations()

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/pom.xml?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/pom.xml Sun Feb  8 21:28:35 2009
@@ -189,7 +189,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.components.portletentity.jpa</id>
@@ -209,7 +209,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.components.portletpreferences.jpa</id>
@@ -229,7 +229,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                     <execution>
                         <id>org.apache.jetspeed.components.portletregistry.jpa</id>
@@ -249,7 +249,7 @@
                                     <value>true</value>
                                 </property>
                             </toolProperties>
-                        </configuration>                  
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/jpa/PortletPreferencesProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/jpa/PortletPreferencesProviderImpl.java?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/jpa/PortletPreferencesProviderImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/jpa/PortletPreferencesProviderImpl.java Sun Feb  8 21:28:35 2009
@@ -252,7 +252,7 @@
         String portletName = pd.getPortletName();
         // perform delete
         EntityManager entityManager = getEntityManager();
-        Query portletPreferencesDelete = entityManager.createNamedQuery("DELETE_PORTLET_APPLICATION_PREFERENCES");
+        Query portletPreferencesDelete = entityManager.createNamedQuery("DELETE_PORTLET_PREFERENCES");
         portletPreferencesDelete.setParameter("dtype", DISCRIMINATOR_PORTLET);
         portletPreferencesDelete.setParameter("applicationName", applicationName);
         portletPreferencesDelete.setParameter("portletName", portletName);

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/pom.xml?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/pom.xml Sun Feb  8 21:28:35 2009
@@ -167,6 +167,52 @@
                     </execution>
                 </executions>
             </plugin>
+ 	        <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>org.apache.jetspeed.security.spi.jpa</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                        <configuration>
+                            <classes>${project.build.directory}/classes/org/apache/jetspeed/security/spi/jpa</classes>
+                            <toolProperties>                      	 
+                                <property>
+                                    <name>addDefaultConstructor</name>
+                                    <value>true</value>
+                                </property>
+                                <property>
+                                    <name>enforcePropertyRestrictions</name>
+                                    <value>true</value>
+                                </property>
+                            </toolProperties>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>org.apache.jetspeed.security.jpa</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                        <configuration>
+                            <classes>${project.build.directory}/classes/org/apache/jetspeed/security/jpa</classes>
+                            <toolProperties>                      	 
+                                <property>
+                                    <name>addDefaultConstructor</name>
+                                    <value>true</value>
+                                </property>
+                                <property>
+                                    <name>enforcePropertyRestrictions</name>
+                                    <value>true</value>
+                                </property>
+                            </toolProperties>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <testResources>
             <testResource>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/JETSPEED-INF/ojb/security_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/JETSPEED-INF/ojb/security_repository.xml?rev=742172&r1=742171&r2=742172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/JETSPEED-INF/ojb/security_repository.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/JETSPEED-INF/ojb/security_repository.xml Sun Feb  8 21:28:35 2009
@@ -296,7 +296,7 @@
           column="domain_id"/>
       <collection-descriptor
           name="attributes"
-          element-class-ref="org.apache.jetspeed.security.impl.SecurityAttributeValue"
+          element-class-ref="org.apache.jetspeed.security.impl.SecurityAttributeValueImpl"
           auto-retrieve="true"
           auto-update="true"
           auto-delete="none"
@@ -336,7 +336,7 @@
    - S E C U R I T Y   A T T R I B U T E S
    -->
   <class-descriptor
-      class="org.apache.jetspeed.security.impl.SecurityAttributeValue"
+      class="org.apache.jetspeed.security.impl.SecurityAttributeValueImpl"
       table="SECURITY_ATTRIBUTE"
   >
       <documentation>Represents a Security Principal Attribute definition.</documentation>

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractGroupManagerImpl.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/AbstractGroupManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractGroupManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractGroupManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,278 @@
+/* 
+ * 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.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: GroupManagerImpl.java 702099 2008-10-06 11:13:38Z ate $
+ */
+public abstract class AbstractGroupManagerImpl extends BaseJetspeedPrincipalManager implements GroupManager
+{
+    private static final long serialVersionUID = 8602530495755862863L;
+
+    /** The logger. */
+    private static final Log log = LogFactory.getLog(AbstractGroupManagerImpl.class);
+
+    protected JetspeedPrincipalType userType;
+    protected JetspeedPrincipalType roleType;
+    protected UserManager userManager;
+    
+    protected AbstractGroupManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType roleType, 
+                                       JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
+    {
+        super(principalType, jpam, jpsm);
+        this.userType = userType;
+        this.roleType = roleType;
+    }
+    
+    private void checkInitialized()
+    {    	
+    	if (userManager == null)
+    	{
+        	userManager = (UserManager)getPrincipalManagerProvider().getManager(userType);
+    	}
+    }      
+    
+    /* (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);
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractPermissionManagerImpl.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/AbstractPermissionManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractPermissionManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractPermissionManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,164 @@
+/*
+ * 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.impl;
+
+import java.security.Permissions;
+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.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;
+
+/**
+ * @version $Id: PermissionManagerImpl.java 700986 2008-10-02 02:00:17Z ate $
+ *
+ */
+public abstract class AbstractPermissionManagerImpl implements PermissionManager
+{
+    protected HashMap<String, JetspeedPermissionFactory> factoryMap = new HashMap<String, JetspeedPermissionFactory>();
+    protected JetspeedPermissionAccessManager jpam;
+    protected JetspeedPermissionStorageManager jpsm;
+
+    private static ThreadLocal<HashMap<Long,Permissions>> permissionsCache = new ThreadLocal<HashMap<Long,Permissions>>();
+    
+    protected AbstractPermissionManagerImpl(List<JetspeedPermissionFactory> factories, JetspeedPermissionAccessManager jpam, JetspeedPermissionStorageManager jpsm)
+    {
+        for (JetspeedPermissionFactory pf : factories)
+        {
+            factoryMap.put(pf.getType(), pf);
+        }
+        this.jpam = jpam;
+        this.jpsm = jpsm;
+    }
+    
+    protected 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();
+        }
+    }
+    
+    public int parseActions(String actions)
+    {
+        return JetspeedActions.getContainerActionsMask(actions);
+    }
+    
+    @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();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractRoleManagerImpl.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/AbstractRoleManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractRoleManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractRoleManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,337 @@
+/* 
+ * 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.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: RoleManagerImpl.java 702099 2008-10-06 11:13:38Z ate $
+ */
+public abstract class AbstractRoleManagerImpl extends BaseJetspeedPrincipalManager implements RoleManager
+{
+    private static final long serialVersionUID = 3461703672327948090L;
+
+    /** The logger. */
+    private static final Log log = LogFactory.getLog(AbstractRoleManagerImpl.class);
+    
+    protected JetspeedPrincipalType userType;
+    protected JetspeedPrincipalType groupType;
+    protected UserManager userManager;
+    protected GroupManager groupManager;
+    
+    protected AbstractRoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType userType, JetspeedPrincipalType groupType,
+                                      JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm)
+    {
+        super(principalType, jpam, jpsm);
+        this.userType = userType;
+        this.groupType = groupType;
+    }
+    
+    private void checkInitialized()
+    {    	
+    	if (userManager == null)
+    	{
+    		userManager = (UserManager)getPrincipalManagerProvider().getManager(userType);
+    	}
+    	if (groupManager == null)
+    	{
+    		groupManager = (GroupManager)getPrincipalManagerProvider().getManager(groupType);
+    	}
+    }
+    
+    /* (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);
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractTransientJetspeedPrincipal.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/AbstractTransientJetspeedPrincipal.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractTransientJetspeedPrincipal.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractTransientJetspeedPrincipal.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,167 @@
+/*
+ * 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.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;
+
+/**
+ * AbstractTransientJetspeedPrincipal
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public abstract class AbstractTransientJetspeedPrincipal implements JetspeedPrincipal, Serializable
+{
+    private static final long serialVersionUID = -3222995278900548238L;
+
+    protected static JetspeedPrincipalManagerProvider jpmp;
+
+    public static void setJetspeedPrincipalManagerProvider(JetspeedPrincipalManagerProvider jpmp)
+    {
+        TransientJetspeedPrincipal.jpmp = jpmp;
+    }
+    
+    protected transient JetspeedPrincipalType jpt;
+    protected transient SecurityAttributes sa;
+    
+    protected AbstractTransientJetspeedPrincipal()
+    {
+        setTypeName((jpmp != null) ? jpmp.getPrincipalTypeByClassName(getClass().getName()).getName() : null);
+    }
+    
+    protected AbstractTransientJetspeedPrincipal(String type)
+    {
+        setTypeName(type);
+    }
+    
+    public Long getId()
+    {
+        return null;
+    }
+
+    public abstract String getTypeName();
+
+    public abstract void setTypeName(String type);
+
+    public abstract String getName();
+
+    public synchronized JetspeedPrincipalType getType()
+    {
+        if (jpt == null)
+        {
+            jpt = jpmp.getPrincipalType(getTypeName());
+        }
+        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;
+    }
+    
+    public void setRemovable(boolean removable)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean isExtendable()
+    {
+        return true;
+    }
+    
+    public void setExtendable(boolean extendable)
+    {
+        throw new UnsupportedOperationException();
+    }
+    
+    public synchronized SecurityAttributes getSecurityAttributes()
+    {
+        if (sa == null)
+        {
+            sa = new SecurityAttributesImpl(this);
+        }
+        return sa;
+    }
+    
+    public Map<String, String> getInfoMap()
+    {
+        return getSecurityAttributes().getInfoMap();
+    }
+
+    public String toString()
+    {
+        return getType().getName()+": "+getName()+" (id: "+(getId())+", transient: "+isTransient()+", mapped: "+isMapped()+")";
+    }
+    
+    public abstract Long getDomainId();
+
+    public abstract void setDomainId(Long domainId);
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractUserManagerImpl.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/AbstractUserManagerImpl.java?rev=742172&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractUserManagerImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/AbstractUserManagerImpl.java Sun Feb  8 21:28:35 2009
@@ -0,0 +1,265 @@
+/* 
+ * 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.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: UserManagerImpl.java 721251 2008-11-27 17:55:08Z woonsan $
+ */
+public abstract class AbstractUserManagerImpl extends BaseJetspeedPrincipalManager implements UserManager, UserSubjectPrincipalsProvider
+{
+    private static final long serialVersionUID = -5582007187364289034L;
+
+    private static final Log log = LogFactory.getLog(AbstractUserManagerImpl.class);
+
+	protected String anonymousUser = "guest";
+	protected JetspeedPrincipalType roleType;
+	protected JetspeedPrincipalType groupType;
+
+	protected UserPasswordCredentialManager credentialManager;
+	protected RoleManager roleManager;
+	protected GroupManager groupManager;
+	protected Map<String, UserSubjectPrincipalsResolver> usprMap = new HashMap<String, UserSubjectPrincipalsResolver>();
+
+	protected AbstractUserManagerImpl(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;
+	}
+
+	private 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);
+	}
+
+    @SuppressWarnings("unchecked")
+	public List<User> getUsers(String nameFilter) throws SecurityException
+	{
+		return (List<User>) getPrincipals(nameFilter);
+	}
+
+    @SuppressWarnings("unchecked")
+	public List<User> getUsersInGroup(String groupFullPathName) throws SecurityException
+	{
+		return (List<User>) super.getAssociatedTo(groupFullPathName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
+	}
+
+    @SuppressWarnings("unchecked")
+	public List<User> getUsersInRole(String roleFullPathName) throws SecurityException
+	{
+		return (List<User>) super.getAssociatedTo(roleFullPathName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
+	}
+
+    @SuppressWarnings("unchecked")
+    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;
+	}
+
+	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);
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/DefaultLoginModule.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/DefaultLoginModule.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/DefaultLoginModule.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/DefaultLoginModule.java Sun Feb  8 21:28:35 2009
@@ -33,6 +33,7 @@
 import org.apache.jetspeed.security.AuthenticatedUser;
 import org.apache.jetspeed.security.LoginModuleProxy;
 import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.SubjectHelper;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
@@ -84,6 +85,9 @@
     /** <p>InternalUserPrincipal manager service.</p> */
     protected UserManager ums;
     
+    /** <p>InternalRolePrincipal manager service.</p> */
+    protected RoleManager rms;
+    
     /** The portal user role. */
     protected String portalUserRole;
 
@@ -103,6 +107,7 @@
         {
             this.authProvider = loginModuleProxy.getAuthenticationProvider();
             this.ums = loginModuleProxy.getUserManager();
+            this.rms = loginModuleProxy.getRoleManager();
             this.portalUserRole = loginModuleProxy.getPortalUserRole();
         }
         debug = false;
@@ -115,21 +120,23 @@
     /**
      * Create a new login module that uses the given user manager.
      * @param userManager the user manager to use
+     * @param roleManager the role manager to use
      * @param portalUserRole the portal user role to use
      */
-    protected DefaultLoginModule (AuthenticationProvider authProvider, UserManager userManager, String portalUserRole) 
+    protected DefaultLoginModule (AuthenticationProvider authProvider, UserManager userManager, RoleManager roleManager, String portalUserRole) 
     {
         this.authProvider = authProvider;
         this.ums = userManager;
+        this.rms = roleManager;
         this.portalUserRole = portalUserRole;
         debug = false;
         success = false;
         commitSuccess = false;
         username = null;
     }
-    protected DefaultLoginModule (AuthenticationProvider authProvider, UserManager userManager) 
+    protected DefaultLoginModule (AuthenticationProvider authProvider, UserManager userManager, RoleManager roleManager) 
     {
-        this(authProvider, userManager, LoginModuleProxy.DEFAULT_PORTAL_USER_ROLE_NAME);
+        this(authProvider, userManager, roleManager, LoginModuleProxy.DEFAULT_PORTAL_USER_ROLE_NAME);
     }
     
     /**
@@ -315,7 +322,7 @@
         {
             // add portal user role: used in web.xml authorization to
             // detect authenticated portal users
-            subject.getPrincipals().add(new RoleImpl(portalUserRole));        
+            subject.getPrincipals().add(rms.newRole(portalUserRole, false));
         }
     }
 }



---------------------------------------------------------------------
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