aboutsummaryrefslogtreecommitdiff
path: root/spss.test/src/testgenerator/TestGeneratorCX2.java
diff options
context:
space:
mode:
Diffstat (limited to 'spss.test/src/testgenerator/TestGeneratorCX2.java')
-rw-r--r--spss.test/src/testgenerator/TestGeneratorCX2.java1050
1 files changed, 1050 insertions, 0 deletions
diff --git a/spss.test/src/testgenerator/TestGeneratorCX2.java b/spss.test/src/testgenerator/TestGeneratorCX2.java
new file mode 100644
index 000000000..ed5c5194a
--- /dev/null
+++ b/spss.test/src/testgenerator/TestGeneratorCX2.java
@@ -0,0 +1,1050 @@
+package testgenerator;
+
+import iaik.ixsil.algorithms.Transform;
+import iaik.ixsil.algorithms.TransformImplEnvelopedSignature;
+import iaik.ixsil.core.Position;
+import iaik.ixsil.util.URI;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import at.gv.egovernment.moa.util.Base64Utils;
+import at.gv.egovernment.moa.util.Constants;
+import at.gv.egovernment.moa.util.DOMUtils;
+import at.gv.egovernment.moa.util.EntityResolverChain;
+import at.gv.egovernment.moa.util.MOAEntityResolver;
+import at.gv.egovernment.moa.util.MOAErrorHandler;
+import at.gv.egovernment.moa.util.StreamEntityResolver;
+
+/**
+ * @author Administrator
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class TestGeneratorCX2 extends TestCases {
+
+ String datadirectory = "data/CX2/";
+
+ String defaultblock =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
+ "<CreateXMLSignatureRequest xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+
+ "<KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>"+
+ "<SingleSignatureInfo SecurityLayerConformity=\"false\">"+
+ "<DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">"+
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>"+
+ "</DataObject>"+
+ "<CreateTransformsInfoProfile>"+
+ "<CreateTransformsInfo>"+
+ "<FinalDataMetaInfo>"+
+ "<MimeType>text/plain</MimeType>"+
+ "</FinalDataMetaInfo>"+
+ "</CreateTransformsInfo>"+
+ "</CreateTransformsInfoProfile>"+
+ "</DataObjectInfo>"+
+ "<CreateSignatureInfo xmlns:data=\"http://uri.data.org\">"+
+ "<!-- insert create -->"+
+ "<CreateSignatureEnvironmentProfile>"+
+ "<CreateSignatureLocation Index=\"0\">//data:Document</CreateSignatureLocation>"+
+ "<!-- insert supp -->"+
+ "</CreateSignatureEnvironmentProfile>"+
+ "</CreateSignatureInfo>"+
+ "</SingleSignatureInfo>"+
+ "</CreateXMLSignatureRequest>";
+
+ public String fileprefix = null;
+ public String filesuffix = null;
+
+ private static final int canAlgCanXML = 1;
+ private static final int canAlgCanXMLwithCom = 2;
+ private static final int canAlgExcXML = 3;
+ private static final int canAlgExcXMLwithCom = 4;
+
+ public TestGeneratorCX2() throws Exception {
+
+ super();
+
+ // Set config properties
+ configuration_.setProperty("TestClass", "TestGeneratorCX2");
+// configuration_.setProperty("privateKeyFile", baseDir + "additionalFiles/keys/RSAPrivateKey.der");
+// configuration_.setProperty("publicKeyFile", baseDir + "additionalFiles/keys/RSAPublicKey.der");
+// configuration_.setProperty("signatureFile", baseDir + "additionalFiles/signatures/Signature.unit1.xml");
+
+ iaik.security.provider.IAIK.addAsProvider();
+ iaik.security.ecc.provider.ECCProvider.addAsProvider();
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestGeneratorCX2 testcase = new TestGeneratorCX2();
+
+ testcase.createConfig();
+ testcase.create001();
+ testcase.create002();
+ testcase.create003();
+ testcase.create004();
+ testcase.create005();
+ testcase.create006();
+ testcase.create007();
+ testcase.create008();
+ testcase.create009();
+
+ testcase.create051();
+ testcase.create052();
+ testcase.create053();
+ testcase.create054();
+ testcase.create055();
+ testcase.create056();
+ testcase.create057();
+
+ }
+
+ public void createConfig() throws Exception {
+
+ String file = configuration_.getProperty("baseDir") + datadirectory +
+ configuration_.getProperty("TestClass") +
+ ".Config.xml";
+ String config =
+
+ "<MOAConfiguration xmlns=\"http://reference.e-government.gv.at/namespace/moaconfig/20021122#\">"+
+ " <KeyGroup id=\"PKCS12RSAKey1\"> <Key id=\"resources/test-ee2003_normal(buergerkarte).p12\"/> </KeyGroup>"+
+ " <KeyGroup id=\"PKCS12RSAKeyExpired\"> <Key id=\"sicher-demo(buergerkarte).p12\"/> </KeyGroup>"+
+ " <KeyGroup id=\"PKCS12ECDSAKey1\"> <Key id=\"ecc.p12\"/> </KeyGroup> "+
+ " <KeyGroup id=\"HSMRSAKey1\"> <Key id=\"???\"/> </KeyGroup>"+
+ " <KeyGroup id=\"HSMECDSAKey1\"> <Key id=\"???\"/> </KeyGroup>"+
+ " <DigestMethodAlgorithm name=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>"+
+ " <SignatureAlgorithm name=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>"+
+ " <CanonicalizationAlgorithm name=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>"+
+ " <CreateSignatureEnvironmentProfile id=\"CreateSignatureEnvironmentProfile1\" filename=\""+"file:/"+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml\"/>"+
+ "</MOAConfiguration>";
+
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(config.getBytes());
+ fos.flush();
+ fos.close();
+
+ fileprefix = configuration_.getProperty("baseDir")+ datadirectory + configuration_.getProperty("TestClass") + ".";
+ filesuffix = ".xml";
+ }
+
+ public void create001() throws Exception {
+
+ String TestNumber = "001";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>"+
+ //readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ writeFile(reqFile,req);
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+ Document reqDoc = builder.parse(bis);
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/node()";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create002() throws Exception {
+
+ String TestNumber = "002";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDocument.xml"+"\"/>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+ Document reqDoc = builder.parse(bis);
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/node()";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create003() throws Exception {
+
+ String TestNumber = "003";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<Base64Content>"+readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/testDocument.xml")+"</Base64Content>"+
+ "</CreateSignatureEnvironment>");
+
+ //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//Hugo");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+ Document reqDoc = builder.parse(bis);
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/node()";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\">",cutXML(readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"))+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create004() throws Exception {
+
+ String TestNumber = "004";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+ Document reqDoc = builder.parse(bis);
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/node()";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+ }
+
+ public void create005() throws Exception {
+
+ String TestNumber = "005";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,"<!-- insert supp -->",
+ "<Supplement>"+
+ "<Content Reference=\"http://tollesSchema.org/test.xsd\">"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element>"+
+ "</xsd:schema>"+
+ "</XMLContent>"+
+ "</Content>"+
+ "</Supplement>");
+
+ req = replaceString(req,"<FinalDataMetaInfo>",
+ "<dsig:Transforms><dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></dsig:Transforms>"+
+ "<FinalDataMetaInfo>");
+
+
+
+ //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
+ System.out.println("!!!");
+ System.out.println(req);
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\"#document\">"+
+ "</DataObject>"
+ );
+
+ System.out.println(req);
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ //InputStream bis = new ByteArrayInputStream(("<data:Document attr=\"document\" xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org\">Dies sind Testdaten</data:Document>").getBytes());
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Map m = new HashMap();
+ m.put("http://tollesSchema.org/test.xsd",new ByteArrayInputStream((
+ "<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element></xsd:schema>").getBytes()));
+
+ EntityResolverChain chain = new EntityResolverChain();
+ chain.addEntityResolver(new StreamEntityResolver(m));
+ chain.addEntityResolver(new MOAEntityResolver());
+ builder.setEntityResolver(chain);
+
+ //Dokument Parsen
+ Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ //String xPath_Pos = "/node()";
+ String xPath_Pos = "//data:Document";
+ //XPAth-Prefixe deklarieren
+ //String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ String xPath_Prefix = "data http://uri.data.org";
+
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ //cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ Transform[] tr = new Transform[1];
+ TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
+ tr[0] = trans;
+ //Enveloped Transformation
+ cpkcs.createReferenceWithTransforms(new URI("#document"),tr,"reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create006() throws Exception {
+
+ String TestNumber = "006";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\">Dies sind Testdaten</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,
+ "<CreateSignatureEnvironmentProfile>"+
+ "<CreateSignatureLocation Index=\"0\">//data:Document</CreateSignatureLocation>"+
+ "<!-- insert supp -->"+
+ "</CreateSignatureEnvironmentProfile>",
+ "<CreateSignatureEnvironmentProfileID>CreateSignatureEnvironmentProfile1</CreateSignatureEnvironmentProfileID>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+
+
+ Document reqDoc = builder.parse(bis);
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/node()";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create007() throws Exception {
+
+ String TestNumber = "007";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<Base64Content>"+
+ ""+Base64Utils.encode(("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Document SYSTEM \"http://dtd.org/tollesDTD.dtd\"><Document attr=\"document\">Dies sind Testdaten</Document>").getBytes())+""+
+ "</Base64Content>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\"#document\">"+
+ "</DataObject>"
+ );
+
+ req = replaceString(req,"<!-- insert supp -->",
+ "<Supplement>"+
+ "<Content Reference=\"http://dtd.org/tollesDTD.dtd\">"+
+ "<Base64Content>"+
+ ""+Base64Utils.encode(("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!ELEMENT Document (#PCDATA | ANY)*><!ATTLIST Document attr ID #REQUIRED>").getBytes())+""+
+ "</Base64Content>"+
+ "</Content>"+
+ "</Supplement>");
+
+ req = replaceString(req," xmlns:data=\"http://uri.data.org\"","");
+ req = replaceString(req,"//data:Document","//Document");
+
+
+ req = replaceString(req,"<FinalDataMetaInfo>",
+ "<dsig:Transforms><dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></dsig:Transforms>"+
+ "<FinalDataMetaInfo>");
+
+ //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//Hugo");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<!DOCTYPE Document SYSTEM \"http://dtd.org/tollesDTD.dtd\"><Document attr=\"document\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ //Dokument Parsen
+ Map m = new HashMap();
+ m.put("http://dtd.org/tollesDTD.dtd",new ByteArrayInputStream((
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!ELEMENT Document (#PCDATA | ANY)*><!ATTLIST Document attr ID #REQUIRED>").getBytes()));
+
+ EntityResolverChain chain = new EntityResolverChain();
+ chain.addEntityResolver(new StreamEntityResolver(m));
+ chain.addEntityResolver(new MOAEntityResolver());
+ builder.setEntityResolver(chain);
+
+ Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "/Document";
+ //XPAth-Prefixe deklarieren
+ String xPath_Prefix = "";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ //cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ Transform[] tr = new Transform[1];
+ TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
+ tr[0] = trans;
+ //Enveloped Transformation
+ cpkcs.createReferenceWithTransforms(new URI("#document"),tr,"reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<Document attr=\"document\" xmlns=\"\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create008() throws Exception {
+
+ String TestNumber = "008";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,"<!-- insert supp -->",
+ "<Supplement>"+
+ "<Content Reference=\"http://tollesSchema.org/test.xsd\">"+
+ "<Base64Content>"+
+
+ Base64Utils.encode(("<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element>"+
+ "</xsd:schema>").getBytes())+
+
+ "</Base64Content>"+
+ "</Content>"+
+ "</Supplement>");
+
+ req = replaceString(req,"<FinalDataMetaInfo>",
+ "<dsig:Transforms><dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></dsig:Transforms>"+
+ "<FinalDataMetaInfo>");
+
+
+ //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
+ System.out.println("!!!");
+ System.out.println(req);
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\"#document\">"+
+ "</DataObject>"
+ );
+
+ System.out.println(req);
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>").getBytes());
+ //Document-Builder holen
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Map m = new HashMap();
+ m.put("http://tollesSchema.org/test.xsd",new ByteArrayInputStream((
+ "<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element>"+
+ "</xsd:schema>").getBytes()));
+
+ EntityResolverChain chain = new EntityResolverChain();
+ chain.addEntityResolver(new StreamEntityResolver(m));
+ chain.addEntityResolver(new MOAEntityResolver());
+ builder.setEntityResolver(chain);
+
+ //Dokument Parsen
+ Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ String xPath_Pos = "//data:Document";
+ //XPAth-Prefixe deklarieren
+ //String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ String xPath_Prefix = "data http://uri.data.org";
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ //cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ Transform[] tr = new Transform[1];
+ TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
+ tr[0] = trans;
+ //Enveloped Transformation
+ cpkcs.createReferenceWithTransforms(new URI("#document"),tr,"reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document attr=\"document\" xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create009() throws Exception {
+
+ String TestNumber = "009";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,"<!-- insert supp -->",
+ "<Supplement>"+
+ "<Content Reference=\"http://tollesSchema.org/test.xsd\">"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element>"+
+ "</xsd:schema>"+
+ "</XMLContent>"+
+ "</Content>"+
+ "</Supplement>");
+
+ req = replaceString(req,"<FinalDataMetaInfo>",
+ "<dsig:Transforms><dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></dsig:Transforms>"+
+ "<FinalDataMetaInfo>");
+
+
+
+ //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
+ System.out.println("!!!");
+ System.out.println(req);
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\"#xpointer(id(document))\">"+
+ "</DataObject>"
+ );
+
+ System.out.println(req);
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
+
+ //InputStream bis = new ByteArrayInputStream(("<data:Document attr=\"document\" xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org\">Dies sind Testdaten</data:Document>").getBytes());
+ InputStream bis = new ByteArrayInputStream(("<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">Dies sind Testdaten</data:Document>").getBytes());
+ //Document-Builder holen
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setValidating(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Map m = new HashMap();
+ m.put("http://tollesSchema.org/test.xsd",new ByteArrayInputStream((
+ "<xsd:schema targetNamespace=\"http://uri.data.org\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://uri.data.org\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" id=\"tollesSchema\">"+
+ "<xsd:element name=\"Document\">"+
+ "<xsd:complexType mixed=\"true\">"+
+ "<xsd:sequence maxOccurs=\"unbounded\" minOccurs=\"0\">"+
+ "<xsd:any namespace=\"##any\" processContents=\"lax\"/>"+
+ "</xsd:sequence>"+
+ "<xsd:attribute name=\"attr\" type=\"xsd:ID\" use=\"required\"/>"+
+ "</xsd:complexType>"+
+ "</xsd:element></xsd:schema>").getBytes()));
+
+ EntityResolverChain chain = new EntityResolverChain();
+ chain.addEntityResolver(new StreamEntityResolver(m));
+ chain.addEntityResolver(new MOAEntityResolver());
+ builder.setEntityResolver(chain);
+
+ //Dokument Parsen
+ Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
+
+ System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement()));
+ //Position für die Signatur angeben
+ //String xPath_Pos = "/node()";
+ String xPath_Pos = "//data:Document";
+ //XPAth-Prefixe deklarieren
+ //String xPath_Prefix = "data xmlns:data=\"http://uri.data.org\"";
+ String xPath_Prefix = "data http://uri.data.org";
+
+ Position pos = new Position(xPath_Pos, xPath_Prefix,0);
+
+ CreatePKCSSignature cpkcs = new CreatePKCSSignature();
+ //Signer erzeugen, der das obige Doc als Basis nimmt, und die Signatur an der besagten stelle einfügt
+ cpkcs.init(reqDoc,pos,"signature-1-1");
+ cpkcs.setCanoncialization(canAlgCanXML);
+ //cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt","reference-1-1");
+ Transform[] tr = new Transform[1];
+ TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
+ tr[0] = trans;
+ //Enveloped Transformation
+ cpkcs.createReferenceWithTransforms(new URI("#xpointer(id(document))"),tr,"reference-1-1");
+ cpkcs.setKeyInformation(1);
+
+
+ Document doc = cpkcs.returnSig();
+
+ String output = makeOutputFile(doc,"<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" attr=\"document\" xsi:schemaLocation=\"http://uri.data.org http://tollesSchema.org/test.xsd\">",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</data:Document>");
+
+ writeFile(resFile, output);
+
+ }
+
+ public void create051() throws Exception {
+
+ String TestNumber = "051";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<CreateSignatureInfo xmlns:data=\"http://uri.data.org\">","<CreateSignatureInfo>");
+
+ req = replaceString(req,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document xmlns:data=\"http://uri.data.org\">daten</data:Document><Text>toller Text</Text>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,"<CreateSignatureLocation Index=\"0\">","<CreateSignatureLocation Index=\"0\" xmlns:data=\"http://uri.data.org\">");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"1109");
+
+ }
+
+ public void create052() throws Exception {
+
+ String TestNumber = "052";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<Base64Content>PFRhZzE+PC9UYWcxPjxUYWcyPjwvVGFnMj4NCg0K</Base64Content><!-- Inhalt: <Tag1></Tag1><Tag2></Tag2> -->"+
+ "</CreateSignatureEnvironment>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"2218");
+
+ }
+
+ public void create053() throws Exception {
+
+ String TestNumber = "053";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment/>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"1110");
+
+ }
+
+ public void create054() throws Exception {
+
+ String TestNumber = "054";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\"><data:Document xmlns:data=\"http://uri.data.org\">Dies sind Testdaten</data:Document></XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,
+ "<CreateTransformsInfo>"+
+ "<FinalDataMetaInfo>"+
+ "<MimeType>text/plain</MimeType>"+
+ "</FinalDataMetaInfo>"+
+ "</CreateTransformsInfo>",
+ "<CreateTransformsInfo>"+
+ "<dsig:Transforms>"+
+ "<dsig:Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">"+
+ "<dsig:XPath>/data:book/data:first-name/node()</dsig:XPath>"+
+ "</dsig:Transform>"+
+ "</dsig:Transforms>"+
+ "<FinalDataMetaInfo>"+
+ "<MimeType>text/xml</MimeType>"+
+ "</FinalDataMetaInfo>"+
+ "</CreateTransformsInfo>");
+
+ req = replaceString(req,
+ "<CreateSignatureLocation Index=\"0\">//data:Document</CreateSignatureLocation>",
+ "<CreateSignatureLocation Index=\"0\">//data:Document1</CreateSignatureLocation>");
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/BookData.xml"+"\"/>");
+
+ //req = replaceString(req,"/data:Document","/data:nonExistingElement");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"2212");
+
+ }
+
+ public void create056() throws Exception {
+
+ String TestNumber = "056";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document>andereDaten als in "+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,
+ "<CreateSignatureEnvironmentProfile>"+
+ "<CreateSignatureLocation Index=\"0\">//data:Document</CreateSignatureLocation>"+
+ "<!-- insert supp -->"+
+ "</CreateSignatureEnvironmentProfile>",
+ "<CreateSignatureEnvironmentProfileID>wrongCreateSignatureEnvironmentProfile</CreateSignatureEnvironmentProfileID>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"2236");
+
+ }
+
+ public void create057() throws Exception {
+
+ String TestNumber = "057";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment>"+
+ "<XMLContent xml:space=\"preserve\"><data:Document xmlns:data=\"http://uri.data.org\">Dies sind Testdaten</data:Document></XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ req = replaceString(req,
+ "<CreateTransformsInfo>"+
+ "<FinalDataMetaInfo>"+
+ "<MimeType>text/plain</MimeType>"+
+ "</FinalDataMetaInfo>"+
+ "</CreateTransformsInfo>",
+ "<CreateTransformsInfo>"+
+ "<dsig:Transforms>"+
+ "<dsig:Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">"+
+ "<dsig:XPath>/data:book/data:first-name/node()</dsig:XPath>"+
+ "</dsig:Transform>"+
+ "</dsig:Transforms>"+
+ "<FinalDataMetaInfo>"+
+ "<MimeType>text/xml</MimeType>"+
+ "</FinalDataMetaInfo>"+
+ "</CreateTransformsInfo>");
+
+ req = replaceString(req,
+ "<CreateSignatureLocation Index=\"0\">//data:Document</CreateSignatureLocation>",
+ "<CreateSignatureLocation Index=\"0\">]]'_'[[//data:Document</CreateSignatureLocation>");
+
+ req = replaceString(req,
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"+"\">"+
+ "<XMLContent xml:space=\"preserve\">"+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"</XMLContent>"+
+ "</DataObject>",
+ "<DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/BookData.xml"+"\"/>");
+
+ //req = replaceString(req,"/data:Document","/data:nonExistingElement");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"2212");
+
+ }
+
+ public void create055() throws Exception {
+
+ String TestNumber = "055";
+ String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
+
+ String req = replaceString(defaultblock,"<!-- insert create -->",
+ "<CreateSignatureEnvironment Reference=\""+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml\">"+
+ "<XMLContent xml:space=\"preserve\">"+
+ "<data:Document>andereDaten als in "+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml</data:Document>"+
+ "</XMLContent>"+
+ "</CreateSignatureEnvironment>");
+
+ writeFile(reqFile,req);
+
+ String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix;
+
+ writeFile(resFile,"1110");
+
+ }
+
+
+ public void writeFile(String filename,String data) throws Exception
+ {
+ BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
+ bw.write(data);
+ bw.close();
+ }
+
+ public String makeOutputFile(Document signatureDoc,String prefix,String suffix) throws Exception
+ {
+ ArrayList foundNodes = new ArrayList();
+ findNode(signatureDoc.getDocumentElement(),"dsig:Signature",foundNodes);
+
+ Node outputNode = null;
+
+ if(foundNodes.size()>0)
+ {
+ outputNode = (Node)foundNodes.get(0);
+ }
+
+ String erg = Node2String(outputNode);
+
+ // remove the <?xml ?> Prologue
+ int pos = erg.indexOf("<dsig");
+ erg = erg.substring(pos);
+
+ // insert the dsig:signature element in a MOA Response Message
+ erg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
+ "<CreateXMLSignatureResponse" +
+ " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\""+
+ " >"+
+ //" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\">"+
+ "<SignatureEnvironment>" +prefix+
+ erg +suffix+ "</SignatureEnvironment> </CreateXMLSignatureResponse>";
+
+ return erg;
+ }
+
+ public String makeOutputFile(Document signatureDoc) throws Exception
+ {
+ return this.makeOutputFile(signatureDoc,"","");
+ }
+}