portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r742669 [1/2] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: components/jetspeed-capability/src/test/resources/ components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/ components/jetspeed-page-manager/src/test/resourc...
Date Mon, 09 Feb 2009 18:37:07 GMT
Author: rwatler
Date: Mon Feb  9 18:37:05 2009
New Revision: 742669

URL: http://svn.apache.org/viewvc?rev=742669&view=rev
Log:
JPA SSO Component Integration
------------------------------------------
- support JPA version of SSO component and implement unit tests for same
- abstract OJB and JPA SSO components where possible to maximize reuse
- use custom Spring MergingPersistenceUnitManager to support extension of security persistence
  unit with SSO and to enable future similar extension of other JPA persistent units
- complete OJB and JPA isolation of persisitent security object model


Added:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/jpa/MergingPersistenceUnitManager.java
    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-sso/src/main/java/org/apache/jetspeed/sso/jpa/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOSiteImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOUserImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/AbstractSSOUserManagerSPIImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/jpa/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/jpa/JetspeedPersistentSSOSiteManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/jpa/SSOUserManagerSPIImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/resources/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/resources/META-INF/
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/resources/META-INF/persistence.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestOpenJPASSOComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestOpenJPASSOManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/resources/jndi.properties
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/resources/jpa-sso.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/resources/log4j.properties
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/resources/openjpa-sso.xml
Modified:
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/test/resources/jpa-capabilities.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/resources/jpa-database-page-manager.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/test/resources/jpa-registry.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/ext/JBossLoginModule.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SecurityDomainStorageManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/UserPasswordCredentialStorageManager.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/JetspeedSecurityPersistenceManager.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/serializer/JetspeedSecuritySerializer.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/resources/jpa-security.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/pom.xml
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOManagerImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/SSOSiteManagerSPI.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/JetspeedPersistentSSOSiteManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/SSOUserManagerSPIImpl.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/AbstractSecurityTestCase.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOComponent.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java
    portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityDomain.java

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/test/resources/jpa-capabilities.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/test/resources/jpa-capabilities.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/test/resources/jpa-capabilities.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-capability/src/test/resources/jpa-capabilities.xml Mon Feb  9 18:37:05 2009
@@ -30,7 +30,7 @@
     </bean>
 
     <!-- JPA Configuration -->
-    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+    <bean id="persistenceUnitManager" class="org.apache.jetspeed.components.rdbms.jpa.MergingPersistenceUnitManager">
         <property name="dataSources">
             <map>
                 <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/java/org/apache/jetspeed/page/PageManagerTestShared.java Mon Feb  9 18:37:05 2009
@@ -78,6 +78,7 @@
 import org.apache.jetspeed.security.SecurityAttributeTypes;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.impl.TransientJetspeedPrincipal;
+import org.apache.jetspeed.security.spi.PersistentJetspeedPermission;
 import org.apache.jetspeed.security.spi.impl.FolderPermission;
 import org.apache.jetspeed.security.spi.impl.FragmentPermission;
 import org.apache.jetspeed.security.spi.impl.JetspeedPermissionFactory;
