[jboss-svn-commits] JBL Code SVN: r29346 - in labs/jbossesb/workspace/dbevenius/saml_support/product: lib/ext and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Sep 15 03:27:57 EDT 2009


Author: beve
Date: 2009-09-15 03:27:56 -0400 (Tue, 15 Sep 2009)
New Revision: 29346

Added:
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-sts.war
   labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/assertion.xml
Removed:
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-bindings-1.0.0.beta1-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-bindings-jboss-1.0.0.beta1-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-api-1.0.0.beta1-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-core-1.0.0.beta1-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-model-1.0.0.beta1-SNAPSHOT.jar
   labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-xmlsec-model-1.0.0.beta1-SNAPSHOT.jar
Modified:
   labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath
   labs/jbossesb/workspace/dbevenius/saml_support/product/ivy.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/build.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/actions/security/JBossSTSActionUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/build.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/deployment.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-esb.xml
   labs/jbossesb/workspace/dbevenius/saml_support/product/services/base-project-build.xml
Log:
Added jboss-identity versions to ivy.xml
JBossSTSAction is now using a ThreadLocal to store the SamlPrincipal.
Added jboss-sts.war to the security_saml quickstart.


Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/.classpath	2009-09-15 07:27:56 UTC (rev 29346)
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry kind="lib" path="build/jbossesb-server-4.6/client/jaxb-impl.jar"/>
+	<classpathentry kind="lib" path="lib/ext/jbossws-core.jar"/>
+	<classpathentry kind="lib" path="lib/ext/jboss-jaxws.jar"/>
+	<classpathentry kind="lib" path="lib/ext/jboss-saaj.jar"/>
 	<classpathentry excluding="**/.svn/" kind="src" path="rosetta/src"/>
 	<classpathentry excluding="**/.svn/" kind="src" path="rosetta/tests/src"/>
 	<classpathentry excluding="**/.svn/" kind="src" path="rosetta/tests/resources"/>
@@ -96,19 +100,13 @@
 	<classpathentry kind="lib" path="build/lib/xstream-1.2.2.jar"/>
 	<classpathentry kind="lib" path="ftp/lib/ftplet-api-1.0-incubator-SNAPSHOT.jar"/>
 	<classpathentry kind="lib" path="ftp/lib/ftpserver-core-1.0-incubator-SNAPSHOT.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-identity-fed-api-1.0.0.beta1-SNAPSHOT.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-identity-fed-core-1.0.0.beta1-SNAPSHOT.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-identity-fed-model-1.0.0.beta1-SNAPSHOT.jar"/>
 	<classpathentry kind="lib" path="lib/ext/commons-net-2.0.0-652071.jar"/>
 	<classpathentry kind="lib" path="lib/ext/commons-ssl-0.3.4.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jboss-ejb3x.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-jaxws.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jboss-messaging-client.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-saaj.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jbossts-common.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jbossweb.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jbossweb-service.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jbossws-core.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jbossws-spi.jar"/>
 	<classpathentry kind="lib" path="lib/ext/jms/activemq/backport-util-concurrent-2.1.jar"/>
 	<classpathentry kind="lib" path="lib/ext/standalone/c3p0-0.9.1-pre9.jar"/>
@@ -133,9 +131,13 @@
 	<classpathentry kind="var" path="ESB_ROOT/testlib/xmlunit-1.2.jar"/>
 	<classpathentry kind="lib" path="build/lib/freemarker-2.3.11.jar"/>
 	<classpathentry kind="lib" path="lib/ext/mockito-all-1.8.0.jar"/>
-	<classpathentry kind="lib" path="build/jbossesb-server-4.6/client/jaxb-impl.jar"/>
-	<classpathentry kind="lib" path="lib/ext/jboss-identity-xmlsec-model-1.0.0.beta1-SNAPSHOT.jar"/>
 	<classpathentry kind="lib" path="lib/ext/milyn-smooks-core-1.3-20090908.125018-2.jar"/>
 	<classpathentry kind="lib" path="lib/ext/milyn-commons-1.3-20090908.105925-1.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-bindings-1.0.0.beta2.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-bindings-jboss-1.0.0.beta2.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-api-1.0.0.beta2.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-core-1.0.0.beta2.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-fed-model-1.0.0.beta2.jar"/>
