[jboss-svn-commits] JBL Code SVN: r29390 - in labs/jbossesb/workspace/dbevenius/saml_support/product: rosetta/src/org/jboss/soa/esb/services/security/auth/login and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 17 03:13:42 EDT 2009
Author: beve
Date: 2009-09-17 03:13:38 -0400 (Thu, 17 Sep 2009)
New Revision: 29390
Added:
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SOAPSecurityHeaderVisitor.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/assertion-expected.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-expected.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-no-security-header.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector-template.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/soap-request.xml
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/services/security/auth/login/SamlPrincipal.java
labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml
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/jboss-esb.xml
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/PrintSubjectAction.java
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/test/SendJMSMessage.java
labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
Log:
Added smooks visitor that can update a SOAP Header with a Saml Assertion.
Updated the security_saml quickstart to use this.
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-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/actions/security/JBossSTSAction.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -100,10 +100,10 @@
final WSTrustClient wsTrustClient = createWSTrustClient(message);
final Element assertion = wsTrustClient.issueToken(tokenType);
+ log.info("SecurityToken valid : " + wsTrustClient.validateToken(assertion));
+
SamlContext.setContext(new SamlPrincipal(assertion));
- log.info("SecurityToken valid : " + wsTrustClient.validateToken(assertion));
-
if (addAssertionToEsbAuthRequest)
{
addToEsbAuthRequest(assertion, message);
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java 2009-09-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipal.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -25,6 +25,7 @@
import java.io.StringWriter;
import java.security.Principal;
+import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
@@ -89,6 +90,7 @@
try
{
Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
final Source source = new DOMSource(assertion);
final StringWriter writer = new StringWriter();
final Result result = new StreamResult(writer);
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SOAPSecurityHeaderVisitor.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SOAPSecurityHeaderVisitor.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SOAPSecurityHeaderVisitor.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,271 @@
+/*
+ * 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.ws;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.xml.namespace.QName;
+
+import org.milyn.SmooksException;
+import org.milyn.cdr.annotation.ConfigParam;
+import org.milyn.container.ExecutionContext;
+import org.milyn.delivery.annotation.Initialize;
+import org.milyn.delivery.sax.SAXElement;
+import org.milyn.delivery.sax.SAXElementVisitor;
+import org.milyn.delivery.sax.SAXText;
+import org.milyn.delivery.sax.SAXVisitor;
+import org.milyn.delivery.sax.WriterUtil;
+import org.milyn.javabean.decoders.BooleanDecoder;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * SOAPSecurityHeaderVisitor is a Smooks Visitor that will add a
+ * SOAP Security Header to a SOAP Envelope.
+ *
+ * The Security Header can be any xml header returned by the abstract
+ * method {@link #getHeaderToInsert()}.
+ * </p>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public abstract class SOAPSecurityHeaderVisitor implements SAXElementVisitor
+{
+ private static final String HEADER_ADDED = "addedToken";
+
+ private String headerElementName;
+ private String headerNS;
+ private String securityElementName;
+ private String securityNS;
+ private String securityPrefix;
+ private boolean addSecurityXmlNsAttribute;
+
+ private QName securityQName;
+ private QName headerQName;
+
+ private SAXVisitor writerOwner = this;
+ private boolean rewriteEntities = true;
+
+ /**
+ * Should be implemented by subclasses and return the security
+ * header to be inserted into the SOAP Security Header.
+ *
+ * @return String The header to be inserted into the SOAP Security Header.
+ */
+ protected abstract String getHeaderToInsert();
+
+ @Initialize
+ public void initialize()
+ {
+ securityQName = new QName(securityNS, securityElementName, securityPrefix);
+ headerQName = new QName(headerNS, headerElementName);
+ }
+
+ /**
+ * Will simply write the start of the element.
+ *
+ * @param element The current {@link SAXElement}.
+ * @param executionContext Smooks {@link ExecutionContext}.
+ */
+ public void visitBefore(final SAXElement element, final ExecutionContext executionContext) throws SmooksException, IOException
+ {
+ WriterUtil.writeStartElement(element, element.getWriter(writerOwner), rewriteEntities);
+ }
+
+ /**
+ * Will write the SAXTex.
+ *
+ * @param element The current {@link SAXElement}.
+ * @param text The {@link SAXText} to write.
+ * @param executionContext Smooks {@link ExecutionContext}.
+ */
+ public void onChildText(final SAXElement element, final SAXText text, final ExecutionContext executionContext) throws SmooksException, IOException
+ {
+ if (element.isWriterOwner(writerOwner))
+ {
+ text.toWriter(element.getWriter(writerOwner), rewriteEntities);
+ }
+ }
+
+ /**
+ * Will create a new Security header element if one does not exist and add the header, the String
+ * returned from {@link #getHeaderToInsert()}, into the newly created Security header.
+ *
+ * If a Security header does exist the header, the String returned from {@link #getHeaderToInsert()},
+ * will be inserted into the existing header.
+ *
+ * @param element The current {@link SAXElement}.
+ * @param text The {@link SAXText} to write.
+ * @param executionContext Smooks {@link ExecutionContext}.
+ */
+ public void visitAfter(final SAXElement element, final ExecutionContext executionContext) throws SmooksException, IOException
+ {
+ if (element.isWriterOwner(writerOwner))
+ {
+ final Boolean headerAdded = (Boolean) executionContext.getAttribute(HEADER_ADDED);
+ if (headerAdded == null)
+ {
+ final QName elementQName = element.getName();
+ if (elementQName.equals(securityQName))
+ {
+ // A Security Header exists so we simply add the header to it.
+ addHeader(element);
+ }
+ else if (elementQName.equals(headerQName))
+ {
+ // No Security Header exists in the SOAP Header so we must create one.
+ final AttributesImpl attributesImpl = new AttributesImpl();
+ if (addSecurityXmlNsAttribute)
+ {
+ // Add a xmlns to the Security Header that is to be created.
+ attributesImpl.addAttribute("", securityQName.getLocalPart(), "xmlns:" + securityQName.getPrefix(), "CDDATA",securityQName.getNamespaceURI());
+ }
+ // Create the Security Header
+ final SAXElement securityElement = new SAXElement(securityQName, attributesImpl, element);
+
+ final Writer writer = element.getWriter(writerOwner);
+ // Write the start of the Security Header element
+ WriterUtil.writeStartElement(securityElement, writer, rewriteEntities);
+ // Add the specific Security Header to the newly created Security Header
+ addHeader(element);
+ // Write the end of the Security Header element
+ WriterUtil.writeEndElement(securityElement, writer);
+ }
+ executionContext.setAttribute(HEADER_ADDED, Boolean.TRUE);
+ }
+
+ WriterUtil.writeEndElement(element, element.getWriter(writerOwner));
+ }
+ }
+
+ /**
+ * Will write the String returned from {@link #getHeaderToInsert()} to the
+ * passed in {@link SAXElement}..
+ *
+ * @param element The current {@link SAXElement}.
+ */
+ private void addHeader(final SAXElement element) throws IOException
+ {
+ Writer writer = element.getWriter(writerOwner);
+ final String header = getHeaderToInsert();
+ if (header != null)
+ {
+ writer.append(header);
+ }
+ }
+
+ /**
+ * No Operation implemented.
+ */
+ public void onChildElement(final SAXElement element, final SAXElement childElement, final ExecutionContext executionContext) throws SmooksException, IOException
+ {
+ // NoOP
+ }
+
+ /**
+ * This is the name of the Security element header. This will be used for matching
+ * a pre-existing Security header element in a SOAP Envelope and also used when
+ * creating a new Security header (that is if one does not exist).
+ * For example:
+ * Envelope/Header/Security
+ *
+ * @param securityElementName The name of the Security header element
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "Security")
+ public SOAPSecurityHeaderVisitor setSecurityElementName(String securityElementName)
+ {
+ this.securityElementName = securityElementName;
+ return this;
+ }
+
+ /**
+ * The name of the SOAP Header element.
+ *
+ * @param name The name of the SOAP Header element.
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "Header")
+ public SOAPSecurityHeaderVisitor setHeaderElementName(String name)
+ {
+ this.headerElementName = name;
+ return this;
+ }
+
+ /**
+ * The namespace(ns) of the SOAP Envelope. Used to support different version.
+ *
+ * @param ns The SOAP Envelope namespace.
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "http://schemas.xmlsoap.org/soap/envelope/")
+ public SOAPSecurityHeaderVisitor setHeaderNS(String ns)
+ {
+ this.headerNS = ns;
+ return this;
+ }
+
+ /**
+ * The namespace(ns) of the SOAP Secuirty Headerl. Used to support different version.
+ *
+ * @param ns The SOAP SecurityHeader namespace.
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
+ public SOAPSecurityHeaderVisitor setSecurityNS(String securityNS)
+ {
+ this.securityNS = securityNS;
+ return this;
+ }
+
+ /**
+ * This is the Security Header prefix which will be used when creating a new Security header.
+ * For example, setting this to sec would generate a Security Header looking like:
+ * <pre>
+ * <sec:Security xmlns:sec=...
+ * </pre>
+ *
+ * @param prefix The prefix for the Security Header element.
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "wsse")
+ public SOAPSecurityHeaderVisitor setSecurityPrefix(String prefix)
+ {
+ this.securityPrefix = prefix;
+ return this;
+ }
+
+ /**
+ * Determines if an xmlns attribute should be added to a created Security Header
+ * element. This might not be needed or desired if you know that this declaration
+ * exist in the higher up in the SOAP Envelope.
+ *
+ * @param add True will add the xmlns attribute to a created Security Header element. False will not.
+ * @return {@link SOAPSecurityHeaderVisitor} To support method chaining.
+ */
+ @ConfigParam (defaultVal = "false", decoder = BooleanDecoder.class)
+ public SOAPSecurityHeaderVisitor setAddSecurityXmlNSAttribute(final boolean add)
+ {
+ this.addSecurityXmlNsAttribute = add;
+ return this;
+ }
+}
\ No newline at end of file
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitor.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,46 @@
+/*
+ * 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.ws;
+
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
+import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
+
+/**
+ * Extends {@link SOAPSecurityHeaderVisitor} to add a SAML Assertion
+ * to a SOAP Security Header.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class SamlVisitor extends SOAPSecurityHeaderVisitor
+{
+ @Override
+ protected String getHeaderToInsert()
+ {
+ SamlPrincipal samlPrincipal = SamlContext.getContext();
+ if (samlPrincipal != null)
+ {
+ return samlPrincipal.getAssertion();
+ }
+ return null;
+ }
+
+}
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
+
+ <params>
+ <param name="stream.filter.type">SAX</param>
+ <param name="default.serialization.on">true</param>
+ </params>
+
+ <resource-config selector="@selector@" selector-namespace="@selectorNamespace@">
+ <resource>org.jboss.soa.esb.services.security.auth.ws.SamlVisitor</resource>
+ <param name="securityNS">@securityNamespace@</param>
+ <param name="headerNS">@headerNamespace@</param>
+ <param name="addSecurityXmlNSAttribute">true</param>
+ </resource-config>
+
+</smooks-resource-list>
\ No newline at end of file
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
+
+ <import file="/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml">
+ <param name="selector">/Envelope/Header/Security</param>
+ <param name="selectorNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="securityNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="headerNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ </import>
+
+ <import file="/org/jboss/soa/esb/services/security/auth/ws/smooks-saml-injector-template.xml">
+ <param name="selector">/Envelope/Header</param>
+ <param name="selectorNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ <param name="securityNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="headerNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ </import>
+
+</smooks-resource-list>
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml 2009-09-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -3,6 +3,7 @@
<params>
<param name="stream.filter.type">SAX</param>
+ <param name="default.serialization.on">false</param>
</params>
<import file="/org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security-template.xml">
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-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/SamlPrincipalUnitTest.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -54,7 +54,7 @@
public void stringConstructor() throws IOException, SecurityServiceException, SAXException
{
final SamlPrincipal samlPrincipal = new SamlPrincipal(StreamUtils.readStreamString(getClass().getResourceAsStream("assertion.xml"), "UTF-8"));
- final Document expected = XMLUnit.buildControlDocument(new InputSource(getClass().getResourceAsStream("assertion.xml")));
+ final Document expected = XMLUnit.buildControlDocument(new InputSource(getClass().getResourceAsStream("assertion-expected.xml")));
final Document actual = XMLUnit.buildTestDocument(samlPrincipal.getAssertion());
XMLAssert.assertXMLEqual(expected, actual);
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/assertion-expected.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/assertion-expected.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/login/assertion-expected.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,30 @@
+<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>
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/SamlVisitorUnitTest.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,176 @@
+/*
+ * 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.ws;
+
+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.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.milyn.FilterSettings;
+import org.milyn.Smooks;
+import org.milyn.StreamFilterType;
+import org.milyn.payload.StringResult;
+import org.milyn.payload.StringSource;
+
+/**
+ * Unit test for {@link SamlVisitor}
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class SamlVisitorUnitTest
+{
+ private static final String SECURITY_NS = "http://security";
+ private static final String HEADER_NS = "http://header";
+ private static final String SECURITY_START = "<t:Security xmlns:t=\"" + SECURITY_NS + "\">";
+ private static final String HEADER_START = "<h:Header xmlns:h=\"" + HEADER_NS + "\">";
+
+ @Test
+ public void addAssertionToEmptySecurityHeader() throws Exception
+ {
+ final Smooks smooks = createSmooks("Envelope/Header/Security");
+
+ final StringSource source = new StringSource("<Envelope><Header>" + SECURITY_START + "</t:Security></Header></Envelope>");
+ final StringResult result = new StringResult();
+
+ final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ SamlContext.setContext(samlPrincipal);
+
+ smooks.filterSource(source, result);
+
+ final String expected = "<Envelope><Header>" + SECURITY_START + "<dummyAssertion/></t:Security></Header></Envelope>";
+ final String actual = result.toString();
+
+ XMLAssert.assertXMLEqual("Expected the assertion to have been added to the Security header", expected, actual);
+ }
+
+ /**
+ * This test shows that it's is possible have the the {@link SamlVisitor#getHeaderToInsert()
+ * method return null which will simply produce an unchanged security header.
+ */
+ @Test
+ public void addNoAssertionToEmptySecurityHeader() throws Exception
+ {
+ final Smooks smooks = createSmooks("Envelope/Header/Security");
+
+ final String expected = "<Envelope><Header>" + SECURITY_START + "</t:Security></Header></Envelope>";
+ final StringSource source = new StringSource(expected);
+ final StringResult result = new StringResult();
+
+ smooks.filterSource(source, result);
+
+ final String actual = result.toString();
+
+ XMLAssert.assertXMLEqual("Expected the SOAP Message to be unchanged", expected, actual);
+ }
+
+ @Test
+ public void addAssertionToSOAPHeader() throws Exception
+ {
+ final Smooks smooks = createSmooks("Envelope/Header");
+
+ final String soap = "<Envelope>" + HEADER_START + "</h:Header></Envelope>";
+ final StringSource source = new StringSource(soap);
+ final StringResult result = new StringResult();
+
+ final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ SamlContext.setContext(samlPrincipal);
+
+ smooks.filterSource(source, result);
+
+ final String expected = "<Envelope>" + HEADER_START + SECURITY_START + "<dummyAssertion/></t:Security></h:Header></Envelope>";
+ final String actual = result.toString();
+ XMLAssert.assertXMLEqual("Expected a Security Header to have been created an the assertion inserted into it", expected, actual);
+ }
+
+ @Test
+ public void configFromFileWithSecurityHeader() throws Exception
+ {
+ final Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-saml-injector.xml"));
+
+ final String soap = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject.xml"), "UTF-8");
+ final StringSource source = new StringSource(soap);
+ final StringResult result = new StringResult();
+
+ final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ SamlContext.setContext(samlPrincipal);
+
+ smooks.filterSource(source, result);
+
+ final String expected = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-expected.xml"), "UTF-8");
+ final String actual = result.toString();
+ XMLAssert.assertXMLEqual("Expected the assertion to have been added to the Security header", expected, actual);
+ }
+
+ @Test
+ public void configFromFileWithoutSecurityHeader() throws Exception
+ {
+ final Smooks smooks = new Smooks(getClass().getResourceAsStream("smooks-saml-injector.xml"));
+
+ final String soap = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-no-security-header.xml"), "UTF-8");
+ final StringSource source = new StringSource(soap);
+ final StringResult result = new StringResult();
+
+ final SamlPrincipal samlPrincipal = new SamlPrincipal("<dummyAssertion/>");
+ SamlContext.setContext(samlPrincipal);
+
+ smooks.filterSource(source, result);
+
+ final String expected = StreamUtils.readStreamString(getClass().getResourceAsStream("saml-inject-expected.xml"), "UTF-8");
+ final String actual = result.toString();
+ XMLAssert.assertXMLEqual("Expected a Security Header to have been created an the assertion inserted into it", expected, actual);
+ }
+
+ private Smooks createSmooks(final String selector)
+ {
+ final Smooks smooks = new Smooks();
+ smooks.setFilterSettings(new FilterSettings().setFilterType(StreamFilterType.SAX));
+
+ final SOAPSecurityHeaderVisitor samlVisitor = new SamlVisitor();
+ samlVisitor.setSecurityElementName("Security").setSecurityNS(SECURITY_NS).setSecurityPrefix("t").setAddSecurityXmlNSAttribute(true);
+ samlVisitor.setHeaderNS(HEADER_NS).setHeaderElementName("Header");
+
+ smooks.addVisitor(samlVisitor, selector);
+ return smooks;
+ }
+
+ @BeforeClass
+ public static void before()
+ {
+ XMLUnit.setIgnoreWhitespace(true);
+ }
+
+ @After
+ public void teardown()
+ {
+ SamlContext.clearContext();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(SamlVisitorUnitTest.class);
+ }
+}
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-expected.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-expected.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-expected.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,14 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <soap:Header>
+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <dummyAssertion/>
+ </wsse:Security>
+ </soap:Header>
+
+ <soap:Body>
+ </soap:Body>
+
+</soap:Envelope>
+
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-no-security-header.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-no-security-header.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject-no-security-header.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,11 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <soap:Header>
+ </soap:Header>
+
+ <soap:Body>
+ </soap:Body>
+
+</soap:Envelope>
+
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/saml-inject.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,13 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <soap:Header>
+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ </wsse:Security>
+ </soap:Header>
+
+ <soap:Body>
+ </soap:Body>
+
+</soap:Envelope>
+
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-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/build.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -6,7 +6,7 @@
</description>
<!-- additional deploys -->
- <property name="additional.deploys" value="jboss-wsse-client.xml"/>
+ <property name="additional.deploys" value="jboss-wsse-client.xml, smooks/*.xml"/>
<target name="quickstart-specific-predeploys">
<copy file="${basedir}/jboss-sts.war" todir="${org.jboss.esb.server.deploy.dir}"/>
@@ -52,7 +52,7 @@
-->
<java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.securitysaml.test.SendJMSMessage" failonerror="true">
<arg value="queue/quickstart_security_saml_gw"/>
- <arg value="Dummy message payload"/>
+ <arg value="soap-request.xml"/>
<classpath refid="exec-classpath"/>
</java>
</target>
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-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/jboss-esb.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -12,22 +12,17 @@
<jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_security_saml_esb"/>
</jms-bus>
</jms-provider>
-
- <!--jbr-provider name="JBR-Http" protocol="http" host="localhost">
- <jbr-bus busid="Http-1" port="8765" />
- </jbr-provider-->
-
</providers>
<services>
<service category="SamlSecurityQuickstart" name="unsecuredService" description="" invmScope="GLOBAL">
+
<listeners>
<jms-listener name="JMSGatewayListener" busidref="quickstartGatewayChannel" is-gateway="true"/>
</listeners>
<actions mep="OneWay">
- <action name="print-before" class="org.jboss.soa.esb.samples.quickstart.securitysaml.PrintSubjectAction"/>
<action name="issueToken" class="org.jboss.soa.esb.actions.security.JBossSTSAction">
<property name="serviceName" value="JBossSTS"/>
@@ -39,6 +34,10 @@
<property name="addToEsbAuthRequest" value="true"/>
</action>
+ <action name="addSamlSecurityHeader" class="org.jboss.soa.esb.smooks.SmooksAction">
+ <property name="smooksConfig" value="/smooks/smooks-saml-injector.xml" />
+ </action>
+
<action name="routeAction" class="org.jboss.soa.esb.actions.StaticRouter">
<property name="destinations">
<route-to service-category="SamlSecurityQuickstart" service-name="securedService"/>
@@ -54,16 +53,13 @@
<security moduleName="jbossesb-saml" callbackHandler="org.jboss.soa.esb.services.security.auth.login.JBossSTSCallbackHandler"/>
<listeners>
- <!--jbr-listener name="Http-Gateway" busidref="Http-1" is-gateway="true"/-->
<jms-listener name="JMS-ESBListener" busidref="quickstartEsbChannel"/>
</listeners>
<actions mep="OneWay">
- <action name="print-before" class="org.jboss.soa.esb.samples.quickstart.securitysaml.PrintSubjectAction"/>
-
- <!--action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.SOAPProcessor">
+ <action name="JBossWSAdapter" class="org.jboss.soa.esb.actions.soap.SOAPProcessor">
<property name="jbossws-endpoint" value="GoodbyeWorldWS"/>
- </action-->
+ </action>
</actions>
</service>
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector-template.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector-template.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector-template.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
+
+ <params>
+ <param name="stream.filter.type">SAX</param>
+ <param name="default.serialization.on">true</param>
+ </params>
+
+ <resource-config selector="@selector@" selector-namespace="@selectorNamespace@">
+ <resource>org.jboss.soa.esb.services.security.auth.ws.SamlVisitor</resource>
+ <param name="securityNS">@securityNamespace@</param>
+ <param name="headerNS">@headerNamespace@</param>
+ <param name="addXmlNS">@addXmlNs@</param>
+ </resource-config>
+
+</smooks-resource-list>
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/smooks/smooks-saml-injector.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd">
+
+ <import file="smooks-saml-injector-template.xml">
+ <param name="selector">/Envelope/Header/Security</param>
+ <param name="selectorNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="securityNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="headerNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ </import>
+
+ <import file="smooks-saml-injector-template.xml">
+ <param name="selector">/Envelope/Header</param>
+ <param name="selectorNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ <param name="securityNamespace">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</param>
+ <param name="headerNamespace">http://schemas.xmlsoap.org/soap/envelope/</param>
+ <param name="addXmlNs">false</param>
+ </import>
+
+</smooks-resource-list>
Added: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/soap-request.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/soap-request.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/soap-request.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -0,0 +1,9 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:good="http://security_saml/goodbyeworld" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
+ <soapenv:Header>
+ </soapenv:Header>
+ <soapenv:Body>
+ <good:sayGoodbye>
+ <message>Goodbye!!</message>
+ </good:sayGoodbye>
+ </soapenv:Body>
+</soapenv:Envelope>
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/PrintSubjectAction.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/PrintSubjectAction.java 2009-09-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/PrintSubjectAction.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -37,6 +37,8 @@
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.security.auth.login.SamlContext;
+import org.jboss.soa.esb.services.security.auth.login.SamlPrincipal;
public class PrintSubjectAction extends AbstractActionLifecycle
{
@@ -52,6 +54,9 @@
{
System.out.println("SecurityContext " + message.getProperties().getProperty("org.jboss.soa.esb.services.security.context"));
System.out.println("Subject : " + Subject.getSubject(AccessController.getContext()));
+ SamlPrincipal samlPrincipal = SamlContext.getContext();
+ if (samlPrincipal != null)
+ System.out.println("SamlAssertion : " + samlPrincipal.getAssertion());
return message;
}
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/test/SendJMSMessage.java 2009-09-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/src/org/jboss/soa/esb/samples/quickstart/securitysaml/test/SendJMSMessage.java 2009-09-17 07:13:38 UTC (rev 29390)
@@ -34,6 +34,7 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.net.InetAddress;
+import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.soa.esb.actions.StoreMessageToFile;
@@ -83,7 +84,7 @@
{
SendJMSMessage sm = new SendJMSMessage();
String destination = args[0];
- String payload = args[1];
+ String payload = StreamUtils.getResourceAsString(args[1], "UTF-8");
try
{
Modified: labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml 2009-09-17 03:06:58 UTC (rev 29389)
+++ labs/jbossesb/workspace/dbevenius/saml_support/product/samples/quickstarts/security_saml/war/resources/WEB-INF/web.xml 2009-09-17 07:13:38 UTC (rev 29390)
@@ -7,7 +7,7 @@
<servlet>
<servlet-name>GoodbyeWorldWS</servlet-name>
- <servlet-class>org.jboss.soa.esb.samples.quickstart.securitycert.webservice.GoodbyeWorldWS</servlet-class>
+ <servlet-class>org.jboss.soa.esb.samples.quickstart.securitysaml.webservice.GoodbyeWorldWS</servlet-class>
</servlet>
<servlet-mapping>
More information about the jboss-svn-commits
mailing list