portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r736069 [2/3] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ applications/jetspeed-demo/ applications/jetspeed-dependencies/ components/ components/jetspeed-capability/ components/jetspeed-db-tools/ components/jetspeed-page-manager...
Date Tue, 20 Jan 2009 19:10:46 GMT
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java Tue Jan 20 11:10:43 2009
@@ -27,6 +27,7 @@
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalManager;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
+import org.apache.jetspeed.security.PrincipalManagerEventListener;
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
@@ -208,5 +209,22 @@
         // TODO Auto-generated method stub
         
     }
-    
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#addListener(org.apache.jetspeed.security.PrincipalManagerEventListener)
+     */
+    public void addListener(PrincipalManagerEventListener listener)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#removeListener(org.apache.jetspeed.security.PrincipalManagerEventListener)
+     */
+    public void removeListener(PrincipalManagerEventListener listener)
+    {
+        // TODO Auto-generated method stub
+        
+    }    
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerImpl.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/JetspeedSerializerImpl.java Tue Jan 20 11:10:43 2009
@@ -25,6 +25,10 @@
 import java.util.List;
 import java.util.Map;
 
+import javolution.xml.XMLBinding;
+import javolution.xml.XMLObjectReader;
+import javolution.xml.XMLObjectWriter;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.serializer.objects.JSApplication;
@@ -64,6 +68,8 @@
 import org.apache.jetspeed.serializer.objects.JSRuleCriterion;
 import org.apache.jetspeed.serializer.objects.JSRuleCriterions;
 import org.apache.jetspeed.serializer.objects.JSSecurityAttributes;
+import org.apache.jetspeed.serializer.objects.JSSecurityDomain;
+import org.apache.jetspeed.serializer.objects.JSSecurityDomains;
 import org.apache.jetspeed.serializer.objects.JSSnapshot;
 import org.apache.jetspeed.serializer.objects.JSUser;
 import org.apache.jetspeed.serializer.objects.JSUserAttributes;
@@ -72,10 +78,6 @@
 import org.apache.jetspeed.serializer.objects.JSUserUsers;
 import org.apache.jetspeed.serializer.objects.JSUsers;
 
-import javolution.xml.XMLBinding;
-import javolution.xml.XMLObjectReader;
-import javolution.xml.XMLObjectWriter;
-
 /**
  * Main JetspeedSerializer implementation delegating the real serializing to JetspeedComponentSerializer instances
  * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
@@ -227,6 +229,8 @@
         binding.setAlias(JSEntities.class, "Entities");
         binding.setAlias(JSEntityPreference.class, "Principal");
         binding.setAlias(JSEntityPreferences.class, "Settings");
+        binding.setAlias(JSSecurityDomains.class, "SecurityDomains");
+        binding.setAlias(JSSecurityDomain.class, "SecurityDomain");
 
         binding.setAlias(String.class, "String");
         binding.setAlias(Integer.class, "int");

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-serializer/src/main/java/org/apache/jetspeed/serializer/objects/JSSnapshot.java Tue Jan 20 11:10:43 2009
@@ -73,6 +73,9 @@
     private String defaultRule;
 
     private JSApplications applications;
+    
+    private JSSecurityDomains securityDomains;
+    
 
     /**
      * check the software version and subvversion against the saved
@@ -104,6 +107,7 @@
         permissions = new JSPermissions();
         rules = new JSProfilingRules();
         applications = new JSApplications();
+        securityDomains=new JSSecurityDomains();
     }
 
     public JSSnapshot(String name)
@@ -486,6 +490,16 @@
         this.applications = applications;
     }
 
+    public JSSecurityDomains getSecurityDomains()
+    {
+        return securityDomains;
+    }
+    
+    public void setSecurityDomains(JSSecurityDomains securityDomains)
+    {
+        this.securityDomains = securityDomains;
+    }
+
 
     /***************************************************************************
      * SERIALIZER
@@ -579,6 +593,10 @@
                 {
                     xml.add(g.getApplications());
                 }
+                if ( !g.getSecurityDomains().isEmpty() )
+                {
+                    xml.add(g.getSecurityDomains());
+                }
             }
             catch (Exception e)
             {
@@ -665,6 +683,8 @@
                         g.rules = (JSProfilingRules) o1;
                     else if (o1 instanceof JSApplications)
                         g.applications = (JSApplications) o1;
+                    else if (o1 instanceof JSSecurityDomains)
+                        g.securityDomains = (JSSecurityDomains) o1;
                 }
             }
             catch (Exception e)

Propchange: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jan 20 11:10:43 2009
@@ -1,9 +1,7 @@
 target
 surefire*.properties
 jcoverage.ser
-
 .settings
-
 .classpath
-
 .project
+jetspeed-mvn.properties

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=736069&r1=736068&r2=736069&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 Tue Jan 20 11:10:43 2009
@@ -35,7 +35,7 @@
     </parent>
     <packaging>jar</packaging>
 
-    <!-- Dependencies -->
+    <!-- Dependencies --> 
 
     <dependencies>
 
@@ -65,6 +65,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>jetspeed-file-cache</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>javax.transaction</groupId>
             <artifactId>jta</artifactId>
             <scope>test</scope>
@@ -75,37 +80,22 @@
             <version>${org.apache.jetspeed.test.jdbc.driver.version}</version>
             <scope>test</scope>
         </dependency>      
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>jetspeed-cm</artifactId>
+            <scope>test</scope>
+        </dependency>
         
     </dependencies>
 
     <build>
         <plugins>
-            <!-- Temporary excluding blocks starts -->
-            <!-- TODO: Refactor SSO components and test cases. After that, remove the excluding blocks. -->
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
-                    <excludes>
-                        <exclude>**/*.java</exclude>
-                    </excludes>
-                    <testExcludes>
-                        <exclude>**/*.java</exclude>
-                    </testExcludes>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <exclude>**/*.java</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-            <!-- Temporary excluding blocks ends -->
             <plugin>
                 <groupId>${pom.groupId}</groupId>
                 <artifactId>jetspeed-unpack-maven-plugin</artifactId>
@@ -124,7 +114,7 @@
                                 <resources>
                                     <resource>
                                         <path>assembly</path>
-                                        <include>sso.xml,transaction.xml,cache.xml,security-*.xml</include>
+                                        <include>sso.xml,transaction.xml,security-*.xml,static-bean-references.xml,boot/datasource.xml</include>
                                     </resource>
                                     <resource>
                                         <path>db-ojb</path>
@@ -141,6 +131,12 @@
                 <directory>src/test/resources</directory>
                 <filtering>true</filtering>
             </testResource>
+            <testResource>
+                <directory>src/test/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </testResource>
         </testResources>
     </build>
 </project>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/JETSPEED-INF/ojb/sso_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/JETSPEED-INF/ojb/sso_repository.xml?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/JETSPEED-INF/ojb/sso_repository.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/JETSPEED-INF/ojb/sso_repository.xml Tue Jan 20 11:10:43 2009
@@ -18,87 +18,6 @@
 
 <descriptor-repository version="1.0">
 
