[jboss-identity-commits] JBoss Identity SVN: r203 - in identity-federation/trunk/identity-fed-model: src/test/java/org/jboss/test/identity/federation and 4 other directories.

jboss-identity-commits at lists.jboss.org jboss-identity-commits at lists.jboss.org
Wed Jan 7 14:31:25 EST 2009


Author: sguilhen at redhat.com
Date: 2009-01-07 14:31:25 -0500 (Wed, 07 Jan 2009)
New Revision: 203

Added:
   identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/
   identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/trust/
   identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/trust/UnmarshallingTestCase.java
   identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/
   identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/collection-request.xml
   identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/simple-request.xml
Modified:
   identity-federation/trunk/identity-fed-model/.classpath
   identity-federation/trunk/identity-fed-model/.project
   identity-federation/trunk/identity-fed-model/pom.xml
Log:
Added testcase to validate the unmarshalling of ws-trust messages

Modified: identity-federation/trunk/identity-fed-model/.classpath
===================================================================
--- identity-federation/trunk/identity-fed-model/.classpath	2009-01-07 19:16:28 UTC (rev 202)
+++ identity-federation/trunk/identity-fed-model/.classpath	2009-01-07 19:31:25 UTC (rev 203)
@@ -1,30 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src/main/java"/>
-	<classpathentry kind="src" path="src/test/resources"/>
-	<classpathentry kind="src" path="src/main/resources"/>
-	<classpathentry kind="src" path="src/test/java"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="var" path="M2_REPO/opensaml/opensaml/2.1.0/opensaml-2.1.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
-	<classpathentry kind="var" path="M2_REPO/opensaml/xmltooling/1.0.1/xmltooling-1.0.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.0/slf4j-api-1.5.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.0/slf4j-log4j12-1.5.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-xmlsec/xmlsec/1.3.0/xmlsec-1.3.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-logging/commons-logging-api/1.0.3/commons-logging-api-1.0.3.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-velocity/velocity/1.5/velocity-1.5.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/apache-lang/commons-lang/2.1/commons-lang-2.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/opensaml/openws/1.1.0/openws-1.1.0.jar"/>
-	<classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.5.2/joda-time-1.5.2.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-xacml-saml/2.0.3-SNAPSHOT/jboss-xacml-saml-2.0.3-SNAPSHOT.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-xacml/2.0.2.GA/jboss-xacml-2.0.2.GA.jar"/>
-	<classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-impl/2.1.9/jaxb-impl-2.1.9.jar"/>
-	<classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/codehaus-stax/stax/1.1.1/stax-1.1.1.jar"/>
-	<classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/identity-xmlsecmodel"/>
-	<classpathentry kind="output" path="target-eclipse/"/>
-</classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaf/activation/1.1/activation-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-logging/commons-logging-api/1.0.3/commons-logging-api-1.0.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging-api/1.1/commons-logging-api-1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/javolution/4.1.0/javolution-4.1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-impl/2.1.4/jaxb-impl-2.1.4.jar" sourcepath="M2_REPO/sun-jaxb/jaxb-impl/2.1.4/jaxb-impl-2.1.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-xjc/2.1.4/jaxb-xjc-2.1.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/identity/jboss-identity-xmlsec-model/1.0.0-SNAPSHOT/jboss-identity-xmlsec-model-1.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/identity/jboss-identity-xmlsec-model/1.0.0-SNAPSHOT/jboss-identity-xmlsec-model-1.0.0-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-sunxacml/2.0.3-SNAPSHOT/jboss-sunxacml-2.0.3-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/jboss-sunxacml/2.0.3-SNAPSHOT/jboss-sunxacml-2.0.3-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-xacml/2.0.3-SNAPSHOT/jboss-xacml-2.0.3-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/jboss-xacml/2.0.3-SNAPSHOT/jboss-xacml-2.0.3-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-xacml-saml/2.0.3-SNAPSHOT/jboss-xacml-saml-2.0.3-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/jboss-xacml-saml/2.0.3-SNAPSHOT/jboss-xacml-saml-2.0.3-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/net/sf/joda-time/1.4/joda-time-1.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+  <classpathentry kind="var" path="M2_REPO/opensaml/opensaml/2.2.0/opensaml-2.2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/opensaml/openws/1.2.0/openws-1.2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xalan/serializer/2.7.0.patch01-brew/serializer-2.7.0.patch01-brew.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/codehaus-stax/stax/1.1.1/stax-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0/stax-api-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/velocity/velocity-dep/1.5/velocity-dep-1.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xalan/xalan/j_2.7.0/xalan-j_2.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xmlsec/xmlsec/1.3.0/xmlsec-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/xmlsec/1.4.1/xmlsec-1.4.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/opensaml/xmltooling/1.1.0/xmltooling-1.1.0.jar"/>
+</classpath>
\ No newline at end of file