+	<classpathentry kind="lib" path="build/lib/jboss-identity-xmlsec-model-1.0.0.beta2.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/ivy.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/ivy.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/ivy.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -160,10 +160,13 @@
 
         <dependency org="org.jboss.security" name="jboss-security-spi" rev="2.1.0.20090318"/>
 
-		<!-- JBoss Identity Federation 
-        <dependency org="org.jboss.identity" name="jboss-identity-fed-api" rev="1.0.0.beta1-SNAPSHOT"/>
-        <dependency org="org.jboss.identity" name="jboss-identity-fed-core" rev="1.0.0.beta1-SHAPSHOT"/>
-		-->
+		<!-- JBoss Identity Federation -->
+        <dependency org="org.jboss.identity" name="jboss-identity-fed-api" rev="1.0.0.beta2"/>
+        <dependency org="org.jboss.identity" name="jboss-identity-fed-core" rev="1.0.0.beta2"/>
+        <dependency org="org.jboss.identity" name="jboss-identity-fed-model" rev="1.0.0.beta2"/>
+        <dependency org="org.jboss.identity" name="jboss-identity-xmlsec-model" rev="1.0.0.beta2"/>
+        <dependency org="org.jboss.identity" name="jboss-identity-bindings" rev="1.0.0.beta2"/>
+        <dependency org="org.jboss.identity" name="jboss-identity-bindings-jboss" rev="1.0.0.beta2"/>
 
     </dependencies>
 </ivy-module>

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-bindings-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-bindings-jboss-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-api-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-core-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-fed-model-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/workspace/dbevenius/saml_support/product/lib/ext/jboss-identity-xmlsec-model-1.0.0.beta1-SNAPSHOT.jar
===================================================================
(Binary files differ)

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/build.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/build.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -22,6 +22,7 @@
 	
 	<path id="org.jboss.esb.rosetta.base.classpath">
         <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="*.jar"/>
+        <fileset dir="${org.jboss.esb.ext.lib.dir}/endorsed" includes="jboss-saaj.jar"/>
         <fileset dir="${org.jboss.esb.lib.dir}" includes="*.jar"/>
         <fileset dir="../../testlib" includes="emma*.jar"/>
         <fileset dir="${org.jboss.esb.ext.lib.dir}/standalone" includes="*.jar"/>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -52,6 +52,7 @@
 import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
 import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
 import org.jboss.soa.esb.services.security.auth.login.JBossSTSConstants;
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
 import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
 import org.w3c.dom.Element;
 
@@ -78,7 +79,6 @@
     private final MessagePayloadProxy payloadProxy;
 
     private boolean addAssertionToEsbAuthRequest;
-    private boolean addAssertionToMessage;
 
     public JBossSTSAction(final ConfigTree config) throws ConfigurationException
     {
@@ -89,13 +89,7 @@
         password = config.getRequiredAttribute(JBossSTSConstants.PASSWORD_OPTION);
         tokenType = config.getRequiredAttribute(JBossSTSConstants.TOKEN_TYPE_OPTION);
         payloadProxy = new MessagePayloadProxy(config);
-        
         addAssertionToEsbAuthRequest = config.getBooleanAttribute(ADD_TO_ESB_AUTH_REQUEST, false);
-        addAssertionToMessage = config.getBooleanAttribute(ADD_TO_ESB_MESSAGE, false);
-        if (!addAssertionToEsbAuthRequest && !addAssertionToMessage)
-        {
-            throw new ConfigurationException("Atleast on of " + ADD_TO_ESB_AUTH_REQUEST + " or " + ADD_TO_ESB_MESSAGE + " properties must be set to true");
-        }
     }
 
     public Message process(final Message message) throws ActionProcessingException
