Author: sohil.shah(a)jboss.com
Date: 2007-09-19 21:58:45 -0400 (Wed, 19 Sep 2007)
New Revision: 8374
Added:
modules/identity/trunk/sso/src/etc/josso/login.jsp
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/META-INF/
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/META-INF/jboss-service.xml
Removed:
modules/identity/trunk/sso/src/etc/josso/josso_login.jsp
Modified:
modules/identity/trunk/sso/build.xml
modules/identity/trunk/sso/src/etc/josso/context.xml
modules/identity/trunk/sso/src/etc/josso/josso-agent-config.xml
modules/identity/trunk/sso/src/etc/josso/login-config.xml
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/CASTestCase.java
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/JOSSOTestCase.java
modules/identity/trunk/sso/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/sso-beans.xml
Log:
JOSSO integration fixes and more tests
Modified: modules/identity/trunk/sso/build.xml
===================================================================
--- modules/identity/trunk/sso/build.xml 2007-09-19 22:28:58 UTC (rev 8373)
+++ modules/identity/trunk/sso/build.xml 2007-09-20 01:58:45 UTC (rev 8374)
@@ -208,10 +208,17 @@
<mkdir dir="${build.lib}"/>
<jar jarfile="${build.lib}/portal-identity-sso-lib.jar">
<fileset dir="${build.classes}"
excludes="org/jboss/portal/test/**"/>
- </jar>
+ </jar>
</target>
+ <target name="package-tests" depends="output">
+ <jar jarfile="${build.lib}/portal-identity-sso-test-lib.jar">
+ <fileset dir="${build.classes}"/>
+ <fileset dir="${build.resources}/portal-identity-test-jar"/>
+ </jar>
+ </target>
+
<!-- ================================================================== -->
<!-- Cleaning -->
<!-- ================================================================== -->
@@ -238,8 +245,11 @@
<target name="main" depends="most"/>
<target name="all" depends="_default:all"/>
<target name="most" depends="_default:most"/>
- <target name="help" depends="_default:help"/>
+ <target name="help" depends="_default:help"/>
+ <!-- ================================================================== -->
+ <!-- Deployment. -->
+ <!-- ================================================================== -->
<!--
Deploying the CAS SSO Framework integration
@@ -253,19 +263,25 @@
<target name="deploy-cas" depends="output">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<delete
file="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/lib/casclient-lenient.jar"/>
- <copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/META-INF"
overwrite="true">
+
+ <!-- portal-cas-sso sar file setup -->
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/META-INF"
overwrite="true">
<fileset dir="${build.resources}/portal-cas-sso-sar/META-INF"
includes="jboss-service.xml"/>
</copy>
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/lib"
overwrite="true">
<fileset dir="${cas.cas.lib}" includes="casclient.jar"/>
<fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
</copy>
+
+ <!-- jboss portal integration with the CAS Authentication server -->
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/cas.war/WEB-INF/lib"
overwrite="true">
<fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
</copy>
<copy todir="${jboss.home}/server/${portal.deploy.dir}/cas.war/WEB-INF"
overwrite="true">
<fileset dir="${build.etc}/cas"
includes="deployerConfigContext.xml"/>
</copy>
+
+ <!-- core jboss portal changes -->
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
<fileset dir="${build.etc}/cas" includes="context.xml"/>
</copy>
@@ -273,6 +289,8 @@
<target name="deploy-cas-lenient" depends="output">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<delete
file="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/lib/casclient.jar"/>
+
+ <!-- portal-cas-sso sar file setup -->
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-cas-sso.sar/META-INF"
overwrite="true">
<fileset dir="${build.resources}/portal-cas-sso-sar/META-INF"
includes="jboss-service.xml"/>
</copy>
@@ -280,14 +298,125 @@
<fileset dir="${cas.cas.lib}"
includes="casclient-lenient.jar"/>
<fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
</copy>
+
+ <!-- jboss portal integration with the CAS Authentication server -->
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/cas.war/WEB-INF/lib"
overwrite="true">
<fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
</copy>
<copy todir="${jboss.home}/server/${portal.deploy.dir}/cas.war/WEB-INF"
overwrite="true">
<fileset dir="${build.etc}/cas"
includes="deployerConfigContext.xml"/>
</copy>
+
+ <!-- core jboss portal changes -->
<copy
todir="${jboss.home}/server/${portal.deploy.dir}/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
<fileset dir="${build.etc}/cas" includes="context.xml"/>
</copy>
</target>
+
+ <!--
+ Deploying the JOSSO SSO Framework integration
+
+ These tasks deploy the JBoss Portal JOSSO integration as a separate service packaged
as
+ portal-josso-sso.sar archive
+
+ It also deploys any custom configuration/dependencies into the JOSSO war file which is
the
+ JOSSO Authentication Server
+ -->
+ <target name="deploy-josso" depends="output">
+ <require file="${jboss.home}/server/${portal.deploy.dir}"/>
+ <!-- portal-josso sar file setup -->
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-josso-sso.sar/META-INF"
overwrite="true">
+ <fileset dir="${build.resources}/portal-josso-sso-sar/META-INF"
includes="jboss-service.xml"/>
+ </copy>
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/portal-josso-sso.sar/lib"
overwrite="true">
+ <fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
+ </copy>
+
+ <!-- core josso integration with JBoss AS setup -->
+ <copy todir="${jboss.home}/server/${portal.deploy.dir}/../conf"
overwrite="true">
+ <fileset dir="${build.etc}/josso" includes="josso-agent-config.xml,
josso-config.xml, login-config.xml"/>
+ </copy>
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/jbossweb-tomcat55.sar"
overwrite="true">
+ <fileset dir="${build.etc}/josso" includes="server.xml"/>
+ <fileset dir="${josso.josso.lib}" includes="josso-1.5.jar,
josso-common-1.5.jar, josso-jboss4-plugin-1.5.jar,
josso-tomcat55-plugin-1.5.jar"/>
+ </copy>
+
+ <!-- jboss portal integration with the josso authentication server -->
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/josso.war/WEB-INF/classes"
overwrite="true">
+ <fileset dir="${build.etc}/josso"
includes="josso-gateway-config.xml"/>
+ </copy>
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/josso.war/WEB-INF/lib"
overwrite="true">
+ <fileset dir="${build.lib}"
includes="portal-identity-sso-lib.jar"/>
+ </copy>
+
+ <!-- core jboss portal changes -->
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/jboss-portal.sar/portal-server.war"
overwrite="true">
+ <fileset dir="${build.etc}/josso" includes="login.jsp,
error.jsp"/>
+ </copy>
+ <copy
todir="${jboss.home}/server/${portal.deploy.dir}/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
+ <fileset dir="${build.etc}/josso"
includes="context.xml"/>
+ </copy>
+ </target>
+
+
+ <!-- ================================================================== -->
+ <!-- Testing and Reporting. -->
+ <!-- ================================================================== -->
+ <!--
+ Unit Testing the SSO Framework integrations
+ -->
+ <target name="tests" depends="package-tests">
+ <execute-tests>
+ <!--
+ <x-sysproperty>
+ <jvmarg value="-Xdebug"/>
+ <jvmarg
value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"/>
+ </x-sysproperty>
+ -->
+ <x-test>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.sso.CASTestCase"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.identity.sso.JOSSOTestCase"/>
+ </x-test>
+ <x-classpath>
+ <pathelement
location="${build.lib}/portal-identity-sso-test-lib.jar"/>
+ <path refid="jboss.microcontainer.classpath"/>
+ <path refid="jboss.jbossxb.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <path refid="apache.commons.classpath"/>
+ <path refid="apache.xerces.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="apache.codec.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="jboss.portal/modules/test.classpath"/>
+ <path refid="jboss.portal/modules/common.classpath"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+
+ <!--
+ Produces test reports
+ -->
+ <target name="reports" depends="init">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.reports}/html"/>
+ <property name="test.reports"
value="${module.output}/tests"/>
+ <junitreport todir="${build.reports}">
+ <fileset dir="${test.reports}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="frames"
todir="${build.reports}/html"/>
+ </junitreport>
+ </target>
+ <target name="reports-noframes" depends="init">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.reports}/html"/>
+ <property name="test.reports"
value="${module.output}/tests"/>
+ <junitreport todir="${build.reports}">
+ <fileset dir="${test.reports}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="noframes"
todir="${build.reports}/html"/>
+ </junitreport>
+ </target>
</project>
Modified: modules/identity/trunk/sso/src/etc/josso/context.xml
===================================================================
--- modules/identity/trunk/sso/src/etc/josso/context.xml 2007-09-19 22:28:58 UTC (rev
8373)
+++ modules/identity/trunk/sso/src/etc/josso/context.xml 2007-09-20 01:58:45 UTC (rev
8374)
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<Context>
- <Valve className="org.jboss.portal.identity.sso.cas.JOSSOLogoutValve"/>
+ <Valve
className="org.jboss.portal.identity.sso.josso.JOSSOLogoutValve"/>
</Context>
Modified: modules/identity/trunk/sso/src/etc/josso/josso-agent-config.xml
===================================================================
--- modules/identity/trunk/sso/src/etc/josso/josso-agent-config.xml 2007-09-19 22:28:58
UTC (rev 8373)
+++ modules/identity/trunk/sso/src/etc/josso/josso-agent-config.xml 2007-09-20 01:58:45
UTC (rev 8374)
@@ -11,9 +11,8 @@
<partner-app>
<context>/portal</context>
</partner-app>
- <!-- used for testing purposes -->
<partner-app>
<context>/portal2</context>
- </partner-app>
+ </partner-app>
</partner-apps>
</agent>
Deleted: modules/identity/trunk/sso/src/etc/josso/josso_login.jsp
===================================================================
--- modules/identity/trunk/sso/src/etc/josso/josso_login.jsp 2007-09-19 22:28:58 UTC (rev
8373)
+++ modules/identity/trunk/sso/src/etc/josso/josso_login.jsp 2007-09-20 01:58:45 UTC (rev
8374)
@@ -1,41 +0,0 @@
-<%--
- ~ Copyright (c) 2004-2006, Novascope S.A. and the JOSSO team
- ~ All rights reserved.
- ~ Redistribution and use in source and binary forms, with or
- ~ without modification, are permitted provided that the following
- ~ conditions are met:
- ~
- ~ * Redistributions of source code must retain the above copyright
- ~ notice, this list of conditions and the following disclaimer.
- ~
- ~ * Redistributions in binary form must reproduce the above copyright
- ~ notice, this list of conditions and the following disclaimer in
- ~ the documentation and/or other materials provided with the
- ~ distribution.
- ~
- ~ * Neither the name of the JOSSO team nor the names of its
- ~ contributors may be used to endorse or promote products derived
- ~ from this software without specific prior written permission.
- ~
- ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- ~ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- ~ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- ~ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- ~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- ~ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- ~ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ~ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- ~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- ~ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- ~ POSSIBILITY OF SUCH DAMAGE.
- --%>
-
-<%@page contentType="text/html; charset=iso-8859-1"
language="java" session="true" %>
-<!--
-Redirects the user to the propper login page. Configured as the login url the web.xml
for this application.
--->
-<%
- response.sendRedirect(request.getContextPath() + "/josso_login/");
-%>
Modified: modules/identity/trunk/sso/src/etc/josso/login-config.xml
===================================================================
--- modules/identity/trunk/sso/src/etc/josso/login-config.xml 2007-09-19 22:28:58 UTC (rev
8373)
+++ modules/identity/trunk/sso/src/etc/josso/login-config.xml 2007-09-20 01:58:45 UTC (rev
8374)
@@ -156,7 +156,7 @@
<!-- JOSSO JAAS Module configuration -->
<application-policy name = "josso">
<authentication>
- <login-module code =
"org.jboss.portal.identity.auth.JOSSOLoginModule"
+ <login-module code =
"org.jboss.portal.identity.sso.josso.JOSSOLoginModule"
flag = "required">
<module-option name="debug">true</module-option>
</login-module>
Added: modules/identity/trunk/sso/src/etc/josso/login.jsp
===================================================================
--- modules/identity/trunk/sso/src/etc/josso/login.jsp (rev 0)
+++ modules/identity/trunk/sso/src/etc/josso/login.jsp 2007-09-20 01:58:45 UTC (rev 8374)
@@ -0,0 +1,41 @@
+<%--
+ ~ Copyright (c) 2004-2006, Novascope S.A. and the JOSSO team
+ ~ All rights reserved.
+ ~ Redistribution and use in source and binary forms, with or
+ ~ without modification, are permitted provided that the following
+ ~ conditions are met:
+ ~
+ ~ * Redistributions of source code must retain the above copyright
+ ~ notice, this list of conditions and the following disclaimer.
+ ~
+ ~ * Redistributions in binary form must reproduce the above copyright
+ ~ notice, this list of conditions and the following disclaimer in
+ ~ the documentation and/or other materials provided with the
+ ~ distribution.
+ ~
+ ~ * Neither the name of the JOSSO team nor the names of its
+ ~ contributors may be used to endorse or promote products derived
+ ~ from this software without specific prior written permission.
+ ~
+ ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ ~ CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ ~ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ ~ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ ~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ ~ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ ~ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ ~ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ~ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ~ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ ~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ ~ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ ~ POSSIBILITY OF SUCH DAMAGE.
+ --%>
+
+<%@page contentType="text/html; charset=iso-8859-1"
language="java" session="true" %>
+<!--
+Redirects the user to the propper login page. Configured as the login url the web.xml
for this application.
+-->
+<%
+ response.sendRedirect(request.getContextPath() + "/josso_login/");
+%>
Modified:
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/CASTestCase.java
===================================================================
---
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/CASTestCase.java 2007-09-19
22:28:58 UTC (rev 8373)
+++
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/CASTestCase.java 2007-09-20
01:58:45 UTC (rev 8374)
@@ -47,9 +47,9 @@
/**
*
*/
- private String portalServer = null;
- private String firstPortalContext = null;
- private String secondPortalContext = null;
+ private String firstPortal = null;
+ private String secondPortal = null;
+ private String sameHostSecondPortal = null;
private String userLoggedInIndicator = null;
private String username = null;
private String password = null;
@@ -88,132 +88,130 @@
this.runtimeContext.stop();
//Data cleanup
- this.runtimeContext = null;
- this.portalServer = null;
- this.firstPortalContext = null;
- this.secondPortalContext = null;
+ this.runtimeContext = null;
}
-
+
/**
*
* @return
*/
- public String getFirstPortalContext()
+ public String getUserLoggedInIndicator()
{
- return firstPortalContext;
+ return userLoggedInIndicator;
}
/**
*
- * @param firstPortalContext
+ * @param userLoggedInIndicator
*/
- public void setFirstPortalContext(String firstPortalContext)
+ public void setUserLoggedInIndicator(String userLoggedInIndicator)
{
- this.firstPortalContext = firstPortalContext;
+ this.userLoggedInIndicator = userLoggedInIndicator;
}
-
+
/**
*
* @return
*/
- public String getPortalServer()
+ public String getPassword()
{
- return portalServer;
+ return password;
}
/**
*
- * @param portalServer
+ * @param password
*/
- public void setPortalServer(String portalServer)
+ public void setPassword(String password)
{
- this.portalServer = portalServer;
+ this.password = password;
}
/**
*
* @return
*/
- public String getSecondPortalContext()
+ public String getUsername()
{
- return secondPortalContext;
+ return username;
}
/**
*
- * @param secondPortalContext
+ * @param username
*/
- public void setSecondPortalContext(String secondPortalContext)
+ public void setUsername(String username)
{
- this.secondPortalContext = secondPortalContext;
+ this.username = username;
}
/**
*
* @return
- */
- public String getUserLoggedInIndicator()
+ */
+ public String getFirstPortal()
{
- return userLoggedInIndicator;
+ return firstPortal;
}
/**
*
- * @param userLoggedInIndicator
+ * @param firstPortal
*/
- public void setUserLoggedInIndicator(String userLoggedInIndicator)
+ public void setFirstPortal(String firstPortal)
{
- this.userLoggedInIndicator = userLoggedInIndicator;
+ this.firstPortal = firstPortal;
}
-
+
/**
*
* @return
*/
- public String getPassword()
+ public String getSecondPortal()
{
- return password;
+ return secondPortal;
}
/**
*
- * @param password
+ * @param secondPortal
*/
- public void setPassword(String password)
+ public void setSecondPortal(String secondPortal)
{
- this.password = password;
+ this.secondPortal = secondPortal;
}
-
+
/**
*
* @return
*/
- public String getUsername()
+ public String getSameHostSecondPortal()
{
- return username;
+ return sameHostSecondPortal;
}
/**
*
- * @param username
+ * @param sameHostSecondPortal
*/
- public void setUsername(String username)
+ public void setSameHostSecondPortal(String sameHostSecondPortal)
{
- this.username = username;
+ this.sameHostSecondPortal = sameHostSecondPortal;
}
/**
+ * This tests the scenario when the two portals are deployed on separate
hosts/servers
*
* @throws Exception
*/
- public void test() throws Exception
+ public void testMultiHostDeployment() throws Exception
{
Cookie casCookie = null;
String firstPortalFinalResponse = null;
String secondPortalFinalResponse = null;
//Load the main portal page on firstPortalContext
- String firstContextPortalUrl =
"http://"+this.portalServer+"/"+this.firstPortalContext;
+ String firstContextPortalUrl = this.firstPortal;
WebConversation portalConversation = this.startConversation(firstContextPortalUrl);
TestCase.assertFalse(this.isUserLoggedIn(portalConversation.getResponse()));
@@ -252,7 +250,7 @@
TestCase.assertTrue(this.isUserLoggedIn(firstPortalFinalResponse));
//Load the main portal page on secondPortalContext
- String secondContextPortalUrl =
"http://"+this.portalServer+"/"+this.secondPortalContext;
+ String secondContextPortalUrl = this.secondPortal;
portalConversation = this.startConversation(secondContextPortalUrl);
//Click the Login Link on the secondPortalContext
@@ -280,7 +278,86 @@
}
/**
+ * This tests the scenario where the two portals are deployed within the same
host/server but under
+ * different web contexts
*
+ * @throws Exception
+ */
+ public void testSameHostDeployment() throws Exception
+ {
+ Cookie casCookie = null;
+ String firstPortalFinalResponse = null;
+ String secondPortalFinalResponse = null;
+
+ //Load the main portal page on firstPortalContext
+ String firstContextPortalUrl = this.firstPortal;
+ WebConversation portalConversation = this.startConversation(firstContextPortalUrl);
+ TestCase.assertFalse(this.isUserLoggedIn(portalConversation.getResponse()));
+
+ //Click the Login link on the firstPortalContext
+ String firstContextLoginUrl = firstContextPortalUrl +
"/auth/portal/default/default";
+ this.sendGet(firstContextLoginUrl, portalConversation);
+
+ //Perform redirect to the CAS Server
+ TestCase.assertNotNull(portalConversation.getRedirectLocation());
+ TestCase.assertEquals(portalConversation.getStatusCode(), 302);
+ String casLocation = portalConversation.getRedirectLocation();
+ WebConversation casConversation = this.startConversation(casLocation);
+ String response = casConversation.getResponse();
+ //Extract the conversionId from the response
+ int searchIndex = response.indexOf("value=\"_c")+7;
+ int endIndex = response.indexOf('"', searchIndex);
+ String lt = response.substring(searchIndex,endIndex);
+
+ //Perform HTTP Post based authentication with the CAS Server
+ Map postParams = new HashMap();
+ postParams.put("username", this.username);
+ postParams.put("password", this.password);
+ postParams.put("_eventId", "submit");
+ postParams.put("lt",lt);
+ this.sendPost(casLocation,postParams, casConversation);
+
+ //The Portal Session should now be autenticated
+ TestCase.assertNotNull(casConversation.getRedirectLocation());
+ TestCase.assertEquals(casConversation.getStatusCode(), 302);
+
TestCase.assertTrue(casConversation.getRedirectLocation().indexOf(firstContextLoginUrl) !=
-1);
+ TestCase.assertNotNull(casConversation.getCasCookie());
+ String goBack = casConversation.getRedirectLocation();
+ casCookie = casConversation.getCasCookie();
+ portalConversation = this.startConversation(goBack);
+ firstPortalFinalResponse = portalConversation.getResponse();
+ TestCase.assertTrue(this.isUserLoggedIn(firstPortalFinalResponse));
+
+ //Load the main portal page on secondPortalContext
+ String secondContextPortalUrl = this.sameHostSecondPortal;
+ portalConversation = this.startConversation(secondContextPortalUrl);
+
+ //Click the Login Link on the secondPortalContext
+ String secondContextLoginUrl = secondContextPortalUrl +
"/auth/portal/default/default";
+ this.sendGet(secondContextLoginUrl, portalConversation);
+
+ //Perform re-direct to the CAS Server but this time sending in the CAS cookie
+ TestCase.assertNotNull(portalConversation.getRedirectLocation());
+ TestCase.assertEquals(portalConversation.getStatusCode(), 302);
+ casLocation = portalConversation.getRedirectLocation();
+ casConversation = this.startConversation(casLocation,casCookie);
+
+
+ //Assert the redirect and it should be to the CAS Server, but this time
+ //It should end up with an Authenticated session back to the secondPortalContext
+ secondPortalFinalResponse = casConversation.getResponse();
+ TestCase.assertTrue(this.isUserLoggedIn(secondPortalFinalResponse));
+
+ //Assert and make sure its the same user logged into both Portals
+ String firstPortalUser = this.extractLoggedInUser(firstPortalFinalResponse);
+ String secondPortalUser = this.extractLoggedInUser(secondPortalFinalResponse);
+ TestCase.assertEquals(firstPortalUser, this.username);
+ TestCase.assertEquals(secondPortalUser, this.username);
+ TestCase.assertEquals(firstPortalUser, secondPortalUser);
+ }
+
+ /**
+ *
* @param portalUrl
* @return
* @throws Exception
Modified:
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/JOSSOTestCase.java
===================================================================
---
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/JOSSOTestCase.java 2007-09-19
22:28:58 UTC (rev 8373)
+++
modules/identity/trunk/sso/src/main/org/jboss/portal/test/identity/sso/JOSSOTestCase.java 2007-09-20
01:58:45 UTC (rev 8374)
@@ -47,9 +47,10 @@
/**
*
*/
- private String portalServer = null;
- private String firstPortalContext = null;
- private String secondPortalContext = null;
+ private String firstPortal = null;
+ private String secondPortal = null;
+ private String sameHostSecondPortal = null;
+ private String jossoServer = null;
private String userLoggedInIndicator = null;
private String username = null;
private String password = null;
@@ -88,132 +89,148 @@
this.runtimeContext.stop();
//Data cleanup
- this.runtimeContext = null;
- this.portalServer = null;
- this.firstPortalContext = null;
- this.secondPortalContext = null;
+ this.runtimeContext = null;
}
-
+
/**
*
* @return
*/
- public String getFirstPortalContext()
+ public String getUserLoggedInIndicator()
{
- return firstPortalContext;
+ return userLoggedInIndicator;
}
/**
*
- * @param firstPortalContext
+ * @param userLoggedInIndicator
*/
- public void setFirstPortalContext(String firstPortalContext)
+ public void setUserLoggedInIndicator(String userLoggedInIndicator)
{
- this.firstPortalContext = firstPortalContext;
+ this.userLoggedInIndicator = userLoggedInIndicator;
}
-
+
/**
*
* @return
*/
- public String getPortalServer()
+ public String getPassword()
{
- return portalServer;
+ return password;
}
/**
*
- * @param portalServer
+ * @param password
*/
- public void setPortalServer(String portalServer)
+ public void setPassword(String password)
{
- this.portalServer = portalServer;
+ this.password = password;
}
/**
*
* @return
*/
- public String getSecondPortalContext()
+ public String getUsername()
{
- return secondPortalContext;
+ return username;
}
/**
*
- * @param secondPortalContext
+ * @param username
*/
- public void setSecondPortalContext(String secondPortalContext)
+ public void setUsername(String username)
{
- this.secondPortalContext = secondPortalContext;
+ this.username = username;
}
/**
*
* @return
- */
- public String getUserLoggedInIndicator()
+ */
+ public String getFirstPortal()
{
- return userLoggedInIndicator;
+ return firstPortal;
}
/**
*
- * @param userLoggedInIndicator
+ * @param firstPortal
*/
- public void setUserLoggedInIndicator(String userLoggedInIndicator)
+ public void setFirstPortal(String firstPortal)
{
- this.userLoggedInIndicator = userLoggedInIndicator;
+ this.firstPortal = firstPortal;
}
-
+
/**
*
* @return
*/
- public String getPassword()
+ public String getSecondPortal()
{
- return password;
+ return secondPortal;
}
/**
*
- * @param password
+ * @param secondPortal
*/
- public void setPassword(String password)
+ public void setSecondPortal(String secondPortal)
{
- this.password = password;
+ this.secondPortal = secondPortal;
}
+
+ /**
+ *
+ * @return
+ */
+ public String getJossoServer()
+ {
+ return jossoServer;
+ }
/**
*
+ * @param jossoServer
+ */
+ public void setJossoServer(String jossoServer)
+ {
+ this.jossoServer = jossoServer;
+ }
+
+ /**
+ *
* @return
*/
- public String getUsername()
+ public String getSameHostSecondPortal()
{
- return username;
+ return sameHostSecondPortal;
}
/**
*
- * @param username
+ * @param sameHostSecondPortal
*/
- public void setUsername(String username)
+ public void setSameHostSecondPortal(String sameHostSecondPortal)
{
- this.username = username;
+ this.sameHostSecondPortal = sameHostSecondPortal;
}
/**
+ * This tests the scenario when the two portals are deployed on separate
hosts/servers
*
* @throws Exception
*/
- public void test() throws Exception
+ public void testMultiHostDeployment() throws Exception
{
Cookie ssoCookie = null;
String firstPortalFinalResponse = null;
String secondPortalFinalResponse = null;
//Load the main portal page on firstPortalContext
- String firstContextPortalUrl =
"http://"+this.portalServer+"/"+this.firstPortalContext;
+ String firstContextPortalUrl = this.firstPortal;
WebConversation portalConversation = this.startConversation(firstContextPortalUrl);
TestCase.assertFalse(this.isUserLoggedIn(portalConversation.getResponse()));
@@ -242,7 +259,7 @@
postParams.put("josso_username", this.username);
postParams.put("josso_password", this.password);
postParams.put("josso_cmd", "login");
-
this.sendPost("http://"+this.portalServer+"/"+action,postParams,
ssoConversation);
+ this.sendPost("http://"+ this.jossoServer
+"/"+action,postParams, ssoConversation);
//Go back to the Portal since login has succeeded, starting with assertion on the
JOSSO Agent installed on the Portal
String assertUrl = ssoConversation.getRedirectLocation();
@@ -260,7 +277,7 @@
TestCase.assertTrue(this.isUserLoggedIn(firstPortalFinalResponse));
//Load the main portal page on secondPortalContext
- String secondContextPortalUrl =
"http://"+this.portalServer+"/"+this.secondPortalContext;
+ String secondContextPortalUrl = this.secondPortal;
portalConversation = this.startConversation(secondContextPortalUrl);
//Click the Login Link on the secondPortalContext
@@ -290,7 +307,96 @@
}
/**
+ * This tests the scenario where the two portals are deployed within the same
host/server but under
+ * different web contexts
*
+ * @throws Exception
+ */
+ public void testSameHostDeployment() throws Exception
+ {
+ Cookie ssoCookie = null;
+ String firstPortalFinalResponse = null;
+ String secondPortalFinalResponse = null;
+
+ //Load the main portal page on firstPortalContext
+ String firstContextPortalUrl = this.firstPortal;
+ WebConversation portalConversation = this.startConversation(firstContextPortalUrl);
+ TestCase.assertFalse(this.isUserLoggedIn(portalConversation.getResponse()));
+
+ //Click the Login link on the firstPortalContext
+ String firstContextLoginUrl = firstContextPortalUrl +
"/auth/portal/default/default";
+ this.sendGet(firstContextLoginUrl, portalConversation);
+
+ //Navigate to a secured resource on the portal
+ TestCase.assertNotNull(portalConversation.getRedirectLocation());
+ TestCase.assertEquals(portalConversation.getStatusCode(), 302);
+ String portalToJOSSO = portalConversation.getRedirectLocation();
+ this.sendGet(portalToJOSSO, portalConversation);
+
+ //When authentication is triggered, move over to the JOSSO server establishing an
SSO session with JOSSO
+ String jossoLocation = portalConversation.getRedirectLocation();
+ WebConversation ssoConversation = this.startConversation(jossoLocation);
+ String response = ssoConversation.getResponse();
+
+ //Extract the josso post action value
+ int searchIndex = response.indexOf("action=\"")+9;
+ int endIndex = response.indexOf('"', searchIndex);
+ String action = response.substring(searchIndex,endIndex);
+
+ //Perform HTTP Post based authentication with the JOSSO Server
+ Map postParams = new HashMap();
+ postParams.put("josso_username", this.username);
+ postParams.put("josso_password", this.password);
+ postParams.put("josso_cmd", "login");
+ this.sendPost("http://"+ this.jossoServer
+"/"+action,postParams, ssoConversation);
+
+ //Go back to the Portal since login has succeeded, starting with assertion on the
JOSSO Agent installed on the Portal
+ String assertUrl = ssoConversation.getRedirectLocation();
+ this.sendGet(assertUrl, portalConversation);
+
+ //Now go back to the original Portal resource requested. This time user should have
an authenticated session established
+ TestCase.assertNotNull(portalConversation.getRedirectLocation());
+ TestCase.assertEquals(portalConversation.getStatusCode(), 302);
+
TestCase.assertTrue(portalConversation.getRedirectLocation().indexOf(firstContextLoginUrl)
!= -1);
+ TestCase.assertNotNull(portalConversation.getSSOCookie());
+ String goBack = portalConversation.getRedirectLocation();
+ ssoCookie = ssoConversation.getSSOCookie();
+ this.sendGet(goBack, portalConversation);
+ firstPortalFinalResponse = portalConversation.getResponse();
+ TestCase.assertTrue(this.isUserLoggedIn(firstPortalFinalResponse));
+
+ //Load the main portal page on secondPortalContext
+ String secondContextPortalUrl = this.sameHostSecondPortal;
+ portalConversation = this.startConversation(secondContextPortalUrl);
+
+ //Click the Login Link on the secondPortalContext
+ String secondContextLoginUrl = secondContextPortalUrl +
"/auth/portal/default/default";
+ this.sendGet(secondContextLoginUrl, portalConversation);
+
+ //Perform re-direct to the JOSSO Server but this time sending in the JOSSO cookie
+ TestCase.assertNotNull(portalConversation.getRedirectLocation());
+ TestCase.assertEquals(portalConversation.getStatusCode(), 302);
+ portalToJOSSO = portalConversation.getRedirectLocation();
+ this.sendGet(portalToJOSSO, portalConversation);
+
+
+ //Assert the redirect and it should be to the JOSSO Server, but this time
+ //It should end up with an Authenticated session back to the secondPortalContext
+ jossoLocation = portalConversation.getRedirectLocation();
+ ssoConversation = this.startConversation(jossoLocation,ssoCookie);
+ secondPortalFinalResponse = ssoConversation.getResponse();
+ TestCase.assertTrue(this.isUserLoggedIn(secondPortalFinalResponse));
+
+ //Assert and make sure its the same user logged into both Portals
+ String firstPortalUser = this.extractLoggedInUser(firstPortalFinalResponse);
+ String secondPortalUser = this.extractLoggedInUser(secondPortalFinalResponse);
+ TestCase.assertEquals(firstPortalUser, this.username);
+ TestCase.assertEquals(secondPortalUser, this.username);
+ TestCase.assertEquals(firstPortalUser, secondPortalUser);
+ }
+
+ /**
+ *
* @param portalUrl
* @return
* @throws Exception
Modified:
modules/identity/trunk/sso/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/sso-beans.xml
===================================================================
---
modules/identity/trunk/sso/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/sso-beans.xml 2007-09-19
22:28:58 UTC (rev 8373)
+++
modules/identity/trunk/sso/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/sso-beans.xml 2007-09-20
01:58:45 UTC (rev 8374)
@@ -31,9 +31,9 @@
<factory bean="BeanFactory"/>
<parameter>CASConfig</parameter>
</constructor>
- <property name="portalServer">localhost</property>
- <property name="firstPortalContext">portal</property>
- <property name="secondPortalContext">portal2</property>
+ <property name="firstPortal">http://cas-01/portal</property>
+ <property
name="secondPortal">http://cas-02/portal</property>
+ <property
name="sameHostSecondPortal">http://cas-01/portal2</property>
<property name="userLoggedInIndicator">Logged in
as:</property>
<property name="username">user</property>
<property name="password">user</property>
@@ -44,9 +44,10 @@
<factory bean="BeanFactory"/>
<parameter>JOSSOConfig</parameter>
</constructor>
- <property name="portalServer">localhost</property>
- <property name="firstPortalContext">portal</property>
- <property name="secondPortalContext">portal2</property>
+ <property
name="firstPortal">http://josso-01/portal</property>
+ <property
name="secondPortal">http://josso-02/portal</property>
+ <property
name="sameHostSecondPortal">http://josso-01/portal2</property>
+ <property name="jossoServer">josso-01</property>
<property name="userLoggedInIndicator">Logged in
as:</property>
<property name="username">user</property>
<property name="password">user</property>
Added:
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/META-INF/jboss-service.xml
===================================================================
---
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/META-INF/jboss-service.xml
(rev 0)
+++
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/META-INF/jboss-service.xml 2007-09-20
01:58:45 UTC (rev 8374)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<server>
+ <mbean
+ code="org.jboss.portal.identity.sso.josso.JOSSOIdentityServiceImpl"
+ name="portal:service=Module,type=JOSSOIdentityService"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+
<depends>portal:service=Module,type=IdentityServiceController</depends>
+ </mbean>
+</server>
\ No newline at end of file