-<!--
-	   - S E C U R I T Y   P R I N C I P A L (Short version for SSO lookup)
-	-->	
-	<class-descriptor
-	    class="org.apache.jetspeed.sso.impl.SSOPrincipalImpl"
-	    proxy="dynamic"
-	    table="SECURITY_PRINCIPAL"
-	>
-	    <documentation>Represents a user principal.</documentation>
-	    <field-descriptor
-	        name="principalId"
-	        column="principal_id"
-	        jdbc-type="BIGINT"
-	        primarykey="true"
-	        indexed="true"
-	        autoincrement="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="classname"
-	        column="classname"
-	        jdbc-type="VARCHAR"
-	        nullable="false"
-	        length="254"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="isMappingOnly"
-	        column="is_mapping_only"
-	        jdbc-type="INTEGER"
-	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="fullPath"
-	        column="full_path"
-	        jdbc-type="VARCHAR"
-	        nullable="false"
-	        length="254"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="creationDate"
-	        column="creation_date"
-	        jdbc-type="TIMESTAMP"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="modifiedDate"
-	        column="modified_date"
-	        jdbc-type="TIMESTAMP"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-      <field-descriptor
-          name="enabled"
-          column="is_enabled"
-          jdbc-type="INTEGER"
-          conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-          nullable="false"
-      >
-      </field-descriptor>
-      <collection-descriptor
-	        name="remotePrincipals"
-	        element-class-ref="org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl"
-	        proxy="true"
-	        refresh="true"
-	        auto-retrieve="true"
-	        auto-update="object"
-	        auto-delete="object"
-	        indirection-table="SSO_PRINCIPAL_TO_REMOTE"
-	    >
-	        <documentation>This is the reference to principals.</documentation>
-	        <fk-pointing-to-this-class column="PRINCIPAL_ID"/>
-	        <fk-pointing-to-element-class column="REMOTE_PRINCIPAL_ID"/>
-	    </collection-descriptor>
-      </class-descriptor>
-
-	
 	<!--
 	   - S I T E
 	-->	
@@ -109,164 +28,72 @@
 	>
 	    <documentation>Represents the single sign on site</documentation>
 	    <field-descriptor
-	        name="siteId"
+	        name="id"
 	        column="SITE_ID"
 	        jdbc-type="INTEGER"
 	        primarykey="true"
 	        indexed="true"
-	        autoincrement="true"
-	    >
-	    </field-descriptor>
+	        autoincrement="true"/>
 	    <field-descriptor
 	        name="name"
 	        column="NAME"
 	        jdbc-type="VARCHAR"
 	        nullable="false"
-	        length="254"
-	    >
-	    </field-descriptor>
+	        indexed="true"
+	        length="254"/>
 	    <field-descriptor
-	        name="siteURL"
+	        name="url"
 	        column="URL"
 	        jdbc-type="VARCHAR"
 	        nullable="false"
-	        length="254"
-	    >
-	    </field-descriptor>
+	        length="254"/>
 	    <field-descriptor
 	        name="isAllowUserSet"
 	        column="ALLOW_USER_SET"
 	        jdbc-type="INTEGER"
 	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="false"
-	    >
-	    </field-descriptor>
+	        nullable="false"/>
 	    <field-descriptor
 	        name="isCertificateRequired"
 	        column="REQUIRES_CERTIFICATE"
 	        jdbc-type="INTEGER"
 	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    
+	        nullable="false"/>	    
 	    <field-descriptor
-	        name="isChallangeResponseAuthentication"
+	        name="challengeResponseAuthentication"
 	        column="CHALLENGE_RESPONSE_AUTH"
 	        jdbc-type="INTEGER"
 	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="false"
-	    >
-	    </field-descriptor>
+	        nullable="false"/>
 	    <field-descriptor
 	        name="isFormAuthentication"
 	        column="FORM_AUTH"
 	        jdbc-type="INTEGER"
 	        conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
-	        nullable="false"
-	    >
-	    </field-descriptor>
+	        nullable="false"/>
 	    <field-descriptor
 	        name="formUserField"
 	        column="FORM_USER_FIELD"
 	        jdbc-type="VARCHAR"
 	        nullable="false"
-	        length="128"
-	    >
-	    </field-descriptor>
+	        length="128"/>
 	    <field-descriptor
 	        name="formPwdField"
 	        column="FORM_PWD_FIELD"
 	        jdbc-type="VARCHAR"
 	        nullable="false"
-	        length="128"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="realm"
-	        column="REALM"
-	        jdbc-type="VARCHAR"
-	        nullable="false"
-	        length="128"
-	    >
-	    </field-descriptor>
-	     <collection-descriptor
-	        name="principals"
-	        element-class-ref="org.apache.jetspeed.sso.impl.SSOPrincipalImpl"
-	       proxy="true"
-	        refresh="true"
-	        auto-retrieve="true"
-	        auto-update="object"
-	        auto-delete="object"
-	        indirection-table="SSO_SITE_TO_PRINCIPALS"
-	    >
-	        <documentation>This is the reference to principals.</documentation>
-	        <fk-pointing-to-this-class column="SITE_ID"/>
-	        <fk-pointing-to-element-class column="PRINCIPAL_ID"/>
-	    </collection-descriptor>
-	    <collection-descriptor
-	        name="remotePrincipals"
-	        element-class-ref="org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl"
-	       proxy="true"
-	        refresh="true"
-	        auto-retrieve="true"
-	        auto-update="object"
-	        auto-delete="object"
-	        indirection-table="SSO_SITE_TO_REMOTE"
-	    >
-	        <documentation>This is the reference to principals.</documentation>
-	        <fk-pointing-to-this-class column="SITE_ID"/>
-	        <fk-pointing-to-element-class column="PRINCIPAL_ID"/>
-	    </collection-descriptor>
+	        length="128"/>
+		<field-descriptor
+			name="realm"
+			column="REALM"
+			jdbc-type="VARCHAR"
+			nullable="false"
+			length="128"/>
+		<field-descriptor 
+			name="securityDomainId" 
+			nullable="false" 
+			jdbc-type="BIGINT"
+			column="domain_id"/>
 	</class-descriptor>
 	
-	<!-- SSO Cookie -->
-	
-	<class-descriptor
-	    class="org.apache.jetspeed.sso.impl.SSOCookieImpl"
-	    proxy="dynamic"
-	    table="SSO_COOKIE"
-	>
-	    <documentation>Represents the single sign on cookie</documentation>
-	    <field-descriptor
-	        name="cookieId"
-	        column="COOKIE_ID"
-	        jdbc-type="INTEGER"
-	        primarykey="true"
-	        indexed="true"
-	        autoincrement="true"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="cookie"
-	        column="COOKIE"
-	        jdbc-type="VARCHAR"
-	        nullable="false"
-	        length="1024"
-	    >
-	    </field-descriptor>
-	    <field-descriptor
-	        name="createDate"
-	        column="CREATE_DATE"
-	        jdbc-type="TIMESTAMP"
-	        nullable="false"
-	    >
-	    </field-descriptor>
-	    
-	    <collection-descriptor
-	        name="remotePrincipals"
-	        element-class-ref="org.apache.jetspeed.security.om.impl.InternalUserPrincipalImpl"
-	       proxy="true"
-	        refresh="true"
-	        auto-retrieve="true"
-	        auto-update="object"
-	        auto-delete="object"
-	        indirection-table="SSO_COOKIE_TO_REMOTE"
-	    >
-	        <documentation>This is the reference to principals for a cookie.</documentation>
-	        <fk-pointing-to-this-class column="COOKIE_ID"/>
-	        <fk-pointing-to-element-class column="REMOTE_PRINCIPAL_ID"/>
-	    </collection-descriptor>
-	    </class-descriptor>
-	
 </descriptor-repository>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/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/impl/SSOSiteImpl.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOSiteImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/main/java/org/apache/jetspeed/sso/impl/SSOSiteImpl.java Tue Jan 20 11:10:43 2009
@@ -1,306 +1,250 @@
 /*
-* 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.
-*/
+ * 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.impl;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.apache.jetspeed.sso.SSOException;
 import org.apache.jetspeed.sso.SSOSite;