@@ -106,13 +100,10 @@
             final WSTrustClient wsTrustClient = createWSTrustClient(message);
             final Element assertion = wsTrustClient.issueToken(tokenType);
             
+            SamlContext.setContext(new SamlPrincipal(assertion));
+            
             log.info("SecurityToken valid : " + wsTrustClient.validateToken(assertion));
             
-            if (addAssertionToMessage)
-            {
-	            payloadProxy.setPayload(message, assertion);
-            }
-            
             if (addAssertionToEsbAuthRequest)
             {
 	            addToEsbAuthRequest(assertion, message);
@@ -123,10 +114,6 @@
         {
             throw new ActionProcessingException("Caught WSTrustException while calling issueToken: ", e);
         }
-        catch (final MessageDeliverException e)
-        {
-            throw new ActionProcessingException(e.getMessage(), e);
-        }
         return message;
     }
     

Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlContext.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors 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.soa.esb.services.security.auth.login;
+
+import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+
+/**
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * 
+ */
+public final class SamlContext
+{
+    private static final ThreadLocal<SamlPrincipal> CONTEXT = new ThreadLocal<SamlPrincipal>();
+    
+    private SamlContext() {}
+
+    public static void clearContext()
+    {
+        CONTEXT.set(null);
+    }
+
+    public static SamlPrincipal getContext()
+    {
+        return CONTEXT.get();
+    }
+
+    public static void setContext(final SamlPrincipal principal)
+    {
+        CONTEXT.set(principal);
+    }
+
+}

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/actions/security/JBossSTSActionUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/actions/security/JBossSTSActionUnitTest.java	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/actions/security/JBossSTSActionUnitTest.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -35,6 +35,7 @@
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.services.security.auth.login.JBossSTSConstants;
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
 import org.junit.Test;
 import org.w3c.dom.Element;
 
@@ -58,10 +59,10 @@
         stsAction.initialise();
         
         Message message = MessageFactory.getInstance().getMessage();
-        Message processed = stsAction.process(message);
-        Object object = processed.getBody().get();
+        stsAction.process(message);
+        Object object = SamlContext.getContext().getAssertionElement();
         assertTrue(object instanceof Element);
-        
+        SamlContext.clearContext();
     }
     
     @Test (expected = ConfigurationException.class)
@@ -145,12 +146,6 @@
             return this;
         }
         
-        public ConfigBuilder addToEsbMessage(final boolean add)
-        {
-            config.setAttribute(JBossSTSAction.ADD_TO_ESB_MESSAGE, Boolean.toString(add));
-            return this;
-        }
-        
         public ConfigBuilder addToEsbAuthRequestMessage(final boolean add)
         {
             config.setAttribute(JBossSTSAction.ADD_TO_ESB_AUTH_REQUEST, Boolean.toString(add));
@@ -159,11 +154,6 @@
         
         public ConfigTree build()
         {
-            if (config.getAttribute(JBossSTSAction.ADD_TO_ESB_MESSAGE) == null)
-            {
-                addToEsbMessage(true);
-            }
-            
             return config;
         }
     }

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -22,8 +22,6 @@
 
 import java.io.IOException;
 
-import javax.xml.transform.stream.StreamSource;
-
 import junit.framework.JUnit4TestAdapter;
 
 import org.custommonkey.xmlunit.XMLAssert;

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/build.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/build.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -7,6 +7,14 @@
 
 	<!-- additional deploys -->
     <property name="additional.deploys" value="jboss-wsse-client.xml"/>
+
+	<target name="quickstart-specific-predeploys">
+		<copy file="${basedir}/jboss-sts.war" todir="${org.jboss.esb.server.deploy.dir}"/>
+    </target>
+
+	 <target name="quickstart-specific-undeploys">
+		<delete file="${org.jboss.esb.server.deploy.dir}/jboss-sts.war"/>
+    </target>
 			
 	<!-- Import the base Ant build script... -->
 	<import file="../conf/base-build.xml"/>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/deployment.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/deployment.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/deployment.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -2,6 +2,6 @@
     <depends>jboss.esb:deployment=soap.esb</depends>
     <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_saml_gw</depends>
     <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_saml_esb</depends>