Modified: identity-federation/trunk/identity-fed-model/.project
===================================================================
--- identity-federation/trunk/identity-fed-model/.project	2009-01-07 19:16:28 UTC (rev 202)
+++ identity-federation/trunk/identity-fed-model/.project	2009-01-07 19:31:25 UTC (rev 203)
@@ -1,17 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>identity-fed-model</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-	</natures>
-</projectDescription>
+  <name>jboss-identity-fed-model</name>
+  <comment>JBoss Identity Federation Model contains the JAXB2 model.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Modified: identity-federation/trunk/identity-fed-model/pom.xml
===================================================================
--- identity-federation/trunk/identity-fed-model/pom.xml	2009-01-07 19:16:28 UTC (rev 202)
+++ identity-federation/trunk/identity-fed-model/pom.xml	2009-01-07 19:31:25 UTC (rev 203)
@@ -95,5 +95,11 @@
          <artifactId>junit</artifactId>
          <scope>test</scope>
       </dependency>
+      <dependency>
+         <groupId>apache-xalan</groupId>
+         <artifactId>serializer</artifactId>
+         <version>2.7.0.patch01-brew</version>
+         <scope>test</scope>
+      </dependency>
    </dependencies>
 </project>

Added: identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/trust/UnmarshallingTestCase.java
===================================================================
--- identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/trust/UnmarshallingTestCase.java	                        (rev 0)
+++ identity-federation/trunk/identity-fed-model/src/test/java/org/jboss/test/identity/federation/ws/trust/UnmarshallingTestCase.java	2009-01-07 19:31:25 UTC (rev 203)
@@ -0,0 +1,140 @@
+/*
+ * 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.jboss.test.identity.federation.ws.trust;
+
+import java.io.File;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.ValidationEventLocator;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.identity.federation.ws.trust.RequestSecurityTokenType;
+
+/**
+ * <p>
+ * A {@code TestCase} that validates the unmarshalling of ws-trust messages.
+ * </p>
+ * 
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class UnmarshallingTestCase extends TestCase
+{
+
+   /**
+    * <p>
+    * Tests unmarshalling a simple ws-trust security token request.
+    * </p>
+    * 
+    * @throws Exception if an error occurs while running the test.
+    */
+   @SuppressWarnings("unchecked")
+   public void testUnmarshallTokenRequest() throws Exception
+   {
+      JAXBContext context = JAXBContext.newInstance("org.jboss.identity.federation.ws.trust");
+      Unmarshaller unmarshaller = context.createUnmarshaller();
+      // this.setValidatingSchema("/schema/wstrust/v1_3/ws-trust-1.3.xsd", unmarshaller);
+
+      // unmarshall the sample security token request.
+      URI sampleURI = this.getClass().getResource("/wstrust/simple-request.xml").toURI();
+      Object object = unmarshaller.unmarshal(new File(sampleURI));
+      assertNotNull("Unexpected null object", object);
+      assertTrue("Unexpected object type", object instanceof JAXBElement);
+
+      JAXBElement element = (JAXBElement) object;
+      assertEquals("Invalid element name", "RequestSecurityToken", element.getName().getLocalPart());
+      assertEquals("Invalid element type", RequestSecurityTokenType.class, element.getDeclaredType());
+
+      // validate the request contents.
+      RequestSecurityTokenType request = (RequestSecurityTokenType) element.getValue();
+      List<Object> contents = request.getAny();
+      assertNotNull("Unexpected null request contents", contents);
+      assertEquals("Unexpected number of elements", 2, contents.size());
+
+      // first element should be TokenType.
+      JAXBElement<String> tokenType = (JAXBElement<String>) contents.get(0);
+      assertEquals("TokenType", tokenType.getName().getLocalPart());
+      assertEquals("http://example.org/mySpecialToken", tokenType.getValue());
+
+      // second element should be RequestType.
+      JAXBElement<String> requestType = (JAXBElement<String>) contents.get(1);
+      assertEquals("RequestType", requestType.getName().getLocalPart());
+      assertEquals("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue", requestType.getValue());
+   }
+
+   public void testUnmarshallTokenCollectionRequest() throws Exception
+   {
+      JAXBContext context = JAXBContext
+            .newInstance("org.jboss.identity.federation.ws.trust");
+      Unmarshaller unmarshaller = context.createUnmarshaller();
+      // this.setValidatingSchema("/schema/wstrust/v1_3/ws-trust-1.3.xsd", unmarshaller);
+
+      // unmarshall the sample security token request.
+      URI sampleURI = this.getClass().getResource("/wstrust/collection-request.xml").toURI();
+      Object object = unmarshaller.unmarshal(new File(sampleURI));
+
+      JAXBElement element = (JAXBElement) object;
+   }
+
+   /**
+    * <p>
+    * Enable schema validation for the specified {@code Unmarshaller}.
+    * </p>
+    * 
+    * @param schemaFile the location of the schema file.
+    * @param unmarshaller the {@code Unmarshaller} where schema validation will be enabled.
+    * @throws Exception if an error occurs while setting the schema.
+    */
+   private void setValidatingSchema(String schemaFile, Unmarshaller unmarshaller) throws Exception
+   {
+      // create the schema based on the schema file.
+      URI schemaURI = this.getClass().getResource(schemaFile).toURI();
+      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+      Schema schema = factory.newSchema(new File(schemaURI));
+
+      // set the schema and the event handler.
+      unmarshaller.setSchema(schema);
+      unmarshaller.setEventHandler(new ValidationEventHandler()
+      {
+         // allow unmarshalling to continue even if there are errors.
+         public boolean handleEvent(ValidationEvent ve)
+         {
+            if (ve.getSeverity() != ValidationEvent.WARNING)
+            {
+               ValidationEventLocator vel = ve.getLocator();
+               System.out.println("Line:Col[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + "]:"
+                     + ve.getMessage());
+            }
+            return true;
+         }
+      });
+   }
+}