-import org.apache.jetspeed.sso.SSOPrincipal;
 
 /**
-* SSOSiteImpl
-* 	Class holding information about the Site and credentials for Single Sign on SSO.
-*	OJB will map the database entries into this class
-*
-* @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
-* @version $Id$
-*/
-
-public class SSOSiteImpl implements SSOSite {
-	
-	// Private member for OJB mapping
-	private int		siteId;
-	private String	name;
-	private String	siteURL;
-	private boolean	isAllowUserSet;
-	private boolean isCertificateRequired;
-	
-	private boolean	isChallangeResponseAuthentication;
-	
-	/* Realm used to do ChallengeResponse Authentication */
-	private String	realm;
-	
-	private boolean	isFormAuthentication;
-	
-	/* Names of fields for User and Password values. The names are up to the
-	 * application developer and therefore it must be configurable for SSO*/
-	private String	formUserField;
-	private String	formPwdField;
-	
-	private Collection	principals = new Vector();
-	private Collection	remotePrincipals = new Vector();
-	
-	/**
+ * SSOSiteImpl Class holding information about the Site and credentials for
+ * Single Sign on SSO. OJB will map the database entries into this class
+ * 
+ * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+
+public class SSOSiteImpl implements SSOSite
+{
+
+    // Private member for OJB mapping
+    private int id;
+
+    private String name;
+
+    private String url;
+
+    private boolean isAllowUserSet;
+
+    private boolean isCertificateRequired;
+
+    private boolean challengeResponseAuthentication;
+
+    /* Realm used to do ChallengeResponse Authentication */
+    private String realm;
+
+    private boolean isFormAuthentication;
+
+    /*
+     * Names of fields for User and Password values. The names are up to the
+     * application developer and therefore it must be configurable for SSO
+     */
+    private String formUserField;
+
+    private String formPwdField;
+
+    private Long securityDomainId;
+
+    /**
 	 * 
 	 */
-	public SSOSiteImpl() {
-		super();
-		
-	}
+    public SSOSiteImpl()
+    {
+        super();
 
-	/*
-	 * Setters and getters for member variables
-	 */
-	
-	/**
-	 * @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 principals.
-	 */
-	public Collection getPrincipals() {
-		return this.principals;
-	}
-	/**
-	 * @param principals The principals to set.
-	 */
-	public void setPrincipals(Collection principals) {
-		this.principals.addAll(principals);
-	}
-	/**
-	 * @return Returns the siteId.
-	 */
-	public int getSiteId() {
-		return siteId;
-	}
-	/**
-	 * @param siteId The siteId to set.
-	 */
-	public void setSiteId(int siteId) {
-		this.siteId = siteId;
-	}
-	/**
-	 * @return Returns the siteURL.
-	 */
-	public String getSiteURL() {
-		return siteURL;
-	}
-	/**
-	 * @param siteURL The siteURL to set.
-	 */
-	public void setSiteURL(String siteURL) {
-		this.siteURL = siteURL;
-	}
-	
-	/**
-	 * Utility functions
-	 * addCredential()
-	 * Adds the credentail to the credentials collection
-	 *
-	 */
-	
-	
-	
-		/**
-		 * addPrincipal
-		 * Adds the SSOPrincipal to the principals collection
-		 *
-		 */
-		public void addPrincipal(SSOPrincipal principal) throws SSOException {
-			boolean bStatus = false;
-			
-			try
-			{
-				bStatus = principals.add(principal);
-			}
-			catch(Exception e)
-			{
-				// Adding credentail to coollection failed -- notify caller with SSOException
-				throw new SSOException(SSOException.FAILED_ADDING_PRINCIPAL_TO_MAPPING_TABLE_FOR_SITE + e.getMessage()); 
-			}
-			
-			if ( bStatus == false)
-				throw new SSOException(SSOException.FAILED_ADDING_PRINCIPAL_TO_MAPPING_TABLE_FOR_SITE ); 	
-		}
-		
-		/**
-		* removePrincipal()
-		 * removes a principal from the principals collection
-		 *
-		 */
-		public void removePrincipal(long principalId) throws SSOException
-		{
-			boolean bStatus = false;
-			SSOPrincipal principalObj = null;
-			Iterator itSitePrincipals = principals.iterator();
-			
-			while (itSitePrincipals.hasNext() )
-			{
-				principalObj = (SSOPrincipal)itSitePrincipals.next();
-				if ( principalObj.getPrincipalId() == principalId)
-				{
-				
-					try
-					{
-						bStatus = principals.remove(principalObj);
-					}
-					catch(Exception e)
-					{
-						// Adding credentail to coollection failed -- notify caller with SSOException
-						throw new SSOException(SSOException.FAILED_REMOVING_PRINCIPAL_FROM_MAPPING_TABLE_FOR_SITE + e.getMessage()); 
-					}
-					
-					if ( bStatus == false)
-						throw new SSOException(SSOException.FAILED_REMOVING_PRINCIPAL_FROM_MAPPING_TABLE_FOR_SITE ); 
-				}
-					
-			}
-		}
-    /**
-     * @return Returns the remotePrincipals.
+    }
+    
+    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 Collection getRemotePrincipals() {
-        return remotePrincipals;
+    public void setAllowUserSet(boolean isAllowUserSet)
+    {
+        this.isAllowUserSet = isAllowUserSet;
     }
+
     /**
-     * @param remotePrincipals The remotePrincipals to set.
+     * @return Returns the isCertificateRequired.
      */
-    public void setRemotePrincipals(Collection remotePrincipals) {
-        this.remotePrincipals = remotePrincipals;
+    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;
+    }
+
     /**
-     * Define the Authentication methods. 
-     * Supported are: Challenge Response and From based
+     * @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 
+     * 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
-    	
+        // 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;
+    }
+
     
-    /*
-     * Uses Challenge Response mechanism for authentication
-     */
-    public void setChallengeResponseAuthentication()
+    public boolean isChallengeResponseAuthentication()
     {
-    	// Set the fields for ChallengeResponse and clear other authentication methods
-    	
+        return challengeResponseAuthentication;
+    }
+
+    
+    public void setChallengeResponseAuthentication(
+            boolean challengeResponseAuthentication)
+    {
+        this.challengeResponseAuthentication = challengeResponseAuthentication;
     }
 
-    /* Setters/Getters for Authentication settings */
-	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 isChallangeResponseAuthentication() {
-		return isChallangeResponseAuthentication;
-	}
-
-	public void setChallengeResponseAuthentication(
-			boolean isChallangeResponseAuthentication) {
-		this.isChallangeResponseAuthentication = isChallangeResponseAuthentication;
-	}
-
-	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;
-	}
-	
-	/*
-	 *  (non-Javadoc)
-	 * @see org.apache.jetspeed.sso.SSOSite#setRealm(java.lang.String)
-	 */
-	public void setRealm(String realm)
-	{
-		this.realm = realm;
-	}
-	
-	/*
-	 *  (non-Javadoc)
-	 * @see org.apache.jetspeed.sso.SSOSite#getRealm()
-	 */
-	public String getRealm()
-	{
-		return this.realm;
-	}    
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestBasicSSO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestBasicSSO.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestBasicSSO.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestBasicSSO.java Tue Jan 20 11:10:43 2009
@@ -16,6 +16,10 @@
  */
 package org.apache.jetspeed.sso;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import org.apache.commons.httpclient.Cookie;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
@@ -26,10 +30,6 @@
 import org.apache.commons.httpclient.auth.HttpAuthenticator;
 import org.apache.commons.httpclient.methods.GetMethod;
 
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
 
 /**
  * TestBasicSSO

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOComponent.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOComponent.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOComponent.java Tue Jan 20 11:10:43 2009
@@ -17,17 +17,6 @@
 
 package org.apache.jetspeed.sso;
 
-import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.impl.GroupPrincipalImpl;
-import org.apache.jetspeed.security.impl.UserPrincipalImpl;
-import org.apache.jetspeed.security.util.test.AbstractSecurityTestcase;
-import org.apache.jetspeed.sso.SSOProvider;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import javax.security.auth.Subject;
-
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -36,13 +25,17 @@
 import java.util.List;
 import java.util.Set;
 
-import org.apache.jetspeed.sso.SSOException;
-import java.lang.Exception;
+import javax.security.auth.Subject;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.security.SecurityException;
 
 /**
  * @author   David Le Strat
  */
-public class TestSSOComponent extends AbstractSecurityTestcase
+public abstract class TestSSOComponent extends AbstractSecurityTestCase
 {
     /**
      * test url for this UnitTest
@@ -66,7 +59,7 @@
     static private String TEST_GROUP_USER = "jack";
 
     /** The property manager. */
-    private static SSOProvider ssoBroker = null;
+    private static SSOManager ssoManager = null;
 
     /**
      * @see junit.framework.TestCase#setUp()
@@ -77,7 +70,7 @@
 
         try
         {
-            ssoBroker = (SSOProvider) scm.getComponent("ssoProvider");
+            ssoManager = (SSOManager) scm.getComponent("org.apache.jetspeed.sso.SSOManager");
         }
         catch (Exception ex)
         {
@@ -101,278 +94,279 @@
         return new TestSuite(TestSSOComponent.class);
     }
 
-    /**
-     * <p>
-     * Test user root.
-     * </p>
-     */
-    public void testSSOGroup() throws Exception
-    {
-        System.out.println("*************************************\n" + "Start Unit Test for SSO Group Support"
-                + "\n*************************************");
-
-        // Create a user
-        try
-        {
-            ums.addUser(TEST_GROUP_USER, "password");
-        }
-        catch (SecurityException sex)
-        {
-            // assertTrue("user already exists. exception caught: " + sex, false);
-        }
-
-        // Create a group
-        try
-        {
-            gms.addGroup(TEST_GROUP);
-            System.out.println("Creating Group " + TEST_GROUP + " and adding User " + TEST_GROUP_USER + " succeeded!.");
-        }
-        catch (SecurityException secex)
-        {
-            System.out.println("Creating Group " + TEST_GROUP + " and adding User " + TEST_GROUP_USER
-                    + " failed. Group might already exist. Continue test...");
-            // secex.printStackTrace();
-            // throw new Exception(secex.getMessage());
-        }
-
-        if (gms.groupExists(TEST_GROUP))
-        {
-            // Add user to Group
-            gms.addUserToGroup(TEST_GROUP_USER, TEST_GROUP);
-        }
-        else
-        {
-            assertTrue("Could not create group. Abort test.", false);
-        }
-
-        // Initialization of Group
-        Principal principal = new GroupPrincipalImpl(TEST_GROUP);
-        Set principals = new HashSet();
-        principals.add(principal);
-        Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
-
-        // Add SSO Credential for Group
-        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
-        {
-            try
-            {
-                ssoBroker.addCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_1);
-                System.out.println("SSO Credential added for Group:" + TEST_GROUP + " site: " + TEST_URL);
-            }
-            catch (SSOException ssoex)
-            {
-                System.out.println("SSO Credential add FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
-                ssoex.printStackTrace();
-                throw new Exception(ssoex.getMessage());
-            }
-        }
-        else
-        {
-            System.out.println("Group:" + TEST_GROUP + " site: " + TEST_URL + " has already a remote credential");
-        }
-
-        // Create Principal for User
-        principal = new UserPrincipalImpl(TEST_GROUP_USER);
-        principals = new HashSet();
-        principals.add(principal);
-        subject = new Subject(true, principals, new HashSet(), new HashSet());
-
-        // User should have credential for site
-        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
-        {
-            // Group expansion failed. User not recognized
-            System.out.println("No SSO Credential for user:" + TEST_GROUP_USER + " site: " + TEST_URL);
-
-            // Test failure
-            try
-            {
-                ums.removeUser(TEST_GROUP_USER);
-                gms.removeGroup(TEST_GROUP);
-            }
-            catch (SecurityException sex)
-            {
-                assertTrue("could not remove user and group. exception caught: " + sex, false);
-            }
-
-            throw new Exception("SSO Unit test for Group support failed");
-        }
-        else
-        {
-            // Group lookup succesful
-            System.out.println("SSO Test for Group support successful" + "\nSSO Credential for user:" + TEST_GROUP_USER
-                    + " site: " + TEST_URL + " found. User is member of Group " + TEST_GROUP);
-        }
-
-        // Cleanup test.
-
-        /*
-         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
-         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
-         * releases
-         */
-        try
-        {
-            // Remove credential for Site
-            ssoBroker.removeCredentialsForSite("/group/" + TEST_GROUP, TEST_URL);
-            System.out.println("SSO Credential removed for Group:" + TEST_GROUP + " site: " + TEST_URL);
-        }
-        catch (SSOException ssoex)
-        {
-            System.out.println("SSO Credential remove FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
-            throw new Exception(ssoex.getMessage());
-        }
-
-        try
-        {
-            ums.removeUser(TEST_GROUP_USER);
-            gms.removeGroup(TEST_GROUP);
-        }
-        catch (SecurityException sex)
-        {
-            assertTrue("could not remove user and group. exception caught: " + sex, false);
-        }
-
-    }
-
-    public void testSSO() throws Exception
-    {
-        System.out.println("***************************\nStart Unit Test for SSO API\n***************************");
-
-        // Create a user
-        try
-        {
-            ums.addUser(TEST_USER, "password");
-        }
-        catch (SecurityException sex)
-        {
-            // assertTrue("user already exists. exception caught: " + sex, false);
-        }
-
-        // Initialization
-        Principal principal = new UserPrincipalImpl(TEST_USER);
-        Set principals = new HashSet();
-        principals.add(principal);
-        Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
-
-        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
-        {
-            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL);
-
-            // Add credential
-            try
-            {
-                ssoBroker.addCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_1);
-                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL);
-            }
-            catch (SSOException ssoex)
-            {
-                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL);
-                ssoex.printStackTrace();
-                throw new Exception(ssoex.getMessage());
-            }
-        }
-        else
-        {
-            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL);
-        }
-
-        // Add another remote principal for the same user
-        if (ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
-        {
-            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL2);
-
-            // Add credential
-            try
-            {
-                ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
-                ssoBroker.setRealmForSite(TEST_URL2, "Nagios Access");
-                
-                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL2);
-            }
-            catch (SSOException ssoex)
-            {
-                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL2);
-                ssoex.printStackTrace();
-                throw new Exception(ssoex.getMessage());
-            }
-        }
-        else
-        {
-            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL2);
-        }
-
-        // Add the credentail again -- should get an error
-        try
-        {
-            ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
-            throw new Exception("Added same credentail twice -- API should prevent users from doing that.");
-
-        }
-        catch (SSOException ssoex)
-        {
-            System.out.println("Adding same SSO Credential twice failed (as expected) Message :" + ssoex.getMessage());
-        }
-        catch (Exception e)
-        {
-            throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
-        }
-
-        // Test if the credential where persisted
-
-        // Test credential update
-        SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
-        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
-                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL);
-
-        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
-                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);
-
-        try
-        {
-            // Update Remote credential
-            System.out.println("SSO Credential Update");
-            ssoBroker.updateCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_2);
-
-            ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
-            System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: "
-                    + ssocontext.getRemoteCredential());
-
-        }
-        catch (SSOException ssoex)
-        {
-            System.out.println("SSO Credential update FAILED for user:" + TEST_USER + " site: " + TEST_URL);
-            throw new Exception(ssoex.getMessage());
-        }
-          
-        /*
-         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
-         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
-         * releases try { // Remove credential for Site ssoBroker.removeCredentialsForSite(subject, TEST_URL);
-         * System.out.println("SSO Credential removed for user:" + TEST_USER+ " site: " + TEST_URL); }
-         * catch(SSOException ssoex) { System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " +
-         * TEST_URL); throw new Exception(ssoex.getMessage()); }
-         */
-
-        Iterator sites = ssoBroker.getSites("");
-        while (sites.hasNext())
-        {
-            SSOSite site = (SSOSite) sites.next();
-            System.out.println("Site = " + site.getName());
-        }
-        // Cleanup
-        try
-        {
-        	ssoBroker.removeCredentialsForSite(subject, TEST_URL);
-        	ssoBroker.removeCredentialsForSite(subject, TEST_URL2);
-        	System.out.println("SSO Credential removed for user:" + TEST_USER+ " sites: " + TEST_URL + " " + TEST_URL2); 
-        }
-        catch(SSOException ssoex) 
-        { 
-        	System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " + TEST_URL + " and " + TEST_URL2); 
-        	throw new Exception(ssoex.getMessage());
-        }
-
-    }
+//    /**
+//     * <p>
+//     * Test user root.
+//     * </p>
+//     */
+//    public void testSSOGroup() throws Exception
+//    {
+//        System.out.println("*************************************\n" + "Start Unit Test for SSO Group Support"
+//                + "\n*************************************");
+//
+//        // Create a user
+//        try
+//        {
+//            ums.addUser(TEST_GROUP_USER);
+//        }
+//        catch (SecurityException sex)
+//        {
+//            // assertTrue("user already exists. exception caught: " + sex, false);
+//        }
+//
+//        // Create a group
+//        try
+//        {
+//            gms.addGroup(TEST_GROUP);
+//            System.out.println("Creating Group " + TEST_GROUP + " and adding User " + TEST_GROUP_USER + " succeeded!.");
+//        }
+//        catch (SecurityException secex)
+//        {
+//            System.out.println("Creating Group " + TEST_GROUP + " and adding User " + TEST_GROUP_USER
+//                    + " failed. Group might already exist. Continue test...");
+//            // secex.printStackTrace();
+//            // throw new Exception(secex.getMessage());
+//        }
+//
+//        if (gms.groupExists(TEST_GROUP))
+//        {
+//            // Add user to Group
+//            gms.addUserToGroup(TEST_GROUP_USER, TEST_GROUP);
+//        }
+//        else
+//        {
+//            assertTrue("Could not create group. Abort test.", false);
+//        }
+//
+//        // Initialization of Group
+//        
+//        Principal principal = gms.newTransientGroup(TEST_GROUP);
+//        Set principals = new HashSet();
+//        principals.add(principal);
+//        Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
+//
+//        // Add SSO Credential for Group
+//        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
+//        {
+//            try
+//            {
+//                ssoBroker.addCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_1);
+//                System.out.println("SSO Credential added for Group:" + TEST_GROUP + " site: " + TEST_URL);
+//            }
+//            catch (SSOException ssoex)
+//            {
+//                System.out.println("SSO Credential add FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
+//                ssoex.printStackTrace();
+//                throw new Exception(ssoex.getMessage());
+//            }
+//        }
+//        else
+//        {
+//            System.out.println("Group:" + TEST_GROUP + " site: " + TEST_URL + " has already a remote credential");
+//        }
+//
+//        // Create Principal for User
+//        principal = ums.newTransientUser(TEST_GROUP_USER);
+//        principals = new HashSet();
+//        principals.add(principal);
+//        subject = new Subject(true, principals, new HashSet(), new HashSet());
+//
+//        // User should have credential for site
+//        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
+//        {
+//            // Group expansion failed. User not recognized
+//            System.out.println("No SSO Credential for user:" + TEST_GROUP_USER + " site: " + TEST_URL);
+//
+//            // Test failure
+//            try
+//            {
+//                ums.removeUser(TEST_GROUP_USER);
+//                gms.removeGroup(TEST_GROUP);
+//            }
+//            catch (SecurityException sex)
+//            {
+//                assertTrue("could not remove user and group. exception caught: " + sex, false);
+//            }
+//
+//            throw new Exception("SSO Unit test for Group support failed");
+//        }
+//        else
+//        {
+//            // Group lookup succesful
+//            System.out.println("SSO Test for Group support successful" + "\nSSO Credential for user:" + TEST_GROUP_USER
+//                    + " site: " + TEST_URL + " found. User is member of Group " + TEST_GROUP);
+//        }
+//
+//        // Cleanup test.
+//
+//        /*
+//         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
+//         * constrGroupPrincipalImplaint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
+//         * releases
+//         */
+//        try
+//        {
+//            // Remove credential for Site
+//            ssoBroker.removeCredentialsForSite("/group/" + TEST_GROUP, TEST_URL);
+//            System.out.println("SSO Credential removed for Group:" + TEST_GROUP + " site: " + TEST_URL);
+//        }
+//        catch (SSOException ssoex)
+//        {
+//            System.out.println("SSO Credential remove FAILED for Group:" + TEST_GROUP + " site: " + TEST_URL);
+//            throw new Exception(ssoex.getMessage());
+//        }
+//
+//        try
+//        {
+//            ums.removeUser(TEST_GROUP_USER);
+//            gms.removeGroup(TEST_GROUP);
+//        }
+//        catch (SecurityException sex)
+//        {
+//            assertTrue("could not remove user and group. exception caught: " + sex, false);
+//        }
+//
+//    }
+//
+//    public void testSSO() throws Exception
+//    {
+//        System.out.println("***************************\nStart Unit Test for SSO API\n***************************");
+//
+//        // Create a user
+//        try
+//        {
+//            ums.addUser(TEST_USER);
+//        }
+//        catch (SecurityException sex)
+//        {
+//            // assertTrue("user already exists. exception caught: " + sex, false);
+//        }
+//
+//        // Initialization
+//        Principal principal = ums.newTransientUser(TEST_USER);
+//        Set principals = new HashSet();
+//        principals.add(principal);
+//        Subject subject = new Subject(true, principals, new HashSet(), new HashSet());
+//
+//        if (ssoBroker.hasSSOCredentials(subject, TEST_URL) == false)
+//        {
+//            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL);
+//
+//            // Add credential
+//            try
+//            {
+//                ssoBroker.addCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_1);
+//                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL);
+//            }
+//            catch (SSOException ssoex)
+//            {
+//                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL);
+//                ssoex.printStackTrace();
+//                throw new Exception(ssoex.getMessage());
+//            }
+//        }
+//        else
+//        {
+//            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL);
+//        }
+//
+//        // Add another remote principal for the same user
+//        if (ssoBroker.hasSSOCredentials(subject, TEST_URL2) == false)
+//        {
+//            System.out.println("No SSO Credential for user:" + TEST_USER + " site: " + TEST_URL2);
+//
+//            // Add credential
+//            try
+//            {
+//                ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
+//                ssoBroker.setRealmForSite(TEST_URL2, "Nagios Access");
+//                
+//                System.out.println("SSO Credential added for user:" + TEST_USER + " site: " + TEST_URL2);
+//            }
+//            catch (SSOException ssoex)
+//            {
+//                System.out.println("SSO Credential add FAILED for user:" + TEST_USER + " site: " + TEST_URL2);
+//                ssoex.printStackTrace();
+//                throw new Exception(ssoex.getMessage());
+//            }
+//        }
+//        else
+//        {
+//            System.out.println("SSO Credential found for user:" + TEST_USER + " site: " + TEST_URL2);
+//        }
+//
+//        // Add the credentail again -- should get an error
+//        try
+//        {
+//            ssoBroker.addCredentialsForSite(subject, REMOTE_USER2, TEST_URL2, REMOTE_PWD_2);
+//            throw new Exception("Added same credentail twice -- API should prevent users from doing that.");
+//
+//        }
+//        catch (SSOException ssoex)
+//        {
+//            System.out.println("Adding same SSO Credential twice failed (as expected) Message :" + ssoex.getMessage());
+//        }
+//        catch (Exception e)
+//        {
+//            throw new Exception("Adding SSO Credential twice throw an unandled exception. Error: " + e.getMessage());
+//        }
+//
+//        // Test if the credential where persisted
+//
+//        // Test credential update
+//        SSOContext ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
+//        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
+//                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL);
+//
+//        System.out.println("SSO Credential: User:" + ssocontext.getRemotePrincipalName() + " Password: "
+//                + ssocontext.getRemoteCredential() + " for site: " + TEST_URL2);
+//
+//        try
+//        {
+//            // Update Remote credential
+//            System.out.println("SSO Credential Update");
+//            ssoBroker.updateCredentialsForSite(subject, REMOTE_USER, TEST_URL, REMOTE_PWD_2);
+//
+//            ssocontext = ssoBroker.getCredentials(subject, TEST_URL);
+//            System.out.println("SSO Credential updated: User:" + ssocontext.getRemotePrincipalName() + " Password: "
+//                    + ssocontext.getRemoteCredential());
+//
+//        }
+//        catch (SSOException ssoex)
+//        {
+//            System.out.println("SSO Credential update FAILED for user:" + TEST_USER + " site: " + TEST_URL);
+//            throw new Exception(ssoex.getMessage());
+//        }
+//          
+//        /*
+//         * For hypersonic the cascading deletes are not generated by Torque and the remove credentials fails with a
+//         * constraint error. Comment test out for M1 release but the problem needs to be addressed for the upcoming
+//         * releases try { // Remove credential for Site ssoBroker.removeCredentialsForSite(subject, TEST_URL);
+//         * System.out.println("SSO Credential removed for user:" + TEST_USER+ " site: " + TEST_URL); }
+//         * catch(SSOException ssoex) { System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " +
+//         * TEST_URL); throw new Exception(ssoex.getMessage()); }
+//         */
+//
+//        Iterator sites = ssoBroker.getSites("");
+//        while (sites.hasNext())
+//        {
+//            SSOSite site = (SSOSite) sites.next();
+//            System.out.println("Site = " + site.getName());
+//        }
+//        // Cleanup
+//        try
+//        {
+//        	ssoBroker.removeCredentialsForSite(subject, TEST_URL);
+//        	ssoBroker.removeCredentialsForSite(subject, TEST_URL2);
+//        	System.out.println("SSO Credential removed for user:" + TEST_USER+ " sites: " + TEST_URL + " " + TEST_URL2); 
+//        }
+//        catch(SSOException ssoex) 
+//        { 
+//        	System.out.println("SSO Credential remove FAILED for user:" + TEST_USER+ " site: " + TEST_URL + " and " + TEST_URL2); 
+//        	throw new Exception(ssoex.getMessage());
+//        }
+//
+//    }
 
     /**
      * <p>

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java Tue Jan 20 11:10:43 2009
@@ -17,24 +17,24 @@
 package org.apache.jetspeed.portlet;
 
 import java.io.IOException;
-import java.security.AccessControlContext;
-import java.security.AccessController;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
 import javax.portlet.PortletPreferences;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.security.auth.Subject;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.jetspeed.security.JSSubject;
-import org.apache.jetspeed.sso.SSOContext;
+import org.apache.jetspeed.portlet.sso.SSOPortletUtil;
+import org.apache.jetspeed.security.PasswordCredential;
 import org.apache.jetspeed.sso.SSOException;
-import org.apache.jetspeed.sso.SSOProvider;
+import org.apache.jetspeed.sso.SSOManager;
+import org.apache.jetspeed.sso.SSOSite;
+import org.apache.jetspeed.sso.SSOUser;
 
 /**
  * SSOIFramePortlet
@@ -63,13 +63,13 @@
     public static final String SSO_FORM_CREDENTIAL = "ssoCredential";
     
     private PortletContext context;
-    private SSOProvider sso;
+    private SSOManager sso;
 
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
         context = getPortletContext();
-        sso = (SSOProvider)context.getAttribute("cps:SSO");
+        sso = (SSOManager)context.getAttribute("cps:SSO");
         if (null == sso)
         {
            throw new PortletException("Failed to find SSO Provider on portlet initialization");
@@ -79,28 +79,38 @@
     public void doEdit(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        try
-        {
-            Subject subject = getSubject();                 
-            String site = request.getPreferences().getValue("SRC", "");
-            SSOContext context = sso.getCredentials(subject, site);
-            getContext(request).put(SSO_FORM_PRINCIPAL, context.getRemotePrincipalName());
-            getContext(request).put(SSO_FORM_CREDENTIAL, context.getRemoteCredential());
-        }
-        catch (SSOException e)
-        {
-            if (e.getMessage().equals(SSOException.NO_CREDENTIALS_FOR_SITE))
-            {
-                // no credentials configured in SSO store
-                // switch to SSO Configure View
-                getContext(request).put(SSO_FORM_PRINCIPAL, "");
-                getContext(request).put(SSO_FORM_CREDENTIAL, "");
+        String siteUrl = request.getPreferences().getValue("SRC", "");
+        
+        SSOSite site = sso.getSiteByUrl(siteUrl);
+        if (site != null){
+            try
+            {
+                SSOUser remoteUser = SSOPortletUtil.getRemoteUser(sso,request,site);
+                if (remoteUser != null){
+                    PasswordCredential pwc = sso.getCredentials(remoteUser);
+                    getContext(request).put(SSO_FORM_PRINCIPAL, pwc.getUserName());
+                    getContext(request).put(SSO_FORM_CREDENTIAL, pwc.getPassword());
+                } else {
+                    getContext(request).put(SSO_FORM_PRINCIPAL, "");
+                    getContext(request).put(SSO_FORM_CREDENTIAL, "");
+                }
             }
-            else
+            catch (SSOException e)
             {
-                throw new PortletException(e);
-            }
-        }        
+                if (e.getMessage().equals(SSOException.NO_CREDENTIALS_FOR_SITE))
+                {
+                    // no credentials configured in SSO store
+                    // switch to SSO Configure View
+                    getContext(request).put(SSO_FORM_PRINCIPAL, "");
+                    getContext(request).put(SSO_FORM_CREDENTIAL, "");
+                }
+                else
+                {
+                    throw new PortletException(e);
+                }
+            }       
+        }
+         
         
         super.doEdit(request, response);
     }
@@ -108,7 +118,11 @@
     public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        String site = request.getPreferences().getValue("SRC", null);
+        String siteUrl = request.getPreferences().getValue("SRC", null);
+        SSOSite site = null;
+        if (siteUrl != null){
+            site = sso.getSiteByUrl(siteUrl);
+        }
         if (site == null)
         {
             // no credentials configured in SSO store
@@ -121,10 +135,15 @@
         
         try
         {
-            Subject subject = getSubject();                 
-            SSOContext context = sso.getCredentials(subject, site);
-            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, context.getRemotePrincipalName());
-            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, context.getRemoteCredential());
+            SSOUser remoteUser = SSOPortletUtil.getRemoteUser(sso,request,site);
+            if (remoteUser != null){
+                PasswordCredential pwc = sso.getCredentials(remoteUser);
+                request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
+                request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
+            } else {
+                request.setAttribute(PARAM_VIEW_PAGE, this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
+                setupPreferencesEdit(request, response);
+            }
         }
         catch (SSOException e)
         {
@@ -154,42 +173,28 @@
         // ssoUserName 
         String ssoPrincipal = request.getParameter(SSO_FORM_PRINCIPAL);
         String ssoCredential = request.getParameter(SSO_FORM_CREDENTIAL);        
-        /*
         if (ssoPrincipal == null || ssoCredential == null)
         {
-            
             actionResponse.setPortletMode(PortletMode.EDIT); // stay on edit
         }
-        */
-        String site = request.getPreferences().getValue("SRC", "");
-        try
-        {
-            Subject subject = getSubject();
-            if (sso.hasSSOCredentials(subject, site))
+        
+        String siteUrl = request.getPreferences().getValue("SRC", "");
+        SSOSite site = sso.getSiteByUrl(siteUrl);
+        if (site != null){
+            try
             {
-                SSOContext context = sso.getCredentials(subject, site);
-                if (!context.getRemotePrincipalName().equals(ssoPrincipal))
-                {
-                    sso.removeCredentialsForSite(subject, site);
-                    sso.addCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
-                }
-                else
-                {
-                    sso.updateCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
-                }
+                SSOPortletUtil.updateUser(sso,request,site,ssoPrincipal, ssoCredential);
             }
-            else
+            catch (SSOException e)
             {
-                sso.addCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
+                throw new PortletException(e);
             }
         }
-        catch (SSOException e)
-        {
-            throw new PortletException(e);
-        }
         
     }
     
