From f6b97c358fe0de6618d91ef81c25a87b221ae3c6 Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>
Date: Thu, 24 Nov 2005 16:51:09 +0000
Subject: This commit was manufactured by cvs2svn to create tag
'Build-SPSS-1_3_0'.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build-SPSS-1_3_0@595 d688527b-c9ab-4aba-bd8d-4036d912da1d
---
spss.test/src/testgenerator/TestGeneratorCX2.java | 1050 ---------------------
1 file changed, 1050 deletions(-)
delete mode 100644 spss.test/src/testgenerator/TestGeneratorCX2.java
(limited to 'spss.test/src/testgenerator/TestGeneratorCX2.java')
diff --git a/spss.test/src/testgenerator/TestGeneratorCX2.java b/spss.test/src/testgenerator/TestGeneratorCX2.java
deleted file mode 100644
index ed5c5194a..000000000
--- a/spss.test/src/testgenerator/TestGeneratorCX2.java
+++ /dev/null
@@ -1,1050 +0,0 @@
-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 =
- ""+
- ""+
- "PKCS12RSAKey1"+
- ""+
- ""+
- ""+
- "Dies sind Testdaten"+
- ""+
- ""+
- ""+
- ""+
- "text/plain"+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "//data:Document"+
- ""+
- ""+
- ""+
- ""+
- "";
-
- 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 =
-
- ""+
- " "+
- " "+
- " "+
- " "+
- " "+
- " "+
- " "+
- " "+
- " "+
- "";
-
- 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,"",
- ""+
- ""+
- ""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+""+
- //readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+
- ""+
- "");
-
- writeFile(reqFile,req);
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create002() throws Exception {
-
- String TestNumber = "002";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- "");
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create003() throws Exception {
-
- String TestNumber = "003";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/testDocument.xml")+""+
- "");
-
- //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//Hugo");
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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,"",cutXML(readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"))+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create004() throws Exception {
-
- String TestNumber = "004";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- ""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+""+
- ""+
- "");
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
- }
-
- public void create005() throws Exception {
-
- String TestNumber = "005";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- "Dies sind Testdaten"+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- "");
-
-
-
- //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
- System.out.println("!!!");
- System.out.println(req);
-
- req = replaceString(req,
- ""+
- "Dies sind Testdaten"+
- "",
- ""+
- ""
- );
-
- System.out.println(req);
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- //InputStream bis = new ByteArrayInputStream(("Dies sind Testdaten").getBytes());
- InputStream bis = new ByteArrayInputStream(("Dies sind Testdaten").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((
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create006() throws Exception {
-
- String TestNumber = "006";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- "Dies sind Testdaten"+
- ""+
- "");
-
- req = replaceString(req,
- ""+
- "//data:Document"+
- ""+
- "",
- "CreateSignatureEnvironmentProfile1");
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create007() throws Exception {
-
- String TestNumber = "007";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- ""+Base64Utils.encode(("Dies sind Testdaten").getBytes())+""+
- ""+
- "");
-
- req = replaceString(req,
- ""+
- "Dies sind Testdaten"+
- "",
- ""+
- ""
- );
-
- req = replaceString(req,"",
- ""+
- ""+
- ""+
- ""+Base64Utils.encode(("").getBytes())+""+
- ""+
- ""+
- "");
-
- req = replaceString(req," xmlns:data=\"http://uri.data.org\"","");
- req = replaceString(req,"//data:Document","//Document");
-
-
- req = replaceString(req,"",
- ""+
- "");
-
- //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//Hugo");
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream((""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"").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((
- "").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create008() throws Exception {
-
- String TestNumber = "008";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- "Dies sind Testdaten"+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- ""+
- ""+
-
- Base64Utils.encode((""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "").getBytes())+
-
- ""+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- "");
-
-
- //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
- System.out.println("!!!");
- System.out.println(req);
-
- req = replaceString(req,
- ""+
- "Dies sind Testdaten"+
- "",
- ""+
- ""
- );
-
- System.out.println(req);
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- InputStream bis = new ByteArrayInputStream(("Dies sind Testdaten").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((
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create009() throws Exception {
-
- String TestNumber = "009";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"",
- ""+
- ""+
- "Dies sind Testdaten"+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "");
-
- req = replaceString(req,"",
- ""+
- "");
-
-
-
- //req = replaceString(req,"Index=\"0\">//data:Document","Index=\"0\">//data:Document");
- System.out.println("!!!");
- System.out.println(req);
-
- req = replaceString(req,
- ""+
- "Dies sind Testdaten"+
- "",
- ""+
- ""
- );
-
- System.out.println(req);
-
- writeFile(reqFile,req);
-
- String resFile = fileprefix + TestNumber + ".Res"+filesuffix;
-
- //InputStream bis = new ByteArrayInputStream(("Dies sind Testdaten").getBytes());
- InputStream bis = new ByteArrayInputStream(("Dies sind Testdaten").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((
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- ""+
- "").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,"",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+"");
-
- writeFile(resFile, output);
-
- }
-
- public void create051() throws Exception {
-
- String TestNumber = "051";
- String reqFile = fileprefix + TestNumber + ".Req"+filesuffix;
-
- String req = replaceString(defaultblock,"","");
-
- req = replaceString(req,"",
- ""+
- ""+
- "datentoller Text"+
- ""+
- "");
-
- req = replaceString(req,"","");
-
- 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,"",
- ""+
- "PFRhZzE+PC9UYWcxPjxUYWcyPjwvVGFnMj4NCg0K"+
- "");
-
- 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,"",
- "");
-
- 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,"",
- ""+
- "Dies sind Testdaten"+
- "");
-
- req = replaceString(req,
- ""+
- ""+
- "text/plain"+
- ""+
- "",
- ""+
- ""+
- ""+
- "/data:book/data:first-name/node()"+
- ""+
- ""+
- ""+
- "text/xml"+
- ""+
- "");
-
- req = replaceString(req,
- "//data:Document",
- "//data:Document1");
-
- req = replaceString(req,
- ""+
- ""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+""+
- "",
- "");
-
- //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,"",
- ""+
- ""+
- "andereDaten als in "+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml"+
- ""+
- "");
-
- req = replaceString(req,
- ""+
- "//data:Document"+
- ""+
- "",
- "wrongCreateSignatureEnvironmentProfile");
-
- 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,"",
- ""+
- "Dies sind Testdaten"+
- "");
-
- req = replaceString(req,
- ""+
- ""+
- "text/plain"+
- ""+
- "",
- ""+
- ""+
- ""+
- "/data:book/data:first-name/node()"+
- ""+
- ""+
- ""+
- "text/xml"+
- ""+
- "");
-
- req = replaceString(req,
- "//data:Document",
- "]]'_'[[//data:Document");
-
- req = replaceString(req,
- ""+
- ""+readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")+""+
- "",
- "");
-
- //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,"",
- ""+
- ""+
- "andereDaten als in "+configuration_.getProperty("webbaseDir")+"resources/CSEP.xml"+
- ""+
- "");
-
- 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 Prologue
- int pos = erg.indexOf(""+
- ""+
- //" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\">"+
- "" +prefix+
- erg +suffix+ " ";
-
- return erg;
- }
-
- public String makeOutputFile(Document signatureDoc) throws Exception
- {
- return this.makeOutputFile(signatureDoc,"","");
- }
-}
--
cgit v1.2.3