@@ -807,6 +808,7 @@
     {
         private static final SecurityAttributeTypes attributeTypes = new SecurityAttributeTypes()
         {
+            private static final long serialVersionUID = 1L;
 
             public Map<String, SecurityAttributeType> getAttributeTypeMap()
             {
@@ -839,6 +841,8 @@
             super(type, name);
             this.type = new JetspeedPrincipalType()
             {               
+                private static final long serialVersionUID = 1L;
+
                 public SecurityAttributeTypes getAttributeTypes()
                 {
                     return attributeTypes;
@@ -888,6 +892,45 @@
         }
     }
     
+    public static class TestPermission implements PersistentJetspeedPermission
+    {
+        private static final long serialVersionUID = 1L;
+        private String type; 
+        private String name; 
+        private String actions; 
+
+        public TestPermission(String type, String name)
+        {
+            this.type = type;
+            this.name = name;
+        }
+
+        public Long getId()
+        {
+            return null;
+        }
+
+        public void setActions(String actions)
+        {
+            this.actions = actions;
+        }
+
+        public String getActions()
+        {
+            return actions;
+        }
+
+        public String getName()
+        {
+            return name;
+        }
+
+        public String getType()
+        {
+            return type;
+        }        
+    }
+    
     public static class TestPermissionFactory implements PermissionFactory
     {
         private static Map<String, JetspeedPermissionFactory> factories = new HashMap<String, JetspeedPermissionFactory>();
@@ -900,12 +943,12 @@
 
         public JetspeedPermission newPermission(String type, String name, String actions)
         {
-            return factories.get(type).newPermission(name, actions);
+            return factories.get(type).newPermission(new TestPermission(type, name), actions);            
         }
 
         public JetspeedPermission newPermission(String type, String name, int mask)
         {
-            return factories.get(type).newPermission(name, mask);
+            return factories.get(type).newPermission(new TestPermission(type, name), mask);            
         }
 
         public int parseActions(String actions)

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/resources/jpa-database-page-manager.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/resources/jpa-database-page-manager.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/resources/jpa-database-page-manager.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/test/resources/jpa-database-page-manager.xml Mon Feb  9 18:37:05 2009
@@ -30,7 +30,7 @@
     </bean>
 
     <!-- JPA Configuration -->
-    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+    <bean id="persistenceUnitManager" class="org.apache.jetspeed.components.rdbms.jpa.MergingPersistenceUnitManager">
         <property name="dataSources">
             <map>
                 <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml Mon Feb  9 18:37:05 2009
@@ -30,7 +30,7 @@
     </bean>
 
     <!-- JPA Configuration -->
-    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+    <bean id="persistenceUnitManager" class="org.apache.jetspeed.components.rdbms.jpa.MergingPersistenceUnitManager">
         <property name="dataSources">
             <map>
                 <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/jpa/MergingPersistenceUnitManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/jpa/MergingPersistenceUnitManager.java?rev=742669&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/jpa/MergingPersistenceUnitManager.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/rdbms/jpa/MergingPersistenceUnitManager.java Mon Feb  9 18:37:05 2009
@@ -0,0 +1,140 @@
+/*
+ * 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.components.rdbms.jpa;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager;
+import org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo;
+
+/**
+ * MergingPersistenceUnitManager
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class MergingPersistenceUnitManager extends DefaultPersistenceUnitManager
+{
+    private static final Log logger = LogFactory.getLog(MergingPersistenceUnitManager.class);
+
+    /**
+     * Default constructor.
+     */
+    public MergingPersistenceUnitManager()
+    {
+    }
+    
+    /* (non-Javadoc)
+     * @see org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager#postProcessPersistenceUnitInfo(org.springframework.orm.jpa.persistenceunit.MutablePersistenceUnitInfo)
+     */
+    protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo persistenceUnitInfo)
+    {
+        // post process persistence unit information normally
+        super.postProcessPersistenceUnitInfo(persistenceUnitInfo);
+        
+        // merge existing persistence unit information into current;
+        // normally, only last persistence unit information is used
+        String persistenceUnitName = persistenceUnitInfo.getPersistenceUnitName();
+        MutablePersistenceUnitInfo existingPersistenceUnitInfo = getPersistenceUnitInfo(persistenceUnitName);
+        if (existingPersistenceUnitInfo != null)
+        {
+            boolean merged = false;
+            boolean mergeConflict = false;
+            
+            // merge jar file urls
+            for (URL jarFileUrl : existingPersistenceUnitInfo.getJarFileUrls())
+            {
+                if (!persistenceUnitInfo.getJarFileUrls().contains(jarFileUrl))
+                {
+                    persistenceUnitInfo.addJarFileUrl(jarFileUrl);
+                    merged = true;
+                }
+            }
+            
+            // merge managed class names
+            for (String managedClassName : existingPersistenceUnitInfo.getManagedClassNames())
+            {
+                if (!persistenceUnitInfo.getManagedClassNames().contains(managedClassName))
+                {
+                    persistenceUnitInfo.addManagedClassName(managedClassName);
+                    merged = true;
+                }
+            }
+
+            // merge mapping file names
+            for (String mappingFileNames : existingPersistenceUnitInfo.getMappingFileNames())
+            {
+                if (!persistenceUnitInfo.getMappingFileNames().contains(mappingFileNames))
+                {
+                    persistenceUnitInfo.addMappingFileName(mappingFileNames);
+                    merged = true;
+                }                
+            }
+
+            // merge properties
+            for (Map.Entry<Object,Object> property : existingPersistenceUnitInfo.getProperties().entrySet())
+            {
+                if (!persistenceUnitInfo.getProperties().containsKey(property.getKey()))
+                {
+                    persistenceUnitInfo.addProperty(property.getKey().toString(), property.getValue().toString());
+                    merged = true;
+                }
+                else if (!persistenceUnitInfo.getProperties().get(property.getKey()).equals(property.getValue()))
+                {
+                    mergeConflict = true;
+                }
+            }
+
+            // verify other persistence unit settings
+            if (((existingPersistenceUnitInfo.getPersistenceProviderClassName() == null) && (persistenceUnitInfo.getPersistenceProviderClassName() != null)) ||
+                ((existingPersistenceUnitInfo.getPersistenceProviderClassName() != null) && !existingPersistenceUnitInfo.getPersistenceProviderClassName().equals(persistenceUnitInfo.getPersistenceProviderClassName())))
+            {
+                mergeConflict = true;                
+            }
+            if (((existingPersistenceUnitInfo.getPersistenceProviderPackageName() == null) && (persistenceUnitInfo.getPersistenceProviderPackageName() != null)) ||
+                ((existingPersistenceUnitInfo.getPersistenceProviderPackageName() != null) && !existingPersistenceUnitInfo.getPersistenceProviderPackageName().equals(persistenceUnitInfo.getPersistenceProviderPackageName())))
+            {
+                mergeConflict = true;                
+            }
+            if (existingPersistenceUnitInfo.getTransactionType() != persistenceUnitInfo.getTransactionType())
+            {
+                mergeConflict = true;                
+            }
+            if (existingPersistenceUnitInfo.getJtaDataSource() != persistenceUnitInfo.getJtaDataSource())
+            {
+                mergeConflict = true;                
+            }
+            if (existingPersistenceUnitInfo.getNonJtaDataSource() != persistenceUnitInfo.getNonJtaDataSource())
+            {
+                mergeConflict = true;                
+            }
+            
+            // log merge and potential merge conflict
+            if (merged)
+            {
+                logger.info("Merged "+persistenceUnitName+" JPA persistence units: "+existingPersistenceUnitInfo.getPersistenceUnitRootUrl()+" and "+persistenceUnitInfo.getPersistenceUnitRootUrl());
+            }
+            if (mergeConflict)
+            {
+                logger.warn("Merge conflicts found between "+persistenceUnitName+" JPA persistence units: "+existingPersistenceUnitInfo.getPersistenceUnitRootUrl()+" and "+persistenceUnitInfo.getPersistenceUnitRootUrl());
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/test/resources/jpa-registry.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/test/resources/jpa-registry.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/test/resources/jpa-registry.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/test/resources/jpa-registry.xml Mon Feb  9 18:37:05 2009
@@ -30,7 +30,7 @@
     </bean>
 
     <!-- JPA Configuration -->
-    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+    <bean id="persistenceUnitManager" class="org.apache.jetspeed.components.rdbms.jpa.MergingPersistenceUnitManager">
         <property name="dataSources">
             <map>
                 <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>

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=742669&r1=742668&r2=742669&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 Mon Feb  9 18:37:05 2009
@@ -322,7 +322,7 @@
         {
             // add portal user role: used in web.xml authorization to
             // detect authenticated portal users
-            subject.getPrincipals().add(rms.newRole(portalUserRole, false));
+            subject.getPrincipals().add(rms.newTransientRole(portalUserRole));
         }
     }
 }

Added: 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/SecurityAttributeValue.java?rev=742669&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributeValue.java Mon Feb  9 18:37:05 2009
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+/**
+ * @version $Id: $
+ *
+ */
+public interface SecurityAttributeValue
+{
+    /**
+     * Get name of attribute.
+     * 
+     * @return attribute name.
+     */
+    public String getName();
+    
+    /**
+     * Set name of attribute.
+     * 
+     * @param attribute name.
+     */
+    public void setName(String name);
+    
+    /**
+     * Get string value of attribute.
+     * 
+     * @return attribute value.
+     */
+    public String getStringValue();
+    
+    /**
+     * Set attribute value.
+     * 
+     * @param stringValue attribute value.
+     */
+    public void setStringValue(String stringValue);
+}

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=742669&r1=742668&r2=742669&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 Mon Feb  9 18:37:05 2009
@@ -123,7 +123,7 @@
         {
             // add portal user role: used in web.xml authorization to
             // detect authenticated portal users
-            roles.addMember(rms.newRole(portalUserRole, false));        
+            roles.addMember(rms.newTransientRole(portalUserRole));        
         }
         subject.getPrincipals().add(roles);
     }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SecurityDomainStorageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SecurityDomainStorageManager.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SecurityDomainStorageManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SecurityDomainStorageManager.java Mon Feb  9 18:37:05 2009
@@ -26,6 +26,10 @@
  */
 public interface SecurityDomainStorageManager
 {
+    
+    public SecurityDomain newDomain();
+
+    public SecurityDomain copyDomain(SecurityDomain domain);
 
     public void addDomain(SecurityDomain domain) throws SecurityException;
 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/UserPasswordCredentialStorageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/UserPasswordCredentialStorageManager.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/UserPasswordCredentialStorageManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/UserPasswordCredentialStorageManager.java Mon Feb  9 18:37:05 2009
@@ -27,6 +27,7 @@
  */
 public interface UserPasswordCredentialStorageManager extends Serializable
 {
+    PasswordCredential newPasswordCredential(User user);
     PasswordCredential getPasswordCredential(User user) throws SecurityException;
     void storePasswordCredential(PasswordCredential credential) throws SecurityException;
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/AbstractUserPasswordCredentialManagerImpl.java Mon Feb  9 18:37:05 2009
@@ -48,6 +48,11 @@
         this.upcpm = upcpm;
     }
 
+    public PasswordCredential newPasswordCredential(User user)
+    {
+        return upcsm.newPasswordCredential(user);
+    }
+
     public PasswordCredential getPasswordCredential(User user) throws SecurityException
     {
         PasswordCredential credential = upcsm.getPasswordCredential(user);

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedSecurityPersistenceManager.java Mon Feb  9 18:37:05 2009
@@ -470,6 +470,14 @@
     //
     // UserPasswordCredentialStorageManager interface implementation
     //
+    
+    public PasswordCredential newPasswordCredential(User user)
+    {
+        PasswordCredentialImpl pwc = new PasswordCredentialImpl();
+        pwc.setUser(user);
+        return pwc;
+    }
+    
     public PasswordCredential getPasswordCredential(User user)
     {
         Criteria criteria = new Criteria();
@@ -977,6 +985,16 @@
         }
     }
     
+    public SecurityDomain newDomain()
+    {
+        return new SecurityDomainImpl();
+    }
+        
+    public SecurityDomain copyDomain(SecurityDomain domain)
+    {
+        return new SecurityDomainImpl((SecurityDomainImpl)domain);
+    }
+        
     public void addDomain(SecurityDomain domain) throws SecurityException 
     {
         if (domainExists(domain))

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/jpa/JetspeedSecurityPersistenceManager.java Mon Feb  9 18:37:05 2009
@@ -574,6 +574,13 @@
     // UserPasswordCredentialStorageManager interface implementation
     //
 
+    public PasswordCredential newPasswordCredential(User user)
+    {
+        PasswordCredentialImpl pwc = new PasswordCredentialImpl();
+        pwc.setUser(user);
+        return pwc;
+    }
+    
     @Transactional (readOnly=true)
     public PasswordCredential getPasswordCredential(User user)
     {
@@ -1268,6 +1275,16 @@
         }
     }
     
+    public SecurityDomain newDomain()
+    {
+        return new SecurityDomainImpl();
+    }
+
+    public SecurityDomain copyDomain(SecurityDomain domain)
+    {
+        return new SecurityDomainImpl((SecurityDomainImpl)domain);
+    }    
+        
     @Transactional (readOnly=false, rollbackFor=SecurityException.class)
     public void addDomain(SecurityDomain domain) throws SecurityException 
     {

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java Mon Feb  9 18:37:05 2009
@@ -47,7 +47,6 @@
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
-import org.apache.jetspeed.security.impl.SecurityDomainImpl;
 import org.apache.jetspeed.security.spi.SecurityDomainAccessManager;
 import org.apache.jetspeed.security.spi.SecurityDomainStorageManager;
 import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
@@ -256,7 +255,7 @@
     protected SecurityDomain checkDomainExistsOtherwiseCreate(String domainName) throws SecurityException{
         SecurityDomain domain = domainAccessManager.getDomainByName(domainName);
         if (domain == null){
-            SecurityDomainImpl newDomain = new SecurityDomainImpl();
+            SecurityDomain newDomain = domainStorageManager.newDomain();
             newDomain.setName(domainName);
             newDomain.setEnabled(true);
             newDomain.setRemote(false);
@@ -337,7 +336,7 @@
                     }
                 }
                 
-                SecurityDomainImpl newDomain = new SecurityDomainImpl();
+                SecurityDomain newDomain = domainStorageManager.newDomain();
                 newDomain.setName(jsDomain.getName());
                 newDomain.setOwnerDomainId(ownerDomainId);
                 newDomain.setRemote(jsDomain.isRemote());

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java Mon Feb  9 18:37:05 2009
@@ -34,7 +34,7 @@
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.impl.SecurityDomainImpl;
+import org.apache.jetspeed.security.SecurityDomain;
 import org.apache.jetspeed.security.spi.SecurityDomainAccessManager;
 import org.apache.jetspeed.security.spi.SecurityDomainStorageManager;
 
@@ -81,16 +81,16 @@
 
         // TODO: remove when default seed contains the default domain        
         SecurityDomain domain = domainAccessManager.getDomainByName(SecurityDomain.SYSTEM_NAME); 
-        if (domain == null){
-            
-            SecurityDomainImpl newDomain = new SecurityDomainImpl();
+        if (domain == null)
+        {
+            SecurityDomain newDomain = domainStorageManager.newDomain();
             newDomain.setName(SecurityDomain.SYSTEM_NAME);
             domainStorageManager.addDomain(newDomain);
         } 
         domain = domainAccessManager.getDomainByName(SecurityDomain.DEFAULT_NAME); 
-        if (domain == null){
-            
-            SecurityDomainImpl newDomain = new SecurityDomainImpl();
+        if (domain == null)
+        {            
+            SecurityDomain newDomain = domainStorageManager.newDomain();
             newDomain.setName(SecurityDomain.DEFAULT_NAME);
             domainStorageManager.addDomain(newDomain);
         }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jpa-security.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jpa-security.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jpa-security.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/resources/jpa-security.xml Mon Feb  9 18:37:05 2009
@@ -30,7 +30,7 @@
     </bean>
 
     <!-- JPA Configuration -->
-    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+    <bean id="persistenceUnitManager" class="org.apache.jetspeed.components.rdbms.jpa.MergingPersistenceUnitManager">
         <property name="dataSources">
             <map>
                 <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>
@@ -351,7 +351,7 @@
         <constructor-arg index="3"><value>portal-user</value></constructor-arg>
     </bean>
 
-    <!-- JPA security Manager Context -->
+    <!-- JPA Security Manager Context -->
     <bean id="securityManagerContext" class="org.apache.jetspeed.security.spi.jpa.SecurityManagerContext" scope="prototype" init-method="initialize" destroy-method="terminate">
         <property name="securityManager" ref="org.apache.jetspeed.security.spi.JetspeedSecurityPersistenceManager"/>
     </bean>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/pom.xml?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/pom.xml Mon Feb  9 18:37:05 2009
@@ -125,6 +125,52 @@
                     </execution>
                 </executions>
             </plugin>
+ 	        <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>org.apache.jetspeed.sso.spi.jpa</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                        <configuration>
+                            <classes>${project.build.directory}/classes/org/apache/jetspeed/sso/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.sso.jpa</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                        <configuration>
+                            <classes>${project.build.directory}/classes/org/apache/jetspeed/sso/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-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOManagerImpl.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOManagerImpl.java Mon Feb  9 18:37:05 2009
@@ -20,9 +20,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
 import javax.security.auth.Subject;
 
@@ -34,10 +32,8 @@
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
-import org.apache.jetspeed.security.impl.SecurityDomainImpl;
 import org.apache.jetspeed.security.spi.SecurityDomainAccessManager;
 import org.apache.jetspeed.security.spi.SecurityDomainStorageManager;
-import org.apache.jetspeed.security.spi.impl.PasswordCredentialImpl;
 import org.apache.jetspeed.sso.SSOClient;
 import org.apache.jetspeed.sso.SSOException;
 import org.apache.jetspeed.sso.SSOManager;
@@ -119,21 +115,28 @@
     public void setPassword(SSOUser user, String pwd) throws SSOException
     {
     	PasswordCredential pwdCred = null;
-    	
-    	try{
-    	    pwdCred=ssoUserManagerSPI.getPasswordCredential(user);
-    	} catch (SecurityException secex){
-    	    
+    	try
+    	{
+    	    pwdCred = ssoUserManagerSPI.getPasswordCredential(user);
     	}
-    	if (pwdCred != null){
-    	    pwdCred.setPassword(pwd, false);
-    	} else {
-            pwdCred=new PasswordCredentialImpl(user,pwd);
+    	catch (SecurityException secex)
+    	{
+            throw new SSOException(secex);
     	}
-    	
-    	try{
+    	if (pwdCred != null)
+    	{
+            pwdCred.setPassword(pwd, false);
+    	}
+    	else
+    	{
+    	    throw new SSOException("Unable to get password credential for user: "+user);
+    	}    	
+    	try
+    	{
     	    ssoUserManagerSPI.storePasswordCredential(pwdCred);
-    	} catch (SecurityException sx){
+    	}
+    	catch (SecurityException sx)
+    	{
     		throw new SSOException(sx);
     	}
     }
@@ -172,7 +175,7 @@
     		throw new SSOException(SSOException.SITE_ALREADY_EXISTS);
     	}
     	
-		SecurityDomainImpl sd = new SecurityDomainImpl();
+		SecurityDomain sd = domainStorageManager.newDomain();
     	sd.setName(site.getName());
     	sd.setOwnerDomainId(ownerDomainId);
     	sd.setEnabled(true);    	
@@ -338,7 +341,7 @@
                 throw new SSOException("Unable to rename site to '"+site.getName()+"': a security domain with that name already exists!");
             }
             SecurityDomain domain = domainAccessManager.getDomain(currentSite.getSecurityDomainId());
-            SecurityDomainImpl renamedDomain = new SecurityDomainImpl(domain);
+            SecurityDomain renamedDomain = domainStorageManager.copyDomain(domain);
             renamedDomain.setName(site.getName());
             try{
                 domainStorageManager.updateDomain(renamedDomain);    
@@ -373,8 +376,12 @@
         return ssoSiteManagerSPI.getById(id);
     }
     
-    public SSOSite newSite(String name, String url){
-        return new SSOSiteImpl(name,url);
+    public SSOSite newSite(String name, String url)
+    {
+        SSOSite site = ssoSiteManagerSPI.newSite();
+        site.setName(name);
+        site.setURL(url);
+        return site;
     }
     
     public void setUserManager(UserManager userMan)

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOSiteImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOSiteImpl.java?rev=742669&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOSiteImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOSiteImpl.java Mon Feb  9 18:37:05 2009
@@ -0,0 +1,288 @@
+/*
+ * 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.sso.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.sso.SSOSite;
+
+/**
+ * SSOSiteImpl Class holding information about the Site and credentials for
+ * Single Sign on SSO.
+ * 
+ * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id: SSOSiteImpl.java 736069 2009-01-20 19:10:43Z rwatler $
+ */
+@Entity (name="SSOSite")
+@Table (name="SSO_SITE")
+@NamedQueries ({@NamedQuery(name="SSO_SITE", query="select ss from SSOSite ss where ss.id = :id"),
+                @NamedQuery(name="SSO_SITE_NAME", query="select ss from SSOSite ss where ss.name = :name"),
+                @NamedQuery(name="SSO_SITE_URL", query="select ss from SSOSite ss where ss.url = :url"),
+                @NamedQuery(name="SSO_SITE_LIKE_URL_NAME", query="select ss from SSOSite ss where ss.url like :url or ss.name like :name"),
+                @NamedQuery(name="SSO_SITE_DOMAIN", query="select ss from SSOSite ss where ss.securityDomainId = :domainId order by ss.name asc")})
+public class SSOSiteImpl implements SSOSite
+{
+    // Members
+    
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="SITE_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    @SuppressWarnings("unused")
+    private int jpaVersion;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="URL")
+    private String url;
+    @Basic
+    @Column (name="ALLOW_USER_SET")
+    private boolean isAllowUserSet;
+    @Basic
+    @Column (name="REQUIRES_CERTIFICATE")
+    private boolean isCertificateRequired;
+    @Basic
+    @Column (name="CHALLENGE_RESPONSE_AUTH")
+    private boolean challengeResponseAuthentication;
+    @Basic
+    @Column (name="FORM_AUTH")
+    private boolean isFormAuthentication;
+    /* Configurable name of form fields for User values. */
+    @Basic
+    @Column (name="FORM_USER_FIELD")
+    private String formUserField;
+    /* Configurable name of form fields for Password values. */
+    @Basic
+    @Column (name="FORM_PWD_FIELD")
+    private String formPwdField;
+    /* Realm used to do ChallengeResponse Authentication */
+    @Basic
+    @Column (name="REALM")
+    private String realm;
+    @Basic
+    @Column (name="DOMAIN_ID")
+    private Long securityDomainId;
+
+    // Implementation
+    
+    public SSOSiteImpl()
+    {
+        super();
+    }
+    
+    public SSOSiteImpl(String name, String url)
+    {
+        this();
+        this.name=name;
+        this.url=url;
+    }
+    
+    /**
+     * @return Returns the isAllowUserSet.
+     */
+    public boolean isAllowUserSet()
+    {
+        return isAllowUserSet;
+    }
+
+    /**
+     * @param isAllowUserSet
+     *            The isAllowUserSet to set.
+     */
+    public void setAllowUserSet(boolean isAllowUserSet)
+    {
+        this.isAllowUserSet = isAllowUserSet;
+    }
+
+    /**
+     * @return Returns the isCertificateRequired.
+     */
+    public boolean isCertificateRequired()
+    {
+        return isCertificateRequired;
+    }
+
+    /**
+     * @param isCertificateRequired
+     *            The isCertificateRequired to set.
+     */
+    public void setCertificateRequired(boolean isCertificateRequired)
+    {
+        this.isCertificateRequired = isCertificateRequired;
+    }
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * @param name
+     *            The name to set.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * @return Returns the siteId.
+     */
+    public int getId()
+    {
+        return id;
+    }
+
+    /**
+     * @return sets the id of the site
+     */
+    public void setId(int id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * @return Returns the siteURL.
+     */
+    public String getURL()
+    {
+        return url;
+    }
+
+    /**
+     * @param siteURL
+     *            The siteURL to set.
+     */
+    public void setURL(String url)
+    {
+        this.url = url;
+    }
+
+    /**
+     * Define the Authentication methods. Supported are: Challenge Response and
+     * From based
+     */
+    /**
+     * Form authentication requires two fields that hold the credential
+     * information for the request.
+     */
+    public void setFormAuthentication(String formUserField, String formPwdField)
+    {
+        // Set the fields for Form Authentication and clear other authentication
+        // methods
+
+    }
+   
+    public String getFormPwdField()
+    {
+        return formPwdField;
+    }
+
+    public void setFormPwdField(String formPwdField)
+    {
+        this.formPwdField = formPwdField;
+    }
+
+    public String getFormUserField()
+    {
+        return formUserField;
+    }
+
+    public void setFormUserField(String formUserField)
+    {
+        this.formUserField = formUserField;
+    }
+
+    public boolean isFormAuthentication()
+    {
+        return isFormAuthentication;
+    }
+
+    public void setFormAuthentication(boolean isFormAuthentication)
+    {
+        this.isFormAuthentication = isFormAuthentication;
+    }
+
+    public void configFormAuthentication(String formUserField,
+            String formPwdField)
+    {
+        this.isFormAuthentication = true;
+        this.setChallengeResponseAuthentication(false);
+
+        this.formPwdField = formPwdField;
+        this.formUserField = formUserField;
+    }
+
+    public void setRealm(String realm)
+    {
+        this.realm = realm;
+    }
+
+    public String getRealm()
+    {
+        return this.realm;
+    }
+
+    public Long getSecurityDomainId()
+    {
+        return securityDomainId;
+    }
+
+    public void setSecurityDomainId(Long securityDomainId)
+    {
+        this.securityDomainId = securityDomainId;
+    }
+
+    
+    public boolean isChallengeResponseAuthentication()
+    {
+        return challengeResponseAuthentication;
+    }
+
+    
+    public void setChallengeResponseAuthentication(boolean challengeResponseAuthentication)
+    {
+        this.challengeResponseAuthentication = challengeResponseAuthentication;
+    }
+
+    /**
+     * Test whether element is newly created.
+     * 
+     * @return new status of element.
+     */
+    public boolean isNew()
+    {
+        return (id == 0);
+    }    
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOUserImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOUserImpl.java?rev=742669&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOUserImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/jpa/SSOUserImpl.java Mon Feb  9 18:37:05 2009
@@ -0,0 +1,47 @@
+/* 
+ * 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.sso.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.JetspeedPrincipalType;
+import org.apache.jetspeed.security.jpa.PersistentJetspeedPrincipal;
+import org.apache.jetspeed.sso.SSOUser;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id: SSOUserImpl.java 736069 2009-01-20 19:10:43Z rwatler $
+ */
+@Entity (name="SSOUser")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="SECURITY_PRINCIPAL")
+@DiscriminatorColumn (name="PRINCIPAL_TYPE")
+@DiscriminatorValue (value=JetspeedPrincipalType.SSO_USER)
+public class SSOUserImpl extends PersistentJetspeedPrincipal implements SSOUser 
+{
+    private static final long serialVersionUID = 1L;
+
+    public SSOUserImpl()
+    {
+        super();
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/SSOSiteManagerSPI.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/SSOSiteManagerSPI.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/SSOSiteManagerSPI.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/SSOSiteManagerSPI.java Mon Feb  9 18:37:05 2009
@@ -37,6 +37,8 @@
 	SSOSite getById(int id);
 
     void update(SSOSite site) throws SSOException;
+
+    SSOSite newSite();
     
     SSOSite add(SSOSite site) throws SSOException; 
     

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/AbstractSSOUserManagerSPIImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/AbstractSSOUserManagerSPIImpl.java?rev=742669&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/AbstractSSOUserManagerSPIImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/AbstractSSOUserManagerSPIImpl.java Mon Feb  9 18:37:05 2009
@@ -0,0 +1,193 @@
+/* 
+ * 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.sso.spi.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
+import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.SecurityDomain;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager;
+import org.apache.jetspeed.security.spi.JetspeedDomainPrincipalAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
+import org.apache.jetspeed.security.spi.SecurityDomainAccessManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialAccessManager;
+import org.apache.jetspeed.security.spi.UserPasswordCredentialStorageManager;
+import org.apache.jetspeed.sso.SSOUser;
+import org.apache.jetspeed.sso.impl.IsOwnedByPrincipalAssociationHandler;
+import org.apache.jetspeed.sso.impl.IsRemoteIdentityForPrincipalAssociationHandler;
+import org.apache.jetspeed.sso.spi.SSOUserManagerSPI;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id: AbstractSSOUserManagerSPIImpl.java 736069 2009-01-20 19:10:43Z rwatler $
+ */
+public abstract class AbstractSSOUserManagerSPIImpl extends BaseJetspeedPrincipalManager implements SSOUserManagerSPI
+{
+    private static final long serialVersionUID = 1L;
+
+    private JetspeedDomainPrincipalAccessManager domainPrincipalAccess;
+    private SecurityDomainAccessManager domainAccess;
+    
+    private UserPasswordCredentialStorageManager credentialStorageManager;
+    private UserPasswordCredentialAccessManager credentialAccessManager;
+
+    protected AbstractSSOUserManagerSPIImpl(JetspeedPrincipalType principalType, JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialStorageManager credentialStorageManager,
+                                            UserPasswordCredentialAccessManager credentialAccessManager, JetspeedDomainPrincipalAccessManager domainPrincipalAccess, SecurityDomainAccessManager domainAccess)
+    {
+        super(principalType, jpam, jpsm);
+        this.credentialStorageManager = credentialStorageManager;
+        this.credentialAccessManager = credentialAccessManager;
+        this.domainPrincipalAccess=domainPrincipalAccess;
+        this.domainAccess=domainAccess;
+    }
+    
+    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
+    {
+        return null;
+    }
+
+    public JetspeedPrincipal newTransientPrincipal(String name)
+    {
+        return null;
+    }
+
+    public SSOUser addUser(String name, Long domainId, JetspeedPrincipal ownerPrincipal)
+            throws SecurityException
+    {
+        SSOUser user = newUser(name, domainId);
+        Set<JetspeedPrincipalAssociationReference> reqAssociations = new HashSet<JetspeedPrincipalAssociationReference>();
+        reqAssociations.add(new JetspeedPrincipalAssociationReference(JetspeedPrincipalAssociationReference.Type.TO, ownerPrincipal, IsOwnedByPrincipalAssociationHandler.ASSOCIATION_NAME));
+        super.addPrincipal(user, reqAssociations);
+        // by default add a relation to the owner 
+        super.addAssociation(user, ownerPrincipal, IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME);
+        return user;
+    }
+
+    public PasswordCredential getPasswordCredential(SSOUser user) throws SecurityException
+    {
+        PasswordCredential passwordCredential = credentialAccessManager.getPasswordCredential(user.getName(), user.getDomainId());
+        if (passwordCredential == null)
+        {
+            passwordCredential = credentialStorageManager.newPasswordCredential(user);
+        }
+        return passwordCredential;
+    }
+
+    public SSOUser getUser(String userName, Long domainId)
+            throws SecurityException
+    {
+        SSOUser user = (SSOUser)domainPrincipalAccess.getPrincipal(userName, getPrincipalType(), domainId);
+        if (null == user)
+        {
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.SSO_USER, userName));
+        }
+        return user;
+    }
+
+    public Collection<String> getUserNames(String nameFilter, Long domainId)
+            throws SecurityException
+    {
+        return (List<String>) domainPrincipalAccess.getPrincipalNames(nameFilter, getPrincipalType(), domainId);
+    }
+
+    protected List<? extends JetspeedPrincipal> getPrincipals(String nameFilter, Long domainId)
+    {
+        return domainPrincipalAccess.getPrincipals(nameFilter, getPrincipalType(), domainId);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Collection<SSOUser> getUsers(String nameFilter, Long domainId)
+            throws SecurityException
+    {
+        return (List<SSOUser>) getPrincipals(nameFilter, domainId);
+    }
+
+    public void removeUser(String userName, Long domainId)
+            throws SecurityException
+    {
+        JetspeedPrincipal user;        
+        user = getUser(userName, domainId);
+        super.removePrincipal(user);
+    }
+
+    public void storePasswordCredential(PasswordCredential credential) throws SecurityException
+    {
+        credentialStorageManager.storePasswordCredential(credential);
+    }
+
+    public void updateUser(SSOUser user) throws SecurityException
+    {
+        super.updatePrincipal(user);
+    }
+
+    public boolean userExists(String userName, Long domainId)
+    {
+        return domainPrincipalAccess.principalExists(userName, getPrincipalType(), domainId);
+    }
+
+    public Collection<SSOUser> getUsers(JetspeedPrincipal principal) throws SecurityException
+    {
+        Collection<SecurityDomain> allDomains = domainAccess.getDomainsOwnedBy(principal.getDomainId());
+        Collection<SSOUser> users = new ArrayList<SSOUser>();
+        for (SecurityDomain domain : allDomains){
+            users.addAll(getUsers(principal,domain.getDomainId()));
+        }
+        return users;
+    }    
+    
+    @SuppressWarnings("unchecked")
+    public Collection<SSOUser> getUsers(JetspeedPrincipal principal, Long remoteSecurityDomain) throws SecurityException
+    {
+        return (Collection<SSOUser>)_getSSOUsersForPrincipal(principal,remoteSecurityDomain);
+    }    
+
+    private Collection<? extends JetspeedPrincipal> _getSSOUsersForPrincipal(JetspeedPrincipal principal, Long remoteSecurityDomain) throws SecurityException
+    {
+        return domainPrincipalAccess.getAssociatedTo(principal.getName(), getPrincipalType(), principal.getType(), IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME, remoteSecurityDomain, principal.getDomainId());
+    }  
+    
+    public void addSSOUserToPrincipal(SSOUser user, JetspeedPrincipal principal)
+            throws SecurityException
+    {
+        super.addAssociation(user,principal,IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME);
+        
+    }
+
+    public Collection<JetspeedPrincipal> getPortalPrincipals(SSOUser remoteUser, Long portalPrincipalDomain)
+    {
+        Collection<JetspeedPrincipal> principalsFound = new ArrayList<JetspeedPrincipal>();
+        List<JetspeedPrincipalAssociationType> assTypes = super.getAssociationTypes();
+        for (JetspeedPrincipalAssociationType type : assTypes)
+        {
+            if (type.getAssociationName().equals(IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME)){
+                Collection<JetspeedPrincipal> principalsForThisType = domainPrincipalAccess.getAssociatedFrom(remoteUser.getName(), getPrincipalType(), type.getToPrincipalType(), IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME, remoteUser.getDomainId(), portalPrincipalDomain);
+                principalsFound.addAll(principalsForThisType);
+            }
+        }
+        return principalsFound;
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/JetspeedPersistentSSOSiteManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/JetspeedPersistentSSOSiteManager.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/JetspeedPersistentSSOSiteManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/JetspeedPersistentSSOSiteManager.java Mon Feb  9 18:37:05 2009
@@ -25,8 +25,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
-import org.apache.jetspeed.security.SecurityDomain;
-import org.apache.jetspeed.security.impl.SecurityDomainImpl;
 import org.apache.jetspeed.sso.SSOException;
 import org.apache.jetspeed.sso.SSOSite;
 import org.apache.jetspeed.sso.SSOUser;
@@ -56,6 +54,11 @@
        super(repositoryPath);
     }
     
+    public SSOSite newSite()
+    {
+        return new SSOSiteImpl();
+    }
+    
     public SSOSite add(SSOSite ssoSite) throws SSOException
     {
         try

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/SSOUserManagerSPIImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/SSOUserManagerSPIImpl.java?rev=742669&r1=742668&r2=742669&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/SSOUserManagerSPIImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/spi/impl/SSOUserManagerSPIImpl.java Mon Feb  9 18:37:05 2009
@@ -16,20 +16,7 @@
  */
 package org.apache.jetspeed.sso.spi.impl;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
-import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PasswordCredential;
-import org.apache.jetspeed.security.SecurityDomain;
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager;
 import org.apache.jetspeed.security.spi.JetspeedDomainPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
@@ -37,96 +24,26 @@
 import org.apache.jetspeed.security.spi.UserPasswordCredentialAccessManager;
 import org.apache.jetspeed.security.spi.UserPasswordCredentialStorageManager;
 import org.apache.jetspeed.sso.SSOUser;
-import org.apache.jetspeed.sso.impl.IsOwnedByPrincipalAssociationHandler;
-import org.apache.jetspeed.sso.impl.IsRemoteIdentityForPrincipalAssociationHandler;
 import org.apache.jetspeed.sso.impl.SSOUserImpl;
 import org.apache.jetspeed.sso.spi.SSOUserManagerSPI;
 
-
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
  * @version $Id$
  */
-public class SSOUserManagerSPIImpl extends BaseJetspeedPrincipalManager implements SSOUserManagerSPI
+public class SSOUserManagerSPIImpl extends AbstractSSOUserManagerSPIImpl implements SSOUserManagerSPI
 {
+    private static final long serialVersionUID = -2276171226929364245L;
 
-    private static final long serialVersionUID = 1L;
-
-    private JetspeedDomainPrincipalAccessManager domainPrincipalAccess;
-    private SecurityDomainAccessManager domainAccess;
-    
-    private UserPasswordCredentialStorageManager credentialStorageManager;
-    private UserPasswordCredentialAccessManager credentialAccessManager;
-
-    
-    public SSOUserManagerSPIImpl(JetspeedPrincipalType principalType, 
-            JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialStorageManager credentialStorageManager,
-            UserPasswordCredentialAccessManager credentialAccessManager, JetspeedDomainPrincipalAccessManager domainPrincipalAccess, SecurityDomainAccessManager domainAccess)
+    public SSOUserManagerSPIImpl(JetspeedPrincipalType principalType, JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialStorageManager credentialStorageManager,
+                                 UserPasswordCredentialAccessManager credentialAccessManager, JetspeedDomainPrincipalAccessManager domainPrincipalAccess, SecurityDomainAccessManager domainAccess)
     {
-        super(principalType, jpam, jpsm);
-        this.credentialStorageManager = credentialStorageManager;
-        this.credentialAccessManager = credentialAccessManager;
-        this.domainPrincipalAccess=domainPrincipalAccess;
-        this.domainAccess=domainAccess;
-    }
-    
-    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
-    {
-        return null;
-    }
-
-    public JetspeedPrincipal newTransientPrincipal(String name)
-    {
-        return null;
-    }
-
-    public SSOUser addUser(String name, Long domainId, JetspeedPrincipal ownerPrincipal)
-            throws SecurityException
-    {
-        SSOUser user = newUser(name, domainId);
-        Set<JetspeedPrincipalAssociationReference> reqAssociations = new HashSet<JetspeedPrincipalAssociationReference>();
-        reqAssociations.add(new JetspeedPrincipalAssociationReference(JetspeedPrincipalAssociationReference.Type.TO, ownerPrincipal, IsOwnedByPrincipalAssociationHandler.ASSOCIATION_NAME));
-        super.addPrincipal(user, reqAssociations);
-        // by default add a relation to the owner 
-        super.addAssociation(user, ownerPrincipal, IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME);
-        return user;
-    }
-
-    public PasswordCredential getPasswordCredential(SSOUser user)
-            throws SecurityException
-    {
-        return credentialAccessManager.getPasswordCredential(user.getName(),user.getDomainId());
-    }
-
-    public SSOUser getUser(String userName, Long domainId)
-            throws SecurityException
-    {
-        SSOUser user = (SSOUser)domainPrincipalAccess.getPrincipal(userName, getPrincipalType(), domainId);
-        if (null == user)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.SSO_USER, userName));
-        }
-        return user;
-    }
-
-    public Collection<String> getUserNames(String nameFilter, Long domainId)
-            throws SecurityException
-    {
-        return (List<String>) domainPrincipalAccess.getPrincipalNames(nameFilter, getPrincipalType(), domainId);
-    }
-
-    protected List<? extends JetspeedPrincipal> getPrincipals(String nameFilter, Long domainId)
-    {
-        return domainPrincipalAccess.getPrincipals(nameFilter, getPrincipalType(), domainId);
-    }
-    
-    @SuppressWarnings("unchecked")
-    public Collection<SSOUser> getUsers(String nameFilter, Long domainId)
-            throws SecurityException
-    {
-        return (List<SSOUser>) getPrincipals(nameFilter, domainId);
+        super(principalType, jpam, jpsm, credentialStorageManager, credentialAccessManager, domainPrincipalAccess, domainAccess);
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.sso.spi.SSOUserManagerSPI#newUser(java.lang.String, java.lang.Long)
+     */
     public SSOUser newUser(String name, Long domainId)
     {
         SSOUserImpl user = new SSOUserImpl();
@@ -134,70 +51,4 @@
         user.setName(name);
         return user;
     }
-
-    public void removeUser(String userName, Long domainId)
-            throws SecurityException
-    {
-        JetspeedPrincipal user;        
-        user = getUser(userName, domainId);
-        super.removePrincipal(user);
-    }
-
-    public void storePasswordCredential(PasswordCredential credential) throws SecurityException
-    {
-        credentialStorageManager.storePasswordCredential(credential);
-    }
-
-    public void updateUser(SSOUser user) throws SecurityException
-    {
-        super.updatePrincipal(user);
-    }
-
-    public boolean userExists(String userName, Long domainId)
-    {
-        return domainPrincipalAccess.principalExists(userName, getPrincipalType(), domainId);
-    }
-
-    public Collection<SSOUser> getUsers(JetspeedPrincipal principal) throws SecurityException
-    {
-        Collection<SecurityDomain> allDomains = domainAccess.getDomainsOwnedBy(principal.getDomainId());
-        Collection<SSOUser> users = new ArrayList<SSOUser>();
-        for (SecurityDomain domain : allDomains){
-            users.addAll(getUsers(principal,domain.getDomainId()));
-        }
-        return users;
-    }    
-    
-    @SuppressWarnings("unchecked")
-    public Collection<SSOUser> getUsers(JetspeedPrincipal principal, Long remoteSecurityDomain) throws SecurityException
-    {
-        return (Collection<SSOUser>)_getSSOUsersForPrincipal(principal,remoteSecurityDomain);
-    }    
-
-    private Collection<? extends JetspeedPrincipal> _getSSOUsersForPrincipal(JetspeedPrincipal principal, Long remoteSecurityDomain) throws SecurityException
-    {
-        return domainPrincipalAccess.getAssociatedTo(principal.getName(), getPrincipalType(), principal.getType(), IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME, remoteSecurityDomain, principal.getDomainId());
-    }  
-    
-    public void addSSOUserToPrincipal(SSOUser user, JetspeedPrincipal principal)
-            throws SecurityException
-    {
-        super.addAssociation(user,principal,IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME);
-        
-    }
-
-    public Collection<JetspeedPrincipal> getPortalPrincipals(SSOUser remoteUser, Long portalPrincipalDomain)
-    {
-        Collection<JetspeedPrincipal> principalsFound = new ArrayList<JetspeedPrincipal>();
-        List<JetspeedPrincipalAssociationType> assTypes = super.getAssociationTypes();
-        for (JetspeedPrincipalAssociationType type : assTypes)
-        {
-            if (type.getAssociationName().equals(IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME)){
-                Collection<JetspeedPrincipal> principalsForThisType = domainPrincipalAccess.getAssociatedFrom(remoteUser.getName(), getPrincipalType(), type.getToPrincipalType(), IsRemoteIdentityForPrincipalAssociationHandler.ASSOCIATION_NAME, remoteUser.getDomainId(), portalPrincipalDomain);
-                principalsFound.addAll(principalsForThisType);
-            }
-        }
-        return principalsFound;
-    }    
-    
 }



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