+   
+    
     public String getURLSource(RenderRequest request, RenderResponse response, PortletPreferences prefs)
     {
         String baseSource = super.getURLSource(request, response, prefs);
@@ -236,10 +241,4 @@
         }
     }
     
-    private Subject getSubject()
-    {
-        AccessControlContext context = AccessController.getContext();
-        return JSSubject.getSubject(context);         
-    }
-    
 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java Tue Jan 20 11:10:43 2009
@@ -44,11 +44,18 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.portlet.sso.SSOPortletUtil;
 import org.apache.jetspeed.rewriter.WebContentRewriter;
 import org.apache.jetspeed.security.JSSubject;
-import org.apache.jetspeed.sso.SSOContext;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.sso.SSOException;
-import org.apache.jetspeed.sso.SSOProvider;
+import org.apache.jetspeed.sso.SSOManager;
+import org.apache.jetspeed.sso.SSOSite;
+import org.apache.jetspeed.sso.SSOUser;
 import org.apache.portals.messaging.PortletMessaging;
 
 
@@ -121,7 +128,8 @@
     // Data Members
     
     protected PortletContext context;
-    protected SSOProvider sso;
+    protected SSOManager sso;
+    protected UserManager userManager;
     
     
     // Methods
@@ -130,11 +138,28 @@
     {
         super.init(config);
         context = getPortletContext();
-        sso = (SSOProvider)context.getAttribute("cps:SSO");
+        sso = (SSOManager)context.getAttribute("cps:SSO");
         if (null == sso)
         {
-           throw new PortletException("Failed to find SSO Provider on portlet initialization");
+           throw new PortletException("Failed to find SSO Manager on portlet initialization");
         }        
+        userManager = (UserManager) context.getAttribute(CommonPortletServices.CPS_USER_MANAGER_COMPONENT);
+        if (null == userManager)
+        {
+            throw new PortletException("Failed to find the User Manager on portlet initialization");
+        }
+    }
+    
+    protected JetspeedPrincipal getLocalPrincipal(String localUserName){
+        JetspeedPrincipal localPrincipal = null;
+        
+        try{
+            localPrincipal = userManager.getUser(localUserName);
+        } catch (SecurityException secex){
+            
+        }
+        
+        return localPrincipal;
     }
     
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
@@ -142,8 +167,8 @@
     {
         // grab parameters - they will be cleared in processing of edit response
         String webContentParameter = actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
-        String ssoPrincipal = actionRequest.getParameter(SSO_EDIT_FIELD_PRINCIPAL);
-        String ssoCredential = actionRequest.getParameter(SSO_EDIT_FIELD_CREDENTIAL);        
+        String ssoPrincipalName = actionRequest.getParameter(SSO_EDIT_FIELD_PRINCIPAL);
+        String ssoPrincipalPassword = actionRequest.getParameter(SSO_EDIT_FIELD_CREDENTIAL);        
 
         // save the prefs
         super.processAction(actionRequest, actionResponse);
@@ -153,28 +178,37 @@
         {
             // processPreferencesAction(request, actionResponse);
             // get the POST params -- requires HTML post params named above 
-            String site = actionRequest.getPreferences().getValue("SRC", "");
-            
+            String siteName = actionRequest.getPreferences().getValue("SRC", "");
+            String localUser = actionRequest.getUserPrincipal().getName();
             try
             {
-                Subject subject = getSubject();
-                if (sso.hasSSOCredentials(subject, site))
-                {
-                    SSOContext context = sso.getCredentials(subject, site);
-                    if (!context.getRemotePrincipalName().equals(ssoPrincipal))
-                    {
-                        sso.removeCredentialsForSite(subject, site);
-                        sso.addCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
+                SSOSite site = sso.getSiteByName(siteName);
+                if (site != null){
+                    
+                    JetspeedPrincipal localPrincipal = getLocalPrincipal(localUser);
+                    
+                    // find the remote user related directly to the User principal of this user, the user's "private" SSO credentials.
+                    SSOUser currentSSOUser = SSOPortletUtil.getRemoteUser(sso, actionRequest, site);
+                    PasswordCredential pwc = sso.getCredentials(currentSSOUser);
+                	
+                	
+                    if (pwc != null)                    {
+                        
+                        if (!pwc.getUserName().equals(ssoPrincipalName))
+                        {
+                            sso.removeUser(currentSSOUser);                            
+                            sso.addUser(site,localPrincipal,ssoPrincipalName,ssoPrincipalPassword);
+                        }
+                        else
+                        {
+                            sso.setPassword(currentSSOUser,ssoPrincipalPassword);
+                        }
                     }
                     else
                     {
-                        sso.updateCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
+                    	sso.addUser(site,localPrincipal,ssoPrincipalName,ssoPrincipalPassword);
                     }
                 }
-                else
-                {
-                    sso.addCredentialsForSite(subject, ssoPrincipal, site, ssoCredential);
-                }
             }
             catch (SSOException e)
             {
@@ -186,35 +220,31 @@
     public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        String site = request.getPreferences().getValue("SRC", null);
-
+        String siteName = request.getPreferences().getValue("SRC", null);
+        SSOSite site = null;
+        if (siteName != null){
+            site = sso.getSiteByName(siteName);
+        }
         if (site == null)
         {
-            // no SRC configured in prefs - switch to SSO Configure View
+            // no SRC configured in prefs / site not found - switch to SSO Configure View
             request.setAttribute(PARAM_VIEW_PAGE, this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
             setupPreferencesEdit(request, response);
         }
-        else try
-        {
-            Subject subject = getSubject();                 
-            SSOContext context = sso.getCredentials(subject, site);
-            request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, context.getRemotePrincipalName());
-            request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, context.getRemoteCredential());
-        }
-        catch (SSOException e)
+        else 
         {
-            if (e.getMessage().equals(SSOException.NO_CREDENTIALS_FOR_SITE))
-            {
+        	PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso,siteName,request);
+        	if (pwc != null){
+                request.setAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME, pwc.getUserName());
+                request.setAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD, pwc.getPassword());
+        	} else {
                 // no credentials configured in SSO store
                 // switch to SSO Configure View
                 request.setAttribute(PARAM_VIEW_PAGE, this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
                 setupPreferencesEdit(request, response);    
-            }
-            else
-            {
-                throw new PortletException(e);
-            }
-        }        
+        	}
+        }
+         
         
         super.doView(request, response);
     }