-    <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_saml_esb_reply
-    </depends>
+    <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_saml_esb_reply</depends>
+    <depends>jboss.web.deployment:war=/jboss-sts</depends>
 </jbossesb-deployment>

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-esb.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-esb.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -36,7 +36,6 @@
                     <property name="username" value="admin"/>
                     <property name="password" value="admin"/>
                     <property name="tokenType" value="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0"/>
-                    <property name="addToEsbMessage" value="false"/>
                     <property name="addToEsbAuthRequest" value="true"/>
 				</action>
 

Added: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-sts.war
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-sts.war
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/services/base-project-build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/base-project-build.xml	2009-09-15 01:46:40 UTC (rev 29345)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/base-project-build.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -38,6 +38,7 @@
         <fileset dir="${esb.main.lib}" includes="jboss-system-4.2.2.GA.jar" />
 		<fileset dir="lib/ext" includes="*.jar" />
 		<fileset dir="lib/ext/build-time" includes="*.jar" />
+        <fileset dir="${esb.product.lib.ext}/endorsed" includes="jboss-saaj.jar" />
 		<fileset dir="${esb.product.lib.dir}" includes="*.jar" /> <!-- Product Jars. -->
         <fileset dir="${esb.product.lib.ext}" includes="*.jar" />
         <fileset dir="${esb.main.lib}" includes="*.jar" />

