Author: sohil.shah(a)jboss.com
Date: 2009-04-16 23:25:33 -0400 (Thu, 16 Apr 2009)
New Revision: 13225
Added:
modules/identity/trunk/sso/src/main/config/
modules/identity/trunk/sso/src/main/config/josso/
modules/identity/trunk/sso/src/main/config/josso/conf/
modules/identity/trunk/sso/src/main/config/josso/conf/josso-agent-config.xml
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-auth.xml
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-config.xml
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-portal-stores.xml
modules/identity/trunk/sso/src/main/config/josso/conf/login-config.xml
modules/identity/trunk/sso/src/main/config/josso/jboss-portal/
modules/identity/trunk/sso/src/main/config/josso/jboss-portal/context.xml
modules/identity/trunk/sso/src/main/config/josso/jboss-portal/jboss-web.xml
modules/identity/trunk/sso/src/main/config/josso/jboss-portal/login.jsp
modules/identity/trunk/sso/src/main/config/josso/sar/
modules/identity/trunk/sso/src/main/config/josso/sar/META-INF/
modules/identity/trunk/sso/src/main/config/josso/sar/META-INF/jboss-service.xml
modules/identity/trunk/sso/src/test/resources/log4j.properties
Removed:
modules/identity/trunk/sso/src/etc/josso/
modules/identity/trunk/sso/src/resources/portal-josso-sso-sar/
Modified:
modules/identity/trunk/build/pom.xml
modules/identity/trunk/sso/build.xml
modules/identity/trunk/sso/pom.xml
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOIdentityStore.java
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLoginModule.java
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLogoutValve.java
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasySSLProtocolSocketFactory.java
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasyX509TrustManager.java
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/JOSSOTestCase.java
Log:
first taste of success with the latest josso upgrade. josso version, 1.8......phew
Modified: modules/identity/trunk/build/pom.xml
===================================================================
--- modules/identity/trunk/build/pom.xml 2009-04-16 09:05:50 UTC (rev 13224)
+++ modules/identity/trunk/build/pom.xml 2009-04-17 03:25:33 UTC (rev 13225)
@@ -46,11 +46,15 @@
<version.antlr>2.7.7</version.antlr>
<version.dom4j>1.6.1</version.dom4j>
<version.asm>1.5.3</version.asm>
- <version.josso>1.5</version.josso>
+ <version.josso>1.8.0</version.josso>
<version.cas>3.0.7</version.cas>
<version.opensso>20070905-nightly</version.opensso>
<version.spring>2.0.6</version.spring>
-
+ <version.xbean>3.4.3</version.xbean>
+ <version.commons-configuration>1.2</version.commons-configuration>
+ <version.commons-discovery>0.4</version.commons-discovery>
+ <version.xmldb>20021220</version.xmldb>
+ <version.axis>1.4</version.axis>
</properties>
@@ -76,6 +80,22 @@
<enabled>false</enabled>
</releases>
</repository>
+
+ <repository>
+ <id>josso-m2-repo</id>
+ <name>JOSSO Maven2 Repository</name>
+ <url>http://repository.josso.org</url>
+
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ <enabled>true</enabled>
+ </releases>
+
+ <snapshots>
+ <checksumPolicy>fail</checksumPolicy>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
</repositories>
@@ -265,26 +285,36 @@
<version>${version.asm}</version>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-core</artifactId>
<version>${version.josso}</version>
</dependency>
<dependency>
- <groupId>josso</groupId>
+ <groupId>org.josso</groupId>
<artifactId>josso-common</artifactId>
<version>${version.josso}</version>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso-jboss4-plugin</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-agent</artifactId>
<version>${version.josso}</version>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso-tomcat55-plugin</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-basic-authscheme</artifactId>
<version>${version.josso}</version>
</dependency>
<dependency>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-jboss42-agent</artifactId>
+ <version>${version.josso}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-tomcat55-agent</artifactId>
+ <version>${version.josso}</version>
+ </dependency>
+ <dependency>
<groupId>ja-sig-cas</groupId>
<artifactId>cas-server</artifactId>
<version>${version.cas}</version>
@@ -309,7 +339,37 @@
<artifactId>spring</artifactId>
<version>${version.spring}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-spring</artifactId>
+ <version>${version.xbean}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>${version.commons-configuration}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>${version.commons-discovery}</version>
+ </dependency>
+ <dependency>
+ <groupId>xmldb</groupId>
+ <artifactId>xmldb-common</artifactId>
+ <version>${version.xmldb}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis</artifactId>
+ <version>${version.axis}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
Modified: modules/identity/trunk/sso/build.xml
===================================================================
--- modules/identity/trunk/sso/build.xml 2009-04-16 09:05:50 UTC (rev 13224)
+++ modules/identity/trunk/sso/build.xml 2009-04-17 03:25:33 UTC (rev 13225)
@@ -81,51 +81,31 @@
It also deploys any custom configuration/dependencies into the JOSSO war file which is
the
JOSSO Authentication Server
-->
- <target name="install-josso">
- <!-- portal-josso sar file setup -->
+ <target name="install-josso">
+ <!-- core jboss portal installation -->
<jar destfile="target/portal-josso.sar">
<fileset dir="src/resources/portal-josso-sso-sar"/>
<fileset dir="target"
includes="identity-sso-*-SNAPSHOT.jar"/>
</jar>
- <copy todir="${jboss.home}/server/${josso.deploy.dir}"
overwrite="true">
+ <copy todir="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar"
overwrite="true">
<fileset file="target/portal-josso.sar"/>
</copy>
-
- <!-- core josso integration with JBoss AS setup -->
- <copy todir="${jboss.home}/server/${josso.deploy.dir}/../conf"
overwrite="true">
- <fileset dir="src/etc/josso" includes="josso-agent-config.xml,
josso-config.xml, login-config.xml"/>
- </copy>
- <copy
todir="${jboss.home}/server/${josso.deploy.dir}/jbossweb-tomcat55.sar"
overwrite="true">
- <fileset dir="src/etc/josso" includes="server.xml"/>
- <fileset file="${josso.jar}"/>
- <fileset file="${josso-common.jar}"/>
- <fileset file="${josso-jboss4-plugin.jar}"/>
- <fileset file="${josso-tomcat55-plugin.jar}"/>
- <fileset file="${commons-configuration.jar}"/>
- <fileset file="${xmldb-common.jar}"/>
- <fileset file="${axis.jar}"/>
- <fileset file="${commons-discovery.jar}"/>
+ <copy
todir="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar/portal-server.war"
overwrite="true">
+ <fileset dir="src/etc/josso/jboss-portal"
includes="login.jsp"/>
</copy>
+ <copy
todir="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
+ <fileset dir="src/etc/josso/jboss-portal" includes="context.xml,
jboss-web.xml"/>
+ </copy>
- <!-- jboss portal integration with the josso authentication server -->
- <copy
todir="${jboss.home}/server/${josso.deploy.dir}/josso.war/WEB-INF/classes"
overwrite="true">
- <fileset dir="src/etc/josso"
includes="josso-gateway-config.xml"/>
- </copy>
+ <!-- jboss portal integration with the josso authentication server -->
<copy
tofile="${jboss.home}/server/${josso.deploy.dir}/josso.war/WEB-INF/lib/portal-identity-sso-lib.jar"
overwrite="true">
<fileset dir="target"
includes="identity-sso-*-SNAPSHOT.jar"/>
- </copy>
+ </copy>
- <!-- core jboss portal changes -->
- <copy
todir="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar/portal-server.war"
overwrite="true">
- <fileset dir="src/etc/josso" includes="login.jsp,
error.jsp"/>
- </copy>
- <copy
todir="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
- <fileset dir="src/etc/josso" includes="context.xml"/>
- </copy>
- <!-- add portal-identity-sso-lib.jar to jboss portal -->
- <copy
tofile="${jboss.home}/server/${josso.deploy.dir}/jboss-portal.sar/lib/portal-identity-sso-lib.jar"
overwrite="true">
- <fileset dir="target"
includes="identity-sso-*-SNAPSHOT.jar"/>
- </copy>
+ <!-- josso AS installation related -->
+ <copy todir="${jboss.home}/server/${josso.deploy.dir}/conf"
overwrite="true">
+ <fileset dir="src/etc/josso/conf"/>
+ </copy>
</target>
<!-- ================================================================== -->
Modified: modules/identity/trunk/sso/pom.xml
===================================================================
--- modules/identity/trunk/sso/pom.xml 2009-04-16 09:05:50 UTC (rev 13224)
+++ modules/identity/trunk/sso/pom.xml 2009-04-17 03:25:33 UTC (rev 13225)
@@ -9,8 +9,12 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>identity-sso</artifactId>
<packaging>jar</packaging>
- <name>JBoss Portal Identity SSO Integration</name>
+ <name>JBoss Portal Identity SSO Integration</name>
+ <properties>
+ <josso.deploy.dir>josso-01</josso.deploy.dir>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.jboss.portal.identity</groupId>
@@ -18,22 +22,30 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-core</artifactId>
</dependency>
<dependency>
- <groupId>josso</groupId>
+ <groupId>org.josso</groupId>
<artifactId>josso-common</artifactId>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso-tomcat55-plugin</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-agent</artifactId>
</dependency>
<dependency>
- <groupId>josso</groupId>
- <artifactId>josso-jboss4-plugin</artifactId>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-basic-authscheme</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-jboss42-agent</artifactId>
</dependency>
<dependency>
+ <groupId>org.josso</groupId>
+ <artifactId>josso-tomcat55-agent</artifactId>
+ </dependency>
+ <dependency>
<groupId>ja-sig-cas</groupId>
<artifactId>cas-server</artifactId>
</dependency>
@@ -52,86 +64,184 @@
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
- <version>1.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
- <version>0.4</version>
</dependency>
<dependency>
<groupId>xmldb</groupId>
<artifactId>xmldb-common</artifactId>
- <version>20021220</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
- <version>1.4</version>
- </dependency>
+ </dependency>
+
+ <!-- test dependency -->
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>jboss-unit-mc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.unit</groupId>
+ <artifactId>portal-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
- <plugin>
+ <plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>${version.xbean}</version>
+ <executions>
+ <execution>
+ <configuration>
+
<namespace>urn:org:jboss:portal:josso:identitystore</namespace>
+ </configuration>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>josso-dev</id>
+ <build>
+ <plugins>
+ <plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
- <artifactId>maven-antrun-extended-plugin</artifactId>
- <version>1.13</version>
- <executions>
- <!--
- Development time task for installing CAS into your local Portal setup
- -->
- <!--
+ <artifactId>maven-antrun-extended-plugin</artifactId>
+ <executions>
<execution>
- <id>install-cas</id>
+ <id>deploy-josso</id>
<phase>install</phase>
<configuration>
<tasks>
- <property name="jboss.home"
value="/home/soshah/appServers/jboss-4.2.1.GA"/>
- <property name="cas.deploy.dir"
value="cas-01/deploy"/>
- <property name="cas.client.jar"
value="${settings.localRepository}/ja-sig-cas/cas-client/${version.cas}/cas-client-${version.cas}.jar"/>
- <ant antfile="${basedir}/build.xml">
- <target name="install-cas"/>
- </ant>
+ <property environment="env"/>
+
+ <!--If properties are not in command line check if they are set in
env-->
+ <condition property="JBOSS_HOME"
value="${env.JBOSS_HOME}">
+ <and>
+ <isset property="env.JBOSS_HOME"/>
+ <not>
+ <isset property="JBOSS_HOME"/>
+ </not>
+ </and>
+ </condition>
+
+ <fail message="Please set the environment variable JBOSS_HOME or
specify it using -DJBOSS_HOME">
+ <condition>
+ <and>
+ <not>
+ <isset property="JBOSS_HOME"/>
+ </not>
+ </and>
+ </condition>
+ </fail>
+
+ <!-- core jboss portal installation -->
+ <jar destfile="${project.build.directory}/portal-josso.sar">
+ <fileset dir="${basedir}/src/main/config/josso/sar"/>
+ <fileset dir="${project.build.directory}"
includes="identity-sso-*-SNAPSHOT.jar"/>
+ </jar>
+ <copy
todir="${JBOSS_HOME}/server/${josso.deploy.dir}/deploy/jboss-portal.sar"
overwrite="true">
+ <fileset file="${project.build.directory}/portal-josso.sar"/>
+ </copy>
+ <copy
todir="${JBOSS_HOME}/server/${josso.deploy.dir}/deploy/jboss-portal.sar/portal-server.war"
overwrite="true">
+ <fileset dir="${basedir}/src/main/config/josso/jboss-portal"
includes="login.jsp"/>
+ </copy>
+ <copy
todir="${JBOSS_HOME}/server/${josso.deploy.dir}/deploy/jboss-portal.sar/portal-server.war/WEB-INF"
overwrite="true">
+ <fileset dir="${basedir}/src/main/config/josso/jboss-portal"
includes="context.xml, jboss-web.xml"/>
+ </copy>
+
+ <!-- jboss portal integration with the josso authentication server
-->
+ <copy
tofile="${JBOSS_HOME}/server/${josso.deploy.dir}/deploy/josso.war/WEB-INF/lib/portal-identity-sso-lib.jar"
overwrite="true">
+ <fileset dir="${project.build.directory}"
includes="identity-sso-*-SNAPSHOT.jar"/>
+ </copy>
+
+ <!-- josso AS installation related -->
+ <copy todir="${JBOSS_HOME}/server/${josso.deploy.dir}/conf"
overwrite="true">
+ <fileset dir="${basedir}/src/main/config/josso/conf"/>
+ </copy>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
- </execution>
- -->
- <!--
- Development time task for installing JOSSO into your local Portal setup
- -->
- <!--
- <execution>
- <id>install-josso</id>
- <phase>install</phase>
- <configuration>
- <tasks>
- <property name="jboss.home"
value="/home/soshah/appServers/jboss-4.0.5.GA"/>
- <property name="josso.deploy.dir"
value="josso-01/deploy"/>
- <property name="josso.jar"
value="${settings.localRepository}/josso/josso/${version.josso}/josso-${version.josso}.jar"/>
- <property name="josso-common.jar"
value="${settings.localRepository}/josso/josso-common/${version.josso}/josso-common-${version.josso}.jar"/>
- <property name="josso-tomcat55-plugin.jar"
value="${settings.localRepository}/josso/josso-tomcat55-plugin/${version.josso}/josso-tomcat55-plugin-${version.josso}.jar"/>
- <property name="josso-jboss4-plugin.jar"
value="${settings.localRepository}/josso/josso-jboss4-plugin/${version.josso}/josso-jboss4-plugin-${version.josso}.jar"/>
- <property name="commons-configuration.jar"
value="${settings.localRepository}/commons-configuration/commons-configuration/1.2/commons-configuration-1.2.jar"/>
- <property name="commons-discovery.jar"
value="${settings.localRepository}/commons-discovery/commons-discovery/0.4/commons-discovery-0.4.jar"/>
- <property name="xmldb-common.jar"
value="${settings.localRepository}/xmldb/xmldb-common/20021220/xmldb-common-20021220.jar"/>
- <property name="axis.jar"
value="${settings.localRepository}/axis/axis/1.4/axis-1.4.jar"/>
- <ant antfile="${basedir}/build.xml">
- <target name="install-josso"/>
- </ant>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- -->
+ </execution>
</executions>
- </plugin>
- </plugins>
- </build>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>josso-integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <includes>
+ <include>**/JOSSOTestCase.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+
+ <profile>
+ <id>cas-dev</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
+ <artifactId>maven-antrun-extended-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>deploy-cas</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <property name="JBOSS_HOME"
value="/home/soshah/appServers/jboss-4.2.1.GA"/>
+ <property name="cas.deploy.dir"
value="cas-01/deploy"/>
+ <property name="cas.client.jar"
value="${settings.localRepository}/ja-sig-cas/cas-client/${version.cas}/cas-client-${version.cas}.jar"/>
+ <ant antfile="${basedir}/build.xml">
+ <target name="install-cas"/>
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: modules/identity/trunk/sso/src/main/config/josso/conf/josso-agent-config.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/conf/josso-agent-config.xml
(rev 0)
+++
modules/identity/trunk/sso/src/main/config/josso/conf/josso-agent-config.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ JOSSO: Java Open Single Sign-On
+ ~
+ ~ Copyright 2004-2009, Atricore, Inc.
+ ~
+ ~ 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.
+ ~
+ -->
+
+<s:beans
xmlns:s="http://www.springframework.org/schema/beans"
+ xmlns:jb42="urn:org:josso:agent:jboss42"
+ xmlns:agent="urn:org:josso:agent:core"
+ xmlns:protocol="urn:org:josso:protocol:client"
+
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
+ urn:org:josso:agent:jboss42
http://www.josso.org/schema/josso-jboss42-agent.xsd
+ urn:org:josso:agent:core
http://www.josso.org/schema/josso-agent.xsd
+ urn:org:josso:protocol:client
http://www.josso.org/schema/josso-protocol-client.xsd">
+
+ <jb42:agent name="josso-jboss42-agent"
sessionAccessMinInterval="1000" >
+
+ <!-- Gateway LOGIN and LOGOUT URLs -->
+
<gatewayLoginUrl>http://localhost:8080/josso/signon/login.do</gatewayLoginUrl>
+
<gatewayLogoutUrl>http://localhost:8080/josso/signon/logout.do</gatewayLogoutUrl>
+
+ <!-- Gateway service locator -->
+ <gatewayServiceLocator>
+ <!-- Other properties for ws-service-locator :
+ username, password, servicesWebContext, transportSecurity
+ -->
+ <protocol:ws-service-locator endpoint="localhost:8080" />
+ </gatewayServiceLocator>
+
+ <configuration>
+ <agent:agent-configuration>
+
+ <!--
============================================================================= -->
+ <!--
-->
+ <!-- JOSSO Parnter application definicions :
-->
+ <!--
-->
+ <!-- Configure all web applications that should be a josso partner
application -->
+ <!-- within this server.
-->
+ <!-- For each partner application you have to define the proper
web-context. -->
+ <!--
============================================================================= -->
+
+ <agent:partner-apps>
+ <agent:partner-app id="jboss_portal"
context="/portal"/>
+
+ <!-- Simple definition of a partner application -->
+ <!--
+ <agent:partner-app id="MySimplePartnerApp"
context="/simple-partnerapp"/>
+ -->
+
+ <!--
+ <agent:partner-app id="MyPartnerApp1"
context="/partnerapp" >
+ -->
+
+ <!-- The vhost is an ooptional feature:
+ Specify the Host/Virtual Host where this application is runnig
+ This is useful when configuring multiple security domains.
-->
+ <!-- vhost>localhost</vhost--> <!-- You can
configure this as a 'partner-app' element attribute as well -->
+
+ <!-- This is an optional feature :
+ You can reference any web resource collection that should not be
subject to SSO protection.
+ The SSO agent will not provide identity nor demand authentication
to requests matching the
+ security constraint associated to this web resource collections.
+ In order to work, the security constraint must not contain
auth-constraints declarations.
+ See sample web.xml file from josso partnerapp.
+ -->
+ <!--
+
<ignore-web-resource-collections>public-resources,img-resources</ignore-web-resource-collections>
+ -->
+
+ <!-- In addition to the standard JEE security, JOSSO can
propagate the security context using
+ alternative mechanisms, such as custom http headers, request
attributes and cookies, thus making it available
+ to applications which do not rely on JEE security APIs. -->
+ <!--
+ <security-context-propagation>
+ <agent:security-context-propagation-config
+ binding="HTTP_HEADERS"
+ userPlaceHolder="currentLoginName"
+ rolesPlaceHolder="currentUserRoles"/>
+ </security-context-propagation>
+ -->
+ <!--
+ </agent:partner-app>
+ -->
+
+ </agent:partner-apps>
+
+ </agent:agent-configuration>
+ </configuration>
+
+ <!-- Only useful when configuring multiple security domains -->
+ <!-- You can configure your own parameter builder to send parameters to your
SecurityDomainMatcher -->
+ <!--
+ <parametersBuilders>
+ <agent:vhost-parameters-builder/>
+ <agent:appctx-parameters-builder/>
+ </parametersBuilders>
+ -->
+
+ </jb42:agent>
+
+</s:beans>
Added: modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-auth.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-auth.xml
(rev 0)
+++
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-auth.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ ~ JOSSO: Java Open Single Sign-On
+ ~
+ ~ Copyright 2004-2009, Atricore, Inc.
+ ~
+ ~ 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.
+ ~
+ -->
+
+<s:beans
xmlns:s="http://www.springframework.org/schema/beans"
+ xmlns:basic-authscheme="urn:org:josso:basic:authscheme"
+ xmlns:bind-authscheme="urn:org:josso:bind:authscheme"
+ xmlns:ntlm-authscheme="urn:org:josso:ntlm:authscheme"
+ xmlns:strong-authscheme="urn:org:josso:strong:authscheme"
+ xmlns:rememberme-authscheme="urn:org:josso:rememberme:authscheme"
+
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
+ urn:org:josso:strong:authscheme
http://www.josso.org/schema/josso-strong-authscheme.xsd
+ urn:org:josso:basic:authscheme
http://www.josso.org/schema/josso-basic-authscheme.xsd
+ urn:org:josso:bind:authscheme
http://www.josso.org/schema/josso-bind-authscheme.xsd
+ urn:org:josso:ntlm:authscheme
http://www.josso.org/schema/josso-ntlm-authscheme.xsd
+ urn:org:josso:rememberme:authscheme
http://www.josso.org/schema/josso-rememberme-authscheme.xsd
+ ">
+
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- Basic Authentication Scheme -->
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <basic-authscheme:basic-auth-scheme
+ id="josso-basic-authentication"
+ hashAlgorithm="MD5"
+ hashEncoding="HEX"
+ ignorePasswordCase="false"
+ ignoreUserCase="false">
+
+ <basic-authscheme:credentialStore>
+ <s:ref bean="josso-identity-store"/>
+ </basic-authscheme:credentialStore>
+
+ <basic-authscheme:credentialStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </basic-authscheme:credentialStoreKeyAdapter>
+
+ </basic-authscheme:basic-auth-scheme>
+
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- Strong Authentication Scheme -->
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+ <strong-authscheme:strong-auth-scheme
+ id="josso-strong-authentication">
+
+ <strong-authscheme:credentialStore>
+ <s:ref bean="josso-identity-store"/>
+ </strong-authscheme:credentialStore>
+
+ <strong-authscheme:credentialStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </strong-authscheme:credentialStoreKeyAdapter>
+
+ </strong-authscheme:strong-auth-scheme>
+
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- Rememberme Authentication Scheme -->
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <rememberme-authscheme:rememberme-auth-scheme
+ id="josso-rememberme-authentication" >
+
+ <rememberme-authscheme:credentialStore>
+ <s:ref bean="josso-identity-store"/>
+ </rememberme-authscheme:credentialStore>
+
+ <rememberme-authscheme:credentialStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </rememberme-authscheme:credentialStoreKeyAdapter>
+
+ </rememberme-authscheme:rememberme-auth-scheme>
+
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- BIND Authentication Scheme (normally LDAP) -->
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- Requires a be a bindalble credential store ! -->
+ <!-- name attribute is important and must not be changed -->
+ <bind-authscheme:bind-auth-scheme
+ id="josso-bind-authentication"
+ name="basic-authentication"
+ hashAlgorithm="MD5"
+ hashEncoding="HEX"
+ ignorePasswordCase="false"
+ ignoreUserCase="false">
+
+
+ <bind-authscheme:credentialStore>
+ <s:ref bean="josso-identity-store"/>
+ </bind-authscheme:credentialStore>
+
+ <bind-authscheme:credentialStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </bind-authscheme:credentialStoreKeyAdapter>
+
+ </bind-authscheme:bind-auth-scheme>
+
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- NTLM Authentication Scheme -->
+ <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <ntlm-authscheme:ntlm-auth-scheme
+ id="josso-ntlm-authentication">
+
+ <ntlm-authscheme:credentialStore>
+ <s:ref bean="josso-identity-store"/>
+ </ntlm-authscheme:credentialStore>
+
+ <ntlm-authscheme:credentialStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </ntlm-authscheme:credentialStoreKeyAdapter>
+ </ntlm-authscheme:ntlm-auth-scheme>
+
+
+</s:beans>
\ No newline at end of file
Added: modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-config.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-config.xml
(rev 0)
+++
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-config.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ ~ JOSSO: Java Open Single Sign-On
+ ~
+ ~ Copyright 2004-2009, Atricore, Inc.
+ ~
+ ~ 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.
+ ~
+ -->
+
+<s:beans
xmlns:s="http://www.springframework.org/schema/beans"
+ xmlns="urn:org:josso:core"
+ xmlns:def-sdselector="urn:org:josso:default:secdomainselector"
+ xmlns:def-sdregistry="urn:org:josso:default:secdomainregistry"
+ xmlns:simple-sdmatcher="urn:org:josso:simple:secdomainmatcher"
+ xmlns:vhost-sdmatcher="urn:org:josso:vhost:secdomainmatcher"
+ xmlns:appcxt-sdmatcher="urn:org:josso:appctx:secdomainmatcher"
+ xmlns:def-auth="urn:org:josso:default:authenticator"
+ xmlns:basic-authscheme="urn:org:josso:basic:authscheme"
+ xmlns:bind-authscheme="urn:org:josso:bind:authscheme"
+ xmlns:ntlm-authscheme="urn:org:josso:ntlm:authscheme"
+ xmlns:strong-authscheme="urn:org:josso:strong:authscheme"
+ xmlns:memory-istore="urn:org:josso:memory:identitystore"
+ xmlns:def-identitymgr="urn:org:josso:default:identitymgr"
+ xmlns:def-identityprv="urn:org:josso:default:identityprovider"
+ xmlns:def-sessionmgr="urn:org:josso:default:sessionmgr"
+ xmlns:memory-sstore="urn:org:josso:memory:sessionstore"
+ xmlns:def-sidgen="urn:org:josso:default:sessionidgen"
+ xmlns:def-assertionmgr="urn:org:josso:default:assertionmgr"
+ xmlns:memory-astore="urn:org:josso:memory:assertionstore"
+ xmlns:def-aidgen="urn:org:josso:default:assertionidgen"
+ xmlns:def-auditmgr="urn:org:josso:default:auditmgr"
+ xmlns:logger-atrailhandler="urn:org:josso:logger:audittrailhandler"
+ xmlns:def-eventmgr="urn:org:josso:default:eventmgr"
+ xmlns:def-pwdmgr="urn:org:josso:default:passwordmgr"
+ xmlns:def-pwdgen="urn:org:josso:default:passwordgenerator"
+ xmlns:email-pwddist="urn:org:josso:email:passworddistributor"
+ xmlns:simple-lostpwd="urn:org:josso:simple:lostpasswordprocess"
+
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
+ urn:org:josso:core
http://www.josso.org/schema/josso-core.xsd
+ urn:org:josso:default:secdomainselector
http://www.josso.org/schema/josso-default-secdomainselector.xsd
+ urn:org:josso:default:secdomainregistry
http://www.josso.org/schema/josso-default-secdomainregistry.xsd
+ urn:org:josso:simple:secdomainmatcher
http://www.josso.org/schema/josso-simple-secdomainmatcher.xsd
+ urn:org:josso:vhost:secdomainmatcher
http://www.josso.org/schema/josso-vhost-secdomainmatcher.xsd
+ urn:org:josso:appctx:secdomainmatcher
http://www.josso.org/schema/josso-appctx-secdomainmatcher.xsd
+ urn:org:josso:default:authenticator
http://www.josso.org/schema/josso-default-authenticator.xsd
+ urn:org:josso:basic:authscheme
http://www.josso.org/schema/josso-basic-authscheme.xsd
+ urn:org:josso:bind:authscheme
http://www.josso.org/schema/josso-bind-authscheme.xsd
+ urn:org:josso:ntlm:authscheme
http://www.josso.org/schema/josso-ntlm-authscheme.xsd
+ urn:org:josso:strong:authscheme
http://www.josso.org/schema/josso-strong-authscheme.xsd
+ urn:org:josso:memory:identitystore
http://www.josso.org/schema/josso-memory-identitystore.xsd
+ urn:org:josso:default:identitymgr
http://www.josso.org/schema/josso-default-identitymgr.xsd
+ urn:org:josso:default:identityprovider
http://www.josso.org/schema/josso-default-identityprovider.xsd
+ urn:org:josso:default:sessionmgr
http://www.josso.org/schema/josso-default-sessionmgr.xsd
+ urn:org:josso:memory:sessionstore
http://www.josso.org/schema/josso-memory-sessionstore.xsd
+ urn:org:josso:default:sessionidgen
http://www.josso.org/schema/josso-default-sessionidgen.xsd
+ urn:org:josso:default:assertionmgr
http://www.josso.org/schema/josso-default-assertionmgr.xsd
+ urn:org:josso:memory:assertionstore
http://www.josso.org/schema/josso-memory-assertionstore.xsd
+ urn:org:josso:default:assertionidgen
http://www.josso.org/schema/josso-default-assertionidgen.xsd
+ urn:org:josso:default:auditmgr
http://www.josso.org/schema/josso-default-auditmgr.xsd
+ urn:org:josso:logger:audittrailhandler
http://www.josso.org/schema/josso-logger-audittrailhandler.xsd
+ urn:org:josso:default:eventmgr
http://www.josso.org/schema/josso-default-eventmgr.xsd
+ urn:org:josso:default:passwordmgr
http://www.josso.org/schema/josso-default-passwordmanager.xsd
+ urn:org:josso:default:passwordgenerator
http://www.josso.org/schema/josso-default-passwordgenerator.xsd
+ urn:org:josso:email:passworddistributor
http://www.josso.org/schema/josso-email-passworddistributor.xsd
+ urn:org:josso:simple:lostpasswordprocess
http://www.josso.org/schema/josso-simple-lostpasswordprocess.xsd">
+
+ <!-- ================================================================== -->
+ <!-- JOSSO Gateway Configuration using Spring + XBean -->
+ <!-- -->
+ <!-- since JOSSO 1.8 -->
+ <!-- ================================================================== -->
+
+ <!-- To keep things organized when using multiple security domains, prepend the
domain name
+ to component ids, in our case all componetes use the 'josso' prefix -->
+
+ <!-- ================================================================== -->
+ <!-- Some components are configured in different files to make -->
+ <!-- configuraiton easier -->
+ <!-- ================================================================== -->
+
+ <!-- Authentication schemes configuration -->
+ <s:import resource="josso-gateway-auth.xml"/>
+
+ <!-- SSO Self services configuration -->
+ <s:import resource="josso-gateway-selfservices.xml"/>
+
+ <!-- Identity, Session and Assertion Stores configuration -->
+ <s:import resource="josso-gateway-portal-stores.xml" />
+ <!--
+ <s:import resource="josso-gateway-memory-stores.xml" />
+ <s:import resource="josso-gateway-db-stores.xml" />
+ <s:import resource="josso-gateway-ldap-stores.xml" />
+ -->
+
+ <!-- Web configuration (login form, etc) -->
+ <s:import resource="josso-gateway-web.xml" />
+
+ <!-- JMX, used internally -->
+ <s:import resource="josso-gateway-jmx.xml" />
+
+ <!-- ================================================================== -->
+ <!-- Here we define gateway core structure -->
+ <!-- ================================================================== -->
+ <gateway>
+
+ <sso-domain-selector>
+ <def-sdselector:default-domain-selector/>
+ </sso-domain-selector>
+
+ <sso-domains-registry>
+ <def-sdregistry:default-domains-registry/>
+ </sso-domains-registry>
+
+ <!-- =====================================================================
-->
+ <!-- SSO Security Domains, here we have only one domain configured : josso
-->
+ <!-- Most components are configured elsewhere and referenced here to make
-->
+ <!-- configuration easier.
-->
+ <!--
-->
+ <!-- Unless you have multimple security domains, you will not need to
-->
+ <!-- change this part
-->
+ <!-- =====================================================================
-->
+ <domains>
+ <s:ref bean="josso"/>
+ </domains>
+
+ </gateway>
+
+
+ <!-- JOSSO Default security domain -->
+ <domain name="josso" type="web">
+
+ <sso-web-configuration>
+ <s:ref bean="josso-web-configuraiton"/>
+ </sso-web-configuration>
+
+ <matchers>
+ <simple-sdmatcher:simple-matcher/>
+ </matchers>
+
+ <authenticator>
+ <s:ref bean="josso-authenticator"/>
+ </authenticator>
+
+ <identity-manager>
+ <s:ref bean="josso-identity-manager"/>
+ </identity-manager>
+
+ <session-manager>
+ <s:ref bean="josso-session-manager"/>
+ </session-manager>
+
+ <assertion-manager>
+ <s:ref bean="josso-assertion-manager"/>
+ </assertion-manager>
+
+ <identity-provider>
+ <s:ref bean="josso-identity-provider"/>
+ </identity-provider>
+
+ <audit-manager>
+ <s:ref bean="josso-audit-manager"/>
+ </audit-manager>
+
+ <event-manager>
+ <s:ref bean="josso-event-manager"/>
+ </event-manager>
+
+ <!-- Only needed when using NTLM -->
+ <protocol-manager>
+ <s:ref bean="josso-protocol-manager"/>
+ </protocol-manager>
+
+ <!-- Only neede for self-services (lost password, etc). -->
+ <password-manager>
+ <s:ref bean="josso-password-manager"/>
+ </password-manager>
+
+ </domain>
+
+
+ <!-- ===================================================================== -->
+ <!-- SSO Authenticator, all authentication schemes must be configured here -->
+ <!-- ===================================================================== -->
+ <def-auth:authenticator id="josso-authenticator">
+ <def-auth:schemes>
+ <s:ref bean="josso-bind-authentication"/>
+ <!--
+ <s:ref bean="josso-basic-authentication"/>
+ <s:ref bean="josso-strong-authentication"/>
+ <s:ref bean="josso-rememberme-authentication"/>
+ -->
+ <!-- Others like NTLM and BIND go here -->
+ <!--
+ <s:ref bean="josso-bind-authentication"/>
+ -->
+ </def-auth:schemes>
+ </def-auth:authenticator>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Identity manager, referencing identity store -->
+ <!-- ===================================================================== -->
+ <def-identitymgr:identity-manager id="josso-identity-manager">
+
+ <def-identitymgr:identityStore>
+ <s:ref bean="josso-identity-store"/>
+ </def-identitymgr:identityStore>
+
+ <def-identitymgr:identityStoreKeyAdapter>
+ <s:ref bean="josso-simple-key-adapter"/>
+ </def-identitymgr:identityStoreKeyAdapter>
+
+ </def-identitymgr:identity-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Identity provider -->
+ <!-- ===================================================================== -->
+ <def-identityprv:identity-provider id="josso-identity-provider"/>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Session manager, referencing session store -->
+ <!-- ===================================================================== -->
+ <def-sessionmgr:session-manager id="josso-session-manager"
+ maxInactiveInterval="30"
+ maxSessionsPerUser="-1"
+ invalidateExceedingSessions="false"
+ sessionMonitorInterval="10000">
+
+ <def-sessionmgr:session-id-generator>
+ <def-sidgen:id-generator algorithm="MD5"/>
+ </def-sessionmgr:session-id-generator>
+
+ <def-sessionmgr:session-store>
+ <s:ref bean="josso-session-store"/>
+ </def-sessionmgr:session-store>
+
+ </def-sessionmgr:session-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Assertion anager, referencing assertion store -->
+ <!-- ===================================================================== -->
+ <def-assertionmgr:assertion-manager id="josso-assertion-manager">
+
+ <def-assertionmgr:assertion-id-generator>
+ <def-aidgen:id-generator/>
+ </def-assertionmgr:assertion-id-generator>
+
+ <def-assertionmgr:assertion-store>
+ <s:ref bean="josso-assertion-store"/>
+ </def-assertionmgr:assertion-store>
+
+ </def-assertionmgr:assertion-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Audit Manager with audit trail handlers -->
+ <!-- ===================================================================== -->
+ <def-auditmgr:audit-manager id="josso-audit-manager">
+
+ <!-- Audit Trail Handlers list -->
+ <def-auditmgr:handlers>
+ <logger-atrailhandler:audittrail-logger
category="org.josso.AUDIT"/>
+ </def-auditmgr:handlers>
+
+ </def-auditmgr:audit-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Protocol Manager with handlers -->
+ <!-- ===================================================================== -->
+ <default-protocol-manager id="josso-protocol-manager">
+ <!-- To enable NTLM, uncomment this :
+ <handlers>
+ <ntlm-authscheme:ntlm-protocol-handler/>
+ </handlers>
+ -->
+ </default-protocol-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Event manager, based on spring jmx -->
+ <!-- ===================================================================== -->
+ <def-eventmgr:springjmx-event-manager id="josso-event-manager">
+ <def-eventmgr:listeners>
+ <s:ref bean="josso-audit-manager"/>
+ </def-eventmgr:listeners>
+ </def-eventmgr:springjmx-event-manager>
+
+ <!-- ===================================================================== -->
+ <!-- SSO Simple key addapter used in several components -->
+ <!-- ===================================================================== -->
+ <simple-key-adapter id="josso-simple-key-adapter"/>
+
+ <!-- ===================================================================== -->
+ <!-- Spring Mail Sender bean. Configure mail delivery settings here -->
+ <!-- ===================================================================== -->
+ <s:bean id="josso-spring-mailsender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
+ <!-- Spring JavaMaileSender properties :
+ protocol, host, port, username, password -->
+ <s:property name="host" value="mail.mycompany.com"/>
+ </s:bean>
+
+</s:beans>
Added:
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-portal-stores.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-portal-stores.xml
(rev 0)
+++
modules/identity/trunk/sso/src/main/config/josso/conf/josso-gateway-portal-stores.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ ~ JOSSO: Java Open Single Sign-On
+ ~
+ ~ Copyright 2004-2009, Atricore, Inc.
+ ~
+ ~ 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.
+ ~
+ -->
+
+<s:beans
xmlns:s="http://www.springframework.org/schema/beans"
+ xmlns:portal-istore="urn:org:jboss:portal:josso:identitystore"
+ xmlns:memory-sstore="urn:org:josso:memory:sessionstore"
+ xmlns:memory-astore="urn:org:josso:memory:assertionstore"
+
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
+ urn:org:josso:memory:sessionstore
http://www.josso.org/schema/josso-memory-sessionstore.xsd
+ urn:org:josso:memory:assertionstore
http://www.josso.org/schema/josso-memory-assertionstore.xsd
+ ">
+ <!-- ===================================================================== -->
+ <!-- JOSSO Identity Store, the id is very important because it is -->
+ <!-- referenced by the identity manager, auth schemes and who knows where -->
+ <!-- else. -->
+ <!-- ===================================================================== -->
+ <portal-istore:portal-store id="josso-identity-store"
s:scope="singleton"/>
+
+ <!-- ===================================================================== -->
+ <!-- JOSSO Session Store, the id is very important because it is -->
+ <!-- referenced by the session manager and who knows where else -->
+ <!-- ===================================================================== -->
+ <memory-sstore:memory-store id="josso-session-store"/>
+
+ <!-- ===================================================================== -->
+ <!-- JOSSO Assertion Store, the id is very important because it is -->
+ <!-- referenced by the assertion manager and who knows where elese -->
+ <!-- ===================================================================== -->
+ <memory-astore:memory-store id="josso-assertion-store"/>
+</s:beans>
Added: modules/identity/trunk/sso/src/main/config/josso/conf/login-config.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/conf/login-config.xml
(rev 0)
+++ modules/identity/trunk/sso/src/main/config/josso/conf/login-config.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- The XML based
JAAS login configuration read by the
+org.jboss.security.auth.login.XMLLoginConfig mbean. Add
+an application-policy element for each security domain.
+
+The outline of the application-policy is:
+<application-policy name="security-domain-name">
+ <authentication>
+ <login-module code="login.module1.class.name"
flag="control_flag">
+ <module-option name =
"option1-name">option1-value</module-option>
+ <module-option name =
"option2-name">option2-value</module-option>
+ ...
+ </login-module>
+
+ <login-module code="login.module2.class.name"
flag="control_flag">
+ ...
+ </login-module>
+ ...
+ </authentication>
+</application-policy>
+
+$Revision: 64598 $
+--><policy>
+ <!-- Used by clients within the application server VM such as
+ mbeans and servlets that access EJBs.
+ -->
+ <application-policy name="client-login">
+ <authentication>
+ <login-module code="org.jboss.security.ClientLoginModule"
flag="required">
+ <!-- Any existing security context will be restored on logout -->
+ <module-option
name="restore-login-identity">true</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- Security domain for JBossMQ -->
+ <application-policy name="jbossmq">
+ <authentication>
+ <login-module
code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag="required">
+ <module-option
name="unauthenticatedIdentity">guest</module-option>
+ <module-option
name="dsJndiName">java:/DefaultDS</module-option>
+ <module-option name="principalsQuery">SELECT PASSWD FROM
JMS_USERS WHERE USERID=?</module-option>
+ <module-option name="rolesQuery">SELECT ROLEID,
'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- Security domain for JBossMQ when using file-state-service.xml
+ <application-policy name = "jbossmq">
+ <authentication>
+ <login-module code = "org.jboss.mq.sm.file.DynamicLoginModule"
+ flag = "required">
+ <module-option name =
"unauthenticatedIdentity">guest</module-option>
+ <module-option name =
"sm.objectname">jboss.mq:service=StateManager</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+ -->
+
+ <!-- Security domains for testing new jca framework -->
+ <application-policy name="HsqlDbRealm">
+ <authentication>
+ <login-module
code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag="required">
+ <module-option name="principal">sa</module-option>
+ <module-option name="userName">sa</module-option>
+ <module-option name="password"/>
+ <module-option
name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <application-policy name="JmsXARealm">
+ <authentication>
+ <login-module
code="org.jboss.resource.security.ConfiguredIdentityLoginModule"
flag="required">
+ <module-option name="principal">guest</module-option>
+ <module-option name="userName">guest</module-option>
+ <module-option name="password">guest</module-option>
+ <module-option
name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- A template configuration for the jmx-console web application. This
+ defaults to the UsersRolesLoginModule the same as other and should be
+ changed to a stronger authentication mechanism as required.
+ -->
+ <application-policy name="jmx-console">
+ <authentication>
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ <module-option
name="usersProperties">props/jmx-console-users.properties</module-option>
+ <module-option
name="rolesProperties">props/jmx-console-roles.properties</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- A template configuration for the web-console web application. This
+ defaults to the UsersRolesLoginModule the same as other and should be
+ changed to a stronger authentication mechanism as required.
+ -->
+ <application-policy name="web-console">
+ <authentication>
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ <module-option
name="usersProperties">web-console-users.properties</module-option>
+ <module-option
name="rolesProperties">web-console-roles.properties</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!--
+ A template configuration for the JBossWS security domain.
+ This defaults to the UsersRolesLoginModule the same as other and should be
+ changed to a stronger authentication mechanism as required.
+ -->
+ <application-policy name="JBossWS">
+ <authentication>
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
+ <module-option
name="usersProperties">props/jbossws-users.properties</module-option>
+ <module-option
name="rolesProperties">props/jbossws-roles.properties</module-option>
+ <module-option
name="unauthenticatedIdentity">anonymous</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <!-- The default login configuration used by any security domain that
+ does not have a application-policy entry with a matching name
+ -->
+ <application-policy name="other">
+ <!-- A simple server login module, which can be used when the number
+ of users is relatively small. It uses two properties files:
+ users.properties, which holds users (key) and their password (value).
+ roles.properties, which holds users (key) and a comma-separated list of
+ their roles (value).
+ The unauthenticatedIdentity property defines the name of the principal
+ that will be used when a null username and password are presented as is
+ the case for an unuathenticated web client or MDB. If you want to
+ allow such users to be authenticated add the property, e.g.,
+ unauthenticatedIdentity="nobody"
+ -->
+ <authentication>
+ <login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required"/>
+ </authentication>
+ </application-policy>
+
+<!-- ================================================== -->
+ <!-- JOSSO JAAS Login Configuration, automatially generated by JOSSO
Installer-->
+ <application-policy name="josso"> <authentication>
+ <login-module
code="org.jboss.portal.identity.sso.josso.JOSSOLoginModule"
flag="required">
+ <module-option name="debug">true</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+ <!-- ================================================== -->
+</policy>
\ No newline at end of file
Added: modules/identity/trunk/sso/src/main/config/josso/jboss-portal/context.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/jboss-portal/context.xml
(rev 0)
+++ modules/identity/trunk/sso/src/main/config/josso/jboss-portal/context.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<Context>
+ <Valve
className="org.jboss.portal.identity.sso.josso.JOSSOLogoutValve"/>
+</Context>
Added: modules/identity/trunk/sso/src/main/config/josso/jboss-portal/jboss-web.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/jboss-portal/jboss-web.xml
(rev 0)
+++ modules/identity/trunk/sso/src/main/config/josso/jboss-portal/jboss-web.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<jboss-web>
+ <security-domain>java:jaas/josso</security-domain>
+ <context-root>/portal</context-root>
+ <replication-config>
+ <replication-trigger>SET</replication-trigger>
+ </replication-config>
+ <resource-ref>
+ <res-ref-name>jdbc/PortalDS</res-ref-name>
+ <jndi-name>java:PortalDS</jndi-name>
+ </resource-ref>
+</jboss-web>
Added: modules/identity/trunk/sso/src/main/config/josso/jboss-portal/login.jsp
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/jboss-portal/login.jsp
(rev 0)
+++ modules/identity/trunk/sso/src/main/config/josso/jboss-portal/login.jsp 2009-04-17
03:25:33 UTC (rev 13225)
@@ -0,0 +1,168 @@
+<%--
+ ~ 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" %>
+<%
+ response.sendRedirect(request.getContextPath() + "/josso_login/");
+%>
+
+<%--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--%>
+<%--
+
+<%@ page pageEncoding="utf-8" %>
+<%@page import="org.jboss.portal.identity.UserStatus" %>
+<%@page import="org.jboss.portal.server.ParameterSanitizer" %>
+<%@page import="java.util.ResourceBundle" %>
+
+<%
+ ResourceBundle rb = ResourceBundle.getBundle("Resource",
request.getLocale());
+ // todo: use ParameterValidation.sanitize after 2.7.1
+ String loginheight = request.getParameter("loginheight");
+ boolean paramPresent = loginheight != null;
+ loginheight = ParameterSanitizer.sanitizeFromPattern(loginheight,
ParameterSanitizer.CSS_DISTANCE, "300px");
+%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><%= rb.getString("LOGIN_TITLE") %>
+ </title>
+ <style type="text/css">
+ /* <![CDATA[ */
+ body {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ padding-top: <%=loginheight%>;
+ }
+
+ /* ]]> */
+ </style>
+
+ <script>
+ function setFocusOnLoginForm()
+ {
+ try
+ {
+ document.loginform.j_username.focus();
+ }
+ catch (e)
+ {
+ }
+ }
+ </script>
+
+ <link rel="stylesheet" href="/portal-core/css/login.css"
type="text/css"/>
+</head>
+<body onload="setFocusOnLoginForm();">
+
+<div class="login-container">
+
+
+ <div class="login-header">
+ <h2><%= rb.getString("LOGIN_TITLE") %>
+ </h2>
+ </div>
+ <div class="login-content">
+
+ <div class="error-message"
+
style="<%=(request.getAttribute(!UserStatus.OK.equals("org.jboss.portal.userStatus")
? "" : "display:none"))%>;">
+ <%
+
+ if
(UserStatus.DISABLE.equals(request.getAttribute("org.jboss.portal.userStatus")))
+ {
+ out.println(rb.getString("ACCOUNT_DISABLED"));
+ }
+ else if
(UserStatus.WRONGPASSWORD.equals(request.getAttribute("org.jboss.portal.userStatus"))
||
UserStatus.UNEXISTING.equals(request.getAttribute("org.jboss.portal.userStatus")))
+ {
+
out.println(rb.getString("ACCOUNT_INEXISTING_OR_WRONG_PASSWORD"));
+ }
+ else if
(UserStatus.NOTASSIGNEDTOROLE.equals(request.getAttribute("org.jboss.portal.userStatus")))
+ {
+ out.println(rb.getString("ACCOUNT_NOTASSIGNEDTOROLE"));
+ }
+ %>
+ </div>
+ <form method="post" action="<%=
response.encodeURL("j_security_check") %>" name="loginform"
id="loginForm"
+ target="_parent">
+ <div class="form-field">
+ <label for="j_username"><%=
rb.getString("LOGIN_USERNAME") %>
+ </label>
+ <input type="text" name="j_username"
id="j_username" value=""/>
+ </div>
+ <div class="form-field">
+ <label for="j_password"><%=
rb.getString("LOGIN_PASSWORD") %>
+ </label>
+ <input type="password" name="j_password"
id="j_password" value=""/>
+ </div>
+ <br class="clear"/>
+
+ <div class="button-container">
+ <br class="clear"/>
+ <input style="<%=paramPresent ? "" :
"display:none"%>;" type="button" name="cancel"
+ value="<%= rb.getString("LOGIN_CANCEL") %>"
class="cancel-button"
+
onclick="window.parent.hideContentModal('login-modal');"/>
+ <br class="clear"/>
+ <input style="<%=paramPresent ? "" :
"right:10px"%>;" type="submit" name="login"
+ value="<%= rb.getString("LOGIN_SUBMIT") %>"
class="login-button"/>
+ </div>
+ <br class="clear"/>
+ </form>
+
+ </div>
+</div>
+</body>
+</html>
+--%>
Added: modules/identity/trunk/sso/src/main/config/josso/sar/META-INF/jboss-service.xml
===================================================================
--- modules/identity/trunk/sso/src/main/config/josso/sar/META-INF/jboss-service.xml
(rev 0)
+++
modules/identity/trunk/sso/src/main/config/josso/sar/META-INF/jboss-service.xml 2009-04-17
03:25:33 UTC (rev 13225)
@@ -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
Modified:
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOIdentityStore.java
===================================================================
---
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOIdentityStore.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOIdentityStore.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -30,6 +30,7 @@
import org.jboss.mx.util.MBeanProxy;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.portal.identity.sso.josso.JOSSOIdentityService;
+
import org.josso.gateway.SSONameValuePair;
import org.josso.gateway.identity.exceptions.NoSuchUserException;
import org.josso.gateway.identity.exceptions.SSOIdentityException;
@@ -37,22 +38,27 @@
import org.josso.gateway.identity.service.BaseRoleImpl;
import org.josso.gateway.identity.service.BaseUser;
import org.josso.gateway.identity.service.BaseUserImpl;
-import org.josso.gateway.identity.service.store.IdentityStore;
import org.josso.gateway.identity.service.store.UserKey;
import org.josso.gateway.identity.service.store.SimpleUserKey;
+import org.josso.gateway.identity.service.store.IdentityStore;
+
import org.josso.auth.Credential;
import org.josso.auth.CredentialKey;
-import org.josso.auth.BindableCredentialStore;
-import org.josso.auth.exceptions.SSOAuthenticationException;
+import org.josso.auth.CredentialProvider;
import org.josso.auth.scheme.AuthenticationScheme;
import org.josso.auth.scheme.UsernameCredential;
import org.josso.auth.scheme.PasswordCredential;
+import org.josso.auth.BindableCredentialStore;
+import org.josso.auth.exceptions.SSOAuthenticationException;
+
/**
+ * @org.apache.xbean.XBean element="portal-store"
+ *
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class JOSSOIdentityStore implements IdentityStore, BindableCredentialStore
+public class JOSSOIdentityStore implements IdentityStore,BindableCredentialStore
{
/**
*
@@ -81,6 +87,9 @@
MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
this.portalIdentityService = (JOSSOIdentityService)
MBeanProxy.get(JOSSOIdentityService.class,new
ObjectName("portal:service=Module,type=JOSSOIdentityService"),mbeanServer);
+
log.info("-------------------------------------------------------------------");
+ log.info("JBoss Portal JOSSO Identity Store successfully
started.............");
+
log.info("-------------------------------------------------------------------");
}
catch(Exception e)
{
@@ -91,18 +100,34 @@
throw new RuntimeException("JOSSOIdentityStore registration
failed....");
}
}
- //-----IdentityStore
implementation--------------------------------------------------------------------------------------------------
- /**
- *
- */
- public BaseRole[] findRolesByUserKey(UserKey userKey)
- throws SSOIdentityException
- {
+
+ public void setAuthenticationScheme(AuthenticationScheme authenticationScheme)
+ {
if(this.portalIdentityService == null)
{
throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
}
+ this.authenticationScheme = authenticationScheme;
+ }
+ //----------------IdentityStore
implementation------------------------------------------------------------------------------------------------------------------------
+ public boolean userExists(UserKey userKey) throws SSOIdentityException
+ {
+ if(this.portalIdentityService == null)
+ {
+ throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
+ }
+
+ return this.portalIdentityService.exists(userKey.toString());
+ }
+
+ public BaseRole[] findRolesByUserKey(UserKey userKey) throws SSOIdentityException
+ {
+ if(this.portalIdentityService == null)
+ {
+ throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
+ }
+
//Get the role information from the Portal Identity System
String[] userRoles = this.portalIdentityService.getUserRoles(userKey.toString());
@@ -113,17 +138,12 @@
roles[i] = new BaseRoleImpl(userRoles[i]);
}
-
return roles;
}
- /**
- *
- */
- public BaseUser loadUser(UserKey userKey) throws NoSuchUserException,
- SSOIdentityException
- {
- if(this.portalIdentityService == null)
+ public BaseUser loadUser(UserKey userKey) throws NoSuchUserException,
SSOIdentityException
+ {
+ if(this.portalIdentityService == null)
{
throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
}
@@ -134,58 +154,25 @@
user.addProperty("password", "");
return user;
- }
-
- /**
- *
- */
- public boolean userExists(UserKey userKey) throws SSOIdentityException
- {
- if(this.portalIdentityService == null)
+ }
+ //---------------CredentialStore
implementation----------------------------------------------------------------------------------------------------------------------
+ public Credential[] loadCredentials(CredentialKey credentialKey, CredentialProvider
credentialProvider) throws SSOIdentityException
+ {
+ if(this.portalIdentityService == null)
{
throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
}
- return this.portalIdentityService.exists(userKey.toString());
- }
- //---------BindableCredentialStore
implementation---------------------------------------------------------------------------------------------
- /**
- *
- */
- public Credential[] loadCredentials(CredentialKey credentialKey) throws
SSOIdentityException
- {
- if(this.portalIdentityService == null)
- {
- throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
- }
-
//Get the User corresponding to this credentialKey
BaseUser user = this.loadUser((SimpleUserKey)credentialKey);
SSONameValuePair[] properties = user.getProperties();
String password = properties[0].getValue();
return new Credential[]{new UsernameCredential(user.getName()), new
PasswordCredential(password)};
- }
+ }
- /**
- *
- */
public boolean bind(String username, String password) throws
SSOAuthenticationException
{
return this.portalIdentityService.authenticate(username, password);
}
-
-
- /**
- *
- */
- public void setAuthenticationScheme(AuthenticationScheme authenticationScheme)
- {
- if(this.portalIdentityService == null)
- {
- throw new IllegalStateException("JOSSOIdentityStore not properly registered
with the JOSSO system..");
- }
-
- this.authenticationScheme = authenticationScheme;
- }
}
Modified:
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLoginModule.java
===================================================================
---
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLoginModule.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLoginModule.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -36,10 +36,7 @@
import org.apache.log4j.Logger;
import org.josso.gateway.identity.SSORole;
-import org.josso.gateway.identity.SSOUser;
import org.josso.gateway.identity.service.BaseRoleImpl;
-import org.josso.gateway.identity.service.BaseUserImpl;
-import org.josso.tc55.agent.jaas.SSOGatewayLoginModule;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
@@ -50,6 +47,8 @@
import java.util.Map;
import java.util.Set;
+import org.josso.jb42.agent.JBossSSOGatewayLoginModule;
+
/**
* SSOGatewayLogin Module for JBoss.
* <p>
@@ -83,70 +82,20 @@
* @version CVS $Id: JBossSSOGatewayLoginModule.java 338 2006-02-09 16:53:07Z sgonzalez
$
*/
-public class JOSSOLoginModule extends SSOGatewayLoginModule {
+public class JOSSOLoginModule extends JBossSSOGatewayLoginModule
+{
private static final Logger logger = Logger.getLogger(JOSSOLoginModule .class);
-
+
private Subject _savedSubject;
-
- /** the principal to use when user is not authenticated **/
- protected SSOUser _unauthenticatedIdentity;
-
-
- /**
- * Initialize this LoginModule .
- * Save the received Subject to change it when commit() gets invoked.
- *
- * @param subject the Subject to be authenticated.
- *
- * @param callbackHandler a CallbackHandler for communicating
- * with the end user (prompting for user names and
- * passwords, for example).
- *
- * @param sharedState shared LoginModule state.
- *
- * @param options options specified in the login Configuration
- * for this particular LoginModule.
- */
+
public void initialize(Subject subject, CallbackHandler callbackHandler,
- Map sharedState, Map options) {
-
- _savedSubject = subject;
- super.initialize(subject, callbackHandler, sharedState, options);
- // Check for unauthenticatedIdentity option.
- String name = (String) options.get("unauthenticatedIdentity");
- if( name != null )
- {
- try
- {
- _unauthenticatedIdentity = createIdentity(name);
- logger.debug("Saw unauthenticatedIdentity="+name);
- }
- catch(Exception e)
- {
- logger.warn("Failed to create custom unauthenticatedIdentity",
e);
- }
- }
+ Map sharedState, Map options)
+ {
+ super.initialize(subject, callbackHandler, sharedState, options);
+ this._savedSubject = subject;
}
- /**
- * This method supports the unauthenticatedIdentity property used by JBoss.
- */
- public boolean login() throws LoginException {
-
- if (!super.login()) {
- // We have an unauthenticated user, use configured Principal
- if (_unauthenticatedIdentity != null) {
- logger.debug("Authenticated as unauthenticatedIdentity : " +
_unauthenticatedIdentity);
- _ssoUserPrincipal = _unauthenticatedIdentity;
- _succeeded = true;
- return true;
- }
- }
-
- return true;
- }
-
/*
* This method is called if the LoginContext's overall authentication succeeded.
*
@@ -159,55 +108,22 @@
* @return true if this LoginModule's own login and commit
* attempts succeeded, or false otherwise.
*/
- public boolean commit() throws LoginException {
- boolean rc = false;
- // HashMap setsMap = new HashMap();
-
- rc = super.commit();
-
+ public boolean commit() throws LoginException
+ {
+ boolean rc = super.commit();
+
+
Set ssoRolePrincipals = _savedSubject.getPrincipals(SSORole.class);
Group targetGrp = new BaseRoleImpl("Roles");
Iterator i = ssoRolePrincipals.iterator();
Set cour = new java.util.HashSet();
- while (i.hasNext()) {
- Principal p = (Principal)i.next();
-
- targetGrp.addMember(p); // Add user role to "Roles" group
-
+ while (i.hasNext())
+ {
+ Principal p = (Principal)i.next();
//super hack to make the Subject work properly with the Portal Authorization
Engine
((BaseRoleImpl)p).addMember(this.createIdentity(p.getName()));
}
- // Add the "Roles" group to the Subject so that JBoss can fetch user
roles.
- _savedSubject.getPrincipals().removeAll(ssoRolePrincipals);
- _savedSubject.getPrincipals().add(targetGrp);
-
- /*Set ssoUserPrincipals = _savedSubject.getPrincipals(SSOUser.class);
- Group callerPrincipal = new BaseRoleImpl("CallerPrincipal");
- Iterator j = ssoUserPrincipals.iterator();
- if (j.hasNext()) {
- Principal user = (Principal) j.next();
- callerPrincipal.addMember(user);
- }
-
- // Add the "CallerPrincipal" group to the Subject so that JBoss can
fetch user.
- _savedSubject.getPrincipals().add(callerPrincipal);*/
-
- return rc;
+
+ return rc;
}
-
- protected SSOUser createIdentity(String username) {
- return new BaseUserImpl(username);
- }
-
- protected SSORole[] getRoleSets() throws LoginException {
- if (_ssoUserPrincipal == _unauthenticatedIdentity) {
- // Using unauthenticatedIdentity ..
- if(logger.isDebugEnabled())
- logger.debug("Using unauthenticatedIdentity " +
_ssoUserPrincipal + ", returning no roles.");
-
- return new SSORole[0];
- }
- return super.getRoleSets();
- }
-
}
Modified:
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLogoutValve.java
===================================================================
---
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLogoutValve.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/main/java/org/jboss/portal/identity/sso/josso/JOSSOLogoutValve.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -83,8 +83,8 @@
this.getNext().invoke(request, response);
if(request.getAttribute("org.jboss.portal.logout") != null)
- {
- String jossoLogout = httpRequest.getContextPath() +
org.josso.agent.Constants.JOSSO_LOGOUT_URI;
+ {
+ String jossoLogout = httpRequest.getContextPath() + "/josso_logout/";
Cookie cookie = new
Cookie("JOSSO_PORTAL_LOGOUT",httpRequest.getHeader("Referer"));
cookie.setMaxAge(-1); //setting the value so that cookie expires when broser is
closed
Modified:
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasySSLProtocolSocketFactory.java
===================================================================
---
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasySSLProtocolSocketFactory.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasySSLProtocolSocketFactory.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -1,233 +1,233 @@
-///*
-// * $Header:
/home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java,v
1.7 2004/06/11 19:26:27 olegk Exp $
-// * $Revision$
-// * $Date$
-// *
-// * ====================================================================
-// *
-// * 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.
-// * ====================================================================
-// *
-// * This software consists of voluntary contributions made by many
-// * individuals on behalf of the Apache Software Foundation. For more
-// * information on the Apache Software Foundation, please see
-// * <
http://www.apache.org/>.
-// *
-// */
-//
-//package org.jboss.portal.test.identity.sso;
-//
-//import java.io.IOException;
-//import java.net.InetAddress;
-//import java.net.InetSocketAddress;
-//import java.net.Socket;
-//import java.net.SocketAddress;
-//import java.net.UnknownHostException;
-//
-//import org.apache.commons.httpclient.ConnectTimeoutException;
-//import org.apache.commons.httpclient.HttpClientError;
-//import org.apache.commons.httpclient.params.HttpConnectionParams;
-//import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-//
-//import javax.net.SocketFactory;
-//import javax.net.ssl.SSLContext;
-//import javax.net.ssl.TrustManager;
-//
-///**
-// * <p>
-// * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s that
-// * accept self-signed certificates.
-// * </p>
-// * <p>
-// * This socket factory SHOULD NOT be used for productive systems due to security
-// * reasons, unless it is a concious decision and you are perfectly aware of
-// * security implications of accepting self-signed certificates
-// * </p>
-// *
-// * <p>
-// * Example of using custom protocol socket factory for a specific host:
-// *
-// * <pre>
-// * Protocol easyhttps = new Protocol("https", new
EasySSLProtocolSocketFactory(),
-// * 443);
-// * HttpClient client = new HttpClient();
-// * client.getHostConfiguration().setHost("localhost", 443,
easyhttps);
-// * // use relative url only
-// * GetMethod httpget = new GetMethod("/");
-// * client.executeMethod(httpget);
-// * </pre>
-// *
-// * </p>
-// * <p>
-// * Example of using custom protocol socket factory per default instead of the
-// * standard one:
-// *
-// * <pre>
-// * Protocol easyhttps = new Protocol("https", new
EasySSLProtocolSocketFactory(),
-// * 443);
-// * Protocol.registerProtocol("https", easyhttps);
-// * HttpClient client = new HttpClient();
-// * GetMethod httpget = new GetMethod("https://localhost/");
-// * client.executeMethod(httpget);
-// * </pre>
-// *
-// * </p>
-// *
-// * @author <a href="mailto:oleg -at- ural.ru">Oleg
Kalnichevski</a>
-// *
-// * <p>
-// * DISCLAIMER: HttpClient developers DO NOT actively support this component. The
-// * component is provided as a reference material, which may be inappropriate for
-// * use without additional customization.
-// * </p>
-// */
-//
-//public class EasySSLProtocolSocketFactory implements
-// SecureProtocolSocketFactory
-//{
-//
-// private SSLContext sslcontext = null;
-//
-// /**
-// * Constructor for EasySSLProtocolSocketFactory.
-// */
-// public EasySSLProtocolSocketFactory()
-// {
-// super();
-// }
-//
-// private static SSLContext createEasySSLContext()
-// {
-// try
-// {
-// SSLContext context = SSLContext.getInstance("SSL");
-// context.init(null, new TrustManager[]
-// { new EasyX509TrustManager(null) }, null);
-// return context;
-// }
-// catch (Exception e)
-// {
-// throw new HttpClientError(e.toString());
-// }
-// }
-//
-// private SSLContext getSSLContext()
-// {
-// if (this.sslcontext == null)
-// {
-// this.sslcontext = createEasySSLContext();
-// }
-// return this.sslcontext;
-// }
-//
-// /**
-// * @see
SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
-// */
-// public Socket createSocket(String host, int port, InetAddress clientHost,
-// int clientPort) throws IOException, UnknownHostException
-// {
-//
-// return getSSLContext().getSocketFactory().createSocket(host, port,
-// clientHost, clientPort);
-// }
-//
-// /**
-// * Attempts to get a new socket connection to the given host within the given
-// * time limit.
-// * <p>
-// * To circumvent the limitations of older JREs that do not support connect
-// * timeout a controller thread is executed. The controller thread attempts to
-// * create a new socket within the given limit of time. If socket constructor
-// * does not return until the timeout expires, the controller terminates and
-// * throws an {@link ConnectTimeoutException}
-// * </p>
-// *
-// * @param host
-// * the host name/IP
-// * @param port
-// * the port on the host
-// * @param clientHost
-// * the local host name/IP to bind the socket to
-// * @param clientPort
-// * the port on the local machine
-// * @param params
-// * {@link HttpConnectionParams Http connection parameters}
-// *
-// * @return Socket a new socket
-// *
-// * @throws IOException
-// * if an I/O error occurs while creating the socket
-// * @throws UnknownHostException
-// * if the IP address of the host cannot be determined
-// */
-// public Socket createSocket(final String host, final int port,
-// final InetAddress localAddress, final int localPort,
-// final HttpConnectionParams params) throws IOException,
-// UnknownHostException, ConnectTimeoutException
-// {
-// if (params == null)
-// {
-// throw new IllegalArgumentException("Parameters may not be null");
-// }
-// int timeout = params.getConnectionTimeout();
-// SocketFactory socketfactory = getSSLContext().getSocketFactory();
-// if (timeout == 0)
-// {
-// return socketfactory.createSocket(host, port, localAddress, localPort);
-// }
-// else
-// {
-// Socket socket = socketfactory.createSocket();
-// SocketAddress localaddr = new InetSocketAddress(localAddress,
-// localPort);
-// SocketAddress remoteaddr = new InetSocketAddress(host, port);
-// socket.bind(localaddr);
-// socket.connect(remoteaddr, timeout);
-// return socket;
-// }
-// }
-//
-// /**
-// * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
-// */
-// public Socket createSocket(String host, int port) throws IOException,
-// UnknownHostException
-// {
-// return getSSLContext().getSocketFactory().createSocket(host, port);
-// }
-//
-// /**
-// * @see
SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
-// */
-// public Socket createSocket(Socket socket, String host, int port,
-// boolean autoClose) throws IOException, UnknownHostException
-// {
-// return getSSLContext().getSocketFactory().createSocket(socket, host,
-// port, autoClose);
-// }
-//
-// public boolean equals(Object obj)
-// {
-// return ((obj != null) && obj.getClass().equals(
-// EasySSLProtocolSocketFactory.class));
-// }
-//
-// public int hashCode()
-// {
-// return EasySSLProtocolSocketFactory.class.hashCode();
-// }
-//
-//}
+/*
+ * $Header:
/home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commonshttpclient/src/contrib/org/apache/commons/httpclient/contrib/ssl/EasySSLProtocolSocketFactory.java,v
1.7 2004/06/11 19:26:27 olegk Exp $
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http:www.apache.org/>.
+ *
+ */
+
+package org.jboss.portal.test.identity.sso;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.HttpClientError;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+
+/**
+ * <p>
+ * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s that
+ * accept self-signed certificates.
+ * </p>
+ * <p>
+ * This socket factory SHOULD NOT be used for productive systems due to security
+ * reasons, unless it is a concious decision and you are perfectly aware of
+ * security implications of accepting self-signed certificates
+ * </p>
+ *
+ * <p>
+ * Example of using custom protocol socket factory for a specific host:
+ *
+ * <pre>
+ * Protocol easyhttps = new Protocol("https", new
EasySSLProtocolSocketFactory(),
+ * 443);
+ * HttpClient client = new HttpClient();
+ * client.getHostConfiguration().setHost("localhost", 443, easyhttps);
+ * use relative url only
+ * GetMethod httpget = new GetMethod("/");
+ * client.executeMethod(httpget);
+ * </pre>
+ *
+ * </p>
+ * <p>
+ * Example of using custom protocol socket factory per default instead of the
+ * standard one:
+ *
+ * <pre>
+ * Protocol easyhttps = new Protocol("https", new
EasySSLProtocolSocketFactory(),
+ * 443);
+ * Protocol.registerProtocol("https", easyhttps);
+ * HttpClient client = new HttpClient();
+ * GetMethod httpget = new GetMethod("https:localhost/");
+ * client.executeMethod(httpget);
+ * </pre>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:oleg -at- ural.ru">Oleg
Kalnichevski</a>
+ *
+ * <p>
+ * DISCLAIMER: HttpClient developers DO NOT actively support this component. The
+ * component is provided as a reference material, which may be inappropriate for
+ * use without additional customization.
+ * </p>
+ */
+
+public class EasySSLProtocolSocketFactory implements
+ SecureProtocolSocketFactory
+{
+
+ private SSLContext sslcontext = null;
+
+ /**
+ * Constructor for EasySSLProtocolSocketFactory.
+ */
+ public EasySSLProtocolSocketFactory()
+ {
+ super();
+ }
+
+ private static SSLContext createEasySSLContext()
+ {
+ try
+ {
+ SSLContext context = SSLContext.getInstance("SSL");
+ context.init(null, new TrustManager[]
+ { new EasyX509TrustManager(null) }, null);
+ return context;
+ }
+ catch (Exception e)
+ {
+ throw new HttpClientError(e.toString());
+ }
+ }
+
+ private SSLContext getSSLContext()
+ {
+ if (this.sslcontext == null)
+ {
+ this.sslcontext = createEasySSLContext();
+ }
+ return this.sslcontext;
+ }
+
+ /**
+ * @see
SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
+ */
+ public Socket createSocket(String host, int port, InetAddress clientHost,
+ int clientPort) throws IOException, UnknownHostException
+ {
+
+ return getSSLContext().getSocketFactory().createSocket(host, port,
+ clientHost, clientPort);
+ }
+
+ /**
+ * Attempts to get a new socket connection to the given host within the given
+ * time limit.
+ * <p>
+ * To circumvent the limitations of older JREs that do not support connect
+ * timeout a controller thread is executed. The controller thread attempts to
+ * create a new socket within the given limit of time. If socket constructor
+ * does not return until the timeout expires, the controller terminates and
+ * throws an {@link ConnectTimeoutException}
+ * </p>
+ *
+ * @param host
+ * the host name/IP
+ * @param port
+ * the port on the host
+ * @param clientHost
+ * the local host name/IP to bind the socket to
+ * @param clientPort
+ * the port on the local machine
+ * @param params
+ * {@link HttpConnectionParams Http connection parameters}
+ *
+ * @return Socket a new socket
+ *
+ * @throws IOException
+ * if an I/O error occurs while creating the socket
+ * @throws UnknownHostException
+ * if the IP address of the host cannot be determined
+ */
+ public Socket createSocket(final String host, final int port,
+ final InetAddress localAddress, final int localPort,
+ final HttpConnectionParams params) throws IOException,
+ UnknownHostException, ConnectTimeoutException
+ {
+ if (params == null)
+ {
+ throw new IllegalArgumentException("Parameters may not be null");
+ }
+ int timeout = params.getConnectionTimeout();
+ SocketFactory socketfactory = getSSLContext().getSocketFactory();
+ if (timeout == 0)
+ {
+ return socketfactory.createSocket(host, port, localAddress, localPort);
+ }
+ else
+ {
+ Socket socket = socketfactory.createSocket();
+ SocketAddress localaddr = new InetSocketAddress(localAddress,
+ localPort);
+ SocketAddress remoteaddr = new InetSocketAddress(host, port);
+ socket.bind(localaddr);
+ socket.connect(remoteaddr, timeout);
+ return socket;
+ }
+ }
+
+ /**
+ * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
+ */
+ public Socket createSocket(String host, int port) throws IOException,
+ UnknownHostException
+ {
+ return getSSLContext().getSocketFactory().createSocket(host, port);
+ }
+
+ /**
+ * @see
SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
+ */
+ public Socket createSocket(Socket socket, String host, int port,
+ boolean autoClose) throws IOException, UnknownHostException
+ {
+ return getSSLContext().getSocketFactory().createSocket(socket, host,
+ port, autoClose);
+ }
+
+ public boolean equals(Object obj)
+ {
+ return ((obj != null) && obj.getClass().equals(
+ EasySSLProtocolSocketFactory.class));
+ }
+
+ public int hashCode()
+ {
+ return EasySSLProtocolSocketFactory.class.hashCode();
+ }
+
+}
Modified:
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasyX509TrustManager.java
===================================================================
---
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasyX509TrustManager.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/EasyX509TrustManager.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -1,109 +1,109 @@
-///*
-//* ====================================================================
-//*
-//* 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.
-//* ====================================================================
-//*
-//* This software consists of voluntary contributions made by many
-//* individuals on behalf of the Apache Software Foundation. For more
-//* information on the Apache Software Foundation, please see
-//* <
http://www.apache.org/>.
-//*
-//*/
-//
-//package org.jboss.portal.test.identity.sso;
-//
-//import java.security.KeyStore;
-//import java.security.KeyStoreException;
-//import java.security.NoSuchAlgorithmException;
-//import java.security.cert.CertificateException;
-//import java.security.cert.X509Certificate;
-//
-//import javax.net.ssl.TrustManagerFactory;
-//import javax.net.ssl.TrustManager;
-//import javax.net.ssl.X509TrustManager;
-//
-///**
-//* <p>
-//* EasyX509TrustManager unlike default {@link X509TrustManager} accepts
-//* self-signed certificates.
-//* </p>
-//* <p>
-//* This trust manager SHOULD NOT be used for productive systems
-//* due to security reasons, unless it is a concious decision and
-//* you are perfectly aware of security implications of accepting
-//* self-signed certificates
-//* </p>
-//*
-//* @author <a href="mailto:adrian.sutton@ephox.com">Adrian
Sutton</a>
-//* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
-//*
-//* <p>
-//* DISCLAIMER: HttpClient developers DO NOT actively support this component.
-//* The component is provided as a reference material, which may be inappropriate
-//* for use without additional customization.
-//* </p>
-//*/
-//
-//public class EasyX509TrustManager implements X509TrustManager
-//{
-// private X509TrustManager standardTrustManager = null;
-//
-// /**
-// * Constructor for EasyX509TrustManager.
-// */
-// public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException,
KeyStoreException {
-// super();
-// TrustManagerFactory factory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
-// factory.init(keystore);
-// TrustManager[] trustmanagers = factory.getTrustManagers();
-// if (trustmanagers.length == 0) {
-// throw new NoSuchAlgorithmException("no trust manager found");
-// }
-// this.standardTrustManager = (X509TrustManager)trustmanagers[0];
-// }
-//
-// /**
-// * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String
authType)
-// */
-// public void checkClientTrusted(X509Certificate[] certificates,String authType)
throws CertificateException {
-// standardTrustManager.checkClientTrusted(certificates,authType);
-// }
-//
-// /**
-// * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String
authType)
-// */
-// public void checkServerTrusted(X509Certificate[] certificates,String authType)
throws CertificateException {
-// /*if ((certificates != null) && LOG.isDebugEnabled()) {
-// LOG.debug("Server certificate chain:");
-// for (int i = 0; i < certificates.length; i++) {
-// LOG.debug("X509Certificate[" + i + "]=" +
certificates[i]);
-// }
-// }*/
-// if ((certificates != null) && (certificates.length == 1)) {
-// certificates[0].checkValidity();
-// } else {
-// standardTrustManager.checkServerTrusted(certificates,authType);
-// }
-// }
-//
-// /**
-// * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
-// */
-// public X509Certificate[] getAcceptedIssuers() {
-// return this.standardTrustManager.getAcceptedIssuers();
-// }
-//}
\ No newline at end of file
+/*
+* ====================================================================
+*
+* 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.
+* ====================================================================
+*
+* This software consists of voluntary contributions made by many
+* individuals on behalf of the Apache Software Foundation. For more
+* information on the Apache Software Foundation, please see
+* <http:www.apache.org/>.
+*
+*/
+
+package org.jboss.portal.test.identity.sso;
+
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+/**
+* <p>
+* EasyX509TrustManager unlike default {@link X509TrustManager} accepts
+* self-signed certificates.
+* </p>
+* <p>
+* This trust manager SHOULD NOT be used for productive systems
+* due to security reasons, unless it is a concious decision and
+* you are perfectly aware of security implications of accepting
+* self-signed certificates
+* </p>
+*
+* @author <a href="mailto:adrian.sutton@ephox.com">Adrian
Sutton</a>
+* @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+*
+* <p>
+* DISCLAIMER: HttpClient developers DO NOT actively support this component.
+* The component is provided as a reference material, which may be inappropriate
+* for use without additional customization.
+* </p>
+*/
+
+public class EasyX509TrustManager implements X509TrustManager
+{
+ private X509TrustManager standardTrustManager = null;
+
+ /**
+ * Constructor for EasyX509TrustManager.
+ */
+ public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException,
KeyStoreException {
+ super();
+ TrustManagerFactory factory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ factory.init(keystore);
+ TrustManager[] trustmanagers = factory.getTrustManagers();
+ if (trustmanagers.length == 0) {
+ throw new NoSuchAlgorithmException("no trust manager found");
+ }
+ this.standardTrustManager = (X509TrustManager)trustmanagers[0];
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String
authType)
+ */
+ public void checkClientTrusted(X509Certificate[] certificates,String authType) throws
CertificateException {
+ standardTrustManager.checkClientTrusted(certificates,authType);
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String
authType)
+ */
+ public void checkServerTrusted(X509Certificate[] certificates,String authType) throws
CertificateException {
+ /*if ((certificates != null) && LOG.isDebugEnabled()) {
+ LOG.debug("Server certificate chain:");
+ for (int i = 0; i < certificates.length; i++) {
+ LOG.debug("X509Certificate[" + i + "]=" +
certificates[i]);
+ }
+ }*/
+ if ((certificates != null) && (certificates.length == 1)) {
+ certificates[0].checkValidity();
+ } else {
+ standardTrustManager.checkServerTrusted(certificates,authType);
+ }
+ }
+
+ /**
+ * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
+ */
+ public X509Certificate[] getAcceptedIssuers() {
+ return this.standardTrustManager.getAcceptedIssuers();
+ }
+}
\ No newline at end of file
Modified:
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/JOSSOTestCase.java
===================================================================
---
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/JOSSOTestCase.java 2009-04-16
09:05:50 UTC (rev 13224)
+++
modules/identity/trunk/sso/src/test/java/org/jboss/portal/test/identity/sso/JOSSOTestCase.java 2009-04-17
03:25:33 UTC (rev 13225)
@@ -1,726 +1,712 @@
-///******************************************************************************
-// * 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. *
-// ******************************************************************************/
-//package org.jboss.portal.test.identity.sso;
-//
-//import java.util.Map;
-//import java.util.Set;
-//import java.util.Iterator;
-//import java.util.HashMap;
-//
-//import org.jboss.portal.test.framework.mc.TestRuntimeContext;
-//
-//import org.apache.commons.httpclient.HttpClient;
-//import org.apache.commons.httpclient.Cookie;
-//import org.apache.commons.httpclient.NameValuePair;
-//import org.apache.commons.httpclient.methods.GetMethod;
-//import org.apache.commons.httpclient.methods.PostMethod;
-//import org.apache.commons.httpclient.protocol.Protocol;
-//
-//import junit.framework.TestCase;
-//
-///**
-// * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
-// *
-// */
-//public class JOSSOTestCase extends TestCase
-//{
-// /**
-// *
-// */
-// 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;
-//
-// /**
-// *
-// */
-// protected TestRuntimeContext runtimeContext = null;
-//
-// /**
-// *
-// */
-// protected void setUp() throws Exception
-// {
-// super.setUp();
-//
-// this.runtimeContext = new
TestRuntimeContext("org/jboss/portal/test/identity/sso-beans.xml");
-//
-// this.runtimeContext.addBean("JOSSOConfig", this);
-// this.runtimeContext.addBean("CASConfig", new CASTestCase());
-//
-// this.runtimeContext.start();
-//
-// //SSL setup
-// Protocol.registerProtocol("https",new Protocol("https", new
EasySSLProtocolSocketFactory(), 443));
-// }
-//
-// /**
-// *
-// */
-// protected void tearDown() throws Exception
-// {
-// super.tearDown();
-//
-// //Service stoppage
-// this.runtimeContext.stop();
-//
-// //Data cleanup
-// this.runtimeContext = null;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getUserLoggedInIndicator()
-// {
-// return userLoggedInIndicator;
-// }
-//
-// /**
-// *
-// * @param userLoggedInIndicator
-// */
-// public void setUserLoggedInIndicator(String userLoggedInIndicator)
-// {
-// this.userLoggedInIndicator = userLoggedInIndicator;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getPassword()
-// {
-// return password;
-// }
-//
-// /**
-// *
-// * @param password
-// */
-// public void setPassword(String password)
-// {
-// this.password = password;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getUsername()
-// {
-// return username;
-// }
-//
-// /**
-// *
-// * @param username
-// */
-// public void setUsername(String username)
-// {
-// this.username = username;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getFirstPortal()
-// {
-// return firstPortal;
-// }
-//
-// /**
-// *
-// * @param firstPortal
-// */
-// public void setFirstPortal(String firstPortal)
-// {
-// this.firstPortal = firstPortal;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getSecondPortal()
-// {
-// return secondPortal;
-// }
-//
-// /**
-// *
-// * @param secondPortal
-// */
-// public void setSecondPortal(String secondPortal)
-// {
-// this.secondPortal = secondPortal;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getJossoServer()
-// {
-// return jossoServer;
-// }
-//
-// /**
-// *
-// * @param jossoServer
-// */
-// public void setJossoServer(String jossoServer)
-// {
-// this.jossoServer = jossoServer;
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public String getSameHostSecondPortal()
-// {
-// return sameHostSecondPortal;
-// }
-//
-// /**
-// *
-// * @param sameHostSecondPortal
-// */
-// public void setSameHostSecondPortal(String sameHostSecondPortal)
-// {
-// this.sameHostSecondPortal = sameHostSecondPortal;
-// }
-//
-// /**
-// * This tests the scenario when the two portals are deployed on separate
hosts/servers
-// *
-// * @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 = 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.secondPortal;
-// 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);
-// }
-//
-// /**
-// * 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
-// */
-// private WebConversation startConversation(String portalUrl) throws Exception
-// {
-// WebConversation conversation = null;
-//
-// HttpClient httpClient = new HttpClient();
-// GetMethod getMethod = new GetMethod(portalUrl);
-// try
-// {
-// conversation = new WebConversation();
-//
-// int statusCode = httpClient.executeMethod(getMethod);
-// String response = getMethod.getResponseBodyAsString();
-//
-// Cookie[] cookies = httpClient.getState().getCookies();
-// for(int i=0;i<cookies.length;i++)
-// {
-// if(cookies[i].getName().equals("JSESSIONID"))
-// {
-// conversation.setSessionId(cookies[i].getValue());
-// }
-// }
-//
-// conversation.setClient(httpClient);
-// conversation.setStatusCode(statusCode);
-// conversation.setResponse(response);
-// }
-// finally
-// {
-// if(getMethod != null)
-// {
-// getMethod.releaseConnection();
-// }
-// }
-//
-// return conversation;
-// }
-//
-// /**
-// *
-// * @param portalUrl
-// * @return
-// * @throws Exception
-// */
-// private WebConversation startConversation(String portalUrl, Cookie ssoCookie) throws
Exception
-// {
-// WebConversation conversation = null;
-//
-// HttpClient httpClient = new HttpClient();
-// GetMethod getMethod = new GetMethod(portalUrl);
-//
-// //Set ssoCookie to be sent in
-//
getMethod.setRequestHeader("Cookie",ssoCookie.getName()+"="+ssoCookie.getValue());
-//
-// try
-// {
-// conversation = new WebConversation();
-//
-// int statusCode = httpClient.executeMethod(getMethod);
-// String response = getMethod.getResponseBodyAsString();
-//
-// Cookie[] cookies = httpClient.getState().getCookies();
-// for(int i=0;i<cookies.length;i++)
-// {
-// if(cookies[i].getName().equals("JSESSIONID"))
-// {
-// conversation.setSessionId(cookies[i].getValue());
-// }
-// }
-//
-// conversation.setClient(httpClient);
-// conversation.setStatusCode(statusCode);
-// conversation.setResponse(response);
-// }
-// finally
-// {
-// if(getMethod != null)
-// {
-// getMethod.releaseConnection();
-// }
-// }
-//
-// return conversation;
-// }
-//
-// /**
-// *
-// * @param portalUrl
-// * @param conversation
-// * @throws Exception
-// */
-// private void sendGet(String portalUrl,WebConversation conversation) throws
Exception
-// {
-// HttpClient httpClient = conversation.getClient();
-//
-// GetMethod getMethod = new GetMethod(portalUrl);
-// getMethod.setFollowRedirects(false);
-// try
-// {
-// int statusCode = httpClient.executeMethod(getMethod);
-//
-// String response = getMethod.getResponseBodyAsString();
-//
-// Cookie[] cookies = httpClient.getState().getCookies();
-// for(int i=0;i<cookies.length;i++)
-// {
-// if(cookies[i].getName().equals("JSESSIONID"))
-// {
-// conversation.setSessionId(cookies[i].getValue());
-// }
-// if(cookies[i].getName().equals("JOSSO_SESSIONID"))
-// {
-// conversation.setSSOCookie(cookies[i]);
-// }
-// }
-//
-// conversation.setStatusCode(statusCode);
-// conversation.setResponse(response);
-//
-// if(statusCode == 302)
-// {
-// //Store the redirect location
-// String location =
getMethod.getResponseHeader("Location").getValue();
-// conversation.setRedirectLocation(location);
-// }
-// }
-// finally
-// {
-// if(getMethod != null)
-// {
-// getMethod.releaseConnection();
-// }
-// }
-// }
-//
-//
-// /**
-// *
-// * @param url
-// * @param parameters
-// * @param conversation
-// * @throws Exception
-// */
-// private void sendPost(String url,Map parameters,WebConversation conversation) throws
Exception
-// {
-// HttpClient httpClient = conversation.getClient();
-//
-// PostMethod postMethod = new PostMethod(url);
-//
-// //Add post parameters
-// Set keySet = parameters.keySet();
-// NameValuePair[] postdata = new NameValuePair[keySet.size()];
-// int index = 0;
-// for(Iterator itr=keySet.iterator();itr.hasNext();)
-// {
-// String name = (String)itr.next();
-// String value = (String)parameters.get(name);
-// postdata[index++] = new NameValuePair(name,value);
-// }
-// postMethod.setRequestBody(postdata);
-// try
-// {
-// int statusCode = httpClient.executeMethod(postMethod);
-//
-// String response = postMethod.getResponseBodyAsString();
-//
-// Cookie[] cookies = httpClient.getState().getCookies();
-// for(int i=0;i<cookies.length;i++)
-// {
-// if(cookies[i].getName().equals("JSESSIONID"))
-// {
-// conversation.setSessionId(cookies[i].getValue());
-// }
-// if(cookies[i].getName().equals("JOSSO_SESSIONID"))
-// {
-// conversation.setSSOCookie(cookies[i]);
-// }
-// }
-//
-// conversation.setStatusCode(statusCode);
-// conversation.setResponse(response);
-//
-// if(statusCode == 302)
-// {
-// //Store the redirect location
-// String location =
postMethod.getResponseHeader("Location").getValue();
-// conversation.setRedirectLocation(location);
-// }
-// }
-// finally
-// {
-// if(postMethod != null)
-// {
-// postMethod.releaseConnection();
-// }
-// }
-// }
-//
-// /**
-// *
-// * @param response
-// * @return
-// */
-// private boolean isUserLoggedIn(String response)
-// {
-// boolean isUserLoggedIn = false;
-//
-// isUserLoggedIn = (response.indexOf(this.userLoggedInIndicator) != -1);
-//
-// return isUserLoggedIn;
-// }
-//
-// /**
-// *
-// * @param response
-// * @return
-// */
-// private String extractLoggedInUser(String response)
-// {
-// String loggedInUser = null;
-//
-// int startIndex = response.indexOf(this.userLoggedInIndicator) +
this.userLoggedInIndicator.length();
-// int endIndex = response.indexOf("<",startIndex);
-//
-// loggedInUser = response.substring(startIndex,endIndex).trim();
-//
-// return loggedInUser;
-// }
-//
-// /**
-// *
-// * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
-// *
-// */
-// private static class WebConversation
-// {
-// /**
-// *
-// */
-// private HttpClient client = null;
-// private String sessionId = null;
-// private int statusCode = 0;
-// private String response = null;
-// private String redirectLocation = null;
-// private Cookie ssoCookie = null;
-//
-// /**
-// *
-// *
-// */
-// public WebConversation()
-// {
-//
-// }
-//
-// /**
-// *
-// * @return
-// */
-// public HttpClient getClient()
-// {
-// return this.client;
-// }
-//
-// /**
-// *
-// * @param client
-// */
-// public void setClient(HttpClient client)
-// {
-// this.client = client;
-// }
-//
-// public String getResponse()
-// {
-// return response;
-// }
-//
-// public void setResponse(String response)
-// {
-// this.response = response;
-// }
-//
-// public int getStatusCode()
-// {
-// return statusCode;
-// }
-//
-// public void setStatusCode(int statusCode)
-// {
-// this.statusCode = statusCode;
-// }
-//
-// public String getSessionId()
-// {
-// return sessionId;
-// }
-//
-// public void setSessionId(String sessionId)
-// {
-// this.sessionId = sessionId;
-// }
-//
-// public String getRedirectLocation()
-// {
-// return redirectLocation;
-// }
-//
-// public void setRedirectLocation(String redirectLocation)
-// {
-// this.redirectLocation = redirectLocation;
-// }
-//
-// public Cookie getSSOCookie()
-// {
-// return ssoCookie;
-// }
-//
-// public void setSSOCookie(Cookie ssoCookie)
-// {
-// this.ssoCookie = ssoCookie;
-// }
-// }
-//}
+/******************************************************************************
+ * 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. *
+ ******************************************************************************/
+package org.jboss.portal.test.identity.sso;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashMap;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.protocol.Protocol;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class JOSSOTestCase extends TestCase
+{
+ /**
+ *
+ */
+ 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;
+
+
+ /**
+ *
+ */
+ protected void setUp() throws Exception
+ {
+ //SSL setup
+ Protocol.registerProtocol("https",new Protocol("https", new
EasySSLProtocolSocketFactory(), 443));
+
+ this.firstPortal = "http://josso-01/portal";
+ this.secondPortal = "http://josso-02/portal";
+ this.sameHostSecondPortal = "http://josso-01/portal2";
+ this.jossoServer = "josso-01";
+ this.userLoggedInIndicator = "Logged in as:";
+ this.username = "user";
+ this.password = "user";
+ }
+
+ /**
+ *
+ */
+ protected void tearDown() throws Exception
+ {
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getUserLoggedInIndicator()
+ {
+ return userLoggedInIndicator;
+ }
+
+ /**
+ *
+ * @param userLoggedInIndicator
+ */
+ public void setUserLoggedInIndicator(String userLoggedInIndicator)
+ {
+ this.userLoggedInIndicator = userLoggedInIndicator;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ *
+ * @param password
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getUsername()
+ {
+ return username;
+ }
+
+ /**
+ *
+ * @param username
+ */
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getFirstPortal()
+ {
+ return firstPortal;
+ }
+
+ /**
+ *
+ * @param firstPortal
+ */
+ public void setFirstPortal(String firstPortal)
+ {
+ this.firstPortal = firstPortal;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getSecondPortal()
+ {
+ return secondPortal;
+ }
+
+ /**
+ *
+ * @param secondPortal
+ */
+ public void setSecondPortal(String secondPortal)
+ {
+ this.secondPortal = secondPortal;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getJossoServer()
+ {
+ return jossoServer;
+ }
+
+ /**
+ *
+ * @param jossoServer
+ */
+ public void setJossoServer(String jossoServer)
+ {
+ this.jossoServer = jossoServer;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getSameHostSecondPortal()
+ {
+ return sameHostSecondPortal;
+ }
+
+ /**
+ *
+ * @param sameHostSecondPortal
+ */
+ public void setSameHostSecondPortal(String sameHostSecondPortal)
+ {
+ this.sameHostSecondPortal = sameHostSecondPortal;
+ }
+
+ /**
+ * This tests the scenario when the two portals are deployed on separate
hosts/servers
+ *
+ * @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 = 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.secondPortal;
+ 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);
+ }
+
+ /**
+ * 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
+ */
+ private WebConversation startConversation(String portalUrl) throws Exception
+ {
+ WebConversation conversation = null;
+
+ HttpClient httpClient = new HttpClient();
+ GetMethod getMethod = new GetMethod(portalUrl);
+ try
+ {
+ conversation = new WebConversation();
+
+ int statusCode = httpClient.executeMethod(getMethod);
+ String response = getMethod.getResponseBodyAsString();
+
+ Cookie[] cookies = httpClient.getState().getCookies();
+ for(int i=0;i<cookies.length;i++)
+ {
+ if(cookies[i].getName().equals("JSESSIONID"))
+ {
+ conversation.setSessionId(cookies[i].getValue());
+ }
+ }
+
+ conversation.setClient(httpClient);
+ conversation.setStatusCode(statusCode);
+ conversation.setResponse(response);
+ }
+ finally
+ {
+ if(getMethod != null)
+ {
+ getMethod.releaseConnection();
+ }
+ }
+
+ return conversation;
+ }
+
+ /**
+ *
+ * @param portalUrl
+ * @return
+ * @throws Exception
+ */
+ private WebConversation startConversation(String portalUrl, Cookie ssoCookie) throws
Exception
+ {
+ WebConversation conversation = null;
+
+ HttpClient httpClient = new HttpClient();
+ GetMethod getMethod = new GetMethod(portalUrl);
+
+ //Set ssoCookie to be sent in
+
getMethod.setRequestHeader("Cookie",ssoCookie.getName()+"="+ssoCookie.getValue());
+
+ try
+ {
+ conversation = new WebConversation();
+
+ int statusCode = httpClient.executeMethod(getMethod);
+ String response = getMethod.getResponseBodyAsString();
+
+ Cookie[] cookies = httpClient.getState().getCookies();
+ for(int i=0;i<cookies.length;i++)
+ {
+ if(cookies[i].getName().equals("JSESSIONID"))
+ {
+ conversation.setSessionId(cookies[i].getValue());
+ }
+ }
+
+ conversation.setClient(httpClient);
+ conversation.setStatusCode(statusCode);
+ conversation.setResponse(response);
+ }
+ finally
+ {
+ if(getMethod != null)
+ {
+ getMethod.releaseConnection();
+ }
+ }
+
+ return conversation;
+ }
+
+ /**
+ *
+ * @param portalUrl
+ * @param conversation
+ * @throws Exception
+ */
+ private void sendGet(String portalUrl,WebConversation conversation) throws Exception
+ {
+ HttpClient httpClient = conversation.getClient();
+
+ GetMethod getMethod = new GetMethod(portalUrl);
+ getMethod.setFollowRedirects(false);
+ try
+ {
+ int statusCode = httpClient.executeMethod(getMethod);
+
+ String response = getMethod.getResponseBodyAsString();
+
+ Cookie[] cookies = httpClient.getState().getCookies();
+ for(int i=0;i<cookies.length;i++)
+ {
+ if(cookies[i].getName().equals("JSESSIONID"))
+ {
+ conversation.setSessionId(cookies[i].getValue());
+ }
+ if(cookies[i].getName().equals("JOSSO_SESSIONID"))
+ {
+ conversation.setSSOCookie(cookies[i]);
+ }
+ }
+
+ conversation.setStatusCode(statusCode);
+ conversation.setResponse(response);
+
+ if(statusCode == 302)
+ {
+ //Store the redirect location
+ String location =
getMethod.getResponseHeader("Location").getValue();
+ conversation.setRedirectLocation(location);
+ }
+ }
+ finally
+ {
+ if(getMethod != null)
+ {
+ getMethod.releaseConnection();
+ }
+ }
+ }
+
+
+ /**
+ *
+ * @param url
+ * @param parameters
+ * @param conversation
+ * @throws Exception
+ */
+ private void sendPost(String url,Map parameters,WebConversation conversation) throws
Exception
+ {
+ HttpClient httpClient = conversation.getClient();
+
+ PostMethod postMethod = new PostMethod(url);
+
+ //Add post parameters
+ Set keySet = parameters.keySet();
+ NameValuePair[] postdata = new NameValuePair[keySet.size()];
+ int index = 0;
+ for(Iterator itr=keySet.iterator();itr.hasNext();)
+ {
+ String name = (String)itr.next();
+ String value = (String)parameters.get(name);
+ postdata[index++] = new NameValuePair(name,value);
+ }
+ postMethod.setRequestBody(postdata);
+ try
+ {
+ int statusCode = httpClient.executeMethod(postMethod);
+
+ String response = postMethod.getResponseBodyAsString();
+
+ Cookie[] cookies = httpClient.getState().getCookies();
+ for(int i=0;i<cookies.length;i++)
+ {
+ if(cookies[i].getName().equals("JSESSIONID"))
+ {
+ conversation.setSessionId(cookies[i].getValue());
+ }
+ if(cookies[i].getName().equals("JOSSO_SESSIONID"))
+ {
+ conversation.setSSOCookie(cookies[i]);
+ }
+ }
+
+ conversation.setStatusCode(statusCode);
+ conversation.setResponse(response);
+
+ if(statusCode == 302)
+ {
+ //Store the redirect location
+ String location =
postMethod.getResponseHeader("Location").getValue();
+ conversation.setRedirectLocation(location);
+ }
+ }
+ finally
+ {
+ if(postMethod != null)
+ {
+ postMethod.releaseConnection();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param response
+ * @return
+ */
+ private boolean isUserLoggedIn(String response)
+ {
+ boolean isUserLoggedIn = false;
+
+ isUserLoggedIn = (response.indexOf(this.userLoggedInIndicator) != -1);
+
+ return isUserLoggedIn;
+ }
+
+ /**
+ *
+ * @param response
+ * @return
+ */
+ private String extractLoggedInUser(String response)
+ {
+ String loggedInUser = null;
+
+ int startIndex = response.indexOf(this.userLoggedInIndicator) +
this.userLoggedInIndicator.length();
+ int endIndex = response.indexOf("<",startIndex);
+
+ loggedInUser = response.substring(startIndex,endIndex).trim();
+
+ return loggedInUser;
+ }
+
+ /**
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+ private static class WebConversation
+ {
+ /**
+ *
+ */
+ private HttpClient client = null;
+ private String sessionId = null;
+ private int statusCode = 0;
+ private String response = null;
+ private String redirectLocation = null;
+ private Cookie ssoCookie = null;
+
+ /**
+ *
+ *
+ */
+ public WebConversation()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public HttpClient getClient()
+ {
+ return this.client;
+ }
+
+ /**
+ *
+ * @param client
+ */
+ public void setClient(HttpClient client)
+ {
+ this.client = client;
+ }
+
+ public String getResponse()
+ {
+ return response;
+ }
+
+ public void setResponse(String response)
+ {
+ this.response = response;
+ }
+
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
+ public void setStatusCode(int statusCode)
+ {
+ this.statusCode = statusCode;
+ }
+
+ public String getSessionId()
+ {
+ return sessionId;
+ }
+
+ public void setSessionId(String sessionId)
+ {
+ this.sessionId = sessionId;
+ }
+
+ public String getRedirectLocation()
+ {
+ return redirectLocation;
+ }
+
+ public void setRedirectLocation(String redirectLocation)
+ {
+ this.redirectLocation = redirectLocation;
+ }
+
+ public Cookie getSSOCookie()
+ {
+ return ssoCookie;
+ }
+
+ public void setSSOCookie(Cookie ssoCookie)
+ {
+ this.ssoCookie = ssoCookie;
+ }
+ }
+}
Added: modules/identity/trunk/sso/src/test/resources/log4j.properties
===================================================================
--- modules/identity/trunk/sso/src/test/resources/log4j.properties
(rev 0)
+++ modules/identity/trunk/sso/src/test/resources/log4j.properties 2009-04-17 03:25:33 UTC
(rev 13225)
@@ -0,0 +1,8 @@
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n