@@ -223,29 +253,17 @@
     public void doEdit(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        try
-        {
-            Subject subject = getSubject();                 
-            String site = request.getPreferences().getValue("SRC", "");
-            SSOContext context = sso.getCredentials(subject, site);
-            getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, context.getRemotePrincipalName());
-            getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, context.getRemoteCredential());
+        String site = request.getPreferences().getValue("SRC", "");
+    	PasswordCredential pwc = SSOPortletUtil.getCredentialsForSite(sso,site,request);
+    	if (pwc != null){
+            getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, pwc.getUserName());
+            getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, pwc.getPassword());
+        } else {
+            // no credentials configured in SSO store
+            // switch to SSO Configure View
+            getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, "");
+            getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, "");
         }
-        catch (SSOException e)
-        {
-            if (e.getMessage().equals(SSOException.NO_CREDENTIALS_FOR_SITE))
-            {
-                // no credentials configured in SSO store
-                // switch to SSO Configure View
-                getContext(request).put(SSO_EDIT_FIELD_PRINCIPAL, "");
-                getContext(request).put(SSO_EDIT_FIELD_CREDENTIAL, "");
-            }
-            else
-            {
-                throw new PortletException(e);
-            }
-        }        
-        
         super.doEdit(request, response);
     }
 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java Tue Jan 20 11:10:43 2009
