You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/01/11 12:23:40 UTC
svn commit: r1057583 - in /santuario/xml-security-java/trunk: ./
src/test/java/org/apache/xml/security/c14n/implementations/
src/test/java/org/apache/xml/security/test/
src/test/java/org/apache/xml/security/test/algorithms/
src/test/java/org/apache/xml...
Author: coheigea
Date: Tue Jan 11 11:23:39 2011
New Revision: 1057583
URL: http://svn.apache.org/viewvc?rev=1057583&view=rev
Log:
[SANTUARIO-257] - More work on the tests.
Removed:
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/AllTests.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/AllTests.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/EncryptionTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/ModuleTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/AllTests.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/package.html
Modified:
santuario/xml-security-java/trunk/build.xml
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTableTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/UtfHelperTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/CreateExclC14nInteropValues.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/TestUtils.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/AttrCompareTest.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/C14nHelperTest.java
Modified: santuario/xml-security-java/trunk/build.xml
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/build.xml?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/build.xml (original)
+++ santuario/xml-security-java/trunk/build.xml Tue Jan 11 11:23:39 2011
@@ -370,7 +370,7 @@
<formatter type="plain" usefile="false"/>
<batchtest fork="yes" todir="${dir.build.junit.xml}">
<fileset dir="${dir.src.test}">
- <include name="org/apache/xml/security/test/AllTests.java"/>
+ <include name="org/apache/xml/security/**/*Test.java"/>
</fileset>
</batchtest>
<test if="ibm.available" name="org.apache.xml.security.test.interop.IBMTest" todir="${dir.build.junit.xml}"/>
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTableTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTableTest.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTableTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/NameSpaceSymbTableTest.java Tue Jan 11 11:23:39 2011
@@ -21,135 +21,150 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
-public class NameSpaceSymbTableTest extends TestCase {
- public static Test suite() {
- return new TestSuite(NameSpaceSymbTableTest.class);
- }
- static Attr node1,node2;
+public class NameSpaceSymbTableTest extends org.junit.Assert {
+ static Attr node1,node2;
static {
try {
- Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- node1=doc.createAttributeNS("a","b");
- node2=doc.createAttributeNS("b","c");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void testNullFirstXmlns() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ node1 = doc.createAttributeNS("a","b");
+ node2 = doc.createAttributeNS("b","c");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @org.junit.Test
+ public void testNullFirstXmlns() {
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
assertNull(ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testXmlnsPut() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- assertEquals(node1,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://a", node1);
+ assertEquals(node1, ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testXmlnsMap() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- assertEquals(node1,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://a", node1);
+ assertEquals(node1, ns.getMapping("xmlns"));
ns.pop();
- assertEquals(null,ns.getMapping("xmlns"));
+ assertEquals(null, ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testXmlnsMap2() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
+ ns.addMapping("xmlns", "http://a", node1);
ns.pop();
ns.pop();
- assertEquals(null,ns.getMapping("xmlns"));
+ assertEquals(null, ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testXmlnsPrefix() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- assertEquals(node1,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://a", node1);
+ assertEquals(node1, ns.getMapping("xmlns"));
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- assertEquals(null,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://a", node1);
+ assertEquals(null, ns.getMapping("xmlns"));
ns.push();
- ns.addMapping("xmlns","http://b",node1);
- assertEquals(node1,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://b", node1);
+ assertEquals(node1, ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testXmlnsRemovePrefix() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- assertEquals(node1,ns.getMapping("xmlns"));
+ ns.addMapping("xmlns", "http://a", node1);
+ assertEquals(node1, ns.getMapping("xmlns"));
ns.pop();
assertNull(ns.getMapping("xmlns"));
}
+
+ @org.junit.Test
public void testPrefix() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("a","http://a",node1);
- assertEquals(node1,ns.getMapping("a"));
+ ns.addMapping("a", "http://a", node1);
+ assertEquals(node1, ns.getMapping("a"));
ns.push();
assertNull(ns.getMapping("a"));
ns.push();
- ns.addMapping("a","http://c",node1);
- assertEquals(node1,ns.getMapping("a"));
+ ns.addMapping("a", "http://c",node1);
+ assertEquals(node1, ns.getMapping("a"));
ns.pop();
ns.push();
assertNull(ns.getMapping("a"));
- ns.addMapping("a","http://c",node1);
- assertEquals(node1,ns.getMapping("a"));
+ ns.addMapping("a", "http://c",node1);
+ assertEquals(node1, ns.getMapping("a"));
}
+
+ @org.junit.Test
public void testSeveralPrefixes() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("a","http://a",node1);
- ns.addMapping("b","http://b",node2);
- assertEquals(node1,ns.getMapping("a"));
- assertEquals(node2,ns.getMapping("b"));
+ ns.addMapping("a", "http://a",node1);
+ ns.addMapping("b", "http://b",node2);
+ assertEquals(node1, ns.getMapping("a"));
+ assertEquals(node2, ns.getMapping("b"));
ns.push();
assertNull(ns.getMapping("a"));
- }
+ }
+
+ @org.junit.Test
public void testSeveralPrefixes2() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- ns.addMapping("a","http://a",node1);
+ ns.addMapping("a", "http://a",node1);
ns.push();
- assertEquals(node1,ns.getMapping("a"));
+ assertEquals(node1, ns.getMapping("a"));
ns.pop();
- assertEquals(node1,ns.getMapping("a"));
- }
+ assertEquals(node1, ns.getMapping("a"));
+ }
+
+ @org.junit.Test
public void testGetUnrenderedNodes() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- List l=new ArrayList();
- ns.addMapping("xmlns","http://a",node1);
+ List<Attr> l = new ArrayList<Attr>();
+ ns.addMapping("xmlns", "http://a", node1);
ns.push();
ns.getUnrenderedNodes(l);
assertTrue(l.contains(node1));
- Attr n=(Attr)ns.addMappingAndRender("xmlns","",node2);
- assertNotNull("xmlns=\"\" not rendered",n);
+ Attr n = (Attr)ns.addMappingAndRender("xmlns", "", node2);
+ assertNotNull("xmlns=\"\" not rendered", n);
assertEquals(n, node2);
}
+
+ @org.junit.Test
public void testUnrederedNodes() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
ns.push();
- List l=new ArrayList();
+ List<Attr> l = new ArrayList<Attr>();
ns.getUnrenderedNodes(l);
assertTrue(l.isEmpty());
l.clear();
ns.push();
- ns.addMapping("xmlns","http://a",node1);
- ns.addMapping("a","http://a",node2);
+ ns.addMapping("xmlns","http://a", node1);
+ ns.addMapping("a", "http://a", node2);
ns.push();
-
+
ns.getUnrenderedNodes(l);
assertTrue(l.contains(node1));
assertTrue(l.contains(node2));
@@ -164,23 +179,23 @@ public class NameSpaceSymbTableTest exte
ns.getUnrenderedNodes(l);
assertTrue(l.contains(node1));
assertTrue(l.contains(node2));
-
}
+
+ @org.junit.Test
public void testBug38655() {
- NameSpaceSymbTable ns=new NameSpaceSymbTable();
- ns.push();
-
- ns.addMappingAndRender("generated-command","http://foo.com/command",node1);
- ns.addMappingAndRender("generated-event","http://foo.com/event",node1);
- ns.addMappingAndRender("command","http://foo.com/command",node1);
- ns.addMappingAndRender("ui","http://foo.com/ui",node1);
- ns.addMappingAndRender("event","http://foo.com/event",node1);
- ns.addMappingAndRender("instruction","http://foo/instruction",node1);
- ns.addMappingAndRender("directory","http://foo.com/io/directory",node1);
- ns.addMappingAndRender("function","http://foo.com/function",node1);
- ns.addMappingAndRender("xmlns","http://www.w3.org/1999/xhtml",node1);
- ns.addMappingAndRender("ctrl","http://foo.com/controls",node1);
- ns.addMappingAndRender("wiki","http://foo.com/samples/wiki",node1);
-
+ NameSpaceSymbTable ns = new NameSpaceSymbTable();
+ ns.push();
+
+ ns.addMappingAndRender("generated-command", "http://foo.com/command",node1);
+ ns.addMappingAndRender("generated-event", "http://foo.com/event",node1);
+ ns.addMappingAndRender("command", "http://foo.com/command",node1);
+ ns.addMappingAndRender("ui", "http://foo.com/ui", node1);
+ ns.addMappingAndRender("event", "http://foo.com/event", node1);
+ ns.addMappingAndRender("instruction", "http://foo/instruction", node1);
+ ns.addMappingAndRender("directory", "http://foo.com/io/directory", node1);
+ ns.addMappingAndRender("function", "http://foo.com/function", node1);
+ ns.addMappingAndRender("xmlns", "http://www.w3.org/1999/xhtml", node1);
+ ns.addMappingAndRender("ctrl", "http://foo.com/controls", node1);
+ ns.addMappingAndRender("wiki", "http://foo.com/samples/wiki", node1);
}
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/UtfHelperTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/UtfHelperTest.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/UtfHelperTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/c14n/implementations/UtfHelperTest.java Tue Jan 11 11:23:39 2011
@@ -20,54 +20,56 @@ import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class UtfHelperTest extends TestCase {
- public void testBug40156() {
- String s="\u00e4\u00f6\u00fc";
- byte a[]=UtfHelpper.getStringInUtf8(s);
- try {
- byte correct[]=s.getBytes("UTF8");
- boolean equals=Arrays.equals(correct, a);
- assertTrue(equals);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+public class UtfHelperTest extends org.junit.Assert {
+
+ @org.junit.Test
+ public void testBug40156() {
+ String s = "\u00e4\u00f6\u00fc";
+ byte a[] = UtfHelpper.getStringInUtf8(s);
+ try {
+ byte correct[] = s.getBytes("UTF8");
+ boolean equals = Arrays.equals(correct, a);
+ assertTrue(equals);
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- public void testUtf() throws Exception {
- int chunk=1<<16; int j=0;
- ByteArrayOutputStream charByCharOs=new ByteArrayOutputStream();
- ByteArrayOutputStream strOs=new ByteArrayOutputStream();
-
- char chs[]=new char[chunk];
- for (int i=0;i<chunk; i++) {
- int ch=(chunk*j)+i;
- if (ch==0xDBFF) {
- ch=1;
- }
- chs[i]=(char)ch;
- UtfHelpper.writeCharToUtf8((char) ch, charByCharOs);
- }
- String str=new String(chs);
- byte a[]=UtfHelpper.getStringInUtf8(str);
- try {
- // System.out.println("chunk:"+j);
- byte correct[]=str.getBytes("UTF8");
- assertTrue("UtfHelper.getStringInUtf8 failse",Arrays.equals(correct, a));
- assertTrue("UtfHelper.getStringInUtf8 failse",Arrays.equals(correct, charByCharOs.toByteArray()));
- UtfHelpper.writeStringToUtf8(str, strOs);
- assertTrue("UtfHelper.writeStringToUtf8 failse",Arrays.equals(correct, strOs.toByteArray()));
-
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
+ }
+
+ @org.junit.Test
+ public void testUtf() throws Exception {
+ int chunk = 1 << 16;
+ int j = 0;
+ ByteArrayOutputStream charByCharOs = new ByteArrayOutputStream();
+ ByteArrayOutputStream strOs = new ByteArrayOutputStream();
+
+ char chs[] = new char[chunk];
+ for (int i = 0; i < chunk; i++) {
+ int ch = (chunk * j) + i;
+ if (ch == 0xDBFF) {
+ ch = 1;
+ }
+ chs[i] = (char)ch;
+ UtfHelpper.writeCharToUtf8((char)ch, charByCharOs);
}
- public static Test suite() {
- return new TestSuite(UtfHelperTest.class);
+ String str = new String(chs);
+ byte a[] = UtfHelpper.getStringInUtf8(str);
+ try {
+ // System.out.println("chunk:"+j);
+ byte correct[] = str.getBytes("UTF8");
+ assertTrue("UtfHelper.getStringInUtf8 false", Arrays.equals(correct, a));
+ assertTrue(
+ "UtfHelper.getStringInUtf8 false",
+ Arrays.equals(correct, charByCharOs.toByteArray())
+ );
+ UtfHelpper.writeStringToUtf8(str, strOs);
+ assertTrue(
+ "UtfHelper.writeStringToUtf8 false",
+ Arrays.equals(correct, strOs.toByteArray())
+ );
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
}
+ }
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/CreateExclC14nInteropValues.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/CreateExclC14nInteropValues.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/CreateExclC14nInteropValues.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/CreateExclC14nInteropValues.java Tue Jan 11 11:23:39 2011
@@ -36,467 +36,420 @@ import org.w3c.dom.Document;
/**
* Class CreateExclC14nInteropValues
- *
- * @author $Author$
- * @version $Revision$
*/
public class CreateExclC14nInteropValues {
- /**
- * Method main
- *
- * @param unused
- * @throws Exception
- */
- public static void main(String unused[]) throws Exception {
+ /**
+ * Method main
+ *
+ * @param unused
+ * @throws Exception
+ */
+ public static void main(String unused[]) throws Exception {
+
+ org.apache.xml.security.Init.init();
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+ dbf.setNamespaceAware(true);
+
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.newDocument();
+ String directory = "data/org/apache/xml/security/c14n/outExcl/";
+ File signatureFile = new File(directory + "apacheSignature.xml");
+ XMLSignature xmlSignature = new XMLSignature(doc,
+ signatureFile.toURI().toURL().toString(),
+ XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
+
+ doc.appendChild(xmlSignature.getElement());
+ {
+ // ref 0
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ xmlSignature.addDocument("iaikTests.example1.xml", tf);
+ }
+
+ {
+ // ref 1
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
+ xmlSignature.addDocument("iaikTests.example1.xml", tf);
+ }
+
+ {
+ // ref 2
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ xmlSignature.addDocument("iaikTests.example2.xml", tf);
+ }
+
+ {
+ // ref 3
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
+ xmlSignature.addDocument("iaikTests.example2.xml", tf);
+ }
+
+ {
+ // ref 4
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:default",
+ "http://example.org/default");
+ xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
+ xc.setXPath(
+ "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+
+ xmlSignature.addDocument("iaikTests.example3.xml", tf);
+ }
+
+ {
+ // ref 5
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:default",
+ "http://example.org/default");
+ xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
+ xc.setXPath(
+ "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
+ xmlSignature.addDocument("iaikTests.example3.xml", tf);
+ }
+
+ {
+ // ref 6
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ xmlSignature.addDocument("iaikTests.example4.xml", tf);
+ }
+
+ {
+ // ref 7
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
+ xc.setXPath(
+ "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ {
+ InclusiveNamespaces incNS = new InclusiveNamespaces(doc, "ns2");
+
+ tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS,
+ incNS.getElement());
+ }
+ xmlSignature.addDocument("iaikTests.example4.xml", tf);
+ }
+
+ {
+ // ref 8
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object1";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='uk'>" + "\n"
+ + "<included >" + "\n" + "</included>"
+ + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
+ + "\n" + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- org.apache.xml.security.Init.init();
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
- dbf.setNamespaceAware(true);
-
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.newDocument();
- String directory = "data/org/apache/xml/security/c14n/outExcl/";
- File signatureFile = new File(directory + "apacheSignature.xml");
- XMLSignature xmlSignature = new XMLSignature(doc,
- signatureFile.toURL().toString(),
- XMLSignature.ALGO_ID_MAC_HMAC_SHA1);
-
- doc.appendChild(xmlSignature.getElement());
-
- {
-
- // ref 0
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("iaikTests.example1.xml", tf);
- }
-
- {
-
- // ref 1
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
- xmlSignature.addDocument("iaikTests.example1.xml", tf);
- }
-
- {
-
- // ref 2
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("iaikTests.example2.xml", tf);
- }
-
- {
-
- // ref 3
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
- xmlSignature.addDocument("iaikTests.example2.xml", tf);
- }
-
- {
-
- // ref 4
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:default",
- "http://example.org/default");
- xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
- xc.setXPath(
- "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("iaikTests.example3.xml", tf);
- }
-
- {
-
- // ref 5
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:default",
- "http://example.org/default");
- xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
- xc.setXPath(
- "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
- xmlSignature.addDocument("iaikTests.example3.xml", tf);
- }
-
- {
-
- // ref 6
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("iaikTests.example4.xml", tf);
- }
-
- {
-
- // ref 7
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
- xc.setXPath(
- "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- {
- InclusiveNamespaces incNS = new InclusiveNamespaces(doc, "ns2");
-
- tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS,
- incNS.getElement());
- }
-
- xmlSignature.addDocument("iaikTests.example4.xml", tf);
- }
-
- {
-
- // ref 8
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object1";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='uk'>" + "\n"
- + "<included >" + "\n" + "</included>"
- + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
- + "\n" + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
-
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- // ref apache_8
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("#" + id, tf);
- }
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- {
+ // ref apache_8
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 9
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object2";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:lang='uk'>" + "\n"
+ + "<notIncluded xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='uk'>" + "\n"
+ + "<included >" + "\n" + "</included>"
+ + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
+ + "\n" + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- // ref 9
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object2";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:lang='uk'>" + "\n"
- + "<notIncluded xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='uk'>" + "\n"
- + "<included >" + "\n" + "</included>"
- + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
- + "\n" + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
-
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- // ref apache_8
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- xmlSignature.addDocument("#" + id, tf);
- }
+ // ref apache_8
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 10
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object3";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='uk'>" + "\n"
+ + "<included xml:lang='de'>" + "\n" + "</included>"
+ + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
+ + "\n" + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- {
-
- // ref 10
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object3";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='uk'>" + "\n"
- + "<included xml:lang='de'>" + "\n" + "</included>"
- + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
- + "\n" + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
-
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- // ref apache_8
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
+ // ref apache_8
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 11
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object4";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:lang='de'>" + "\n"
+ + "<included xml:lang='de'>" + "\n"
+ + "<notIncluded xml:lang='uk'>" + "\n"
+ + "<included >" + "\n" + "</included>"
+ + "\n" + "</notIncluded>" + "\n" + "</included>"
+ + "\n" + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- xmlSignature.addDocument("#" + id, tf);
- }
-
- {
-
- // ref 11
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object4";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:lang='de'>" + "\n"
- + "<included xml:lang='de'>" + "\n"
- + "<notIncluded xml:lang='uk'>" + "\n"
- + "<included >" + "\n" + "</included>"
- + "\n" + "</notIncluded>" + "\n" + "</included>"
- + "\n" + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
-
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- Transforms tf = new Transforms(doc);
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- {
- XPathContainer xc = new XPathContainer(doc);
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 12
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object5";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:lang='de'>"
+ + "\n"
+ + "<included xml:lang='de'>"
+ + "\n"
+ + "<notIncluded xml:space='preserve' xml:lang='uk'>"
+ + "\n" + "<included >" + "\n"
+ + "</included>" + "\n" + "</notIncluded>" + "\n"
+ + "</included>" + "\n" + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("#" + id, tf);
- }
-
- {
-
- // ref 12
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object5";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:lang='de'>"
- + "\n"
- + "<included xml:lang='de'>"
- + "\n"
- + "<notIncluded xml:space='preserve' xml:lang='uk'>"
- + "\n" + "<included >" + "\n"
- + "</included>" + "\n" + "</notIncluded>" + "\n"
- + "</included>" + "\n" + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
-
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("#" + id, tf);
- }
-
- {
-
- // ref 13
- ObjectContainer obj = new ObjectContainer(doc);
- String id = "object6";
-
- obj.setId(id);
-
- String xmlStr = "" + "<included xml:space='preserve' xml:lang='de'>"
- + "\n"
- + "<included xml:lang='de'>"
- + "\n"
- + "<notIncluded xml:lang='uk'>"
- + "\n" + "<included>" + "\n" + "</included>" + "\n"
- + "</notIncluded>" + "\n" + "</included>" + "\n"
- + "</included>";
- Document importDoc =
- db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 13
+ ObjectContainer obj = new ObjectContainer(doc);
+ String id = "object6";
+
+ obj.setId(id);
+
+ String xmlStr = "" + "<included xml:space='preserve' xml:lang='de'>"
+ + "\n"
+ + "<included xml:lang='de'>"
+ + "\n"
+ + "<notIncluded xml:lang='uk'>"
+ + "\n" + "<included>" + "\n" + "</included>" + "\n"
+ + "</notIncluded>" + "\n" + "</included>" + "\n"
+ + "</included>";
+ Document importDoc =
+ db.parse(new ByteArrayInputStream(xmlStr.getBytes()));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- obj.getElement()
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ obj.getElement()
.appendChild(doc.importNode(importDoc.getDocumentElement(), true));
- obj.getElement().appendChild(doc.createTextNode("\n"));
- xmlSignature.appendObject(obj);
-
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- }
-
- xmlSignature.addDocument("#" + id, tf);
- }
-
- {
-
- // ref 13b
- String id = "object6";
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
- }
-
- xmlSignature.addDocument("#" + id, tf);
- }
-
- {
-
- // ref 13c
- String id = "object6";
- Transforms tf = new Transforms(doc);
-
- {
- XPathContainer xc = new XPathContainer(doc);
-
- xc.setXPath("self::node()[local-name()='included']");
- tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
- tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
- tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
- }
-
- xmlSignature.addDocument("#" + id, tf);
- // xmlSignature.addDocument("#" + id, tf, org.apache.xml.security.algorithms.MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1, "ref13c", null);
- }
-
- String secretKey = "secret";
-
- xmlSignature.getKeyInfo().addKeyName("The UTF-8 octets of \"" + secretKey
- + "\" are used for signing ("
- + secretKey.length() + " octets)");
- xmlSignature.sign(xmlSignature.createSecretKey(secretKey.getBytes()));
-
- FileOutputStream fos = new FileOutputStream(signatureFile);
-
- XMLUtils.outputDOM(doc, fos);
- fos.close();
-
- int length = xmlSignature.getSignedInfo().getLength();
-
- for (int i = 0; i < length; i++) {
- String fname = directory + "c14n-" + i + "-apache.xml";
-
- System.out.println(fname);
- JavaUtils.writeBytesToFilename(fname, xmlSignature.getSignedInfo().getReferencedContentAfterTransformsItem(i).getBytes());
- }
+ obj.getElement().appendChild(doc.createTextNode("\n"));
+ xmlSignature.appendObject(obj);
- XMLSignature s = new XMLSignature(doc.getDocumentElement(),
- signatureFile.toURL().toString());
- boolean verify =
- s.checkSignatureValue(s.createSecretKey("secret".getBytes()));
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ }
+
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 13b
+ String id = "object6";
+ Transforms tf = new Transforms(doc);
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
+ }
+ xmlSignature.addDocument("#" + id, tf);
+ }
+
+ {
+ // ref 13c
+ String id = "object6";
+ Transforms tf = new Transforms(doc);
+
+ {
+ XPathContainer xc = new XPathContainer(doc);
+
+ xc.setXPath("self::node()[local-name()='included']");
+ tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
+ tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
+ tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
+ }
+ xmlSignature.addDocument("#" + id, tf);
+ // xmlSignature.addDocument("#" + id, tf, org.apache.xml.security.algorithms.MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1, "ref13c", null);
+ }
+
+ String secretKey = "secret";
+
+ xmlSignature.getKeyInfo().addKeyName("The UTF-8 octets of \"" + secretKey
+ + "\" are used for signing ("
+ + secretKey.length() + " octets)");
+ xmlSignature.sign(xmlSignature.createSecretKey(secretKey.getBytes()));
+
+ FileOutputStream fos = new FileOutputStream(signatureFile);
+
+ XMLUtils.outputDOM(doc, fos);
+ fos.close();
+
+ int length = xmlSignature.getSignedInfo().getLength();
+
+ for (int i = 0; i < length; i++) {
+ String fname = directory + "c14n-" + i + "-apache.xml";
+
+ System.out.println(fname);
+ JavaUtils.writeBytesToFilename(fname, xmlSignature.getSignedInfo().getReferencedContentAfterTransformsItem(i).getBytes());
+ }
+
+ XMLSignature s = new XMLSignature(doc.getDocumentElement(),
+ signatureFile.toURI().toURL().toString());
+ boolean verify =
+ s.checkSignatureValue(s.createSecretKey("secret".getBytes()));
- System.out.println("verify=" + verify);
+ System.out.println("verify=" + verify);
- System.out.println("");
+ System.out.println("");
- XMLUtils.outputDOMc14nWithComments(doc, System.out);
- }
+ XMLUtils.outputDOMc14nWithComments(doc, System.out);
+ }
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/TestUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/TestUtils.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/TestUtils.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/TestUtils.java Tue Jan 11 11:23:39 2011
@@ -22,27 +22,22 @@ import org.w3c.dom.Element;
public class TestUtils {
- /**
- * Method createDSctx
- *
- * @param doc
- * @param prefix
- * @param namespace
- * @return the element.
- */
- public static Element createDSctx(Document doc, String prefix,
- String namespace) {
-
- if ((prefix == null) || (prefix.trim().length() == 0)) {
- throw new IllegalArgumentException("You must supply a prefix");
- }
-
- Element ctx = doc.createElementNS(null, "namespaceContext");
-
- ctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix.trim(),
- namespace);
-
- return ctx;
- }
+ /**
+ * Method createDSctx
+ *
+ * @param doc
+ * @param prefix
+ * @param namespace
+ * @return the element.
+ */
+ public static Element createDSctx(Document doc, String prefix, String namespace) {
+ if ((prefix == null) || (prefix.trim().length() == 0)) {
+ throw new IllegalArgumentException("You must supply a prefix");
+ }
+
+ Element ctx = doc.createElementNS(null, "namespaceContext");
+ ctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix.trim(), namespace);
+ return ctx;
+ }
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/algorithms/SignatureAlgorithmTest.java Tue Jan 11 11:23:39 2011
@@ -21,46 +21,45 @@ import java.security.PrivateKey;
import javax.xml.parsers.DocumentBuilderFactory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.apache.xml.security.algorithms.SignatureAlgorithm;
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.signature.XMLSignature;
import org.w3c.dom.Document;
-public class SignatureAlgorithmTest extends TestCase {
-
+public class SignatureAlgorithmTest extends org.junit.Assert {
+
/** {@link org.apache.commons.logging} logging facility */
static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(SignatureAlgorithmTest.class.getName());
- static {
- org.apache.xml.security.Init.init();
- }
-
- public void testSameKeySeveralAlgorithmSigning() throws Exception {
- Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- SignatureAlgorithm signatureAlgorithm = new SignatureAlgorithm(doc,XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
- PrivateKey pk=KeyPairGenerator.getInstance("RSA").genKeyPair().getPrivate();
- signatureAlgorithm.initSign(pk);
- signatureAlgorithm.update((byte)2);
- signatureAlgorithm.sign();
- SignatureAlgorithm otherSignatureAlgorithm =
- new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256);
-
- try {
- otherSignatureAlgorithm.initSign(pk);
- } catch (XMLSecurityException ex) {
- log.warn("Test testSameKeySeveralAlgorithmSigning skipped as necessary algorithms not available");
+ static {
+ org.apache.xml.security.Init.init();
+ }
+
+ @org.junit.Test
+ public void testSameKeySeveralAlgorithmSigning() throws Exception {
+ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ SignatureAlgorithm signatureAlgorithm =
+ new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1);
+ PrivateKey pk = KeyPairGenerator.getInstance("RSA").genKeyPair().getPrivate();
+ signatureAlgorithm.initSign(pk);
+ signatureAlgorithm.update((byte)2);
+ signatureAlgorithm.sign();
+ SignatureAlgorithm otherSignatureAlgorithm =
+ new SignatureAlgorithm(doc, XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256);
+
+ try {
+ otherSignatureAlgorithm.initSign(pk);
+ } catch (XMLSecurityException ex) {
+ log.warn(
+ "Test testSameKeySeveralAlgorithmSigning skipped as necessary algorithms "
+ + "not available"
+ );
return;
}
-
- otherSignatureAlgorithm.update((byte)2);
- otherSignatureAlgorithm.sign();
- }
- public static Test suite() {
- return new TestSuite(SignatureAlgorithmTest.class);
- }
+
+ otherSignatureAlgorithm.update((byte)2);
+ otherSignatureAlgorithm.sign();
+ }
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/AttrCompareTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/AttrCompareTest.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/AttrCompareTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/AttrCompareTest.java Tue Jan 11 11:23:39 2011
@@ -16,16 +16,10 @@
*/
package org.apache.xml.security.test.c14n.helper;
-
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.apache.xml.security.c14n.helper.AttrCompare;
import org.apache.xml.security.utils.Constants;
import org.w3c.dom.Attr;
@@ -39,227 +33,201 @@ import org.w3c.dom.NamedNodeMap;
*
* @author Christian Geuer-Pollmann
*/
-public class AttrCompareTest extends TestCase {
+public class AttrCompareTest extends org.junit.Assert {
+
+ static {
+ org.apache.xml.security.Init.init();
+ }
+
+ /**
+ * Method testA1
+ *
+ * @throws ParserConfigurationException
+ */
+ @org.junit.Test
+ public void testA1() throws ParserConfigurationException {
+
+ Document doc = createDoc("documentElement");
+ Element root = doc.getDocumentElement();
+ Attr attr0 = createAttr(doc, "xmlns", "http://default/", Constants.NamespaceSpecNS);
+ Attr attr1 = createAttr(doc, "xmlns:b", "http://val1/", Constants.NamespaceSpecNS);
+
+ root.setAttributeNode(attr0);
+ root.setAttributeNode(attr1);
+
+ NamedNodeMap nnm = root.getAttributes();
+
+ assertEquals("nnm.getLength()", nnm.getLength(), 2);
+
+ Attr attr00 = (Attr) nnm.item(0);
+ Attr attr10 = (Attr) nnm.item(1);
+
+ assertNotNull("Attribute attr00", attr00);
+ assertNotNull("Attribute attr10", attr10);
+
+ AttrCompare attrCompare = new AttrCompare();
+
+ assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
+ assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
+ }
+
+ @org.junit.Test
+ public void testA2() throws ParserConfigurationException {
+
+ Document doc = createDoc("documentElement");
+ Attr attr0 = doc.createAttributeNS(null, "foo");
+ Attr attr1 = doc.createAttributeNS("http://goo", "goo:foo");
+
+ // System.out.println("Attr1: " + attr1 + " (" + attr1.getLocalName() +")");
+
+
+ AttrCompare attrCompare = new AttrCompare();
+
+ assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
+ assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
+
+ }
+
+ /**
+ * Method testA2
+ *
+ * @throws ParserConfigurationException
+ */
+ @org.junit.Test
+ public void __testA2() throws ParserConfigurationException {
+
+ Document doc = createDoc("documentElement");
+ Element root = doc.getDocumentElement();
+ Attr attr0 = createAttr(doc, "aAttr", "val0", null);
+ Attr attr1 = createAttr(doc, "bAttr", "val1", null);
+
+ root.setAttributeNode(attr0);
+ root.setAttributeNode(attr1);
+
+ NamedNodeMap nnm = root.getAttributes();
+
+ assertEquals("nnm.getLength()", nnm.getLength(), 2);
+
+ Attr attr00 = (Attr) nnm.item(0);
+ Attr attr10 = (Attr) nnm.item(1);
+
+ assertNotNull("Attribute attr00", attr00);
+ assertNotNull("Attribute attr10", attr10);
+
+ AttrCompare attrCompare = new AttrCompare();
+
+ assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
+ assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
+ }
+
+ /**
+ * This test uses the attrs[] array to compare every attribute against
+ * the others (and vice versa).
+ *
+ * The attribute values are taken from example 3.3 Start and End Tags
+ * http://www.w3.org/TR/2001/REC-xml-c14n-20010315#Example-SETags
+ *
+ * @throws ParserConfigurationException
+ */
+ @org.junit.Test
+ public void testComplete() throws ParserConfigurationException {
+
+ /* <e5 xmlns="http://example.org"
+ * xmlns:a="http://www.w3.org"
+ * xmlns:b="http://www.ietf.org"
+ * attr="I'm"
+ * attr2="all"
+ * b:attr="sorted"
+ * a:attr="out"></e5>
+ */
+ Document doc = createDoc("documentElement");
+ Element root = doc.getDocumentElement();
+
+ // This List has to be ordered to verify correctness of the comparison
+ //J-
+ Attr attrs[] = {
+ createAttr(doc, "xmlns", "http://example.org", Constants.NamespaceSpecNS),
+ createAttr(doc, "xmlns:a", "http://www.w3.org", Constants.NamespaceSpecNS),
+ createAttr(doc, "xmlns:b", "http://www.ietf.org", Constants.NamespaceSpecNS),
+ createAttr(doc, "attr", "I'm", null),
+ createAttr(doc, "attr2", "all", null),
+ createAttr(doc, "b:attr", "sorted", "http://www.ietf.org"),
+ createAttr(doc, "a:attr", "out", "http://www.w3.org") };
+
+ //J+
+ for (int i = 0; i < attrs.length; i++) {
+ root.setAttributeNode(attrs[i]);
+ }
+
+ NamedNodeMap nnm = root.getAttributes();
+
+ assertEquals("nnm.getLength()", nnm.getLength(), attrs.length);
+
+ for (int i = 0; i < attrs.length; i++) {
+ Attr attr = attrs[i];
+ assertNotNull("Attribute attr", attr);
+ }
+
+ AttrCompare attrCompare = new AttrCompare();
+
+ for (int i = 0; i < attrs.length; i++) {
+ for (int j = i + 1; j < attrs.length; j++) {
+ Attr attr0 = attrs[i];
+ Attr attr1 = attrs[j];
+ assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
+ assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
+ }
+ }
+ }
+
+ /**
+ * Method createAttr
+ *
+ * @param doc
+ * @param QName
+ * @param Value
+ * @param NamespaceURI
+ * @return
+ */
+ private static Attr createAttr(
+ Document doc, String QName, String Value, String NamespaceURI
+ ) {
+ Attr attr = null;
+
+ if ((NamespaceURI != null) && (NamespaceURI.length() > 0)) {
+ attr = doc.createAttributeNS(NamespaceURI, QName);
+ } else {
+ attr = doc.createAttributeNS(null, QName);
+ }
+
+ attr.appendChild(doc.createTextNode(Value));
+
+ return attr;
+ }
+
+ /**
+ * Method createDoc
+ *
+ * @param documentElement
+ * @return
+ * @throws ParserConfigurationException
+ */
+ private static Document createDoc(
+ String documentElement
+ ) throws ParserConfigurationException {
+ DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = dfactory.newDocumentBuilder();
+
+ dfactory.setNamespaceAware(true);
+
+ Document doc = documentBuilder.newDocument();
+ Element root = doc.createElementNS(null, documentElement);
+
+ doc.appendChild(root);
+
+ return doc;
+ }
+
+}
- /**
- * Method suite
- *
- * @return
- */
- public static Test suite() {
- return new TestSuite(AttrCompareTest.class);
- }
-
- /**
- * Constructor AttrCompareTest
- *
- * @param Name_
- */
- public AttrCompareTest(String Name_) {
- super(Name_);
- }
-
- /**
- * Method main
- *
- * @param args
- */
- public static void main(String[] args) {
-
- String[] testCaseName = { "-noloading", AttrCompareTest.class.getName() };
-
- junit.textui.TestRunner.main(testCaseName);
- }
-
- /**
- * Method createAttr
- *
- * @param doc
- * @param QName
- * @param Value
- * @param NamespaceURI
- * @return
- */
- private static Attr createAttr(Document doc, String QName, String Value,
- String NamespaceURI) {
-
- Attr attr = null;
-
- if ((NamespaceURI != null) && (NamespaceURI.length() > 0)) {
- attr = doc.createAttributeNS(NamespaceURI, QName);
- } else {
- attr = doc.createAttributeNS(null, QName);
- }
-
- attr.appendChild(doc.createTextNode(Value));
-
- return attr;
- }
-
- /**
- * Method createDoc
- *
- * @param documentElement
- * @return
- * @throws ParserConfigurationException
- */
- private static Document createDoc(String documentElement)
- throws ParserConfigurationException {
-
- DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder documentBuilder = dfactory.newDocumentBuilder();
-
- dfactory.setNamespaceAware(true);
-
- Document doc = documentBuilder.newDocument();
- Element root = doc.createElementNS(null, documentElement);
-
- doc.appendChild(root);
-
- return doc;
- }
-
- /**
- * Method testA1
- *
- * @throws ParserConfigurationException
- */
- public static void testA1() throws ParserConfigurationException {
-
- Document doc = createDoc("documentElement");
- Element root = doc.getDocumentElement();
- Attr attr0 = createAttr(doc, "xmlns", "http://default/", Constants.NamespaceSpecNS);
- Attr attr1 = createAttr(doc, "xmlns:b", "http://val1/", Constants.NamespaceSpecNS);
-
- root.setAttributeNode(attr0);
- root.setAttributeNode(attr1);
-
- NamedNodeMap nnm = root.getAttributes();
-
- assertEquals("nnm.getLength()", nnm.getLength(), 2);
-
- Attr attr00 = (Attr) nnm.item(0);
- Attr attr10 = (Attr) nnm.item(1);
-
- assertNotNull("Attribute attr00", attr00);
- assertNotNull("Attribute attr10", attr10);
-
- AttrCompare attrCompare = new AttrCompare();
-
- assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
- assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
- }
-
- public static void testA2() throws ParserConfigurationException {
-
- Document doc = createDoc("documentElement");
- Attr attr0 = doc.createAttributeNS(null, "foo");
- Attr attr1 = doc.createAttributeNS("http://goo", "goo:foo");
-
- // System.out.println("Attr1: " + attr1 + " (" + attr1.getLocalName() +")");
-
-
- AttrCompare attrCompare = new AttrCompare();
-
- assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
- assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
-
- }
-
-
- /**
- * Method testA2
- *
- * @throws ParserConfigurationException
- */
- public static void _testA2() throws ParserConfigurationException {
-
- Document doc = createDoc("documentElement");
- Element root = doc.getDocumentElement();
- Attr attr0 = createAttr(doc, "aAttr", "val0", null);
- Attr attr1 = createAttr(doc, "bAttr", "val1", null);
-
- root.setAttributeNode(attr0);
- root.setAttributeNode(attr1);
-
- NamedNodeMap nnm = root.getAttributes();
-
- assertEquals("nnm.getLength()", nnm.getLength(), 2);
-
- Attr attr00 = (Attr) nnm.item(0);
- Attr attr10 = (Attr) nnm.item(1);
-
- assertNotNull("Attribute attr00", attr00);
- assertNotNull("Attribute attr10", attr10);
-
- AttrCompare attrCompare = new AttrCompare();
-
- assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
- assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
- }
-
- /**
- * This test uses the attrs[] array to compare every attribute against
- * the others (and vice versa).
- *
- * The attribute values are taken from example 3.3 Start and End Tags
- * http://www.w3.org/TR/2001/REC-xml-c14n-20010315#Example-SETags
- *
- * @throws ParserConfigurationException
- */
- public static void testComplete() throws ParserConfigurationException {
-
- /* <e5 xmlns="http://example.org"
- * xmlns:a="http://www.w3.org"
- * xmlns:b="http://www.ietf.org"
- * attr="I'm"
- * attr2="all"
- * b:attr="sorted"
- * a:attr="out"></e5>
- */
- Document doc = createDoc("documentElement");
- Element root = doc.getDocumentElement();
-
- // This List has to be ordered to verify correctness of the comparison
- //J-
- Attr attrs[] = {
- createAttr(doc, "xmlns", "http://example.org", Constants.NamespaceSpecNS),
- createAttr(doc, "xmlns:a", "http://www.w3.org", Constants.NamespaceSpecNS),
- createAttr(doc, "xmlns:b", "http://www.ietf.org", Constants.NamespaceSpecNS),
- createAttr(doc, "attr", "I'm", null),
- createAttr(doc, "attr2", "all", null),
- createAttr(doc, "b:attr", "sorted", "http://www.ietf.org"),
- createAttr(doc, "a:attr", "out", "http://www.w3.org") };
-
- //J+
- for (int i = 0; i < attrs.length; i++) {
- root.setAttributeNode(attrs[i]);
- }
-
- NamedNodeMap nnm = root.getAttributes();
-
- assertEquals("nnm.getLength()", nnm.getLength(), attrs.length);
-
- for (int i = 0; i < attrs.length; i++) {
- Attr attr = attrs[i];
-
- assertNotNull("Attribute attr", attr);
- }
-
- AttrCompare attrCompare = new AttrCompare();
-
- for (int i = 0; i < attrs.length; i++) {
- for (int j = i + 1; j < attrs.length; j++) {
- Attr attr0 = attrs[i];
- Attr attr1 = attrs[j];
- assertTrue(attr0 + " < " + attr1, attrCompare.compare(attr0, attr1) < 0);
- assertTrue(attr1 + " < " + attr0, attrCompare.compare(attr1, attr0) > 0);
- }
- }
- }
-
- static {
- org.apache.xml.security.Init.init();
- }
-} //public class AttrCompareTest extends TestCase
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/C14nHelperTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/C14nHelperTest.java?rev=1057583&r1=1057582&r2=1057583&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/C14nHelperTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/c14n/helper/C14nHelperTest.java Tue Jan 11 11:23:39 2011
@@ -17,134 +17,94 @@
*/
package org.apache.xml.security.test.c14n.helper;
-
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.apache.xml.security.c14n.helper.C14nHelper;
/**
- *
- *
- *
- *
* @author Christian Geuer-Pollmann
- *
*/
-public class C14nHelperTest extends TestCase {
+public class C14nHelperTest extends org.junit.Assert {
- /** {@link org.apache.commons.logging} logging facility */
+ /** {@link org.apache.commons.logging} logging facility */
static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(C14nHelperTest.class.getName());
- /**
- * Method suite
- *
- *
- */
- public static Test suite() {
- return new TestSuite(C14nHelperTest.class);
- }
-
- /**
- * Constructor AttrCompareTest
- *
- * @param Name_
- */
- public C14nHelperTest(String Name_) {
- super(Name_);
- }
-
- /**
- * Method main
- *
- * @param args
- */
- public static void main(String[] args) {
-
- String[] testCaseName = { "-noloading", C14nHelperTest.class.getName() };
-
- junit.textui.TestRunner.main(testCaseName);
- }
-
- /**
- * Method testNamespaceIsAbsolute01
- *
- */
- public void testNamespaceIsAbsolute01() {
-
- String namespaceURI = "http://www.w3.org/Signature/";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsAbsolute(namespaceURI));
- }
-
- /**
- *
- *
- * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001JulSep/0068.html">The list</A>
- */
- public void testNamespaceIsAbsolute02() {
-
- String namespaceURI = "http://www.w3.org/../blah";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsAbsolute(namespaceURI));
- }
-
- /**
- * Method testNamespaceIsAbsolute03
- *
- */
- public void testNamespaceIsAbsolute03() {
-
- // unknown protocol?
- String namespaceURI = "hxxp://www.w3.org/";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsAbsolute(namespaceURI));
- }
-
- /**
- * Method testNamespaceIsRelative01
- *
- */
- public void testNamespaceIsRelative01() {
-
- String namespaceURI = "../blah";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsRelative(namespaceURI));
- }
-
- /**
- * Method testNamespaceIsRelative02
- *
- */
- public void testNamespaceIsRelative02() {
-
- String namespaceURI = "blah";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsRelative(namespaceURI));
- }
-
- /**
- * Method testNamespaceIsRelative03
- *
- */
- public void __testNamespaceIsRelative03() {
-
- String namespaceURI = "http://...";
-
- assertTrue("URI fails: \"" + namespaceURI + "\"",
- C14nHelper.namespaceIsRelative(namespaceURI));
- }
-
- static {
- org.apache.xml.security.Init.init();
- }
+ static {
+ org.apache.xml.security.Init.init();
+ }
+
+ /**
+ * Method testNamespaceIsAbsolute01
+ */
+ @org.junit.Test
+ public void testNamespaceIsAbsolute01() {
+
+ String namespaceURI = "http://www.w3.org/Signature/";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsAbsolute(namespaceURI));
+ }
+
+ /**
+ * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001JulSep/0068.html">The list</A>
+ */
+ @org.junit.Test
+ public void testNamespaceIsAbsolute02() {
+
+ String namespaceURI = "http://www.w3.org/../blah";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsAbsolute(namespaceURI));
+ }
+
+ /**
+ * Method testNamespaceIsAbsolute03
+ */
+ @org.junit.Test
+ public void testNamespaceIsAbsolute03() {
+
+ // unknown protocol?
+ String namespaceURI = "hxxp://www.w3.org/";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsAbsolute(namespaceURI));
+ }
+
+ /**
+ * Method testNamespaceIsRelative01
+ */
+ @org.junit.Test
+ public void testNamespaceIsRelative01() {
+
+ String namespaceURI = "../blah";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsRelative(namespaceURI));
+ }
+
+ /**
+ * Method testNamespaceIsRelative02
+ */
+ @org.junit.Test
+ public void testNamespaceIsRelative02() {
+
+ String namespaceURI = "blah";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsRelative(namespaceURI));
+ }
+
+ /**
+ * Method testNamespaceIsRelative03
+ */
+ @org.junit.Test
+ @org.junit.Ignore
+ public void testNamespaceIsRelative03() {
+
+ String namespaceURI = "http://...";
+
+ assertTrue("URI fails: \"" + namespaceURI + "\"",
+ C14nHelper.namespaceIsRelative(namespaceURI));
+ }
+
}