Author: anil.saldhana(a)jboss.com
Date: 2011-09-13 18:52:14 -0400 (Tue, 13 Sep 2011)
New Revision: 1221
Added:
integration-tests/trunk/picketlink-int-webapps/authenticator/
integration-tests/trunk/picketlink-int-webapps/authenticator/pom.xml
integration-tests/trunk/picketlink-int-webapps/authenticator/src/
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/context.xml
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/jboss-web.xml
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/web.xml
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/index.jsp
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/loginmodules/
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/loginmodules/TestRequestUserLoginModule.java
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/PicketLinkAuthenticatorTestCase.java
Modified:
integration-tests/trunk/ant-scripts/ant-build.xml
integration-tests/trunk/parent/pom.xml
integration-tests/trunk/picketlink-int-webapps/pom.xml
integration-tests/trunk/picketlink-trust-tests/src/test/resources/domains/sts-jboss-beans.xml
Log:
PLFED-229: test for PicketLinkAuthenticator
Modified: integration-tests/trunk/ant-scripts/ant-build.xml
===================================================================
--- integration-tests/trunk/ant-scripts/ant-build.xml 2011-09-13 20:10:47 UTC (rev 1220)
+++ integration-tests/trunk/ant-scripts/ant-build.xml 2011-09-13 22:52:14 UTC (rev 1221)
@@ -94,6 +94,7 @@
</antcall>
<copy file="${basedir}/../common-dist/files/jboss-log4j.xml"
todir="${JBAS5_DEPLOY}/../conf"/>
<copy
file="${basedir}/../picketlink-int-webapps/claims/target/claims.war"
todir="${JBAS5_DEPLOY}/picketlink/"/>
+ <copy
file="${basedir}/../picketlink-int-webapps/authenticator/target/authenticator.war"
todir="${JBAS5_DEPLOY}/picketlink/"/>
</target>
@@ -103,6 +104,7 @@
<param name="jbossas"
value="${basedir}/target/jboss-6.0.0.Final"/>
</antcall>
<copy
file="${basedir}/../picketlink-int-webapps/claims/target/claims.war"
todir="${JBAS6_DEPLOY}/picketlink/"/>
+ <copy
file="${basedir}/../picketlink-int-webapps/authenticator/target/authenticator.war"
todir="${JBAS6_DEPLOY}/picketlink/"/>
</target>
<target name="copy-sts-props-jbas5">
Modified: integration-tests/trunk/parent/pom.xml
===================================================================
--- integration-tests/trunk/parent/pom.xml 2011-09-13 20:10:47 UTC (rev 1220)
+++ integration-tests/trunk/parent/pom.xml 2011-09-13 22:52:14 UTC (rev 1221)
@@ -29,7 +29,7 @@
<properties>
<!-- default setting in order to have project imported to IDE without problems
-->
- <pl-version>2.0.0.final</pl-version>
+ <pl-version>2.0.1-SNAPSHOT</pl-version>
<!-- as picketlink-trust-jbossws has different version and is separate project we
have to create new property to reflect this fact -->
<pl-trust-version>2.0.0.final</pl-trust-version>
</properties>
Added: integration-tests/trunk/picketlink-int-webapps/authenticator/pom.xml
===================================================================
--- integration-tests/trunk/picketlink-int-webapps/authenticator/pom.xml
(rev 0)
+++ integration-tests/trunk/picketlink-int-webapps/authenticator/pom.xml 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,38 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.picketlink</groupId>
+ <artifactId>picketlink-integration-tests-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>authenticator</artifactId>
+ <packaging>war</packaging>
+ <name>Authenticator web app</name>
+ <
url>http://labs.jboss.org/portal/picketlink/</url>
+ <description>PicketLink Samples contains the samples for Federated Identity
Needs.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <
url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <warName>authenticator</warName>
+ <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Property changes on: integration-tests/trunk/picketlink-int-webapps/authenticator/pom.xml
___________________________________________________________________
Added: svn:executable
+ *
Added:
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/context.xml
===================================================================
---
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/context.xml
(rev 0)
+++
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/context.xml 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,3 @@
+<Context>
+ <Valve
className="org.picketlink.identity.federation.bindings.tomcat.PicketLinkAuthenticator"
/>
+</Context>
Added:
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/jboss-web.xml
===================================================================
---
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/jboss-web.xml
(rev 0)
+++
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/jboss-web.xml 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,3 @@
+<jboss-web>
+<security-domain>authenticator</security-domain>
+</jboss-web>
Added:
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/web.xml
===================================================================
---
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/WEB-INF/web.xml 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Restricted Access - Get Only</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>STSClient</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>STSClient</role-name>
+ </security-role>
+</web-app>
Added:
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/index.jsp
===================================================================
---
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/index.jsp
(rev 0)
+++
integration-tests/trunk/picketlink-int-webapps/authenticator/src/main/webapp/index.jsp 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,9 @@
+<%@ page import="java.util.*,java.security.*" %>
+
+<%
+Principal principal = request.getUserPrincipal();
+String name=null;
+if(principal != null)
+ name = principal.getName();
+out.write(name);
+%>
Modified: integration-tests/trunk/picketlink-int-webapps/pom.xml
===================================================================
--- integration-tests/trunk/picketlink-int-webapps/pom.xml 2011-09-13 20:10:47 UTC (rev
1220)
+++ integration-tests/trunk/picketlink-int-webapps/pom.xml 2011-09-13 22:52:14 UTC (rev
1221)
@@ -23,6 +23,7 @@
<url>http://www.jboss.org</url>
</organization>
<modules>
+ <module>authenticator</module>
<module>claims</module>
</modules>
</project>
Added:
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/loginmodules/TestRequestUserLoginModule.java
===================================================================
---
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/loginmodules/TestRequestUserLoginModule.java
(rev 0)
+++
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/loginmodules/TestRequestUserLoginModule.java 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.picketlink.test.trust.loginmodules;
+
+import javax.security.auth.login.LoginException;
+import javax.security.jacc.PolicyContext;
+import javax.security.jacc.PolicyContextException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.security.auth.spi.UsersRolesLoginModule;
+
+/**
+ * A test login module that just looks for a request param
+ * "user"
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Sep 13, 2011
+ */
+public class TestRequestUserLoginModule extends UsersRolesLoginModule
+{
+ @Override
+ protected String[] getUsernameAndPassword() throws LoginException
+ {
+ //get the username from the request
+ /** The JACC PolicyContext key for the current Subject */
+ String WEB_REQUEST_KEY = "javax.servlet.http.HttpServletRequest";
+ try
+ {
+ String password = null;
+ HttpServletRequest request = (HttpServletRequest)
PolicyContext.getContext(WEB_REQUEST_KEY);
+ String username = request.getParameter("user");
+ if(username != null && "UserA".equals(username))
+ {
+ password = "PassA";
+ }
+ else if(username != null && "UserB".equals(username))
+ {
+ password = "PassB";
+ }
+ return new String[] { username, password};
+ }
+ catch (PolicyContextException e)
+ {
+ LoginException le = new LoginException();
+ le.initCause(e);
+ throw le;
+ }
+ }
+}
\ No newline at end of file
Added:
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/PicketLinkAuthenticatorTestCase.java
===================================================================
---
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/PicketLinkAuthenticatorTestCase.java
(rev 0)
+++
integration-tests/trunk/picketlink-trust-tests/src/test/java/org/picketlink/test/trust/tests/PicketLinkAuthenticatorTestCase.java 2011-09-13
22:52:14 UTC (rev 1221)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.picketlink.test.trust.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.bindings.tomcat.PicketLinkAuthenticator;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * Test the {@link PicketLinkAuthenticator}
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Sep 13, 2011
+ */
+public class PicketLinkAuthenticatorTestCase
+{
+ @Test
+ public void testDistinctUsers() throws Exception
+ {
+ WebRequest serviceRequest1 = new GetMethodWebRequest(
"http://localhost:8080/authenticator/?user=UserA" );
+ WebConversation webConversation = new WebConversation();
+ WebResponse webResponse = webConversation.getResponse( serviceRequest1 );
+ String responseText = webResponse.getText();
+ assertTrue(responseText.contains("UserA"));
+
+ WebRequest serviceRequest2 = new GetMethodWebRequest(
"http://localhost:8080/authenticator/?user=UserB" );
+ WebConversation webConversation2 = new WebConversation();
+ WebResponse webResponse2 = webConversation2.getResponse( serviceRequest2 );
+ String responseText2 = webResponse2.getText();
+ assertTrue(responseText2.contains("UserB"));
+ }
+}
\ No newline at end of file
Modified:
integration-tests/trunk/picketlink-trust-tests/src/test/resources/domains/sts-jboss-beans.xml
===================================================================
---
integration-tests/trunk/picketlink-trust-tests/src/test/resources/domains/sts-jboss-beans.xml 2011-09-13
20:10:47 UTC (rev 1220)
+++
integration-tests/trunk/picketlink-trust-tests/src/test/resources/domains/sts-jboss-beans.xml 2011-09-13
22:52:14 UTC (rev 1221)
@@ -43,7 +43,6 @@
</authentication>
</application-policy>
- <!-- ejb3 test application-policy definition -->
<application-policy xmlns="urn:jboss:security-beans:1.0"
name="jmx-console">
<authentication>
<login-module
code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag="required">
@@ -53,7 +52,17 @@
</authentication>
</application-policy>
+ <application-policy xmlns="urn:jboss:security-beans:1.0"
name="authenticator">
+ <authentication>
+ <login-module
code="org.picketlink.test.trust.loginmodules.TestRequestUserLoginModule"
flag="required">
+ <module-option
name="usersProperties">sts-users.properties</module-option>
+ <module-option
name="rolesProperties">sts-roles.properties</module-option>
+ <module-option
name="password-stacking">useFirstPass</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
<bean name="PicketLinkTestSystemProperties"
class="org.jboss.varia.property.SystemPropertiesService">
<property name="properties">