Added: labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandler.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors 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.soa.esb.actions.soap;
+
+import java.io.IOException;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
+import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+
+/**
+ * SOAPSamlHandler is a SOAP Protocol Handler that will add a security header to
+ * all outgoing messages if a SamlPrincipal has been set using the
+ * {@link SamlContext}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class SOAPSamlHandler implements SOAPHandler<SOAPMessageContext>
+{
+    public final static String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+    QName securityQName = new QName(SOAPSamlHandler.WSSE_NS, "Security");
+
+    private static final SOAPFactory SOAP_FACTORY = createSOAPFactory();
+
+    public boolean handleMessage(final SOAPMessageContext soapContext)
+    {
+        final Boolean outBound = (Boolean) soapContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+        if (outBound.booleanValue() == false)
+            return false;
+
+        try
+        {
+            final SOAPEnvelope envelope = soapContext.getMessage().getSOAPPart().getEnvelope();
+            SOAPHeader header = envelope.getHeader();
+            if (header == null)
+            {
+                header = envelope.addHeader();
+            }
+            
+            final SOAPElement securityElement = header.addChildElement("Security", "wsse", WSSE_NS);
+            final SamlPrincipal samlPrincipal = SamlContext.getContext();
+            if (samlPrincipal != null)
+            {
+                // Add the assertion elemetn ignoring the result.
+                securityElement.addChildElement(SOAP_FACTORY.createElement(samlPrincipal.getAssertionElement()));
+            }
+        }
+        catch (final SOAPException e)
+        {
+            throw new WebServiceException(e.getMessage(), e);
+        }
+        catch (IOException e)
+        {
+            throw new WebServiceException(e.getMessage(), e);
+        }
+
+        return true;
+    }
+
+    public Set<QName> getHeaders()
+    {
+        return null;
+    }
+
+    public void close(final MessageContext messageContext)
+    {
+    }
+
+    public boolean handleFault(final SOAPMessageContext soapContext)
+    {
+        return false;
+    }
+
+    private static SOAPFactory createSOAPFactory()
+    {
+        try
+        {
+            return SOAPFactory.newInstance();
+        }
+        catch (final SOAPException e)
+        {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPSamlHandlerUnitTest.java	2009-09-15 07:27:56 UTC (rev 29346)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors 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.soa.esb.actions.soap;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
+import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * Unit test for {@link SOAPSamlHandler}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * 
+ */
+public class SOAPSamlHandlerUnitTest
+{
+    private QName assertionQName = new QName("urn:oasis:names:tc:SAML:2.0:assertion", "Assertion");
+
+    @BeforeClass
+    public static void setup()
+    {
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
+    @Test
+    public void handleMessage() throws SOAPException, SAXException, IOException
+    {
+        final SOAPSamlHandler handler = new SOAPSamlHandler();
+        final SOAPMessageContext messageContext = mock(SOAPMessageContext.class);
+        final SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
+
+        when(messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).thenReturn(true);
+        when(messageContext.getMessage()).thenReturn(soapMessage);
+
+        SamlPrincipal samlPrincipal = new SamlPrincipal(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
+        SamlContext.setContext(samlPrincipal);
+
+        boolean result = handler.handleMessage(messageContext);
+        assertTrue(result);
+
+        final SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
+        final Iterator<SOAPElement> securityHeaders = envelope.getHeader().getChildElements(new QName("Security", "wsse", SOAPSamlHandler.WSSE_NS));
+        
+        while (securityHeaders.hasNext())
+        {
+            final SOAPElement securityElement = securityHeaders.next();
+            final Iterator<SOAPElement> assertions = securityElement.getChildElements(assertionQName);
+            while (assertions.hasNext())
+            {
+                final SOAPElement assertionElement = assertions.next();
+                final Document expected = XMLUnit.buildControlDocument(samlPrincipal.getAssertion());
+                final Document actual = XMLUnit.buildTestDocument(SamlPrincipal.assertionToString(assertionElement));
+                XMLAssert.assertXMLEqual(expected, actual);
+            }
+        }
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(SOAPSamlHandlerUnitTest.class);
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/assertion.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/assertion.xml	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/assertion.xml	2009-09-15 07:27:56 UTC (rev 29346)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="ID_74414f7f-1339-4f80-b29a-c947d9177445" IssueInstant="2009-09-10T13:49:30.422Z" Version="2.0">
+    <Issuer>JBossSTS</Issuer>
+    <Subject>
+        <NameID NameQualifier="urn:jboss:identity-federation">beve</NameID>
+        <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"/>
+    </Subject>
+    <Conditions NotBefore="2009-09-10T13:49:30.422Z" NotOnOrAfter="2009-09-10T15:49:30.422Z"/>
+    <dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+        <dsig:SignedInfo><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"/>
+            <dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"/>
+            <dsig:Reference URI="#ID_74414f7f-1339-4f80-b29a-c947d9177445" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+                <dsig:Transforms xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+                    <dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"/>
+                </dsig:Transforms>
+                <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"/>
+                    <dsig:DigestValue xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">so9bv09wxSnauPiq6iC2zs6ubrQ=</dsig:DigestValue>
+            </dsig:Reference>
+        </dsig:SignedInfo>
+        <dsig:SignatureValue>Lf4DYODLtVxSVmd23HJzHTy61ZYDnpaJRTVbRLR2i2zU7v9mskYCVbXY8gm5PYY2V+iYvi+dJ3QlWP9dQu+DHK9rVJSGxSmzfPjrnMC84HH9j2BZBEdKVCpNCAFJQRL+E1jlRB194sjCiuxoMnlR927uMiNcHJRoBSi03kP5tOw=</dsig:SignatureValue>
+            <dsig:KeyInfo>
+                <dsig:KeyValue xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+                    <dsig:RSAKeyValue xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
+                        <dsig:Modulus xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">suGIyhVTbFvDwZdx8Av62zmP+aGOlsBN8WUE3eEEcDtOIZgO78SImMQGwB2C0eIVMhiLRzVPqoW1dCPAveTm653zHOmubaps1fY0lLJDSZbTbhjeYhoQmmaBro/tDpVw5lKJns2qVnMuRK19ju2dxpKwlYGGtrP5VQv00dfNPbs=
+                        </dsig:Modulus>
+                        <dsig:Exponent xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">AQAB</dsig:Exponent>
+                    </dsig:RSAKeyValue>
+            </dsig:KeyValue>
+        </dsig:KeyInfo>
+    </dsig:Signature>
+</Assertion>



More information about the jboss-svn-commits mailing list