@@ -524,7 +524,7 @@
     
     protected HttpMethodBase getHttpMethod(HttpClient client, String uri, Map params, String formMethod, RenderRequest request) throws IOException
     {
-        formMethod = FORM_MULTIPART_METHOD;
+        // formMethod = FORM_MULTIPART_METHOD;
         HttpMethodBase httpMethod = null;
         String useragentProperty = request.getProperty("User-Agent");
         if(formMethod.equalsIgnoreCase(FORM_MULTIPART_METHOD)){ 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java?rev=736069&r1=736068&r2=736069&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java Tue Jan 20 11:10:43 2009
@@ -22,6 +22,9 @@
 import java.io.IOException;
 import java.security.AccessControlContext;
 import java.security.AccessController;
+import java.security.Principal;
+import java.util.Collection;
+
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
@@ -33,8 +36,12 @@
 import javax.security.auth.Subject;
 
 import org.apache.jetspeed.security.JSSubject;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.sso.SSOClient;
 import org.apache.jetspeed.sso.SSOException;
-import org.apache.jetspeed.sso.SSOProvider;
+import org.apache.jetspeed.sso.SSOManager;
+import org.apache.jetspeed.sso.SSOSite;
+import org.apache.jetspeed.sso.SSOUser;
 import org.apache.portals.bridges.common.ScriptPostProcess;
 import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
 
@@ -53,7 +60,7 @@
  */
 public class SSOProxyPortlet extends GenericVelocityPortlet {
     private PortletContext context;
-    private SSOProvider sso;
+    private SSOManager sso;
     
     /* Re-use Proxy client inside the SSO Component */
     private boolean isAuthenticated = false;
@@ -76,19 +83,17 @@
     
     /** ForceSSORefresh*/
     static final String FORCE_SSO_REFRESH = "ForceSSORefresh";
-    
+
     /** Encoding*/
     static final String ENCODING = "Encoding";
     
-    private String destinationURL;
-    private String ssoSite;
     private String encoding;
 
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
         context = getPortletContext();
-        sso = (SSOProvider)context.getAttribute("cps:SSO");
+        sso = (SSOManager) context.getAttribute("cps:SSO");
         if (null == sso)
         {
            throw new PortletException("Failed to find SSO Provider on portlet initialization");
@@ -100,15 +105,15 @@
     throws PortletException, IOException
     {
        	String ssoProxyAction = request.getParameter(ACTION_PARAMETER_SSOPROXY); 
-//       	System.out.println("SSOProxy Action value [" + ssoProxyAction + "]");
        	
-     	if ( ssoProxyAction != null && ssoProxyAction.length() > 0)
-     		this.destinationURL = ssoProxyAction;
-     	else
-     		this.destinationURL = request.getParameter(DESTINATION_URL);
+       	
+//     	if ( ssoProxyAction != null && ssoProxyAction.length() > 0)
+//     		this.destinationURL = ssoProxyAction;
+//     	else
+//     		this.destinationURL = request.getParameter(DESTINATION_URL);
      	
      	
-        this.ssoSite = request.getParameter(SSO_SITE);
+        // this.ssoSiteName = request.getParameter(SSO_SITE);
         this.encoding = request.getParameter(ENCODING);
         if (this.encoding == null)
         	this.encoding =  this.defaultEncoding;
@@ -120,78 +125,70 @@
     public void doView(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
-        String forceRefresh = request.getPreferences().getValue(FORCE_SSO_REFRESH, "false");
-
-        if (destinationURL == null || destinationURL.length() == 0)
+        boolean forceRefresh = Boolean.parseBoolean(request.getPreferences().getValue(FORCE_SSO_REFRESH, "false"));
+        String destinationURL = request.getPreferences().getValue(DESTINATION_URL,null);
+        String ssoSiteName = request.getPreferences().getValue(SSO_SITE,null);
+        
+        if (ssoSiteName == null)
         {
             // No destination configured Switch to configure View
-             request.setAttribute(PARAM_VIEW_PAGE, this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
+            request.setAttribute(PARAM_VIEW_PAGE, this.getPortletConfig().getInitParameter(PARAM_EDIT_PAGE));
             setupPreferencesEdit(request, response);
             super.doView(request, response);
             return;
         }
         
-//      Set the content type
+        // Set the content type
         response.setContentType("text/html");
         
-        /*
-         * Call into the SSO Proxy and process the result page
-         */
-        boolean doRefresh = false;
-        if ( (forceRefresh.compareToIgnoreCase("TRUE") == 0) || this.isAuthenticated == false)
-        	doRefresh = true;
-       
         try
         {
         	StringBuffer page= new StringBuffer();
-            Subject subject = getSubject(); 
-            if (ssoSite == null || ssoSite.length() ==0)
-            	page.append(sso.useSSO(subject, destinationURL,doRefresh));
-            else
-            	page.append(sso.useSSO(subject, destinationURL,ssoSite, doRefresh));
-            
-            // Authentication done at least once
-            this.isAuthenticated = true;
-            /*
-            bis.mark(BLOCK_SIZE);
-            String pageEncoding = getContentCharSet(bis);
-            if (pageEncoding == null)
-            {
-            	pageEncoding = encoding;
-            }
-            
-            Reader read = new InputStreamReader(bis, encoding);
-            
-            
-			char[] bytes = new char[BLOCK_SIZE];
-			
-			int len = read.read(bytes, 0, BLOCK_SIZE);			
-			while (len > 0)
-			{
-				page.append(bytes, 0, len);
-				len = read.read(bytes, 0, BLOCK_SIZE);
-			}
-			
-            //Done
-            read.close();
-            */
-            // Rewrite
-			// Post Process for generated page		
-			PortletURL actionURL = response.createActionURL();
-			ScriptPostProcess processor = new ScriptPostProcess();
-			processor.setInitalPage(page);
-			processor.postProcessPage(actionURL, ACTION_PARAMETER_SSOPROXY);
-			String finalPage = processor.getFinalizedPage();
-			
-			// Write the page
-			response.getWriter().println(finalPage);
+            // Subject subject = getSubject(); 
+            // TODO refactor
+        	// if (sso)
+        	SSOSite site = sso.getSiteByName(ssoSiteName);
+        	if (site == null){
+        		response.getWriter().println("<P>Could not find site with name "+ssoSiteName+"</P>");
+        		return;
+        	}
+        	if (destinationURL == null){
+        		destinationURL = site.getURL();
+        	}
+        	
+        	Principal p = request.getUserPrincipal();
+        	if (p instanceof JetspeedPrincipal){
+                Collection<SSOUser> remoteUsers = sso.getRemoteUsers(site,getSubject());
+                if (remoteUsers.size() > 0){
+                    // TODO: in case of multiple users, invent a way to choose one of them
+                    //   right now, simply the first SSO user is selected
+                    SSOUser remoteUser = remoteUsers.iterator().next();
+                    SSOClient client = sso.getClient(site, remoteUser);
+                    if (client == null){
+                        response.getWriter().println("<P>Could not create client for site with name "+ssoSiteName+" and user "+request.getUserPrincipal().getName()+"</P>");
+                        return;
+                    }
+                    
+                    client.write(destinationURL, forceRefresh, response.getWriter());
+
+                    PortletURL actionURL = response.createActionURL();
+                    ScriptPostProcess processor = new ScriptPostProcess();
+                    processor.setInitalPage(page);
+                    processor.postProcessPage(actionURL, ACTION_PARAMETER_SSOPROXY);
+                    String finalPage = processor.getFinalizedPage();
+                    
+                    // Write the page
+                    response.getWriter().println(finalPage);
+                }
+        	    
+                
+
+        	}
         
         }
         catch (SSOException e)
         {
-        	response.getWriter().println("<P>Error rendering page. Error message<BR>" + e.getMessage() + "</P>");
-        	
-        	this.destinationURL ="";   
+        	response.getWriter().println("<P>Error rendering page. Error message<BR>" + e.getMessage() + "</P>");        	
         }          
     }
     



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