Added: identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/collection-request.xml
===================================================================
--- identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/collection-request.xml	                        (rev 0)
+++ identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/collection-request.xml	2009-01-07 19:31:25 UTC (rev 203)
@@ -0,0 +1,24 @@
+<wst:RequestSecurityTokenCollection xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy/" 
+   xmlns:wsa="http://www.w3.org/2005/08/addressing/">
+
+   <!-- identity token request -->
+   <wst:RequestSecurityToken Context="http://www.example.com/1">
+      <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</wst:TokenType>
+      <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue</wst:RequestType>
+      <wsp:AppliesTo>
+         <wsa:EndpointReference>
+            <wsa:Address>http://manufacturer.example.com/</wsa:Address>
+         </wsa:EndpointReference>
+      </wsp:AppliesTo>
+      <wsp:PolicyReference URI="http://manufacturer.example.com/IdentityPolicy"/>
+   </wst:RequestSecurityToken>
+
+   <!-- certification claim token request -->
+   <wst:RequestSecurityToken Context="http://www.example.com/2">
+      <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</wst:TokenType>
+      <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512 /BatchIssue</wst:RequestType>
+      <wst:Claims>http://manufacturer.example.com/certification</wst:Claims>
+      <wsp:PolicyReference URI="http://certificationbody.example.org/certificationPolicy"/>
+   </wst:RequestSecurityToken>
+
+</wst:RequestSecurityTokenCollection>

Added: identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/simple-request.xml
===================================================================
--- identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/simple-request.xml	                        (rev 0)
+++ identity-federation/trunk/identity-fed-model/src/test/resources/wstrust/simple-request.xml	2009-01-07 19:31:25 UTC (rev 203)
@@ -0,0 +1,4 @@
+<wst:RequestSecurityToken xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512/">
+   <wst:TokenType>http://example.org/mySpecialToken</wst:TokenType>
+   <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</wst:RequestType>
+</wst:RequestSecurityToken>
\ No newline at end of file




More information about the jboss-identity-commits mailing list