portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r734954 [3/4] - in /portals/jetspeed-2/portal/trunk: ./ applications/jetspeed-demo/ applications/jetspeed-dependencies/ components/ components/jetspeed-db-tools/ components/jetspeed-portal/ components/jetspeed-security/src/main/java/org/apa...
Date Fri, 16 Jan 2009 10:07:34 GMT
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,554 @@
+/*
+ * 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;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.PrincipalTypeManager;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.User;
+import org.apache.jetspeed.security.impl.RoleImpl;
+import org.apache.jetspeed.sso.impl.SSOUserImpl;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public class TestSSOManager extends AbstractSecurityTestCase
+{
+
+    public static final String TESTSITE = "testsite";
+    public static final String ANOTHER_TESTSITE = "anotherTestSite";
+
+    public static final String TESTUSER = "testuser";
+    public static final String ANOTHER_TESTUSER = "anotherTestUser";
+
+    public static final String TESTGROUP = "testgroup";
+    public static final String ANOTHER_TESTGROUP = "anotherTestGroup";
+
+    /** The property manager. */
+    private static SSOManager ssoManager = null;
+    
+    private User testuser;
+    private User anotherTestuser;
+    
+    private Group testgroup;
+    private Group anotherTestgroup;
+    
+    private SSOSite testSite;
+    private SSOSite anotherTestSite;
+    
+    /*
+     * 
+     * 
+
+X    SSOUser getRemoteUser(SSOSite site, JetspeedPrincipal principal);
+
+X    SSOUser getRemoteUser(SSOSite site, String remoteUserName);
+
+X    Collection<SSOUser> getRemoteUsers(SSOSite site, Subject subject) throws SSOException;
+
+X    PasswordCredential getCredentials(SSOUser user) throws SSOException;
+
+X    Collection<SSOSite> getSitesForPrincipal(JetspeedPrincipal principal);
+
+     Collection<SSOSite> getSitesForSubject(Subject subject) throws SSOException;
+     
+X    Collection<SSOUser> getUsersForSite(SSOSite site);
+     
+X    Collection<SSOSite> getSites(String filter);
+     
+X    SSOSite getSiteByUrl(String siteUrl);
+
+X    SSOSite getSiteByName(String siteName);
+
+X    void setCredentials(SSOUser user, String pwd) throws SSOException;
+     
+X    void removeUser(SSOUser remoteUser) throws SSOException;
+     
+X    void updateSite(SSOSite site) throws SSOException;
+     
+X    void addSite(String siteName, String siteUrl) throws SSOException; 
+     
+X    void addSite(Long ownerDomainId, String siteName, String siteUrl) throws SSOException;
+     
+X    void removeSite(SSOSite site) throws SSOException;
+     
+X    void addUser(SSOSite site, JetspeedPrincipal localPrincipal, String ssoUsername, String ssoUserPassword) throws SSOException;
+
+    Collection<JetspeedPrincipal> getPortalPrincipals(SSOUser user);
+
+     
+     * 
+     * 
+ 
+     
+     */
+    public void testAddAndFetchSites() throws Exception {
+        addTestUser();
+        addAnotherTestUser();
+        addTestSite();
+        addAnotherTestSite();
+        
+        // test fetching a single site
+        SSOSite site = ssoManager.getSiteByName(TESTSITE);
+        assertEquals(TESTSITE,site.getName());
+        assertEquals("http://www.blah.com",site.getURL());
+        assertNotNull(site.getSecurityDomainId());
+
+        ssoManager.addSite(ssoManager.newSite("foo", "http://www.foo.com"));
+        site = ssoManager.getSiteByName("foo");
+        assertEquals("foo",site.getName());
+        assertEquals("http://www.foo.com",site.getURL());
+        assertNotNull(site.getSecurityDomainId());
+        
+        site = ssoManager.getSiteById(site.getId());
+        assertNotNull(site);
+        
+        site = ssoManager.getSiteByUrl("http://www.foo.com");
+        assertEquals("foo",site.getName());
+        
+        // test fetching multiple sites
+        ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+        
+        Collection<SSOSite> sites = ssoManager.getSitesForPrincipal(testuser);
+        
+        assertEquals(1,sites.size());
+        
+        assertEquals(TESTSITE,sites.iterator().next().getName());
+        
+        sites = ssoManager.getSitesForPrincipal(anotherTestuser);
+        
+        assertEquals(0,sites.size());
+
+        ssoManager.addUser(testSite, anotherTestuser, "remoteUserForAnotherLocalUser", "anotherRemotePwd");
+        ssoManager.addUser(anotherTestSite, anotherTestuser, "someRemoteUser", "someRemotePwd");
+
+        sites = ssoManager.getSitesForPrincipal(anotherTestuser);
+        
+        assertEquals(2,sites.size());
+        
+        ssoManager.removeSite(testSite);
+        
+        site = ssoManager.getSiteByName(TESTSITE);
+        assertNull(site);
+        
+        sites = ssoManager.getSitesForPrincipal(anotherTestuser);
+        
+        assertEquals(1,sites.size());
+        
+        assertEquals(ANOTHER_TESTSITE,sites.iterator().next().getName());
+        
+    }
+    
+    public void testWildCardSiteSearch() throws Exception {
+
+        // test fetching sites with wildcard searches
+        ssoManager.addSite(ssoManager.newSite("Our Website", "http://portals.apache.org/jetspeed-2"));
+        ssoManager.addSite(ssoManager.newSite("Their Website", "http://some.other.portal/"));
+        ssoManager.addSite(ssoManager.newSite("Foo", "http://www.site.com"));
+        ssoManager.addSite(ssoManager.newSite("F%oB%r", "http://www.site-name-with-weird-chars.com"));
+        
+        // match name
+        
+        Collection<SSOSite> sites = ssoManager.getSites("Website");
+        assertEquals(2, sites.size());
+
+        // matches both url and name
+        sites = ssoManager.getSites("site");
+        assertEquals(4, sites.size());
+        
+        // matches only url
+        sites = ssoManager.getSites("portal");
+        assertEquals(2, sites.size());
+
+        // matches nothing
+        sites = ssoManager.getSites("nothing");
+        assertEquals(0, sites.size());
+
+        // matches sites with % in name or url
+        sites = ssoManager.getSites("%oB");
+        assertEquals(1, sites.size());
+
+    }
+    
+    public void testUpdateSite() throws Exception {
+        addTestSite();
+        
+        SSOSite s = ssoManager.getSiteByName(TESTSITE);
+
+        s.setURL("SomeOtherUrl");
+        ssoManager.updateSite(s);
+        s = ssoManager.getSiteByName(TESTSITE);
+        assertEquals("SomeOtherUrl", s.getURL());
+        
+        s.setName("otherName");
+        ssoManager.updateSite(s);
+        s = ssoManager.getSiteByName("otherName");
+        assertEquals("SomeOtherUrl", s.getURL());
+        
+        s.setAllowUserSet(true);
+        s.setCertificateRequired(true);
+        s.setChallengeResponseAuthentication(true);
+        s.setFormAuthentication(true);
+        s.setFormPwdField("formPwdField");
+        s.setFormUserField("formUserField");
+        s.setRealm("realm");
+        s.setURL("siteURL");
+        
+        ssoManager.updateSite(s);
+        s = ssoManager.getSiteByUrl("siteURL");
+        assertTrue(s.isAllowUserSet());
+        assertTrue(s.isCertificateRequired());
+        assertTrue(s.isChallengeResponseAuthentication());
+        assertTrue(s.isFormAuthentication());
+        assertEquals("formPwdField",s.getFormPwdField());
+        assertEquals("formUserField",s.getFormUserField());
+        assertEquals("realm",s.getRealm());
+        assertEquals("siteURL",s.getURL());
+    }
+    
+    public void testFecthSitesForSubject() throws Exception {
+        addTestUser();
+        addAnotherTestUser();
+        addTestSite();
+        addAnotherTestSite();
+        addTestGroup();        
+        
+        ssoManager.addUser(testSite, testuser, "userForTestuserPrincipal", "x");
+        ssoManager.addUser(testSite, testgroup, "foo", "x");
+        ssoManager.addUser(anotherTestSite, testgroup, "userForTestgroupPrincipal", "x");
+        
+        Subject s = new Subject();
+        s.getPrincipals().add(testuser);
+        s.getPrincipals().add(testuser); // add twice 
+        s.getPrincipals().add(testgroup);
+        // the following principal should just be ignored
+        s.getPrincipals().add(new Principal(){
+
+            public String getName()
+            {
+                return "someNonJetspeedPrincipal";
+            }
+            
+        });
+        
+        Collection<SSOSite> sites = ssoManager.getSitesForSubject(s);
+        assertEquals(2, sites.size());
+    }
+    
+    public void testAddAndFetchUsers() throws Exception {
+        addTestUser();
+        addAnotherTestUser();
+        addTestSite();
+        addAnotherTestSite();
+        addTestGroup();        
+        
+        Collection<SSOUser> users = ssoManager.getRemoteUsers(testSite, testuser);
+        assertEquals(0, users.size());
+
+        
+        User subjectUser = ums.addUser("userForSubjectTest");
+        Group subjectGroup = gms.addGroup("groupForSubjectTest");
+        
+        ssoManager.addUser(testSite, subjectUser, "userForTestuserPrincipal", "x");
+        ssoManager.addUser(testSite, subjectGroup, "userForTestgroupPrincipal", "x");
+        
+        Subject s = new Subject();
+        s.getPrincipals().add(subjectUser);
+        s.getPrincipals().add(subjectUser); // add twice 
+        s.getPrincipals().add(subjectGroup);
+        // the following principal should just be ignored
+        s.getPrincipals().add(new Principal(){
+
+            public String getName()
+            {
+                return "someNonJetspeedPrincipal";
+            }
+            
+        });
+        // add a Jetspeed role principal ==> should be ignored as well
+        s.getPrincipals().add(new RoleImpl("someRole"));
+        
+        users = ssoManager.getRemoteUsers(testSite,s);
+        assertEquals(2,users.size());
+
+        ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+        
+        // fetch user by local principal
+        users = ssoManager.getRemoteUsers(testSite, testuser);
+        assertEquals(1,users.size());
+
+        // try the other method for fetching a user, by remote user name
+        SSOUser someRemoteUser = ssoManager.getRemoteUser(testSite, "someRemoteUser");
+        assertNotNull(someRemoteUser);
+    }
+
+    public void testAddDuplicateSite() throws Exception {        
+        ssoManager.addSite(ssoManager.newSite(TESTSITE, "http://www.blah.com"));
+
+        try{
+            ssoManager.addSite(ssoManager.newSite(TESTSITE, "http://www.blah.com"));
+            assertTrue(false);
+        } catch (Exception e){
+            // caught exception, test succeeded
+        }
+
+        // test with a different name, same url
+        try{
+            ssoManager.addSite(ssoManager.newSite("foo", "http://www.blah.com"));
+            assertTrue(false);
+        } catch (Exception e){
+            // caught exception, test succeeded
+        }
+    }
+    
+    /**
+     * Tests SSOManager.testAddUserForLocalGroup()
+     */
+    public void testAddUserForLocalGroup() throws Exception {
+        addTestGroup();
+        addTestSite(); 
+        
+        ssoManager.addUser(testSite, testgroup, "someRemoteUser", "someRemotePwd");
+        
+        // fetch user by local principal
+        Collection<SSOUser> remoteUsers = ssoManager.getRemoteUsers(testSite, testgroup);
+        assertEquals(1, remoteUsers.size());
+
+        // try the other method for fetching a user, by remote user name
+        SSOUser someRemoteUser = ssoManager.getRemoteUser(testSite, "someRemoteUser");
+        assertNotNull(someRemoteUser);
+    }
+    
+    public void testRemoveUser() throws Exception {
+        addTestUser();
+        addTestSite();
+        
+        ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+        SSOUser fetchedUser = ssoManager.getRemoteUser(testSite, "someRemoteUser");
+        
+        // verify the user is really added
+        assertNotNull(fetchedUser);
+        ssoManager.removeUser(fetchedUser);
+        
+        SSOUser fetchedRemovedUser = ssoManager.getRemoteUser(testSite, "someRemoteUser");
+        assertNull(fetchedRemovedUser);
+        
+        try{
+            ssoManager.removeUser(fetchedUser);
+            assertTrue(false); // generate a test error since remove should throw exception
+        } catch (SSOException secex){
+            
+        }
+    }
+
+    /**
+     * Tests SSOManager.addUser()
+     */
+    public void testAddDuplicateUser() throws Exception {
+        addTestUser();
+        addTestSite();
+        
+        ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+
+        try{
+            ssoManager.addUser(testSite, testuser, "someRemoteUser", "whatever");
+            throw new Exception("Test failed: duplicate user was added");
+        } catch (SSOException ssoe){
+            
+        }
+        Collection<SSOUser> remoteUsers = ssoManager.getRemoteUsers(testSite, testuser);
+        assertEquals(1,remoteUsers.size());
+        
+        // test adding remote user with other local user
+        addAnotherTestUser();
+        try{
+            ssoManager.addUser(testSite, anotherTestuser, "someRemoteUser", "myOwnPwd");
+            throw new Exception("Test failed: duplicate user was added");
+        } catch (SSOException ssoe){
+            
+        }
+        
+    }
+    
+    public void testCredentials() throws Exception {
+        addTestUser();
+        addTestSite();
+        
+        SSOUser someRemoteUser = ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+        PasswordCredential pwd = ssoManager.getCredentials(someRemoteUser);
+        assertEquals("someRemotePwd",pwd.getPassword());
+        
+        ssoManager.setPassword(someRemoteUser,"anotherPassword");
+        pwd = ssoManager.getCredentials(someRemoteUser);
+        assertEquals("anotherPassword",pwd.getPassword());
+
+    }
+    
+    public void testFetchPortalPrincipals() throws Exception {
+        addTestUser();
+        addAnotherTestUser();
+        addTestGroup();
+        addAnotherTestGroup();
+        addTestSite();
+        
+        SSOUser addedUser = ssoManager.addUser(testSite, testuser, "someRemoteUser", "someRemotePwd");
+        ssoManager.addAssociation(addedUser, anotherTestuser);
+        ssoManager.addAssociation(addedUser, anotherTestuser);
+        ssoManager.addAssociation(addedUser, testgroup);
+        ssoManager.addAssociation(addedUser, anotherTestgroup);
+        
+        Collection<JetspeedPrincipal> fetchedPrincipals = ssoManager.getPortalPrincipals(addedUser);
+        assertEquals(4,fetchedPrincipals.size());
+
+        SSOUserImpl nonExistingUser = new SSOUserImpl();
+        nonExistingUser.setName("fake");
+        nonExistingUser.setDomainId(addedUser.getDomainId());
+        fetchedPrincipals = ssoManager.getPortalPrincipals(nonExistingUser);
+        assertEquals(0,fetchedPrincipals.size());
+        
+
+    }
+    
+    public void addTestSite() throws Exception {
+        testSite = ssoManager.addSite(ssoManager.newSite(TESTSITE, "http://www.blah.com"));
+    }
+    
+    public void addAnotherTestSite() throws Exception {
+        anotherTestSite = ssoManager.addSite(ssoManager.newSite(ANOTHER_TESTSITE, "http://www.alternative.com"));
+    }
+    
+    public void addTestUser() throws Exception {
+        testuser = ums.addUser(TESTUSER);
+    }
+    
+    public void addAnotherTestUser() throws Exception {
+        anotherTestuser = ums.addUser(ANOTHER_TESTUSER);
+    }
+    
+    public void addTestGroup() throws Exception {
+        testgroup = gms.addGroup(TESTGROUP);
+    }
+    
+    public void addAnotherTestGroup() throws Exception {
+        anotherTestgroup = gms.addGroup(ANOTHER_TESTGROUP);
+    }
+    
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+
+        try
+        {
+            ssoManager = (SSOManager) scm.getComponent("org.apache.jetspeed.sso.SSOManager");
+        }
+        catch (Exception ex)
+        {
+            ex.printStackTrace();
+            throw new Exception("Exception while setup SSO TEST");
+        }
+
+
+        clean();
+
+    }
+
+   
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        clean();
+        super.tearDown();
+        
+        testuser=null;
+        anotherTestuser=null;
+        
+        testgroup=null;
+        anotherTestgroup=null;
+        
+        testSite=null;
+        anotherTestSite=null;
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestSSOManager.class);
+    }
+
+    protected void tryRemovePrincipal(PrincipalTypeManager pman, String pname){
+        try{
+            pman.getPrincipalManager().removePrincipal(pname);
+        } catch (Exception e){
+            
+        }
+    }
+    
+    /**
+     * <p>
+     * Clean properties.
+     * </p>
+     */
+    protected void clean() throws Exception
+    {
+        // remove SSO Sites and SSO Users attached to each site.
+        
+        Collection<SSOSite> sites = ssoManager.getSites("");
+        if (sites != null){
+            for (SSOSite site : sites){
+                Collection<SSOUser> users = ssoManager.getUsersForSite(site);
+                for (SSOUser user : users){
+                    ssoManager.removeUser(user);
+                }
+                ssoManager.removeSite(site);
+            }
+        }
+        
+        tryRemovePrincipal(ums,"testuser");
+        tryRemovePrincipal(ums,"anotherTestuser");
+        
+        tryRemovePrincipal(gms,"testgroup");
+        tryRemovePrincipal(gms,"anotherTestgroup");
+        
+    }
+
+    protected String[] getConfigurations()
+    {
+        String[] confs = super.getConfigurations();
+        List confList = new ArrayList(Arrays.asList(confs));
+        confList.add("sso.xml");
+        return (String[]) confList.toArray(new String[1]);
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/TestSSOManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml Fri Jan 16 02:07:13 2009
@@ -0,0 +1,304 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+    
+    <!-- Cache Manager -->
+    <bean id="cacheManagerConfig" class="org.apache.jetspeed.cache.impl.EhCacheConfigResource">
+        <meta key="j2:cat" value="default,cache"/>
+        <property name="defaultConfigResource" value="ehcache.xml"/>
+        <property name="test" value="true"/>
+    </bean>
+
+    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
+        <meta key="j2:cat" value="default,cache"/>
+        <property name="configLocation" ref="cacheManagerConfig"/>
+    </bean>
+    
+    <!-- Page File Cache -->
+    <bean id="PageFileCache" class="org.apache.jetspeed.cache.file.FileCache" init-method="startFileScanner"
+        destroy-method="stopFileScanner">
+        <meta key="j2:cat" value="default,cache" />
+        <!-- Internal cache -->
+        <constructor-arg index="0">
+            <ref bean="internalPageFileCache" />
+        </constructor-arg>
+        <!-- Scan rate for changes in cached files on the file system -->
+        <constructor-arg index="1">
+            <value>10</value>
+        </constructor-arg>
+    </bean>
+    
+    <!-- Factory bean used to instantiate a EHCache with the specified name (and corresponding
+        configuration in cacheManager.xml -->
+    <bean id="ehPortletContentCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletContentCache" />
+    </bean>
+    
+    <bean id="ContentCacheKeyGenerator" class="org.apache.jetspeed.cache.impl.JetspeedCacheKeyGenerator">
+        <meta key="j2:cat" value="default,cache" />
+        <!-- Keys are order specific in the list:
+            where username  == the user principal name of the current user
+            pipeline  == the name of the active pipeline for the current request (portal | desktop)
+            windowid  == the window id (fragment id) of the portlet
+            sessionid == the current session id 
+            request.{param.name} == request parameter name, such "request.myparam"
+            session.{attribute-name} == session attribute name, such "session.myattribute"
+            
+            username|sessionid AND windowid are required
+        -->
+        <constructor-arg index='0'>
+            <list>
+                <value>sessionid</value>
+                <value>pipeline</value>
+                <value>windowid</value>
+            </list>
+        </constructor-arg>
+    </bean>
+    
+    <bean id="portletContentCache" class="org.apache.jetspeed.cache.impl.EhPortletContentCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg index="0">
+            <ref bean="ehPortletContentCache" />
+        </constructor-arg>
+        <constructor-arg index="1">
+            <ref bean="preferencesCache" />
+        </constructor-arg>
+        <constructor-arg index="2">
+            <ref bean="ContentCacheKeyGenerator" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehDecorationContentCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="decorationContentCache" />
+    </bean>
+    
+    <bean id="decorationContentCache" class="org.apache.jetspeed.cache.impl.EhDecorationContentCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg index="0">
+            <ref bean="ehDecorationContentCache" />
+        </constructor-arg>
+        <constructor-arg index="1">
+            <ref bean="preferencesCache" />
+        </constructor-arg>
+        <constructor-arg index="2">
+            <ref bean="ContentCacheKeyGenerator" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehDecorationConfigurationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="decorationConfigurationCache" />
+    </bean>
+    
+    <bean id="decorationConfigurationCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehDesktopContentCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehPreferencesCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="preferencesCache" />
+    </bean>
+    
+    <bean id="preferencesCache" class="org.apache.jetspeed.cache.impl.EhCacheDistributedImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehPreferencesCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehPortletApplicationOidCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletApplicationOidCache" />
+    </bean>
+    
+    <bean id="ehPortletApplicationNameCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletApplicationNameCache" />
+    </bean>
+    
+    <bean id="ehDesktopContentCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="desktopContentCache" />
+    </bean>
+    
+    <bean id="portletApplicationOidCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehPortletApplicationOidCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="portletApplicationNameCache" class="org.apache.jetspeed.cache.impl.EhCacheDistributedImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehPortletApplicationNameCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="desktopContentCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehDesktopContentCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehPortletDefinitionOidCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletDefinitionOidCache" />
+    </bean>
+    
+    <bean id="ehPortletDefinitionNameCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletDefinitionNameCache" />
+    </bean>
+    
+    
+    <bean id="portletDefinitionOidCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehPortletDefinitionOidCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="portletDefinitionNameCache" class="org.apache.jetspeed.cache.impl.EhCacheDistributedImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehPortletDefinitionNameCache" />
+        </constructor-arg>
+    </bean>
+    
+    <!--  Active Authentication Cache: only use with Active Authentication -->
+    <!-- Factory bean used to instantiate a EHCache with the specified name (and corresponding
+        configuration in cacheManager.xml -->
+    <bean id="ehActiveAuthenticationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="activeAuthenticationCache" />
+    </bean>
+    
+    <bean id="activeAuthenticationCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg index="0">
+            <ref bean="ehActiveAuthenticationCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehPortletWindowCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="portletWindowCache" />
+    </bean>
+    
+    <bean id="portletWindowCache" class="org.apache.jetspeed.cache.impl.EhPortletWindowCache">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg index="0">
+            <ref bean="ehPortletWindowCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehInternalPageFileCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="pageFileCache" />
+    </bean>
+    
+    <bean id="internalPageFileCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehInternalPageFileCache" />
+        </constructor-arg>
+    </bean>
+    
+    <bean id="ehInternalImportPageFileCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache" />
+        <property name="cacheManager">
+            <ref local="cacheManager" />
+        </property>
+        <property name="cacheName" value="importPageFileCache" />
+    </bean>
+    
+    <bean id="internalImportPageFileCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache" />
+        <constructor-arg>
+            <ref bean="ehInternalImportPageFileCache" />
+        </constructor-arg>
+    </bean>
+    
+    <!-- Page Manager Caches -->
+    <bean id="ehPageManagerOidCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache"/>
+        <property name="cacheManager" ref="cacheManager"/>
+        <property name="cacheName" value="pageManagerOidCache"/>
+    </bean>
+    
+    <bean id="ehPageManagerPathCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <meta key="j2:cat" value="default,cache"/>
+        <property name="cacheManager" ref="cacheManager"/>
+        <property name="cacheName" value="pageManagerPathCache"/>
+    </bean>
+    
+    <bean id="pageManagerOidCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <meta key="j2:cat" value="default,cache"/>
+        <constructor-arg><ref bean="ehPageManagerOidCache"/></constructor-arg>
+    </bean>
+    
+    <bean id="pageManagerPathCache" class="org.apache.jetspeed.cache.impl.EhCacheDistributedImpl">
+        <meta key="j2:cat" value="default,cache"/>
+        <constructor-arg><ref bean="ehPageManagerPathCache"/></constructor-arg>
+    </bean>
+    
+</beans>

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOIFramePortlet.java Fri Jan 16 02:07:13 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/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/SSOWebContentPortlet.java Fri Jan 16 02:07:13 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/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/WebContentPortlet.java Fri Jan 16 02:07:13 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)){ 

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,95 @@
+/* 
+ * 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.portlet.sso;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.util.Collection;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.security.JSSubject;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.sso.SSOException;
+import org.apache.jetspeed.sso.SSOManager;
+import org.apache.jetspeed.sso.SSOSite;
+import org.apache.jetspeed.sso.SSOUser;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public abstract class SSOPortletUtil
+{
+
+    public static Subject getSubject()
+    {
+        AccessControlContext context = AccessController.getContext();
+        return JSSubject.getSubject(context);         
+    }
+    
+    public static SSOUser getRemoteUser(SSOManager sso, PortletRequest request, SSOSite site) throws SSOException {
+        Subject subject = getSubject();
+        if (subject != null){
+            Collection<SSOUser> remoteUsers = sso.getRemoteUsers(site, subject);
+            // keep backwards compatibility : enforce a relationship (ssouser : user) of 1-to-n. 
+            // TODO: support multiple SSO users and select 1 that is used for browsing.
+            if (remoteUsers.size() == 1){
+                return remoteUsers.iterator().next();
+            }
+        }
+        return null;
+    }
+    
+    public static void updateUser(SSOManager sso, PortletRequest request, SSOSite site, String newPrincipal, String newPassword) throws SSOException {
+        SSOUser remoteUser = getRemoteUser(sso,request,site);
+        if (remoteUser != null){
+            if (!remoteUser.getName().equals(newPrincipal)){
+                // rename SSO user and update
+                remoteUser.setName(newPrincipal);
+                sso.updateUser(remoteUser);
+            }
+            sso.setPassword(remoteUser, newPassword);
+       }
+    }
+    
+    public static PasswordCredential getCredentialsForSite(SSOManager sso, String siteName, RenderRequest request){
+        PasswordCredential pwc = null;
+        SSOSite site = sso.getSiteByName(siteName);        
+        if (site != null){
+            return getCredentialsForSite(sso, site, request);
+        }
+        return pwc;
+    }
+    
+    public static PasswordCredential getCredentialsForSite(SSOManager sso, SSOSite site, RenderRequest request){
+        PasswordCredential pwc = null;
+        try{
+            SSOUser remoteUser = getRemoteUser(sso,request,site);
+            if (remoteUser != null){
+                pwc=sso.getCredentials(remoteUser);    
+            }
+            
+        } catch (SSOException sx){
+            
+        }
+        return pwc;
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOPortletUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-web-content/src/main/java/org/apache/jetspeed/portlet/sso/SSOProxyPortlet.java Fri Jan 16 02:07:13 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>");        	
         }          
     }
     

Modified: portals/jetspeed-2/portal/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/pom.xml?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/pom.xml Fri Jan 16 02:07:13 2009
@@ -54,9 +54,7 @@
         <module>jetspeed-search</module>
         <module>jetspeed-security</module>
         <module>jetspeed-serializer</module>
-        <!-- Commenting out SSO module for now
-        module>jetspeed-sso</module>
-         -->
+        <module>jetspeed-sso</module>
         <module>jetspeed-statistics</module>
         <module>jetspeed-utils</module>
         <module>jetspeed-web-content</module>

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java Fri Jan 16 02:07:13 2009
@@ -32,6 +32,8 @@
     String ROLE = "role";
     /** build-in supported JetspeedPrincipalType "user" */
     String USER = "user";
+    /** build-in supported JetspeedPrincipalType "ssoUser" */
+    String SSO_USER = "ssoUser";
     
     /**
      * The name to identify the type of a JetspeedPrincipal.

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityException.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityException.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityException.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityException.java Fri Jan 16 02:07:13 2009
@@ -158,6 +158,8 @@
 
     public static final KeyedMessage SECURITY_DOMAIN_NOT_REMOVABLE = new KeyedMessage("The security domain {0} could not be removed.");
 
+    public static final KeyedMessage SECURITY_DOMAIN_UPDATE_FAILURE = new KeyedMessage("Failed to update security domain {0}.");
+
     public static final KeyedMessage DEFAULT_SECURITY_DOMAIN_DOES_NOT_EXIST = new KeyedMessage("The default security domain does not exist.");
 
     /**

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,32 @@
+/* 
+ * 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;
+
+import java.io.Writer;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public interface SSOClient
+{
+
+    String get(String url, boolean refreshProxy) throws SSOException;
+    void write(String url, boolean refreshProxy, Writer out) throws SSOException;
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOClient.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOException.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOException.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOException.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOException.java Fri Jan 16 02:07:13 2009
@@ -29,7 +29,13 @@
 
    /** <p>Adding the credentials to the request failed.</p> */
    public static final String BASIC_AUTHENTICATION_ADD_FAILED = "Adding the credentials to the request failed.";
- 
+
+   /** <p>The site could not be created because a site with the same name exists.</p> */
+   public static final String SITE_ALREADY_EXISTS = "The site could not be created because a site with the same name exists.";
+
+   /** <p>The site could not be created because a site with the same name exists.</p> */
+   public static final String SITE_COULD_NOT_BE_CREATED = "The site could not be created.";
+
    /** <p>The site has no Single Sign On credentails attached.</p> */
    public static final String NO_CREDENTIALS_FOR_SITE = "The site has no Single Sign On credentails attached.";
 

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,29 @@
+/* 
+ * 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;
+
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public interface SSOManager extends SSOUserManager, SSOSiteManager
+{
+
+     SSOClient getClient(SSOSite site, SSOUser user) throws SSOException;
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOProvider.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOProvider.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOProvider.java Fri Jan 16 02:07:13 2009
@@ -22,6 +22,8 @@
 
 import javax.security.auth.Subject;
 
+import org.apache.jetspeed.security.JetspeedPrincipal;
+
 
 /**
 * <p>Utility component to handle SSO requests</p>
@@ -30,14 +32,8 @@
 */
 public interface SSOProvider
 {   
-	/**
-	 * Init
-	 * Called from the Spring Framework to initialize SSO Provider component
-	 * @throws Exception
-	 */
-   void init() throws Exception;
-   
-   /**
+
+    /**
     * This method first authenticates the the SSOSite and then forwards the request
     * to the destination URL. The content will be returned as a string.
     * If the SSOSite and the url match only one call will be executed since the
@@ -50,7 +46,7 @@
     * @return
     * @throws SSOException
     */
-   public String useSSO(Subject subject, String url, String SSOSite, boolean bRefresh) throws SSOException;
+   public String useSSO(SSOUser user, String url, String SSOSite, boolean bRefresh) throws SSOException;
    
    /**
     * Same as the method above except that the user will be authenticated against all
@@ -79,23 +75,22 @@
     */
    Collection getCookiesForUser(Subject user);
    
-   
    /**
     * Public API's for SSO functinality
     * @return
     */
-	boolean	hasSSOCredentials(Subject subject, String site);
+    boolean hasSSOCredentials(Subject subject, String site);
         
-	SSOContext getCredentials(Subject subject, String site)  
+    SSOContext getCredentials(Subject subject, String site)  
         throws SSOException;
     
-	void  addCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)  
+    void  addCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)  
         throws SSOException;
     
     void  updateCredentialsForSite(Subject subject, String remoteUser, String site, String pwd)  
     throws SSOException;
     
-	void removeCredentialsForSite(Subject subject, String site)  
+    void removeCredentialsForSite(Subject subject, String site)  
         throws SSOException;
     
     /**
@@ -151,8 +146,8 @@
     String getSiteURL(String site);
     String getSiteName(String site); 
     
-    void	setRealmForSite(String site, String realm) throws SSOException;
-    String	getRealmForSite(String site) throws SSOException;
+    void    setRealmForSite(String site, String realm) throws SSOException;
+    String  getRealmForSite(String site) throws SSOException;
     
     /**
      * Get all SSOSites that the principal has access to

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSite.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSite.java?rev=734954&r1=734953&r2=734954&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSite.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSite.java Fri Jan 16 02:07:13 2009
@@ -17,9 +17,6 @@
 
 package org.apache.jetspeed.sso;
 
-import java.util.Collection;
-import org.apache.jetspeed.sso.SSOPrincipal;
-
 /**
  * Interface SSOSite
  * 
@@ -58,60 +55,20 @@
 	public void setName(String name) ;
 	
 	/**
-	 * @return Returns the principals.
-	 */
-	public Collection getPrincipals() ;
-	
-	/**
-	 * @param principals The principals to set.
-	 */
-	public void setPrincipals(Collection principals);
-	
-	/**
-	 * @return Returns the siteId.
-	 */
-	public int getSiteId() ;
-	
-	/**
-	 * @param siteId The siteId to set.
+	 * @return Returns the id of the site.
 	 */
-	public void setSiteId(int siteId) ;
+	public int getId() ;
 	
 	/**
 	 * @return Returns the siteURL.
 	 */
-	public String getSiteURL() ;
+	public String getURL() ;
 	
 	/**
 	 * @param siteURL The siteURL to set.
 	 */
-	public void setSiteURL(String siteURL) ;
-	
-	
-	
-	/**
-	 * Adds the SSOPrincipal to the principals collection
-	 *
-	 */
-	public void addPrincipal(SSOPrincipal principal) throws SSOException;
-	
-	/**
-	* removePrincipal()
-	 * removes a principal from the principals collection
-	 *
-	 */
-	public void removePrincipal(long principalId) throws SSOException;
+	public void setURL(String siteURL) ;
 	
-	 /**
-     * getRemotePrincipals 
-     */
-	public Collection getRemotePrincipals();
-	
-    /**
-     * setRemotePrincipals 
-     */
-    public void setRemotePrincipals(Collection remotePrincipals);
-    
     /**
      * Define the Authentication methods. 
      * Supported are: Challenge Response and From based
@@ -130,7 +87,7 @@
      */
     public void setChallengeResponseAuthentication(boolean isChallengeResponseAuthentication);
     
-    public boolean isChallangeResponseAuthentication();
+    public boolean isChallengeResponseAuthentication();
 	public boolean isFormAuthentication();
 
 	public String getFormPwdField();
@@ -141,4 +98,7 @@
 	
 	public void setRealm(String realm);
 	public String getRealm();
+	
+    public Long getSecurityDomainId();
+    public void setSecurityDomainId(Long securityDomain);
 }

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,111 @@
+/* 
+ * 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;
+
+import java.util.Collection;
+
+import javax.security.auth.Subject;
+
+import org.apache.jetspeed.security.JetspeedPrincipal;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public interface SSOSiteManager
+{
+    
+    /**
+     * Creates a new TRANSIENT site object. The site is not added to the persistent store yet.
+     * It just creates a new Site object. Use the addSite(site) method to make the site persistent.
+     * @param name the name of the new site
+     * @param url the url of the new site
+     * @return a new SSO site object
+     * @throws SSOException
+     */
+    SSOSite newSite(String name, String url) throws SSOException;
+    
+    /**
+     * Adds the site to the persistent store. 
+     * @param site the transient site to be added (created with newSite())
+     * @return the persistent site that was added
+     * @throws SSOException
+     */
+    SSOSite addSite(SSOSite site) throws SSOException; 
+    
+    /**
+     * Removes a SSO site
+     * @param site the site to be removed
+     * @throws SSOException
+     */
+    void removeSite(SSOSite site) throws SSOException;
+    
+    /**
+     * Updates an existing SSO site
+     * @param site the site to be updated
+     * @throws SSOException
+     */
+    void updateSite(SSOSite site) throws SSOException;
+    
+    /**
+     * Retrieves all SSO sites related to the given Subject. A Subject can contain multiple
+     * Portal principals, each of which can be related with one or more SSO users.
+     * @param subject
+     * @return the collection of sites related to this subject
+     * @throws SSOException
+     */
+    Collection<SSOSite> getSitesForSubject(Subject subject) throws SSOException;
+    
+    /**
+     * Retrieves all sites directly related to this single principal. Indirect relations are not returned!
+     * Use getSitesForSubject() if you want to get all sites which belong to one user. 
+     * @param principal
+     * @return
+     * @throws SSOException
+     */
+    Collection<SSOSite> getSitesForPrincipal(JetspeedPrincipal principal) throws SSOException;
+    
+    /**
+     * Retrieves sites, given a filter. The filter is matched as a substring of the name or the url of the site.
+     * 
+     * @param filter a string that should match part of the name or url of sites returned
+     * @return a collection of sites which match the filter
+     */
+    Collection<SSOSite> getSites(String filter);
+    
+    /**
+     * Retrieves a site by matching ID
+     * @param id the id of a site
+     * @return the site with the given ID
+     */
+    SSOSite getSiteById(int id);
+    
+    /**
+     * Retrieves a site by matching the URL. The url has to be an exact match.
+     * @param siteUrl the url of a site
+     * @return the site with the given URL
+     */
+    SSOSite getSiteByUrl(String siteUrl);
+    
+    /**
+     * Retrieves a site by matching the name of the site. The name should be an exact match.
+     * @param siteName the name of a site
+     * @return the site with the given name
+     */
+    SSOSite getSiteByName(String siteName);
+
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOSiteManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java?rev=734954&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java Fri Jan 16 02:07:13 2009
@@ -0,0 +1,29 @@
+/* 
+ * 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;
+
+import org.apache.jetspeed.security.User;
+
+/**
+ * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
+ * @version $Id$
+ */
+public interface SSOUser extends User {
+    
+    void setName(String name);
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/sso/SSOUser.java
------------------------------------------------------------------------------
    svn:keywords = Id



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