Picketlink SVN: r480 - trust/trunk/jbossws-native.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 12:09:24 -0400 (Fri, 15 Oct 2010)
New Revision: 480
Modified:
trust/trunk/jbossws-native/pom.xml
Log:
Replacing dependency on jbossws-native with jbossws-common and moving out of snapshot for that
Modified: trust/trunk/jbossws-native/pom.xml
===================================================================
--- trust/trunk/jbossws-native/pom.xml 2010-10-15 16:08:25 UTC (rev 479)
+++ trust/trunk/jbossws-native/pom.xml 2010-10-15 16:09:24 UTC (rev 480)
@@ -44,9 +44,9 @@
<dependencies>
<dependency>
- <groupId>org.jboss.ws.native</groupId>
- <artifactId>jbossws-native-core</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-common</artifactId>
+ <version>1.4.0.CR1</version>
</dependency>
<dependency>
<groupId>org.picketlink</groupId>
14 years, 2 months
Picketlink SVN: r479 - in trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws: handler and 1 other directory.
by picketlink-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-10-15 12:08:25 -0400 (Fri, 15 Oct 2010)
New Revision: 479
Added:
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Util.java
Modified:
trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
Log:
Removing jbossws-native specific references from the SAML2Handler and prevent DOM exception when the assertion element does not come from the same document as the SOAP message
Added: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java (rev 0)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Constants.java 2010-10-15 16:08:25 UTC (rev 479)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.trust.jbossws;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xml.security.utils.EncryptionConstants;
+
+/**
+ * @author Jason T. Greene
+ */
+public class Constants
+{
+ public static final String WSS_SOAP_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-secu...";
+
+ public static final String JBOSS_WSSE_NS = "http://www.jboss.com/jbossws/ws-security";
+
+ public static final String JBOSS_WSSE_PREFIX = "jboss-wsse";
+
+ public static final String WSSE_PREFIX = "wsse";
+
+ public static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext...";
+
+ public static final String WSU_PREFIX = "wsu";
+
+ public static final String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit...";
+
+ public static final String XML_SIGNATURE_NS = org.apache.xml.security.utils.Constants.SignatureSpecNS;
+
+ public static final String XML_ENCRYPTION_NS = EncryptionConstants.EncryptionSpecNS;
+
+ public static final String XML_ENCRYPTION_PREFIX = "ds"; //xmlsec 1.4.2 requires this to be "ds" to correctly create KeyInfo elements
+
+ public static final String ID = "Id";
+
+ public static final String WSU_ID = WSU_PREFIX + ":" + ID;
+
+ public static final String BASE64_ENCODING_TYPE = WSS_SOAP_NS + "#Base64Binary";
+
+ public static final String PASSWORD_TEXT_TYPE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-pr...";
+
+ public static final String PASSWORD_DIGEST_TYPE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-pr...";
+
+ public static final String WSSE_HEADER = WSSE_PREFIX + ":Security";
+
+ public static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
+
+ public static final String XENC_DATAREFERENCE = "DataReference";
+
+ public static final String XENC_REFERENCELIST = "ReferenceList";
+
+ public static final String XENC_ELEMENT_TYPE = EncryptionConstants.TYPE_ELEMENT;
+
+ public static final String XENC_CONTENT_TYPE = EncryptionConstants.TYPE_CONTENT;
+
+ public static final QName WSSE_HEADER_QNAME = new QName(WSSE_NS, "Security");
+}
Added: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Util.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Util.java (rev 0)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/Util.java 2010-10-15 16:08:25 UTC (rev 479)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.trust.jbossws;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Jason T. Greene
+ */
+public class Util
+{
+ public static int count = 0;
+
+ public static String assignWsuId(Element element)
+ {
+ String id = element.getAttributeNS(Constants.WSU_NS, Constants.ID);
+
+ if (id == null || id.length() < 1)
+ {
+ id = generateId();
+ element.setAttributeNS(Constants.WSU_NS, Constants.WSU_ID, id);
+ addNamespace(element, Constants.WSU_PREFIX, Constants.WSU_NS);
+ }
+
+ return id;
+ }
+
+ public static Element getFirstChildElement(Node node)
+ {
+ Node child = node.getFirstChild();
+ while (child != null && child.getNodeType() != Node.ELEMENT_NODE)
+ child = child.getNextSibling();
+
+ return (Element)child;
+ }
+
+ public static Element getNextSiblingElement(Element element)
+ {
+ Node sibling = element.getNextSibling();
+ while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE)
+ sibling = sibling.getNextSibling();
+
+ return (Element)sibling;
+ }
+
+ public static Element getPreviousSiblingElement(Element element)
+ {
+ Node sibling = element.getPreviousSibling();
+ while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE)
+ sibling = sibling.getPreviousSibling();
+
+ return (Element)sibling;
+ }
+
+ public static Element findElement(Element root, String localName, String namespace)
+ {
+ return findElement(root, new QName(namespace, localName));
+ }
+
+ public static Element findElement(Element root, QName name)
+ {
+ // Here lies your standard recusive DFS.....
+ if (matchNode(root, name))
+ return root;
+
+ // Search children
+ for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling())
+ {
+ if (child.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ Node possibleMatch = findElement((Element)child, name);
+ if (possibleMatch != null)
+ return (Element)possibleMatch;
+ }
+
+ return null;
+ }
+
+ public static List<Node> findAllElements(Element root, QName name, boolean local)
+ {
+ List<Node> list = new ArrayList<Node>();
+ if (matchNode(root, name, local))
+ list.add(root);
+
+ for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling())
+ {
+ if (child.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ list.addAll(findAllElements((Element) child, name, local));
+ }
+
+ return list;
+ }
+
+ public static Element findElementByWsuId(Element root, String id)
+ {
+ // Here lies another standard recusive DFS.....
+ if (id.equals(getWsuId(root)))
+ return root;
+
+ // Search children
+ for (Node child = root.getFirstChild(); child != null; child = child.getNextSibling())
+ {
+ if (child.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ Node possibleMatch = findElementByWsuId((Element)child, id);
+ if (possibleMatch != null)
+ return (Element)possibleMatch;
+ }
+
+ return null;
+ }
+
+ public static Element findOrCreateSoapHeader(Element envelope)
+ {
+ String prefix = envelope.getPrefix();
+ String uri = envelope.getNamespaceURI();
+ QName name = new QName(uri, "Header");
+ Element header = findElement(envelope, name);
+ if (header == null)
+ {
+ header = envelope.getOwnerDocument().createElementNS(uri, prefix + ":Header");
+ envelope.insertBefore(header, envelope.getFirstChild());
+ }
+
+ return header;
+ }
+
+ public static String getWsuId(Element element)
+ {
+ if (element.hasAttributeNS(Constants.WSU_NS, Constants.ID))
+ return element.getAttributeNS(Constants.WSU_NS, Constants.ID);
+
+ if (element.hasAttribute(Constants.ID))
+ {
+ String ns = element.getNamespaceURI();
+ if (Constants.XML_SIGNATURE_NS.equals(ns) || Constants.XML_ENCRYPTION_NS.equals(ns))
+ return element.getAttribute(Constants.ID);
+ }
+
+ return null;
+ }
+
+ public static boolean equalStrings(String string1, String string2)
+ {
+ if (string1 == null && string2 == null)
+ return true;
+
+ return string1 != null && string1.equals(string2);
+ }
+
+ public static boolean matchNode(Node node, QName name)
+ {
+ return matchNode(node, name, false);
+ }
+
+ public static boolean matchNode(Node node, QName name, boolean local)
+ {
+ return equalStrings(node.getLocalName(), name.getLocalPart())
+ && (local || equalStrings(node.getNamespaceURI(), name.getNamespaceURI()));
+ }
+
+ public static String generateId()
+ {
+ return generateId("element");
+ }
+
+ public static void addNamespace(Element element, String prefix, String uri)
+ {
+ element.setAttributeNS(Constants.XMLNS_NS, "xmlns:" + prefix, uri);
+ }
+
+ public static String generateId(String prefix)
+ {
+ StringBuilder id = new StringBuilder();
+ long time = System.currentTimeMillis();
+
+ // reasonably gaurantee uniqueness
+ synchronized (Util.class)
+ {
+ count++;
+ }
+
+ id.append(prefix).append("-").append(count).append("-").append(time).append("-").append(id.hashCode());
+
+ return id.toString();
+ }
+}
Modified: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java 2010-10-15 14:20:10 UTC (rev 478)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SAML2Handler.java 2010-10-15 16:08:25 UTC (rev 479)
@@ -21,20 +21,24 @@
*/
package org.picketlink.trust.jbossws.handler;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
import javax.security.auth.Subject;
import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.jboss.logging.Logger;
import org.jboss.security.SecurityContext;
-import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.soap.SOAPMessageImpl;
-import org.jboss.ws.extensions.security.Util;
-import org.jboss.ws.extensions.security.element.SecurityHeader;
-import org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerServer;
+import org.jboss.wsf.common.handler.GenericSOAPHandler;
import org.picketlink.identity.federation.bindings.jboss.subject.PicketLinkPrincipal;
import org.picketlink.identity.federation.core.wstrust.SamlCredential;
+import org.picketlink.trust.jbossws.Constants;
import org.picketlink.trust.jbossws.SAML2Constants;
+import org.picketlink.trust.jbossws.Util;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -42,20 +46,36 @@
* A SAMLv2 WS handler.
*
* @author <a href="mmoyses(a)redhat.com">Marcus Moyses</a>
+ * @author <a href="alessio.soldano(a)jboss.com">Alessio Soldano</a>
* @version $Revision: 1 $
*/
-public class SAML2Handler extends WSSecurityHandlerServer
+public class SAML2Handler extends GenericSOAPHandler
{
protected Logger log = Logger.getLogger(this.getClass());
+ private static Set<QName> headers;
+
+ static
+ {
+ HashSet<QName> set = new HashSet<QName>();
+ set.add(Constants.WSSE_HEADER_QNAME);
+ headers = Collections.unmodifiableSet(set);
+ }
+
+ public Set<QName> getHeaders()
+ {
+ //return a collection with just the wsse:Security header to pass the MustUnderstand check on it
+ return headers;
+ }
+
/**
* Retrieves the SAML assertion from the SOAP payload and lets invocation go to JAAS for validation.
*/
protected boolean handleInbound(MessageContext msgContext)
{
- CommonMessageContext ctx = (CommonMessageContext) msgContext;
- SOAPMessageImpl soapMessage = (SOAPMessageImpl) ctx.getSOAPMessage();
+ SOAPMessageContext ctx = (SOAPMessageContext) msgContext;
+ SOAPMessage soapMessage = ctx.getMessage();
// retrieve the assertion
Document document = soapMessage.getSOAPPart();
@@ -82,8 +102,8 @@
*/
protected boolean handleOutbound(MessageContext msgContext)
{
- CommonMessageContext ctx = (CommonMessageContext) msgContext;
- SOAPMessageImpl soapMessage = (SOAPMessageImpl) ctx.getSOAPMessage();
+ SOAPMessageContext ctx = (SOAPMessageContext) msgContext;
+ SOAPMessage soapMessage = ctx.getMessage();
// retrieve assertion
Element assertion = (Element) ctx.get(SAML2Constants.SAML2_ASSERTION_PROPERTY);
@@ -91,25 +111,42 @@
// add wsse header
Document document = soapMessage.getSOAPPart();
Element soapHeader = Util.findOrCreateSoapHeader(document.getDocumentElement());
- SecurityHeader secHeader = new SecurityHeader(document);
try
{
- Element wsse = secHeader.getElement();
+ Element wsse = getSecurityHeaderElement(document);
wsse.setAttributeNS(soapHeader.getNamespaceURI(), soapHeader.getPrefix() + ":mustUnderstand", "1");
if (assertion != null)
{
// add the assertion as a child of the wsse header
- wsse.appendChild(assertion);
+ // check if the assertion element comes from the same document, otherwise import the node
+ if (document != assertion.getOwnerDocument())
+ {
+ wsse.appendChild(document.importNode(assertion, true));
+ }
+ else
+ {
+ wsse.appendChild(assertion);
+ }
}
soapHeader.insertBefore(wsse, soapHeader.getFirstChild());
}
catch (Exception e)
{
+ e.printStackTrace();
log.error(e);
return false;
}
return true;
}
-
+
+ private Element getSecurityHeaderElement(Document document)
+ {
+ Element element = document.createElementNS(Constants.WSSE_NS, Constants.WSSE_HEADER);
+ Util.addNamespace(element, Constants.WSSE_PREFIX, Constants.WSSE_NS);
+ Util.addNamespace(element, Constants.WSU_PREFIX, Constants.WSU_NS);
+ Util.addNamespace(element, Constants.XML_ENCRYPTION_PREFIX, Constants.XML_SIGNATURE_NS);
+ return element;
+ }
+
}
14 years, 2 months
Picketlink SVN: r477 - in trust/trunk: jbossws-native and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: mmoyses
Date: 2010-10-14 22:13:40 -0400 (Thu, 14 Oct 2010)
New Revision: 477
Modified:
trust/trunk/jbossws-native/pom.xml
trust/trunk/parent/pom.xml
trust/trunk/pom.xml
Log:
preparing next release
Modified: trust/trunk/jbossws-native/pom.xml
===================================================================
--- trust/trunk/jbossws-native/pom.xml 2010-10-15 00:00:03 UTC (rev 476)
+++ trust/trunk/jbossws-native/pom.xml 2010-10-15 02:13:40 UTC (rev 477)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-trust-parent</artifactId>
- <version>1.0.0.CR1</version>
+ <version>1.0.0.CR2</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trust/trunk/parent/pom.xml
===================================================================
--- trust/trunk/parent/pom.xml 2010-10-15 00:00:03 UTC (rev 476)
+++ trust/trunk/parent/pom.xml 2010-10-15 02:13:40 UTC (rev 477)
@@ -8,7 +8,7 @@
<groupId>org.picketlink</groupId>
<artifactId>picketlink-trust-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0.CR1</version>
+ <version>1.0.0.CR2</version>
<name>PicketLink Trust - Parent</name>
<url>http://labs.jboss.org/portal/picketlink/</url>
<description>PicketLink Trust integrates PicketLink with external projects</description>
Modified: trust/trunk/pom.xml
===================================================================
--- trust/trunk/pom.xml 2010-10-15 00:00:03 UTC (rev 476)
+++ trust/trunk/pom.xml 2010-10-15 02:13:40 UTC (rev 477)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-trust-parent</artifactId>
- <version>1.0.0.CR1</version>
+ <version>1.0.0.CR2</version>
<relativePath>parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
14 years, 2 months
Picketlink SVN: r476 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 20:00:03 -0400 (Thu, 14 Oct 2010)
New Revision: 476
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
Log:
install ignore
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java 2010-10-14 22:45:35 UTC (rev 475)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java 2010-10-15 00:00:03 UTC (rev 476)
@@ -52,7 +52,7 @@
* @throws Exception
*/
@Test
- //@Ignore
+ @Ignore
public void testParsingPerformance() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
14 years, 2 months
Picketlink SVN: r475 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 18:45:35 -0400 (Thu, 14 Oct 2010)
New Revision: 475
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
Log:
buffer input stream for stax
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java 2010-10-14 21:57:41 UTC (rev 474)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java 2010-10-14 22:45:35 UTC (rev 475)
@@ -21,6 +21,7 @@
*/
package org.picketlink.test.identity.federation.core.parser;
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.transform.Source;
@@ -39,7 +40,7 @@
*/
public class WST_SAML_ParsingPerfTestCase
{
- private int runs = 1000;
+ private int runs = 5000;
String fileName = "parser/perf/wst-batch-validate-one.xml";
@@ -51,7 +52,7 @@
* @throws Exception
*/
@Test
- @Ignore
+ //@Ignore
public void testParsingPerformance() throws Exception
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
@@ -71,12 +72,15 @@
System.out.println("JAXB, time spent for " + runs
+ " iterations = " + elapsedTimeMillis + " ms or " + elapsedTimeMillis/1000F + " secs");
+ configStream = tcl.getResourceAsStream( fileName );
+ byte[] xmlData = new byte[ configStream.available() ];
+ configStream.read( xmlData );
//Stax Way
start = System.currentTimeMillis();
for( int i = 0 ; i < runs; i++ )
{
- useStax( tcl );
+ useStax( new ByteArrayInputStream( xmlData ) );
}
elapsedTimeMillis = System.currentTimeMillis() - start;
System.out.println("STAX, time spent for " + runs
@@ -88,10 +92,8 @@
WSTrustJAXBFactory.getInstance().parseRequestSecurityToken(source);
}
- private void useStax( ClassLoader tcl ) throws Exception
- {
- InputStream configStream = tcl.getResourceAsStream( fileName );
-
+ private void useStax( InputStream configStream ) throws Exception
+ {
WSTrustParser parser = new WSTrustParser();
parser.parse( configStream );
}
14 years, 2 months
Picketlink SVN: r474 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/parsers/wsa and 4 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 17:57:41 -0400 (Thu, 14 Oct 2010)
New Revision: 474
Added:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsa/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsa/WSAddressingParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueAppliesToTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
Log:
PLFED-109: PLFED-110:
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/ParserController.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -0,0 +1,120 @@
+/*
+ * 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.identity.federation.core.parsers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.parsers.wsa.WSAddressingParser;
+import org.picketlink.identity.federation.core.parsers.wsp.WSPolicyParser;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+
+/**
+ * <p>
+ * A Controller that can act as the front door
+ * for parsing or when you need to locate a parser
+ * that is capable of parsing a {@code QName}
+ * <p>
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class ParserController
+{
+ private static List<ParserNamespaceSupport> parsers = new ArrayList<ParserNamespaceSupport>();
+
+ private static RuntimePermission PARSER_PERM = new RuntimePermission ( "org.picketlink.parser.permission" );
+
+
+ static
+ {
+ add( new SAMLParser() );
+ add( new WSTrustParser() );
+ add( new WSPolicyParser() );
+ add( new WSAddressingParser() );
+ };
+
+ /**
+ * <p>
+ * Add an {@code ParserNamespaceSupport} parser
+ * </p>
+ *
+ * <p>
+ * Under a Java security manager, the following run time permission is required.
+ * "org.picketlink.parser.permission"
+ * </p>
+ * @param parser
+ */
+ public static void add( ParserNamespaceSupport parser )
+ {
+ if( System.getSecurityManager() != null )
+ {
+ System.getSecurityManager().checkPermission( PARSER_PERM );
+ }
+
+ parsers.add( parser );
+ }
+
+ /**
+ * Get an {@code ParserNamespaceSupport} that supports parsing the qname
+ * @param qname
+ * @return A supporting parser or null
+ */
+ public static ParserNamespaceSupport get( QName qname )
+ {
+ int size = parsers.size();
+ if( size > 0 )
+ {
+ for( ParserNamespaceSupport parser : parsers )
+ {
+ if( parser.supports(qname) )
+ return parser;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <p>
+ * Clear the registered parsers.
+ * <b>Note:</b> You really need to have a reason to perform this operation.
+ * Once you have cleared the parsers, you have the opportunity to register
+ * new parsers with {@code #add(ParserNamespaceSupport)} call.
+ * </p>
+ *
+ * <p>
+ * Under a Java security manager, the following run time permission is required.
+ * "org.picketlink.parser.permission"
+ * </p>
+ */
+ public static void clearAll()
+ {
+ if( System.getSecurityManager() != null )
+ {
+ System.getSecurityManager().checkPermission( PARSER_PERM );
+ }
+
+ parsers.clear();
+ }
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsa/WSAddressingParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsa/WSAddressingParser.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsa/WSAddressingParser.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -0,0 +1,103 @@
+/*
+ * 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.identity.federation.core.parsers.wsa;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.AbstractParser;
+import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.ws.addressing.AttributedURIType;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.addressing.ObjectFactory;
+
+/**
+ * <p>
+ * Able to parse the WS-Addressing pieces in WS-T RST.
+ * <p>
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WSAddressingParser extends AbstractParser
+{
+ public static final String ENDPOINT_REFERENCE = "EndpointReference";
+ public static final String ADDRESS = "Address";
+
+ /**
+ * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
+ */
+ public Object parse(XMLEventReader xmlEventReader) throws ParsingException
+ {
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek( xmlEventReader );
+
+ if( xmlEvent instanceof StartElement )
+ {
+ StartElement startElement = (StartElement) xmlEvent;
+
+ String elementName = StaxParserUtil.getStartElementName( startElement );
+ if( elementName.equalsIgnoreCase( ENDPOINT_REFERENCE ))
+ {
+ startElement = StaxParserUtil.getNextStartElement( xmlEventReader );
+ StaxParserUtil.validate(startElement, ENDPOINT_REFERENCE );
+
+ //Lets get the wsa:Address
+ startElement = StaxParserUtil.getNextStartElement( xmlEventReader );
+ StaxParserUtil.validate(startElement, ADDRESS );
+
+ String endpointURI = StaxParserUtil.getElementText( xmlEventReader );
+
+ AttributedURIType attributedURI = new AttributedURIType();
+ attributedURI.setValue(endpointURI);
+ EndpointReferenceType reference = new EndpointReferenceType();
+ reference.setAddress(attributedURI);
+
+ //Lets get the end element
+ EndElement endElement = (EndElement) StaxParserUtil.getNextEvent(xmlEventReader);
+ StaxParserUtil.validate( endElement, ENDPOINT_REFERENCE );
+
+ return new ObjectFactory().createEndpointReference( reference );
+ }
+ }
+ else
+ {
+ StaxParserUtil.getNextEvent(xmlEventReader);
+ }
+ }
+ throw new RuntimeException( "WSAddressing Parsing has failed" );
+ }
+
+ /**
+ * @see {@link ParserNamespaceSupport#supports(QName)}
+ */
+ public boolean supports(QName qname)
+ {
+ return WSTrustConstants.WSA_NS.equals( qname.getNamespaceURI() );
+ }
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wsp/WSPolicyParser.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -0,0 +1,101 @@
+/*
+ * 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.identity.federation.core.parsers.wsp;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.AbstractParser;
+import org.picketlink.identity.federation.core.parsers.ParserController;
+import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
+
+/**
+ * <p>
+ * Parses the WS-Policy elements that can be part
+ * of the WS-T RST
+ * </p>
+ *
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WSPolicyParser extends AbstractParser
+{
+ public static final String APPLIES_TO = "AppliesTo";
+
+ /**
+ * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
+ */
+ public Object parse(XMLEventReader xmlEventReader) throws ParsingException
+ {
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek( xmlEventReader );
+
+ if( xmlEvent instanceof StartElement )
+ {
+ StartElement startElement = (StartElement) xmlEvent;
+
+ String elementName = StaxParserUtil.getStartElementName( startElement );
+ if( elementName.equalsIgnoreCase( APPLIES_TO ))
+ {
+ //Get the AppliesTo element
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+
+ AppliesTo appliesTo = new AppliesTo();
+
+ //Now we do not do anything to the applies to element. We go further
+ startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+
+ QName qname = startElement.getName();
+ ParserNamespaceSupport parser = ParserController.get( qname );
+ if( parser == null )
+ throw new RuntimeException( "Unable to parse:" + qname );
+
+ Object parsedObject = parser.parse( xmlEventReader );
+ appliesTo.getAny().add( parsedObject );
+ return appliesTo;
+ }
+ }
+ else
+ {
+ StaxParserUtil.getNextEvent(xmlEventReader);
+ }
+ }
+ throw new RuntimeException( "WSPolicy Parsing has failed" );
+ }
+
+ /**
+ * @see {@link ParserNamespaceSupport#supports(QName)}
+ */
+ public boolean supports(QName qname)
+ {
+ String nsURI = qname.getNamespaceURI();
+
+ return WSTrustConstants.WSP_NS.equals( nsURI );
+ }
+}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 20:42:04 UTC (rev 473)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -32,10 +32,12 @@
import javax.xml.stream.events.XMLEvent;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.ParserController;
import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
import org.picketlink.identity.federation.ws.trust.CancelTargetType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
@@ -76,23 +78,29 @@
try
{
- StartElement subEvent = StaxParserUtil.getNextStartElement( xmlEventReader );
+ StartElement subEvent = StaxParserUtil.peekNextStartElement( xmlEventReader );
if( subEvent == null )
break;
String tag = StaxParserUtil.getStartElementName( subEvent );
if( tag.equals( WSTrustConstants.REQUEST_TYPE ))
{
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+
String value = StaxParserUtil.getElementText(xmlEventReader);
requestToken.setRequestType( new URI( value ));
}
else if( tag.equals( WSTrustConstants.TOKEN_TYPE ))
{
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+
String value = StaxParserUtil.getElementText(xmlEventReader);
requestToken.setTokenType( new URI( value ));
}
else if( tag.equals( WSTrustConstants.CANCEL_TARGET ))
{
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate(subEvent, WSTrustConstants.CANCEL_TARGET );
WSTCancelTargetParser wstCancelTargetParser = new WSTCancelTargetParser();
CancelTargetType cancelTarget = (CancelTargetType) wstCancelTargetParser.parse( xmlEventReader );
requestToken.setCancelTarget( cancelTarget );
@@ -101,12 +109,27 @@
}
else if( tag.equals( WSTrustConstants.VALIDATE_TARGET ))
{
+ subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
+
WSTValidateTargetParser wstValidateTargetParser = new WSTValidateTargetParser();
ValidateTargetType validateTarget = (ValidateTargetType) wstValidateTargetParser.parse( xmlEventReader );
requestToken.setValidateTarget( validateTarget );
EndElement validateTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
StaxParserUtil.validate( validateTargetEndElement, WSTrustConstants.VALIDATE_TARGET ) ;
}
+ else
+ {
+ QName qname = subEvent.getName();
+ ParserNamespaceSupport parser = ParserController.get( qname );
+ if( parser == null )
+ throw new RuntimeException( "Cannot parse " + qname );
+
+ Object parsedObject = parser.parse( xmlEventReader );
+ if( parsedObject instanceof AppliesTo )
+ {
+ requestToken.setAppliesTo( (AppliesTo) parsedObject );
+ }
+ }
}
catch (URISyntaxException e)
{
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-14 20:42:04 UTC (rev 473)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -63,6 +63,7 @@
// WSS namespaces values.
public static final String WSA_NS = "http://www.w3.org/2005/08/addressing";
+ public static final String WSP_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
public static final String WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit...";
public static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext...";
public static final String WSSE11_NS = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueAppliesToTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueAppliesToTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustIssueAppliesToTestCase.java 2010-10-14 21:57:41 UTC (rev 474)
@@ -0,0 +1,62 @@
+/*
+ * 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.identity.federation.core.parser.wst;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBElement;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.addressing.EndpointReferenceType;
+import org.picketlink.identity.federation.ws.policy.AppliesTo;
+
+/**
+ * Validate the wst applies to parsing
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WSTrustIssueAppliesToTestCase
+{
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testAppliesTo() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-issue-appliesto.xml" );
+
+ WSTrustParser parser = new WSTrustParser();
+ RequestSecurityToken requestToken = ( RequestSecurityToken ) parser.parse( configStream );
+
+ assertEquals( "testcontext", requestToken.getContext() );
+ assertEquals( WSTrustConstants.ISSUE_REQUEST , requestToken.getRequestType().toASCIIString() );
+
+ AppliesTo appliesTo = requestToken.getAppliesTo();
+ JAXBElement<EndpointReferenceType> jaxb = (JAXBElement<EndpointReferenceType>) appliesTo.getAny().get(0);
+ EndpointReferenceType endpoint = jaxb.getValue();
+ assertEquals( "http://services.testcorp.org/provider2", endpoint.getAddress().getValue() );
+ }
+}
\ No newline at end of file
14 years, 2 months
Picketlink SVN: r473 - in federation/trunk/picketlink-fed-core/src/test: resources/parser and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 16:42:04 -0400 (Thu, 14 Oct 2010)
New Revision: 473
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/
federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml
Log:
add simple perf test
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java 2010-10-14 20:42:04 UTC (rev 473)
@@ -0,0 +1,98 @@
+/*
+ * 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.identity.federation.core.parser;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustJAXBFactory;
+import org.w3c.dom.Document;
+
+/**
+ * Some simple perf tests
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WST_SAML_ParsingPerfTestCase
+{
+ private int runs = 1000;
+
+ String fileName = "parser/perf/wst-batch-validate-one.xml";
+
+ /**
+ * This test just tests some saml/wst payload performance
+ * using JAXB and Stax.
+ *
+ * <b>NOTE:</b> For the test to work, just comment out @Ignore
+ * @throws Exception
+ */
+ @Test
+ @Ignore
+ public void testParsingPerformance() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( fileName );
+
+ Document doc = DocumentUtil.getDocument( configStream );
+ Source source = DocumentUtil.getXMLSource(doc);
+
+
+ //JAXB way
+ long start = System.currentTimeMillis();
+ for( int i = 0 ; i < runs; i++ )
+ {
+ useJAXB( source );
+ }
+ long elapsedTimeMillis = System.currentTimeMillis() - start;
+ System.out.println("JAXB, time spent for " + runs
+ + " iterations = " + elapsedTimeMillis + " ms or " + elapsedTimeMillis/1000F + " secs");
+
+
+ //Stax Way
+ start = System.currentTimeMillis();
+ for( int i = 0 ; i < runs; i++ )
+ {
+ useStax( tcl );
+ }
+ elapsedTimeMillis = System.currentTimeMillis() - start;
+ System.out.println("STAX, time spent for " + runs
+ + " iterations = " + elapsedTimeMillis + " ms or " + elapsedTimeMillis/1000F + " secs");
+ }
+
+ private void useJAXB( Source source ) throws Exception
+ {
+ WSTrustJAXBFactory.getInstance().parseRequestSecurityToken(source);
+ }
+
+ private void useStax( ClassLoader tcl ) throws Exception
+ {
+ InputStream configStream = tcl.getResourceAsStream( fileName );
+
+ WSTrustParser parser = new WSTrustParser();
+ parser.parse( configStream );
+ }
+}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml 2010-10-14 20:42:04 UTC (rev 473)
@@ -0,0 +1,50 @@
+<wst:RequestSecurityToken Context="validatecontext2" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
+ <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchValidate</wst:RequestType>
+ <wst:TokenType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Status</wst:TokenType>
+ <wst:ValidateTarget>
+ <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="ID_cf9efbf0-9d7f-4b4a-b77f-d83ecaafd374"
+ IssueInstant="2010-09-30T19:13:37.911Z" Version="2.0">
+ <saml2:Issuer>Test STS</saml2:Issuer>
+ <saml2:Subject>
+ <saml2:NameID NameQualifier="urn:picketlink:identity-federation">jduke</saml2:NameID>
+ <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"/>
+ </saml2:Subject>
+ <saml2:Conditions NotBefore="2010-09-30T19:13:37.911Z" NotOnOrAfter="2010-09-30T21:13:37.911Z">
+ <saml2:AudienceRestriction>
+ <saml2:Audience>http://services.testcorp.org/provider2</saml2:Audience>
+ </saml2:AudienceRestriction>
+ </saml2:Conditions>
+ <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmlds#rsa-sha1"/>
+ <ds:Reference URI="#ID_cf9efbf0-9d7f-4b4a-b77f-d83ecaafd374">
+ <ds:Transforms>
+ <ds:Transform Algorithm="http://www.w3.org/2000/09/xmlds#enveloped-signature"/>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmlds#sha1"/>
+ <ds:DigestValue>TMZdBOA0MvR7aNpCAg2CXggkdZc=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue>
+Q8mEzGWlnWmSmb+KUkP0wju4LOINaUYXBBXNF5vRhYVBixSUe8HSHKzNIdQ+ZGtijaV1vh0LUFbT
+//faZKyHRgPXtskDn8cJTVT6obp7rUIOCKMoCs5p9/bUAbtaQHYjfWpifdT3PaTdlehpS8INK2P0
+JUQYU3q8F3u7je9VHbA=
+ </ds:SignatureValue>
+ <ds:KeyInfo>
+ <ds:KeyValue>
+ <ds:RSAKeyValue>
+ <ds:Modulus>
+suGIyhVTbFvDwZdx8Av62zmP+aGOlsBN8WUE3eEEcDtOIZgO78SImMQGwB2C0eIVMhiLRzVPqoW1
+dCPAveTm653zHOmubaps1fY0lLJDSZbTbhjeYhoQmmaBro/tDpVw5lKJwspqVnMuRK19ju2dxpKw
+lYGGtrP5VQv00dfNPbs=
+ </ds:Modulus>
+ <ds:Exponent>AQAB</ds:Exponent>
+ </ds:RSAKeyValue>
+ </ds:KeyValue>
+ </ds:KeyInfo>
+ </ds:Signature>
+ </saml2:Assertion>
+ </wst:ValidateTarget>
+</wst:RequestSecurityToken>
14 years, 2 months
Picketlink SVN: r472 - federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 12:47:24 -0400 (Thu, 14 Oct 2010)
New Revision: 472
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
Log:
PLFED-109: PLFED-110:
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2010-10-14 16:46:50 UTC (rev 471)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2010-10-14 16:47:24 UTC (rev 472)
@@ -43,6 +43,7 @@
import org.picketlink.identity.federation.ws.trust.CancelTargetType;
/**
+ * Validate the WST Cancel Target for SAML assertions
* @author Anil.Saldhana(a)redhat.com
* @since Oct 14, 2010
*/
14 years, 2 months
Picketlink SVN: r471 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/saml/v2/constants and 2 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 12:46:50 -0400 (Thu, 14 Oct 2010)
New Revision: 471
Added:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTCancelTargetParser.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLURIConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
Log:
PLFED-109: PLFED-110:
Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTCancelTargetParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTCancelTargetParser.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTCancelTargetParser.java 2010-10-14 16:46:50 UTC (rev 471)
@@ -0,0 +1,75 @@
+/*
+ * 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.identity.federation.core.parsers.wst;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.StartElement;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
+import org.picketlink.identity.federation.ws.trust.CancelTargetType;
+
+/**
+ * Stax parser for the wst:CancelTarget element
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 13, 2010
+ */
+public class WSTCancelTargetParser implements ParserNamespaceSupport
+{
+ /**
+ * @see {@link ParserNamespaceSupport#parse(XMLEventReader)}
+ */
+ public Object parse(XMLEventReader xmlEventReader) throws ParsingException
+ {
+ CancelTargetType cancelTarget = new CancelTargetType();
+
+ StartElement startElement = StaxParserUtil.peekNextStartElement( xmlEventReader );
+ String tag = StaxParserUtil.getStartElementName( startElement );
+
+ if( tag.equals( JBossSAMLConstants.ASSERTION.get() ) )
+ {
+ SAMLParser assertionParser = new SAMLParser();
+ AssertionType assertion = (AssertionType) assertionParser.parse( xmlEventReader );
+ cancelTarget.setAny( assertion );
+ }
+
+ return cancelTarget;
+ }
+
+ /**
+ * @see {@link ParserNamespaceSupport#supports(QName)}
+ */
+ public boolean supports(QName qname)
+ {
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
+ && WSTrustConstants.CANCEL_TARGET.equals( localPart );
+ }
+}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 16:21:26 UTC (rev 470)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 16:46:50 UTC (rev 471)
@@ -36,6 +36,7 @@
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.ws.trust.CancelTargetType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
/**
@@ -90,6 +91,14 @@
String value = StaxParserUtil.getElementText(xmlEventReader);
requestToken.setTokenType( new URI( value ));
}
+ else if( tag.equals( WSTrustConstants.CANCEL_TARGET ))
+ {
+ WSTCancelTargetParser wstCancelTargetParser = new WSTCancelTargetParser();
+ CancelTargetType cancelTarget = (CancelTargetType) wstCancelTargetParser.parse( xmlEventReader );
+ requestToken.setCancelTarget( cancelTarget );
+ EndElement cancelTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( cancelTargetEndElement, WSTrustConstants.CANCEL_TARGET ) ;
+ }
else if( tag.equals( WSTrustConstants.VALIDATE_TARGET ))
{
WSTValidateTargetParser wstValidateTargetParser = new WSTValidateTargetParser();
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLURIConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLURIConstants.java 2010-10-14 16:21:26 UTC (rev 470)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLURIConstants.java 2010-10-14 16:46:50 UTC (rev 471)
@@ -37,11 +37,14 @@
AC_IP("urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocol"),
+ BEARER( "urn:oasis:names:tc:SAML:2.0:cm:bearer" ),
ASSERTION_NSURI("urn:oasis:names:tc:SAML:2.0:assertion"),
ATTRIBUTE_FORMAT_BASIC("urn:oasis:names:tc:SAML:2.0:attrname-format:basic"),
ATTRIBUTE_FORMAT_URI("urn:oasis:names:tc:SAML:2.0:attrname-format:uri"),
+ HOLDER_OF_KEY( "urn:oasis:names:tc:SAML:2.0:cm:holder-of-key" ),
+
METADATA_HTTP_REDIRECT_BINDING("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"),
NAMEID_FORMAT_TRANSIENT("urn:oasis:names:tc:SAML:2.0:nameid-format:transient"),
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-14 16:21:26 UTC (rev 470)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustConstants.java 2010-10-14 16:46:50 UTC (rev 471)
@@ -29,6 +29,7 @@
* </p>
*
* @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a>
+ * @author <a href="mailto:asaldhan@redhat.com">Anil Saldhana</a>
*/
public class WSTrustConstants
{
@@ -84,6 +85,7 @@
public static final String RST_COLLECTION = "RequestSecurityTokenCollection";
public static final String REQUEST_TYPE = "RequestType";
public static final String TOKEN_TYPE = "TokenType";
+ public static final String CANCEL_TARGET = "CancelTarget";
public static final String VALIDATE_TARGET = "ValidateTarget";
//Attribute Names
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/wst/WSTrustCancelTargetSamlTestCase.java 2010-10-14 16:46:50 UTC (rev 471)
@@ -0,0 +1,110 @@
+/*
+ * 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.identity.federation.core.parser.wst;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.datatype.DatatypeFactory;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
+import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
+import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
+import org.picketlink.identity.federation.saml.v2.assertion.ConditionsType;
+import org.picketlink.identity.federation.saml.v2.assertion.NameIDType;
+import org.picketlink.identity.federation.saml.v2.assertion.SubjectConfirmationType;
+import org.picketlink.identity.federation.saml.v2.assertion.SubjectType;
+import org.picketlink.identity.federation.ws.trust.CancelTargetType;
+
+/**
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Oct 14, 2010
+ */
+public class WSTrustCancelTargetSamlTestCase
+{
+ @Test
+ public void testWST_CancelTargetSaml() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream configStream = tcl.getResourceAsStream( "parser/wst/wst-cancel-saml.xml" );
+
+ WSTrustParser parser = new WSTrustParser();
+ RequestSecurityToken rst1 = (RequestSecurityToken) parser.parse( configStream );
+ assertEquals( "cancelcontext", rst1.getContext() );
+ assertEquals( WSTrustConstants.CANCEL_REQUEST, rst1.getRequestType().toASCIIString() );
+
+ CancelTargetType cancelTarget = rst1.getCancelTarget();
+
+ AssertionType assertion = (AssertionType) cancelTarget.getAny();
+ validateAssertion( assertion );
+ }
+
+ private void validateAssertion( AssertionType assertion ) throws Exception
+ {
+ DatatypeFactory dtf = DatatypeFactory.newInstance();
+
+ assertNotNull( assertion );
+
+ assertEquals( "ID_cb1eadf5-50a6-4fdf-96bc-412514f52882", assertion.getID() );
+ assertEquals( dtf.newXMLGregorianCalendar( "2010-09-30T19:13:37.603Z" ), assertion.getIssueInstant() );
+ //Issuer
+ assertEquals( "Test STS", assertion.getIssuer().getValue() );
+
+ //Subject
+ SubjectType subject = assertion.getSubject();
+ List<JAXBElement<?>> content = subject.getContent();
+
+ int size = content.size();
+
+ assertEquals( 2, size );
+
+ for( int i = 0 ; i < size; i++ )
+ {
+ JAXBElement<?> node = content.get(i);
+ if( node.getDeclaredType().equals( NameIDType.class ))
+ {
+ NameIDType subjectNameID = (NameIDType) node.getValue();
+
+ assertEquals( "jduke", subjectNameID.getValue() );
+ assertEquals( "urn:picketlink:identity-federation", subjectNameID.getNameQualifier() );
+ }
+
+ if( node.getDeclaredType().equals( SubjectConfirmationType.class ))
+ {
+ SubjectConfirmationType subjectConfirmationType = (SubjectConfirmationType) node.getValue();
+ assertEquals( JBossSAMLURIConstants.BEARER.get(), subjectConfirmationType.getMethod() );
+ }
+ }
+
+ //Conditions
+ ConditionsType conditions = assertion.getConditions();
+ assertEquals( dtf.newXMLGregorianCalendar( "2010-09-30T19:13:37.603Z" ) , conditions.getNotBefore() );
+ assertEquals( dtf.newXMLGregorianCalendar( "2010-09-30T21:13:37.603Z" ) , conditions.getNotOnOrAfter() );
+ }
+}
\ No newline at end of file
14 years, 2 months
Picketlink SVN: r470 - in federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers: util and 1 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2010-10-14 12:21:26 -0400 (Thu, 14 Oct 2010)
New Revision: 470
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLConditionsParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenCollectionParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTValidateTargetParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustParser.java
Log:
PLFED-109: PLFED-110:
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLConditionsParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLConditionsParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLConditionsParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -137,7 +137,11 @@
*/
public boolean supports(QName qname)
{
- return false;
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return nsURI.equals( JBossSAMLURIConstants.ASSERTION_NSURI.get() )
+ && localPart.equals( JBossSAMLConstants.CONDITIONS.get() );
}
/**
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -23,7 +23,6 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
@@ -48,15 +47,7 @@
{
while( xmlEventReader.hasNext() )
{
- XMLEvent xmlEvent = null;
- try
- {
- xmlEvent = xmlEventReader.peek();
- }
- catch (XMLStreamException e)
- {
- throw new ParsingException( e );
- }
+ XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
if( xmlEvent instanceof StartElement )
{
@@ -71,14 +62,7 @@
}
else
{
- try
- {
- xmlEventReader.nextEvent();
- }
- catch (XMLStreamException e)
- {
- throw new ParsingException( e );
- }
+ StaxParserUtil.getNextEvent(xmlEventReader);
}
}
throw new RuntimeException( "SAML Parsing has failed" );
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLSubjectParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -135,8 +135,12 @@
/**
* @see {@link ParserNamespaceSupport#supports(QName)}
*/
- public boolean supports(QName qname)
+ public boolean supports( QName qname )
{
- return false;
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return nsURI.equals( JBossSAMLURIConstants.ASSERTION_NSURI.get() )
+ && localPart.equals( JBossSAMLConstants.SUBJECT.get() );
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -328,6 +328,6 @@
{
String elementTag = getEndElementName( endElement );
if( !tag.equals( elementTag ))
- throw new RuntimeException( "Expecting <" + tag + ">. Found <" + elementTag + ">" );
+ throw new RuntimeException( "Expecting </" + tag + ">. Found </" + elementTag + ">" );
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenCollectionParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenCollectionParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenCollectionParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -23,7 +23,6 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
@@ -45,19 +44,12 @@
*/
public Object parse( XMLEventReader xmlEventReader ) throws ParsingException
{
- try
- {
- xmlEventReader.nextEvent();
- }
- catch (XMLStreamException e)
- {
- throw new ParsingException( e );
- }
+ StaxParserUtil.getNextEvent(xmlEventReader);
RequestSecurityTokenCollection requestCollection = new RequestSecurityTokenCollection();
//Peek at the next event
- while( true )
+ while( xmlEventReader.hasNext() )
{
StartElement peekedElement = StaxParserUtil.peekNextStartElement( xmlEventReader );
if( peekedElement == null )
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTRequestSecurityTokenParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -25,8 +25,7 @@
import java.net.URISyntaxException;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
@@ -83,12 +82,12 @@
String tag = StaxParserUtil.getStartElementName( subEvent );
if( tag.equals( WSTrustConstants.REQUEST_TYPE ))
{
- String value = xmlEventReader.getElementText();
+ String value = StaxParserUtil.getElementText(xmlEventReader);
requestToken.setRequestType( new URI( value ));
}
else if( tag.equals( WSTrustConstants.TOKEN_TYPE ))
{
- String value = xmlEventReader.getElementText();
+ String value = StaxParserUtil.getElementText(xmlEventReader);
requestToken.setTokenType( new URI( value ));
}
else if( tag.equals( WSTrustConstants.VALIDATE_TARGET ))
@@ -97,14 +96,9 @@
ValidateTargetType validateTarget = (ValidateTargetType) wstValidateTargetParser.parse( xmlEventReader );
requestToken.setValidateTarget( validateTarget );
EndElement validateTargetEndElement = StaxParserUtil.getNextEndElement(xmlEventReader);
- if( !StaxParserUtil.getEndElementName( validateTargetEndElement ).equals( WSTrustConstants.VALIDATE_TARGET ) )
- throw new RuntimeException( "</" + WSTrustConstants.VALIDATE_TARGET + "> expected" );
+ StaxParserUtil.validate( validateTargetEndElement, WSTrustConstants.VALIDATE_TARGET ) ;
}
- }
- catch( XMLStreamException e )
- {
- throw new ParsingException( e );
- }
+ }
catch (URISyntaxException e)
{
throw new ParsingException( e );
@@ -119,6 +113,10 @@
*/
public boolean supports(QName qname)
{
- return false;
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
+ && WSTrustConstants.RST.equals( localPart );
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTValidateTargetParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTValidateTargetParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTValidateTargetParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -30,6 +30,7 @@
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
+import org.picketlink.identity.federation.core.wstrust.WSTrustConstants;
import org.picketlink.identity.federation.saml.v2.assertion.AssertionType;
import org.picketlink.identity.federation.ws.trust.ValidateTargetType;
@@ -65,6 +66,10 @@
*/
public boolean supports(QName qname)
{
- return false;
+ String nsURI = qname.getNamespaceURI();
+ String localPart = qname.getLocalPart();
+
+ return WSTrustConstants.BASE_NAMESPACE.equals( nsURI )
+ && WSTrustConstants.VALIDATE_TARGET.equals( localPart );
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustParser.java 2010-10-14 16:07:45 UTC (rev 469)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/wst/WSTrustParser.java 2010-10-14 16:21:26 UTC (rev 470)
@@ -23,7 +23,6 @@
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
@@ -48,15 +47,7 @@
{
while( xmlEventReader.hasNext() )
{
- XMLEvent xmlEvent = null;
- try
- {
- xmlEvent = xmlEventReader.peek();
- }
- catch (XMLStreamException e)
- {
- throw new ParsingException( e );
- }
+ XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
if( xmlEvent instanceof StartElement )
{
@@ -76,14 +67,7 @@
}
else
{
- try
- {
- xmlEventReader.nextEvent();
- }
- catch (XMLStreamException e)
- {
- throw new ParsingException( e );
- }
+ StaxParserUtil.getNextEvent(xmlEventReader);
}
}
throw new RuntimeException( "WSTrust Parsing has failed" );
14 years, 2 months