aboutsummaryrefslogtreecommitdiff
path: root/spss.test/src/testgenerator/TestGeneratorVX.java
diff options
context:
space:
mode:
author(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-08-06 14:26:08 +0000
committer(no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d>2007-08-06 14:26:08 +0000
commitf25a072fd1c3b131d5f2f15689942ca7c55a62c0 (patch)
treebb9a27f99ebbb16c8513ec4bbd72f8f4912b3367 /spss.test/src/testgenerator/TestGeneratorVX.java
parent3c1368b8d7182973c15f10e9ade3c1a0bb4fbaa7 (diff)
downloadmoa-id-spss-f25a072fd1c3b131d5f2f15689942ca7c55a62c0.tar.gz
moa-id-spss-f25a072fd1c3b131d5f2f15689942ca7c55a62c0.tar.bz2
moa-id-spss-f25a072fd1c3b131d5f2f15689942ca7c55a62c0.zip
This commit was manufactured by cvs2svn to create tagtags/Build-ID-1_4_0
'Build-ID-1_4_0'. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build-ID-1_4_0@907 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.test/src/testgenerator/TestGeneratorVX.java')
-rw-r--r--spss.test/src/testgenerator/TestGeneratorVX.java2793
1 files changed, 0 insertions, 2793 deletions
diff --git a/spss.test/src/testgenerator/TestGeneratorVX.java b/spss.test/src/testgenerator/TestGeneratorVX.java
deleted file mode 100644
index 20ff44a22..000000000
--- a/spss.test/src/testgenerator/TestGeneratorVX.java
+++ /dev/null
@@ -1,2793 +0,0 @@
-package testgenerator;
-import iaik.ixsil.algorithms.Transform;
-import iaik.ixsil.algorithms.TransformImplBase64Decode;
-import iaik.ixsil.algorithms.TransformImplCanonicalXML;
-import iaik.ixsil.algorithms.TransformImplCanonicalXMLWithComments;
-import iaik.ixsil.algorithms.TransformImplEnvelopedSignature;
-import iaik.ixsil.algorithms.TransformImplExclusiveCanonicalXML;
-import iaik.ixsil.algorithms.TransformImplExclusiveCanonicalXMLWithComments;
-import iaik.ixsil.algorithms.TransformImplXPath;
-import iaik.ixsil.algorithms.TransformImplXPath2;
-import iaik.ixsil.algorithms.TransformImplXSLT;
-import iaik.ixsil.core.Position;
-import iaik.ixsil.util.URI;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.xml.serialize.DOMWriterImpl;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-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 stephan
- */
-public class TestGeneratorVX extends TestCases {
-
- private static final int canAlgCanXML = 1;
- private static final int canAlgCanXMLwithCom = 2;
- private static final int canAlgExcXML = 3;
- private static final int canAlgExcXMLwithCom = 4;
- private static VXResponseBean vxBean = null;
-
- public static void main(String[] args) throws Exception {
-
- vxBean = new VXResponseBean();
-
- TestGeneratorVX testcase = new TestGeneratorVX();
- testcase.createVXConfig();
-
- testcase.create001();
- testcase.create002();
- testcase.create003();
- testcase.create004();
- testcase.create005();
- testcase.create006();
- testcase.create007();
- testcase.create009();
- testcase.create008();
-
- testcase.create101();
- testcase.create102();
- testcase.create103();
- testcase.create104();
- testcase.create105();
- testcase.create106();
-
- testcase.create301();
- testcase.create302();
- testcase.create303();
- testcase.create304();
- testcase.create305();
-
- testcase.create307();
- testcase.create308();
-
- testcase.create310();
- testcase.create311();
- testcase.create312();
- testcase.create313();
- testcase.create314();
- testcase.create314_2();
- testcase.create315();
- testcase.create316();
- testcase.create317();
- testcase.create318();
- testcase.create318_2();
- testcase.create319();
- testcase.create320();
- testcase.create320_2();
- testcase.create321();
- testcase.create322();
- testcase.create323();
- testcase.create324();
- testcase.create325();
- testcase.create326();
- testcase.create327();
-
- //testcase.createL00();
-
- }
-
- /* ==================================================================================================== */
-
- public TestGeneratorVX() throws Exception {
-
- super();
-
- // Set config properties
- configuration_.setProperty("TestClass", "TestGeneratorVX");
-
- // 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 void testEcc() throws Exception
- {
- Date d = new Date();
- long start = d.getTime();
- long initEcc = 0;
- long timeEcc = 0;
- long initRSA = 0;
- long timeRSA = 0;
-
-
- TestGeneratorVX testcase = new TestGeneratorVX();
- testcase.ecccreate319();
- initEcc = (new Date()).getTime() - start;
- testcase.ecccreate320();
- testcase.ecccreate321();
- testcase.ecccreate322();
- testcase.ecccreate323();
- testcase.ecccreate324();
-
- timeEcc = (new Date()).getTime() - start;
-
- start = (new Date()).getTime();
-
- testcase = new TestGeneratorVX();
- testcase.create319();
- initRSA = (new Date()).getTime() - start;
- testcase.create320();
- testcase.create321();
- testcase.create322();
- testcase.create323();
- testcase.create324();
- timeRSA =(new Date()).getTime() - start;
-
- System.out.println("=========================================================");
- System.out.println("=========================================================");
-
- System.out.println("Init ECC (inkl. 1st Test): "+ (initEcc)+ "ms" );
- System.out.println("ECC-Tests gesamt: "+ (timeEcc)+ "ms" );
- System.out.println("ECC-Tests 2-5: "+ (timeEcc-initEcc)+ "ms" );
- System.out.println("=========================================================");
- System.out.println("Init RSA (inkl. 1st Test): "+ (initRSA)+ "ms" );
- System.out.println("RSA-Tests gesamt: "+ (timeRSA)+ "ms" );
- System.out.println("RSA-Tests 2-5: "+ (timeRSA-initRSA)+ "ms" );
- System.out.println("=========================================================");
- }
-
-public void ecccreate319() throws Exception {
- String testNumber = "ecc319";
-
-
- // Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); // Create from whole cloth
-//
- // Element root = (Element) document.createElement("Data");
- // root.appendChild(document.createTextNode(readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")) );
-// Element root2 = (Element) document.createElement("Element2");
- // root2.appendChild(document.createTextNode("Some other text") );
-
- // root.appendChild(root2);
-
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- //cpkcs.init();
- long start = (new Date()).getTime();
- cpkcs.initECDSA();
- System.out.println("Init-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(true,"Dies sind Testdaten");
- //cpkcs.createReferenceEnvElement(root);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- /**
- * Method create320:
- * The element KeyInfo does NOT contain the X509-certificate but
- * an URI pointing to an external xml-encoded X509-file
- * @throws Exception
- */
- public void ecccreate320() throws Exception {
- String testNumber = "ecc320";
-
- //RetrievalMethdos instead of the integratede Keys
-
- //URI fileURI = new URI(configuration_.getProperty("baseDir") + "resources/test-ee2003_normal.der");
- URI fileURI = new URI("file:/"+configuration_.getProperty("baseDir") + "resources/X509Data.xml");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data");
- //URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
-// cpkcs.init();
-
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation(false, fileURI, typeURI, null);
-
- long start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
-
- public void ecccreate321() throws Exception {
- String testNumber = "ecc321";
-
- //RetrievalMethdos instead of the integratede Keys
-
- URI fileURI = new URI("file:/"+configuration_.getProperty("baseDir") + "resources/test-ee2003_normal.der");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- // cpkcs.init();
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation(false, fileURI, typeURI, null);
-
- long start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
-
- /**
- * Method create322.
- * The reference in the signature points with an xpointer
- * to the ID of an embedded valid manifest dsig:object
- * @throws Exception
- */
- public void ecccreate322() throws Exception {
- String testNumber = "ecc322";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- // cpkcs.init();
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.createReferenceWithManifest(fileURI1,"manifestObject");
-
- cpkcs.setKeyInformation();
- long start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
- }
- /**
- * Method create323:
- * There are two references in the signature pointing
- * with xpointer to two embedded valid manifest dsig:objects
- * @throws Exception
- */
- public void ecccreate323() throws Exception {
- String testNumber = "ecc323";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- // cpkcs.init();
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- URI fileURI2 = new URI(configuration_.getProperty("webbaseDir") + "resources/testXML.txt");
- cpkcs.createReferenceWithManifest(fileURI1,"manifestObject");
-
- //HINWEIS: Durch das 2malige Aufrufen wird ein WEITERES dsig:Object ELEMENT erzeugt... darf das so sein...???
-
- cpkcs.createReferenceWithManifest(fileURI2,"manifestObject2");
- cpkcs.setKeyInformation();
- long start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
- }
- public void ecccreate324() throws Exception {
- String testNumber = "ecc324";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- // cpkcs.init();
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- URI fileURI2 = new URI(configuration_.getProperty("webbaseDir") + "resources/testXML.txt");
- cpkcs.createReferencesWithManifest(fileURI1,"manifestObject",fileURI2);
-
- //HINWEIS: Durch das 2malige Aufrufen wird ein WEITERES dsig:Object ELEMENT erzeugt... darf das so sein...???
- cpkcs.setKeyInformation();
- long start = (new Date()).getTime();
- Document sign = cpkcs.returnSig();
- System.out.println("Sign-Dauer für " +testNumber + ":" + ((new Date()).getTime()-start));
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
- }
-
- public void createL00() throws Exception {
- createL001("1kb");
- createL001("10kb");
- createL001("20kb");
- createL001("50kb");
- createL001("100kb");
- createL001("500kb");
- createL001("1mb");
- createL001("10mb");
- }
-
- public void createL001(String filename) throws Exception {
-
- String testNumber = "001";
-
- //Create a Request with number 001, the current Time (+0 hours)
- // and with the Date and ReturnHashInputDate Elements present
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/"+filename+".txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(false,false,null));
-
- writeFile(vxReqFileL(testNumber,filename),request);
-
-
-
- writeFile(vxResFileL(testNumber,filename), createResponseL(cpkcs.getX509CertString(), testNumber,"0",filename));
- }
-
- /**
- * Method create001.
- * @throws Exception
- */
- /* ===================================================================================================================== */
- /* ===================================================================================================================== */
- /* ===================================================================================================================== */
-
- public void create001() throws Exception {
-
- String testNumber = "001";
-
- //Create a Request with number 001, the current Time (+0 hours)
- // and with the Date and ReturnHashInputDate Elements present
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- /**
- * Method create002.
- * @throws Exception
- */
- public void create002() throws Exception {
- String testNumber = "002";
- //Create a Request with number 002, the current Time (+0 hours)
- // and without the Date and with ReturnHashInputDate Elements present
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,false,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- /**
- * Method create003.
- * @throws Exception
- */
- public void create003() throws Exception {
- String testNumber = "003";
- //Create a Request with number 003, the Time one Day in the past (-24 hours)
- // and with the Date and with ReturnHashInputDate Elements present
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,-24),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- /**
- * Method create004.
- * @throws Exception
- */
- public void create004() throws Exception {
- String testNumber = "004";
- //Create a Request with number 004, the current Time (+0 hours)
- // and with the Date and without ReturnHashInputDate Elements present
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(false,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
- writeFile(vxResFile(testNumber), createResponseWithoutHashInputData(cpkcs.getX509CertString(), testNumber,"0"));
- }
- public void create005() throws Exception {
- String testNumber = "005";
-
- String request =
- createRequestStart(testNumber,true,0, "Reference=\"" + configuration_.getProperty("webbaseDir") + "resources/SignatureVX005.xml\" ")+
- createRequestEnd(false,false,null);
-
- request = replaceString(request,"<XMLContent xml:space=\"preserve\">","");
- request = replaceString(request,"</XMLContent>","");
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(readFileCR(configuration_.getProperty("webbaseDir") + "resources/SignatureVX005Cert.xml")) +
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("1","1","1")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
- /**
- * Method create051.
- * @throws Exception
- */
-
-public void create006() throws Exception {
-
- String testNumber = "006";
- // ERST MAL DAS DOKUMENT ALS STRING AUFBAUEN
- Supplement supp = new Supplement();
- supp.addXMLContent("http://MyServer.com/resources/something.xsd",
- "<xsd:schema targetNamespace=\"http://uri2.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"><xsd:element name=\"Document\"><xsd:complexType mixed=\"true\"><xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\"><xsd:any namespace=\"##any\" processContents=\"lax\"/></xsd:sequence><xsd:attribute name=\"Id\" type=\"xsd:ID\" use=\"required\"/></xsd:complexType></xsd:element></xsd:schema>");
- supp.closeSupplement();
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() + createRequestShortEnd(false);
-
- String requestStart = createRequestStart(testNumber,true,0);
-
-
- String reqDocString =
- "<daten:Document Id=\"myDocument\" " +
- "xmlns:daten=\"http://uri2.data.org\" "+
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
- "xsi:schemaLocation=\"http://uri2.data.org http://MyServer.com/resources/something.xsd http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\" >"
- + "daten</daten:Document>" ;
-
- InputStream bis = new ByteArrayInputStream(reqDocString.getBytes());
- //Document-Builder holen
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(true);
- //factory.setValidating(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
-
- Map m = new HashMap();
- m.put("http://MyServer.com/resources/something.xsd",new ByteArrayInputStream(("<xsd:schema targetNamespace=\"http://uri2.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"><xsd:element name=\"Document\"><xsd:complexType mixed=\"true\"><xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\"><xsd:any namespace=\"##any\" processContents=\"lax\"/></xsd:sequence><xsd:attribute name=\"Id\" 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
- System.out.println(reqDocString);
- //Document reqDoc = builder.parse(bis);
- Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
- //Position für die Signatur angeben
- //String xPath_Pos = "/moa:VerifyXMLSignatureRequest/moa:VerifySignatureInfo/moa:VerifySignatureEnvironment/moa:XMLContent
- String xPath_Pos = "//daten:Document";
- //XPAth-Prefixe deklarieren
- String xPath_Prefix = "daten http://uri2.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
- System.out.println("REQDOC:"+DOMUtils.serializeNode(reqDoc));
- cpkcs.init(reqDoc,pos);
- cpkcs.setCanoncialization(canAlgCanXML);
-
- cpkcs.setKeyInformation();
- /*cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"));
- cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");*/
-
- Transform[] tr = new Transform[1];
- TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
- tr[0] = trans;
- //Enveloped Transformation
- cpkcs.createReferenceWithTransforms(new URI("#myDocument"),tr);
-//Signieren
-
- cpkcs.returnSig();
- //Serialisieren
- String request = requestStart + replaceString(Node2String(reqDoc.getDocumentElement()),"<?xml version=\"1.0\" encoding=\"utf-8\"?>","") + requestEnd;
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
-
- public void create007() throws Exception {
-
- String testNumber = "007";
-
- String dtdLocation = configuration_.getProperty("webbaseDir") + "resources/VX.007DTD.dtd";
-
- // ERST MAL DAS DOKUMENT ALS STRING AUFBAUEN
- Supplement supp = new Supplement();
- supp.addBase64Content(dtdLocation,
- readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/VX.007DTD.dtd"));
- supp.closeSupplement();
-
- String requestEnd = createSignatureInfoEnd()+
- createRequestShortEnd(false);
-
- //String reqDocString = createRequestStart(testNumber,true,0,"","<!DOCTYPE data:Document SYSTEM \"http://MyServer.com/resources/VX.006DTD.dtd\">") +
- String reqDocString = /*createRequestStart(testNumber,true,0) +*/
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Document SYSTEM \"" + dtdLocation + "\"><Document Id=\"myDocument\" " +
-
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
- "xsi:schemaLocation=\"http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\" >"
- + "\ndaten\n</Document>" /*+ requestEnd*/;
-
- InputStream bis = new ByteArrayInputStream(reqDocString.getBytes());
- //Document-Builder holen
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(false);
-
- System.out.println(reqDocString);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- //Dokument Parsen
- Document reqDoc = builder.parse(bis);
- //Position für die Signatur angeben
- String xPath_Pos = "/Document";
- //XPAth-Prefixe deklarieren
- String xPath_Prefix = "";//"data http://uri2.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);
- cpkcs.setCanoncialization(canAlgCanXML);
-
- cpkcs.setKeyInformation();
- /*cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"));
- cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");*/
-
- Transform[] tr = new Transform[1];
- TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
- tr[0] = trans;
- //Enveloped Transformation
- cpkcs.createReferenceWithTransforms(new URI("#myDocument"),tr);
-//Signieren
- cpkcs.returnSig();
- //Serialisieren
- String request = Node2String(reqDoc.getDocumentElement());
-
- int i_pos = request.indexOf("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
- request = request.substring("<?xml version=\"1.0\" encoding=\"utf-8\"?>".length());
-
- request = "<!DOCTYPE Document SYSTEM \"" + dtdLocation + "\">"+request;
-
- System.out.println("DOC:"+request);
-
- request ="<?xml version=\"1.0\" encoding=\"utf-8\"?><VerifyXMLSignatureRequest xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\"><VerifySignatureInfo><VerifySignatureEnvironment><Base64Content>"+Base64Utils.encode(request.getBytes())+"</Base64Content></VerifySignatureEnvironment><VerifySignatureLocation>//dsig:Signature</VerifySignatureLocation></VerifySignatureInfo>"+supp.getSupplement()+"<TrustProfileID>TrustProfile1</TrustProfileID></VerifyXMLSignatureRequest>";
-
-
-
-
- /*int i_pos = request.indexOf("<VerifyXMLSignatureRequest");
- request = request.substring(0,i_pos)+"<!DOCTYPE data:Document SYSTEM \"http://MyServer.com/resources/VX.006DTD.dtd\">\n" +request.substring(i_pos);*/
-
- /*i_pos = request.indexOf("<TrustProfile");
- request = request.substring(0,i_pos)+supp.getSupplement() +request.substring(i_pos);*/
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponseWithoutHashInputData(cpkcs.getX509CertString(), testNumber,"0",false));
- }
-
-
- public void create008() throws Exception {
-
- String testNumber = "008";
-
- String request =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
- "<VerifyXMLSignatureRequest xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\" xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+
- "<VerifySignatureInfo>"+
- "<VerifySignatureEnvironment>"+
- "<XMLContent xml:space=\"preserve\">"+
- "<dsig:Signature Id=\"HS_signature\" xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+
- "<dsig:SignedInfo>"+
- "<dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>"+
- "<dsig:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>"+
- "<dsig:Reference Id=\"reference-data-1\" URI=\"#signed-data\">"+
- "<dsig:Transforms>"+
- "<dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\">"+
- "<xf2:XPath Filter=\"intersect\" xmlns:xf2=\"http://www.w3.org/2002/06/xmldsig-filter2\">id(&apos;signed-data&apos;)/node()</xf2:XPath>"+
- "</dsig:Transform>"+
- "</dsig:Transforms>"+
- "<dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>"+
- "<dsig:DigestValue>4lngV1x/OvR8iFWEBenH4fDihwA=</dsig:DigestValue>"+
- "</dsig:Reference>"+
- "<dsig:Reference Type=\"http://uri.etsi.org/01903/v1.1.1#SignedProperties\" URI=\"#refetsi\">"+
- "<dsig:Transforms>"+
- "<dsig:Transform Algorithm=\"http://www.w3.org/2002/06/xmldsig-filter2\">"+
- "<xf2:XPath Filter=\"intersect\" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\" xmlns:xf2=\"http://www.w3.org/2002/06/xmldsig-filter2\">id(&apos;refetsi&apos;)/etsi:QualifyingProperties/etsi:SignedProperties</xf2:XPath>"+
- "</dsig:Transform>"+
- "</dsig:Transforms>"+
- "<dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>"+
- "<dsig:DigestValue>1j0DWguieuw2cGA06gFjoSNXr+w=</dsig:DigestValue>"+
- "</dsig:Reference>"+
- "</dsig:SignedInfo>"+
- "<dsig:SignatureValue>Yb6fsPNbKyYW+u7cU1EqF9n5QrwLXHqdGD4tJNT5+sA7kQR3Ztqz965vlBH+1pJE"+
- "nGxehxXsesZboVvkJa/jhuI0goCTW9KkdGOP71B7o7/vlyBbxaYKpnVNtBU4/qtT"+
- "xba7M0E32X+tm/x9O6foXIM0AoP3oQBZmjo9rEJ9kfk=</dsig:SignatureValue>"+
- "<dsig:KeyInfo>"+
- "<dsig:X509Data>"+
- "<dsig:X509Certificate>MIIFJTCCBA2gAwIBAgICGTcwDQYJKoZIhvcNAQEFBQAwgaExCzAJBgNVBAYTAkFU"+
- "MUgwRgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGlt"+
- "IGVsZWt0ci4gRGF0ZW52ZXJrZWhyIEdtYkgxIzAhBgNVBAsTGmEtc2lnbi1URVNU"+
- "LVByZW1pdW0tRW5jLTAxMSMwIQYDVQQDExphLXNpZ24tVEVTVC1QcmVtaXVtLUVu"+
- "Yy0wMTAeFw0wMzAyMTAxMzIwNThaFw0wNjAyMTAxMzIwNThaMGoxCzAJBgNVBAYT"+
- "AkFUMRwwGgYDVQQDExNUZXN0cGVyc29uIE1PQTQgQlJaMQwwCgYDVQQEEwNCUlox"+
- "GDAWBgNVBCoTD1Rlc3RwZXJzb24gTU9BNDEVMBMGA1UEBRMMNzkwMTg3NDYxNjMz"+
- "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDS/UW1/tZeCh7HHQmj8auUTEc4"+
- "edAgRDkUVKOm0tF3kE3WZlhGDZL0p84xsdIKyI+bwDCMATATkQwDo/Xxn9jJMi4/"+
- "t80bNyRsHk9giA0wcvz9NgmEcDwKNqawGsR9gNeK8TyIC8AuDkj1EwtkAObMvtp/"+
- "Z1phi47x3JxDDfGDpQIDAQABo4ICHzCCAhswEwYDVR0jBAwwCoAIS7OAw3GTPNgw"+
- "JwYIKwYBBQUHAQMBAf8EGDAWMAgGBgQAjkYBATAKBggrBgEFBQcLATCBggYIKwYB"+
- "BQUHAQEEdjB0MCkGCCsGAQUFBzABhh1odHRwOi8vd3d3LmEtdHJ1c3QuYXQ6ODIv"+
- "b2NzcDBHBggrBgEFBQcwAoY7aHR0cDovL3d3dy5hLXRydXN0LmF0L2NlcnRzL2Et"+
- "c2lnbi1URVNULVByZW1pdW0tU2lnLTAxYS5jcnQwgZQGA1UdIASBjDCBiTB9BgYq"+
- "KAARAQQwczA1BggrBgEFBQcCARYpaHR0cDovL3d3dy5hLXRydXN0LmF0L2RvY3Mv"+
- "Y3AvYS1zaWduLVRFU1QwOgYIKwYBBQUHAgIwLhosRGllc2VzIFplcnRpZmlrYXQg"+
- "ZGllbnQgbnVyIHp1IFRlc3R6d2Vja2VuICEwCAYGBACLMAEBMG8GA1UdHwRoMGYw"+
- "ZKBioGCGXmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9YS1zaWduLVRFU1QtUHJl"+
- "bWl1bS1FbmMtMDEsbz1BLVRydXN0LGM9QVQ/Y2VydGlmaWNhdGVyZXZvY2F0aW9u"+
- "bGlzdD8wEQYDVR0OBAoECE4DxL9ky4M+MA4GA1UdDwEB/wQEAwIGwDAgBgNVHREE"+
- "GTAXgRV0ZXN0cGVyc29uNEBicnouZ3YuYXQwCQYDVR0TBAIwADANBgkqhkiG9w0B"+
- "AQUFAAOCAQEAioVvsZN+NnQxXMTGdjKveTBMRTYzHflkSC8lI9XXltP5+mjIuoB2"+
- "Tn6voovA8dXz9jTsnQt8f8ye0CL2bSS9UVD1jv8So3bavquW+HlkZBAZvL39APNL"+
- "PjUUnWn0QOnrQAJ6W47UwGAUgEw3KcBcJaEa4Xb/8kUj618xGzWl6X0mKsVpxkrf"+
- "+5Cj+nmwDqChll08/90MmhSY4M5FrvmQ9GjAN5FHVsk0FPp02tKCRzoBJtzpB1DW"+
- "KHlgiDHUAXy5eD0XI7PXebPNZ4InvY/jC/IH8PRLdJT249YQmUxZ4neTtFDvb8C1"+
- "Qh6k725fh3hVxqX8ZwwWj9+iGQVk53K3CA==</dsig:X509Certificate>"+
- /*"<dsig:X509Certificate>"+
- readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/IAIKRootMusterbehoerde.cer")+
- "</dsig:X509Certificate>"+*/
- "</dsig:X509Data>"+
- "</dsig:KeyInfo>"+
- "<dsig:Object Id=\"signed-data\">"+
- "<sl10:InfoboxReadRequest xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\">"+
- "<sl10:InfoboxIdentifier>IdentityLink</sl10:InfoboxIdentifier>"+
- "<sl10:BinaryFileParameters ContentIsXMLEntity=\"true\"/>"+
- "</sl10:InfoboxReadRequest>"+
- "</dsig:Object>"+
- "<dsig:Object Id=\"refetsi\">"+
- "<etsi:QualifyingProperties Target=\"#HS_signature\" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\">"+
- "<etsi:SignedProperties>"+
- "<etsi:SignedSignatureProperties>"+
- "<etsi:SigningTime>2003-03-04T12:32:54Z</etsi:SigningTime>"+
- "<etsi:SigningCertificate>"+
- "<etsi:Cert>"+
- "<etsi:CertDigest>"+
- "<etsi:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>"+
- "<etsi:DigestValue>Frhu1o4mL4gQHdJcU0xSA/h4COE=</etsi:DigestValue>"+
- "</etsi:CertDigest>"+
- "<etsi:IssuerSerial>"+
- "<dsig:X509IssuerName>CN=a-sign-TEST-Premium-Enc-01,OU=a-sign-TEST-Premium-Enc-01,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT</dsig:X509IssuerName>"+
- "<dsig:X509SerialNumber>6455</dsig:X509SerialNumber>"+
- "</etsi:IssuerSerial>"+
- "</etsi:Cert>"+
- "</etsi:SigningCertificate>"+
- "<etsi:SignaturePolicyIdentifier>"+
- "<etsi:SignaturePolicyImplied/>"+
- "</etsi:SignaturePolicyIdentifier>"+
- "</etsi:SignedSignatureProperties>"+
- "<etsi:SignedDataObjectProperties>"+
- "<etsi:DataObjectFormat ObjectReference=\"#reference-data-1\">"+
- "<etsi:MimeType>text/xml</etsi:MimeType>"+
- "</etsi:DataObjectFormat>"+
- "</etsi:SignedDataObjectProperties>"+
- "</etsi:SignedProperties>"+
- "</etsi:QualifyingProperties>"+
- "</dsig:Object>"+
- "</dsig:Signature>"+
- "</XMLContent>"+
- "</VerifySignatureEnvironment>"+
- "<VerifySignatureLocation>//dsig:Signature</VerifySignatureLocation>"+
- "</VerifySignatureInfo>"+
- "<TrustProfileID>TrustProfile1</TrustProfileID>"+
- "</VerifyXMLSignatureRequest>";
-
- String response =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
- "<VerifyXMLSignatureResponse xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" >"+
- " <SignerInfo>"+
- " <dsig:X509Data xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+
- " <dsig:X509SubjectName>serialNumber=790187461633,givenName=Testperson MOA4,SN=BRZ,CN=Testperson MOA4 BRZ,C=AT</dsig:X509SubjectName>"+
- " <dsig:X509IssuerSerial>"+
- " <dsig:X509IssuerName>CN=a-sign-TEST-Premium-Enc-01,OU=a-sign-TEST-Premium-Enc-01,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT</dsig:X509IssuerName>"+
- " <dsig:X509SerialNumber>6455</dsig:X509SerialNumber>"+
- " </dsig:X509IssuerSerial>"+
- "<dsig:X509Certificate>MIIFJTCCBA2gAwIBAgICGTcwDQYJKoZIhvcNAQEFBQAwgaExCzAJBgNVBAYTAkFU"+
- "MUgwRgYDVQQKEz9BLVRydXN0IEdlcy4gZi4gU2ljaGVyaGVpdHNzeXN0ZW1lIGlt"+
- "IGVsZWt0ci4gRGF0ZW52ZXJrZWhyIEdtYkgxIzAhBgNVBAsTGmEtc2lnbi1URVNU"+
- "LVByZW1pdW0tRW5jLTAxMSMwIQYDVQQDExphLXNpZ24tVEVTVC1QcmVtaXVtLUVu"+
- "Yy0wMTAeFw0wMzAyMTAxMzIwNThaFw0wNjAyMTAxMzIwNThaMGoxCzAJBgNVBAYT"+
- "AkFUMRwwGgYDVQQDExNUZXN0cGVyc29uIE1PQTQgQlJaMQwwCgYDVQQEEwNCUlox"+
- "GDAWBgNVBCoTD1Rlc3RwZXJzb24gTU9BNDEVMBMGA1UEBRMMNzkwMTg3NDYxNjMz"+
- "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDS/UW1/tZeCh7HHQmj8auUTEc4"+
- "edAgRDkUVKOm0tF3kE3WZlhGDZL0p84xsdIKyI+bwDCMATATkQwDo/Xxn9jJMi4/"+
- "t80bNyRsHk9giA0wcvz9NgmEcDwKNqawGsR9gNeK8TyIC8AuDkj1EwtkAObMvtp/"+
- "Z1phi47x3JxDDfGDpQIDAQABo4ICHzCCAhswEwYDVR0jBAwwCoAIS7OAw3GTPNgw"+
- "JwYIKwYBBQUHAQMBAf8EGDAWMAgGBgQAjkYBATAKBggrBgEFBQcLATCBggYIKwYB"+
- "BQUHAQEEdjB0MCkGCCsGAQUFBzABhh1odHRwOi8vd3d3LmEtdHJ1c3QuYXQ6ODIv"+
- "b2NzcDBHBggrBgEFBQcwAoY7aHR0cDovL3d3dy5hLXRydXN0LmF0L2NlcnRzL2Et"+
- "c2lnbi1URVNULVByZW1pdW0tU2lnLTAxYS5jcnQwgZQGA1UdIASBjDCBiTB9BgYq"+
- "KAARAQQwczA1BggrBgEFBQcCARYpaHR0cDovL3d3dy5hLXRydXN0LmF0L2RvY3Mv"+
- "Y3AvYS1zaWduLVRFU1QwOgYIKwYBBQUHAgIwLhosRGllc2VzIFplcnRpZmlrYXQg"+
- "ZGllbnQgbnVyIHp1IFRlc3R6d2Vja2VuICEwCAYGBACLMAEBMG8GA1UdHwRoMGYw"+
- "ZKBioGCGXmxkYXA6Ly9sZGFwLmEtdHJ1c3QuYXQvb3U9YS1zaWduLVRFU1QtUHJl"+
- "bWl1bS1FbmMtMDEsbz1BLVRydXN0LGM9QVQ/Y2VydGlmaWNhdGVyZXZvY2F0aW9u"+
- "bGlzdD8wEQYDVR0OBAoECE4DxL9ky4M+MA4GA1UdDwEB/wQEAwIGwDAgBgNVHREE"+
- "GTAXgRV0ZXN0cGVyc29uNEBicnouZ3YuYXQwCQYDVR0TBAIwADANBgkqhkiG9w0B"+
- "AQUFAAOCAQEAioVvsZN+NnQxXMTGdjKveTBMRTYzHflkSC8lI9XXltP5+mjIuoB2"+
- "Tn6voovA8dXz9jTsnQt8f8ye0CL2bSS9UVD1jv8So3bavquW+HlkZBAZvL39APNL"+
- "PjUUnWn0QOnrQAJ6W47UwGAUgEw3KcBcJaEa4Xb/8kUj618xGzWl6X0mKsVpxkrf"+
- "+5Cj+nmwDqChll08/90MmhSY4M5FrvmQ9GjAN5FHVsk0FPp02tKCRzoBJtzpB1DW"+
- "KHlgiDHUAXy5eD0XI7PXebPNZ4InvY/jC/IH8PRLdJT249YQmUxZ4neTtFDvb8C1"+
- "Qh6k725fh3hVxqX8ZwwWj9+iGQVk53K3CA==</dsig:X509Certificate>"+
- " <sl11:QualifiedCertificate xmlns:sl11=\"http://www.buergerkarte.at/namespaces/securitylayer/20020831#\"/>"+
- " </dsig:X509Data>"+
- " </SignerInfo>"+
- " <SignatureCheck>"+
- " <Code>0</Code>"+
- " </SignatureCheck>"+
- " <CertificateCheck>"+
- " <Code>0</Code>"+
- " </CertificateCheck>"+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber),response);
- }
-
- public void create009() throws Exception {
-
- String testNumber = "009";
- // ERST MAL DAS DOKUMENT ALS STRING AUFBAUEN
- Supplement supp = new Supplement();
- supp.addXMLContent("http://MyServer.com/resources/something.xsd",
- "<xsd:schema targetNamespace=\"http://uri2.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"><xsd:element name=\"Document\"><xsd:complexType mixed=\"true\"><xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\"><xsd:any namespace=\"##any\" processContents=\"lax\"/></xsd:sequence><xsd:attribute name=\"Id\" type=\"xsd:ID\" use=\"required\"/></xsd:complexType></xsd:element></xsd:schema>");
- supp.closeSupplement();
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() + createRequestShortEnd(false);
-
- String requestStart = createRequestStart(testNumber,true,0);
-
-
- String reqDocString =
- "<daten:Document Id=\"myDocument\" " +
- "xmlns:daten=\"http://uri2.data.org\" "+
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
- "xsi:schemaLocation=\"http://uri2.data.org http://MyServer.com/resources/something.xsd http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\" >"
- + "daten</daten:Document>" ;
-
- InputStream bis = new ByteArrayInputStream(reqDocString.getBytes());
- //Document-Builder holen
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setValidating(true);
- //factory.setValidating(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
-
- Map m = new HashMap();
- m.put("http://MyServer.com/resources/something.xsd",new ByteArrayInputStream(("<xsd:schema targetNamespace=\"http://uri2.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"><xsd:element name=\"Document\"><xsd:complexType mixed=\"true\"><xsd:sequence minOccurs=\"0\" maxOccurs=\"unbounded\"><xsd:any namespace=\"##any\" processContents=\"lax\"/></xsd:sequence><xsd:attribute name=\"Id\" 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
- System.out.println(reqDocString);
- //Document reqDoc = builder.parse(bis);
- Document reqDoc = DOMUtils.parseDocument(bis,true,Constants.ALL_SCHEMA_LOCATIONS, null,chain,new MOAErrorHandler());
- //Position für die Signatur angeben
- //String xPath_Pos = "/moa:VerifyXMLSignatureRequest/moa:VerifySignatureInfo/moa:VerifySignatureEnvironment/moa:XMLContent
- String xPath_Pos = "//daten:Document";
- //XPAth-Prefixe deklarieren
- String xPath_Prefix = "daten http://uri2.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
- System.out.println("REQDOC:"+DOMUtils.serializeNode(reqDoc));
- cpkcs.init(reqDoc,pos);
- cpkcs.setCanoncialization(canAlgCanXML);
-
- cpkcs.setKeyInformation();
- /*cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"));
- cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");*/
-
- Transform[] tr = new Transform[1];
- TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
- tr[0] = trans;
- //Enveloped Transformation
- cpkcs.createReferenceWithTransforms(new URI("#xpointer(id(myDocument))"),tr);
-//Signieren
-
- cpkcs.returnSig();
- //Serialisieren
- String request = requestStart + replaceString(Node2String(reqDoc.getDocumentElement()),"<?xml version=\"1.0\" encoding=\"utf-8\"?>","") + requestEnd;
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
-
- public void create101() throws Exception {
-
- String testNumber = "101";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addMetaInfo("text/plain","http://www.buergerkarte.at");
- supp.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt",
- readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
- //supp.addProfileID("Some ID");
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() + createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- /*vxBean.createXMLDSIGManifestCheck("0","","1")+ */
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
- public void create102() throws Exception {
-
- String testNumber = "102";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addMetaInfo("text/plain",null);
- supp.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt",
- readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
- //supp.addProfileID("Some ID");
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() + "<ReturnHashInputData/>"+createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
-
-
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- public void create103() throws Exception {
-
- String testNumber = "103";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- //supp.addMetaInfo("text/plain",null);
- supp.addXMLContent(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- //supp.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt",
- // readBinaryFileAsBase64(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
- //supp.addProfileID("Some ID");
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() + "<ReturnHashInputData/>"+createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
-
-
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-public void create104() throws Exception {
-
- String testNumber = "104";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addXMLContent(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt", readFileCR(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
-
- String requestEnd =
- createSignatureInfoEnd()+
- supp.getSupplement()+"<ReturnHashInputData/>"+
- createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber+" - Supplement/Content/XMLContent instead of Supplement/Content/Base64Content",true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- public void create105() throws Exception {
-
- String testNumber = "105";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testXML.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addXMLContent(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt", readFileCR(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
-
- Supplement supp2 = new Supplement();
- supp2.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testXML.txt", readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testXML.txt"));
- supp2.closeSupplement();
-
- String requestEnd =
- createSignatureInfoEnd()+
- supp.getSupplement()+
- supp2.getSupplement() +
- createRequestShortEnd(true);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber + " - 2 Supplement elements",true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- "<HashInputData><Base64Content>"+
- readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testSimple.txt") +
- "</Base64Content></HashInputData>"+
- "<HashInputData><Base64Content>"+
- readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testXML.txt") +
- "</Base64Content></HashInputData>"+
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), response);
- }
-
-public void create106() throws Exception {
-
- String testNumber = "106";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String requestEnd =
- createSignatureInfoEnd()+
- "<SupplementProfileID>SupplementProfile2</SupplementProfileID>" +
- "<!-- Supplement Profile 2 enthaelt nicht die referenzierte URI -->" +
- "<SupplementProfileID>SupplementProfile1</SupplementProfileID><ReturnHashInputData/>" +
- createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber +" - 2 SupplementProfileID elements" ,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
-
- public void create301() throws Exception {
-
- String testNumber = "301";
-
- //Testcast with another canoicalization algorithm
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXMLwithCom);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
- /**
- * Method create302.
- * @throws Exception
- */
- public void create302() throws Exception {
-
- String testNumber = "302";
-
- //Testcast with another canoicalization algorithm
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
-
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgExcXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0"));
- }
- /**
- * Method create303.
- * @throws Exception
- */
- public void create303() throws Exception {
-
- String testNumber = "303";
-
- //Testcast with another canoicalization algorithm
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
-
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgExcXMLwithCom);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0"));
- }
-
- public void create304() throws Exception {
-
- String testNumber = "304";
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.initECDSA();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- //cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- //cpkcs.createEnvelopedDataObject("envelopedData",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
-
- cpkcs.createReference(true,readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"),"envelopedData");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0","<dsig:X509IssuerName>CN=IAIK ECDSA Test,OU=JavaSecurity,O=IAIK,C=AT</dsig:X509IssuerName>","<dsig:X509SubjectName>CN=IAIK ECDSA Test,OU=JavaSecurity,O=IAIK,C=AT</dsig:X509SubjectName>","<dsig:X509SerialNumber>68172</dsig:X509SerialNumber>"));
- }
- /**
- * Method create305.
- * @throws Exception
- */
- public void create305() throws Exception {
-
- String testNumber = "305";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- String refData = "Dies sind Testdaten";
-
- cpkcs.createReference(true,refData);
-
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",refData));
- }
-
- /**
- * Method create307.
- * @throws Exception
- */
- public void create307() throws Exception {
-
- String testNumber = "307";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addXMLContent(configuration_.getProperty("baseDir")+"resources/testSimple.txt", readFileCR(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
-
- String requestEnd = createSignatureInfoEnd()+
- supp.getSupplement() +
- createRequestShortEnd(true);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0"));
- }
-
- /**
- * Method create308.
- * @throws Exception
- */
- public void create308() throws Exception {
-
- String testNumber = "308";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- supp.addXMLContent(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt", readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
- supp.closeSupplement();
-
-
- String requestEnd = createSignatureInfoEnd()+ supp.getSupplement() +
- createRequestShortEnd(false);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- requestEnd);
-
- //request = replaceString(request,"<XMLContent xml:space=\"preserve\">","<XMLContent xml:space=\"preserve\">VERAENDERTE DATEN und die Ursprungsdaten: ");
- request = replaceString(request,"Dies sind Testdaten","VERAENDERTE DATEN und die Ursprungsdaten: Dies sind Testdaten");
- //request = replaceString(request,Base64Utils.encode("Dies sind Testdaten".getBytes()),Base64Utils.encode("VERAENDERTE DATEN und die Ursprungsdaten: Dies sind Testdaten".getBytes()));
- //request = replaceString(request,"<ReturnHashInputData/>","");
- /*request = replaceString(request,"Reference=\""+configuration_.getProperty("baseDir")+"resources/testSimple.txt\"","Reference=\"\"");
- request = replaceString(request,"URI=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\"","URI=\"\"");*/
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponse(cpkcs.getX509CertString(),testNumber,"1",1);
-
- writeFile(vxResFile(testNumber), response);
- }
- public void create310() throws Exception {
-
- String testNumber = "310";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- //Erzeugen der Base64-Daten
- //String tmp = readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testSimple.txt");
-
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txtbase64.enc");
-
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplBase64Decode();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
-
- cpkcs.createReferenceWithTransforms(target,tr);
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0"));
- }
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
-//-------311 scheint die XPAth - Transformation nicht richtig auszuführen-
-// (Siehe Output in der Konsole.....)
-
- public void create311() throws Exception {
-
- String testNumber = "311";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
-
- Transform[] tr = new Transform[1];
- TransformImplXPath trans = new TransformImplXPath();
-// TransformImplXSLT trans = new TransformImplXSLT();
-
-
- InputStream s = getHttpInputStream(configuration_.getProperty("webbaseDir")+"resources/BookData.xml");
-// InputStream s2 = new FileInputStream(configuration_.getProperty("baseDir")+"resources/transform.xsl");
- trans.setInput(s,null);
-// trans.setStyleSheet(s2,null);
-
- trans.addNSDeclaration("data",new URI("http://uri.data.org")); //new URI("file:/"+configuration_.getProperty("baseDir")+"resources/BookData.xml"));
- // trans.setXPath("ancestor-or-self::data:first-name");
- trans.setXPath("ancestor-or-self::text()/ancestor-or-self::data:first-name");
-
- tr[0] = trans;
-
- cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir") + "resources/BookData.xml"),tr);
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",1,"text:Ellipse"));
- }
-
-public void create312() throws Exception
- { String testNumber = "312";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init("signature");
- cpkcs.setCanoncialization(canAlgCanXML);
-
- Transform[] tr = new Transform[1];
- TransformImplXPath2 trans = new TransformImplXPath2();
- InputStream s = getHttpInputStream(configuration_.getProperty("webbaseDir")+"resources/CX1_book.xsl");
- trans.setInput(s,null);
-
- HashMap temp = new HashMap();
- temp.put("data",new URI("http://uri.data.org"));
- trans.addXPathFilter("/data:book/data:first-name",TransformImplXPath2.FILTER_MODE_SUBTRACT_,temp);
- tr[0] = trans;
- //System.out.println(getTransformsResult(tr));
- cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir") + "resources/BookData.xml"),tr,"reference-1");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart("312",true,0),
- cpkcs.returnSig(),
- createSignatureInfoEnd()
- + createRequestShortEnd(false));
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
-
-public void create313() throws Exception
- { String testNumber = "313";
-
- // ERST MAL DAS DOKUMENT ALS STRING AUFBAUEN
-
- String requestEnd = createRequestEnd(true,false,null);
-
- String reqDocString = createRequestStart(testNumber,true,0) +
- "<data:Document " +
- "xmlns:data=\"http://uri.data.org\" "+
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Id=\"myDocument\" "+
- "xsi:schemaLocation=\"http://uri.data.org http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX.006Schema.xsd http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\" >"
- + "</data:Document>" + requestEnd;
-
-
- InputStream bis = new ByteArrayInputStream(("<data:Document " +
- "xmlns:data=\"http://uri.data.org\" "+
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Id=\"myDocument\" "+
- "xsi:schemaLocation=\"http://uri.data.org http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX.006Schema.xsd http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\" >"
- + "</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 = "/moa:VerifyXMLSignatureRequest/moa:VerifySignatureInfo/moa:VerifySignatureEnvironment/moa:XMLContent/data:Document";
- 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);
- cpkcs.setCanoncialization(canAlgCanXML);
-
- cpkcs.setKeyInformation(1);
- //cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("webbaseDir")+"resources/testSimple.txt"));
- //cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");
-
- Transform[] tr = new Transform[1];
- TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature();
- tr[0] = trans;
- //Enveloped Transformation
- cpkcs.createReferenceWithTransforms(new URI(""),tr);
-//Signieren
- cpkcs.returnSig();
- //Serialisieren
- String request = Node2String(reqDoc.getDocumentElement());
-
- writeFile(vxReqFile(testNumber),createRequestStart(testNumber,true,0).trim() +cutXML(request).trim()+requestEnd.trim());
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0",1,"text:"+"<data:Document xmlns:data=\"http://uri.data.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Id=\"myDocument\" xsi:schemaLocation=\"http://uri.data.org http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX.006Schema.xsd http://www.w3.org/2000/09/xmldsig# http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd\"></data:Document>"));
-
- }
-
-
- public void create314() throws Exception
- { String testNumber = "314";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init("signature");
- cpkcs.setCanoncialization(canAlgCanXML);
-
- Transform[] tr = new Transform[1];
- TransformImplXSLT trans = new TransformImplXSLT();
- InputStream s = getHttpInputStream(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref.xsl");
- trans.setStyleSheet(s,new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_bookref.xsl"));
- tr[0] = trans;
- cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir") + "resources/BookData.xml"),tr,"reference-1");
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart("314",true,0),
- cpkcs.returnSig(),
- createSignatureInfoEnd()
- + createRequestShortEnd(false));
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
-
-public void create314_2() throws Exception
- { String testNumber = "314_2";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init("signature");
- cpkcs.setCanoncialization(canAlgCanXML);
-
- Transform[] tr = new Transform[1];
- TransformImplXSLT trans = new TransformImplXSLT();
- InputStream s = getHttpInputStream(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref.xsl");
- trans.setStyleSheet(s,new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_bookref.xsl"));
- tr[0] = trans;
- cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir") + "resources/BookData.xml"),tr,"reference-1");
- cpkcs.setKeyInformation();
-
- Supplement supp = new Supplement();
- String suppContent = readFileCR(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl");
- suppContent = replaceString(suppContent, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>","");
- supp.addXMLContent("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_book.xsl", suppContent );
- supp.closeSupplement();
-
- String request =
- makeOutputFile(
- createRequestStart("314_2",true,0),
- cpkcs.returnSig(),
- createSignatureInfoEnd() +
- supp.getSupplement()
- + createRequestShortEnd(false));
-
-/* request = replaceString(request, "http://moa-test.brz.intra.gv.at", "http://MyServer.com");
- request = replaceString(request, "http://moa-test.brz.intra.gv.at", "http://MyServer.com");
- request = replaceString(request, "http://moa-test.brz.intra.gv.at", "http://MyServer.com");
- //Hinweis: ich nehmen an, die URI in DSIG:REFERENCE sollte schon stimmen....
- request = replaceString(request, "http://MyServer.com", "http://moa-test.brz.intra.gv.at"); */
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
- writeFile(vxResFile(testNumber), response);
- }
-
-
- public void create315() throws Exception {
-
- String testNumber = "315";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- //cpkcs.createReference(true,"Dies sind testdaten");
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/test_wo_canonicalisation.XML");
-
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplCanonicalXML();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
-
- String erg = getTransformsResult(tr);
-
- cpkcs.createReferenceWithTransforms(target,tr);
- //cpkcs.createReference(false, "file:/"+ configuration_.getProperty("baseDir")+"resources/test_wo_canonicalisation.XML");
- //cpkcs.createReference(false, "file:/"+ configuration_.getProperty("baseDir")+"resources/test_w_canonicalisation.XML");
-// cpkcs.createReferenceWithManifest(new URI("file:/"+ configuration_.getProperty("baseDir")+"resources/test_w_canonicalisation.XML"),"canonicalizedData");
-
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
-
-
- writeFile(vxReqFile(testNumber),request);
-
-
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",erg));
- }
-
- public void create316() throws Exception {
-
- String testNumber = "316";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/test_wo_canonicalisation.XML");
-
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplCanonicalXMLWithComments();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
-
- String erg = getTransformsResult(tr);
-
- cpkcs.createReferenceWithTransforms(target,tr);
-
- cpkcs.setKeyInformation();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",erg));
- }
- public void create317() throws Exception {
-
- String testNumber = "317";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/test_wo_canonicalisation.XML");
-
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplExclusiveCanonicalXML();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
- String erg = getTransformsResult(tr);
- cpkcs.createReferenceWithTransforms(target,tr);
-
- cpkcs.setKeyInformation();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",erg));
- }
- public void create318() throws Exception {
-
- String testNumber = "318";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/test_wo_canonicalisation.XML");
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplExclusiveCanonicalXMLWithComments();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
-
- String erg = getTransformsResult(tr);
- cpkcs.createReferenceWithTransforms(target,tr);
-
- cpkcs.setKeyInformation();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",erg));
- }
-
- public void create318_2() throws Exception {
-
- String testNumber = "318_2";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- //Create a base64-encoded version of the xml file
-
- //String tmp = readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/test_wo_canonicalisation.XML");
-
- URI target = new URI(configuration_.getProperty("webbaseDir") + "resources/test_wo_canonicalisation.XMLbase64.enc");
-
- Transform[] tr = new Transform[3];
- tr[0] = new TransformImplBase64Decode();
- InputStream s = getHttpInputStream(target.toString());
- tr[0].setInput(s,null);
- tr[1] = new TransformImplCanonicalXMLWithComments();
- tr[1].setInput(s,null);
-
- tr[2] = new TransformImplExclusiveCanonicalXML();
- tr[2].setInput(s,null);
- String erg = getTransformsResult(tr);
- cpkcs.createReferenceWithTransforms(target,tr);
-
- cpkcs.setKeyInformation();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0",erg));
- }
-
- /**
- * Method create319:
- * SignedInfo/Reference appears two times:
- * the first reference points to an enveloped dsig:Object,
- * the seconde reference points to an external File
- * @throws Exception
- */
- public void create319() throws Exception {
- String testNumber = "319";
-
-
- // Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); // Create from whole cloth
-
-// Element root = (Element) document.createElement("Data");
- // root.appendChild(document.createTextNode(readFileCR(configuration_.getProperty("baseDir")+"resources/test-ee2003_normal.derbase64.enc.bak")) );
- //root.appendChild(document.createTextNode("Hallo\nHallo\nHallo"));
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
-
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(true,"Dies sind Testdaten");
- //cpkcs.createReferenceEnvElement(root);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation();
-
- Document sign = cpkcs.returnSig();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- /*String erg = "Dies sind Testdaten" +
- "</XMLContent>\n" +
- " </HashInputData>\n" +
- " <HashInputData>\n" +
- "<XMLContent xml:space=\"preserve\">" +
- readFileCR(configuration_.getProperty("baseDir")+"resources/testSimple.txt"); */
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(),testNumber,"0","Dies sind Testdaten",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt")));
- }
-
- /**
- * Method create320:
- * The element KeyInfo does NOT contain the X509-certificate but
- * an URI pointing to an external xml-encoded X509-file
- * @throws Exception
- */
- public void create320() throws Exception {
- String testNumber = "320";
-
- //RetrievalMethdos instead of the integratede Keys
-
- //URI fileURI = new URI(configuration_.getProperty("baseDir") + "resources/test-ee2003_normal.der");
- URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data");
- //URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation(false, fileURI, typeURI, null);
-
- Document sign = cpkcs.returnSig();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(readFileCR(configuration_.getProperty("webbaseDir") + "resources/SignatureVX005Cert.xml"),testNumber,"0"));
- }
-
-public void create320_2() throws Exception {
- String testNumber = "320_2";
-
- //RetrievalMethdos instead of the integratede Keys
-
- //URI fileURI = new URI(configuration_.getProperty("baseDir") + "resources/test-ee2003_normal.der");
- URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/TEMPX509Data.xml");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data");
- //URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation(false, fileURI, typeURI, null);
-
-// Supplement supp = new Supplement();
-
-// supp.addXMLContent(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml",readFileCR(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"));
-// supp.closeSupplement();
- Document sign = cpkcs.returnSig();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,true,configuration_.getProperty("webbaseDir") + "resources/TEMPX509Data.xml"));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(readFileCR(configuration_.getProperty("webbaseDir") + "resources/SignatureVX005Cert.xml"),testNumber,"0"));
- }
-
-
- /**
- * Method create321.
- * The element KeyInfo does NOT contain the X509-certificate but
- * an URI pointing to an external raw X509-file
- * @throws Exception
- */
- public void create321() throws Exception {
- String testNumber = "321";
-
- //RetrievalMethdos instead of the integratede Keys
-
- URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/test-ee2003_normal.der");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- cpkcs.setKeyInformation(false, fileURI, typeURI, null);
- Document sign = cpkcs.returnSig(); String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- writeFile(vxResFile(testNumber), createResponse(readFileCR(configuration_.getProperty("webbaseDir") + "resources/SignatureVX005Cert.xml"),testNumber,"0"));
- }
-
-
- /**
- * Method create322.
- * The reference in the signature points with an xpointer
- * to the ID of an embedded valid manifest dsig:object
- * @throws Exception
- */
-public void create322() throws Exception {
- String testNumber = "322";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- Element elem = cpkcs.createReferenceWithManifest(fileURI1,"manifestObject");
-
- cpkcs.setKeyInformation();
- Document sign = cpkcs.returnSig(); String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- "<HashInputData><Base64Content>"+
- Base64Utils.encode(stripNLCR(convertManifestToString(elem)).getBytes()) +
- "</Base64Content></HashInputData>"+
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("0","","1")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
- /**
- * Method create323:
- * There are two references in the signature pointing
- * with xpointer to two embedded valid manifest dsig:objects
- * @throws Exception
- */
- public void create323() throws Exception {
- String testNumber = "323";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- URI fileURI2 = new URI(configuration_.getProperty("webbaseDir") + "resources/testXML.txt");
- Element man1 = cpkcs.createReferenceWithManifest(fileURI1,"manifestObject");
-
- //HINWEIS: Durch das 2malige Aufrufen wird ein WEITERES dsig:Object ELEMENT erzeugt... darf das so sein...???
-
- Element man2 = cpkcs.createReferenceWithManifest(fileURI2,"manifestObject2");
- cpkcs.setKeyInformation();
- Document sign = cpkcs.returnSig();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- "<HashInputData><Base64Content>"+
- Base64Utils.encode(stripNLCR(convertManifestToString(man1)).getBytes()) +
- "</Base64Content></HashInputData>"+
- "<HashInputData><Base64Content>"+
- Base64Utils.encode(stripNLCR(convertManifestToString(man2)).getBytes()) +
- "</Base64Content></HashInputData>"+
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("0","","1")+
- vxBean.createXMLDSIGManifestCheck("0","","2")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
-
- }
- public void create324() throws Exception {
- String testNumber = "324";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
- URI fileURI1 = new URI(configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
- URI fileURI2 = new URI(configuration_.getProperty("webbaseDir") + "resources/testXML.txt");
- Element man = cpkcs.createReferencesWithManifest(fileURI1,"manifestObject",fileURI2);
-
- //HINWEIS: Durch das 2malige Aufrufen wird ein WEITERES dsig:Object ELEMENT erzeugt... darf das so sein...???
- cpkcs.setKeyInformation();
- Document sign = cpkcs.returnSig();
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- sign,
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- "<HashInputData><Base64Content>"+
- Base64Utils.encode(stripNLCR(convertManifestToString(man)).getBytes()) +
- "</Base64Content></HashInputData>"+
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("0","","1")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
-
- }
-
- /**
- * Method create325.
- * @throws Exception
- */
- public void create325() throws Exception {
- String testNumber = "325";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- Element mani = cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");
- cpkcs.createEnvelopedDataObject("envelopedData",readFile(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
-
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
- String response = createResponsePart(cpkcs.getX509CertString()) +
- "<HashInputData><Base64Content>"+
- Base64Utils.encode(stripNLCR(convertManifestToString(mani)).getBytes()) +
- "</Base64Content></HashInputData>"+
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("1","1","1")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
- writeFile(vxResFile(testNumber), response);
- }
-
- public void create326() throws Exception {
- String testNumber = "326";
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- Element mani = cpkcs.createReferenceWithManifest(new URI("#xpointer(id('envelopedData')/node())"),"manifestObject");
- cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("baseDir")+"resources/testSimple.txt"));
-
- cpkcs.setKeyInformation();
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(false,false,null));
-
- request = replaceString(request,"<dsig:Object Id=\"envelopedData\">","<dsig:Object Id=\"envelopedData\">Dies sind veraenderte Daten und die Ursprungsdaten: \n");
-
- writeFile(vxReqFile(testNumber),request);
-
- String response = createResponsePart(cpkcs.getX509CertString()) +
- vxBean.createSignatureCheck("0")+
- vxBean.createXMLDSIGManifestCheck("1","1","1")+
- vxBean.createCertificateCheck("0")+
- "</VerifyXMLSignatureResponse>";
-
-
- writeFile(vxResFile(testNumber), response);
- }
-
- /**
- * Method create327: The certificate comes as raw data and is converted to a dsig:object with
- * base64-data, the KeyInfo has a retrievalMethod pointing to that object and transforming the
- * data back to raw-data for using that to create the signature
- * @throws Exception
- */
- public void create327() throws Exception {
-
- String testNumber = "327";
-
- URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/test-ee2003_normal.der");
- URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#rawX509Certificate");
-
-
- CreatePKCSSignature cpkcs = new CreatePKCSSignature();
- cpkcs.init();
- cpkcs.setCanoncialization(canAlgCanXML);
-
- cpkcs.createReference(false,configuration_.getProperty("webbaseDir") + "resources/testSimple.txt");
-
- //DER-encoded RAW-Zertifikat zu Binary64 konvertieren
-
- //String tmp = readBinaryFileAsBase64(fileURI.getPath()); : Funktioniert nicht mehr wegen http-addi
-
- //dsig:Object mit den Binary64-Daten erzeugen (==> CRs weglassen!!!!!)
- cpkcs.createEnvelopedDataObject("rawCertAsBase64",readFileCR(fileURI.toString()+"base64.enc"));
-
- //Neue Transformation erzeugen, um die Base64-Daten zurückzuwandeln
- Transform[] tr = new Transform[1];
- tr[0] = new TransformImplBase64Decode();
- InputStream s = getHttpInputStream(fileURI.toString() + "base64.enc");
- tr[0].setInput(s,null);
-
- //Neues KeyInfo-Objekt erzeugen, wobei nicht die Zertifikate sondern
- //nur eine RetrievalMethod angegeben wird, die auf das oben erzeugte Base64-dsig:Object verweist
- cpkcs.setKeyInformation(true, new URI("#xpointer(id('rawCertAsBase64')/node())") , typeURI, tr);
-
- String request =
- makeOutputFile(
- createRequestStart(testNumber,true,0),
- cpkcs.returnSig(),
- createRequestEnd(true,false,null));
-
- writeFile(vxReqFile(testNumber),request);
-
- cpkcs.setKeyInformation(1);
-
- writeFile(vxResFile(testNumber), createResponse(cpkcs.getX509CertString(), testNumber,"0"));
- }
-
- /**
- * Method makeOutputFile.
- * @param start
- * @param signatureDoc
- * @param end
- * @return String
- * @throws Exception
- */
- public String makeOutputFile(
- String start,
- Document signatureDoc,
- String end)
- 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 = start + erg + end;
-
- return erg;
- }
-
- /**
- * Method createRequestStart.
- * @param testNumber
- * @param useDate
- * @param changeHours
- * @return String
- */
- private String createRequestStart(String testNumber, boolean useDate, int changeHours)
-{
- return createRequestStart(testNumber, useDate,changeHours,"");
-
-}
-
- private String createRequestStart(String testNumber, boolean useDate, int changeHours, String attribut)
- {
- return createRequestStart(testNumber, useDate,changeHours,attribut,"");
- }
- private String createRequestStart(String testNumber, boolean useDate, int changeHours, String attribut,String dtd)
- {String reqStart = null;
- System.out.println("======================================================");
- System.out.println("================== TEST-NUMBER "+ testNumber + " ===================");
- System.out.println("======================================================");
-
- reqStart =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + "<!-- Testnumber: "
- + testNumber
- + "-->\n";
-
- if(dtd!=null && !dtd.trim().equals(""))
- reqStart += dtd;
-
- reqStart+= "<VerifyXMLSignatureRequest\n"
- + " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"
- + " xmlns:xml=\"http://www.w3.org/XML/1998/namespace\""
- + " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">\n";
-
- if (useDate) {
- reqStart += " <DateTime>"
- + getDate(changeHours)
- + "</DateTime>\n";
- }
-
- reqStart += " <VerifySignatureInfo>\n"
- + " <VerifySignatureEnvironment "+attribut+">\n"
- + " <XMLContent xml:space=\"preserve\">" ;
- return reqStart;
- }
-
- /**
- * Method getTransformsResult:the input transforms array will
- * be calculated to return a string-representation of the result
- * @param tr
- * @return String
- * @throws Exception
- */
- private String getTransformsResult(Transform[] tr) throws Exception
- {
- Transform[] myTransforms = tr;
- String result = "";
- for (int t=0; t<tr.length-1; t++)
- {
- myTransforms[t+1].setInput((InputStream)myTransforms[t].transform(),null);
- }
- ByteArrayInputStream is = (ByteArrayInputStream)myTransforms[tr.length-1].transform();
- byte[] b = new byte[1];
- is.read(b);
- while (is.available() > 0)
- {
- result += new String(b);
- is.read(b);
- }
- result += new String(b);
-
- return result;
- }
-
-
- /**
- * Method createRequestEnd.
- * @param useReturnHashInputData
- * @param useSupplement
- * @param supplementReference
- * @return String
- * @throws Exception
- */
- private String createRequestEnd(
- boolean useReturnHashInputData,
- boolean useSupplement,
- String supplementReference)
- throws Exception {
-
- String reqEnd = null;
-
-/* reqEnd =
- "</VerifySignatureEnvironment>\n"
- + " <VerifySignatureLocation>#xpointer(/VerifyXMLSignatureRequest/VerifySignatureInfo/VerifySignatureEnvironment/dsig:Signature)</VerifySignatureLocation>\n"
- + " </VerifySignatureInfo>\n";
-*/
- reqEnd ="</XMLContent>"+
- "</VerifySignatureEnvironment>\n"
- + " <VerifySignatureLocation>//dsig:Signature</VerifySignatureLocation>\n"
- + " </VerifySignatureInfo>\n";
-
-
-
- if (useSupplement)
- {
- reqEnd += " <SupplementProfile>\n" +
- " <Content Reference=\"" + supplementReference.toString() + "\">\n" +
- " <XMLContent xml:space=\"preserve\">"+readFileCR(supplementReference.toString())+"</XMLContent>\n" +
- " </Content>\n" +
- " </SupplementProfile>\n";
- }
-
- if (useReturnHashInputData) {
- reqEnd += " <ReturnHashInputData/>\n";
- }
- reqEnd += " <TrustProfileID>TrustProfile1</TrustProfileID>\n"
- + "</VerifyXMLSignatureRequest>\n";
- return reqEnd;
-
- }
-
- private String createSignatureInfoEnd()
- throws Exception {
-
- return "</XMLContent>"+"</VerifySignatureEnvironment>\n"
- + " <VerifySignatureLocation>//dsig:Signature</VerifySignatureLocation>\n"
- + " </VerifySignatureInfo>\n";
-
- }
-
- private String createRequestShortEnd(boolean useReturnHashInputData)
- throws Exception {
-
- String reqEnd = "";
-
- if (useReturnHashInputData)
- reqEnd = " <ReturnHashInputData/>\n";
-
- reqEnd += " <TrustProfileID>TrustProfile1</TrustProfileID>\n"
- + "</VerifyXMLSignatureRequest>\n";
- return reqEnd;
-
- }
- /**
- * Method createResponse.
- * @param testNumber
- * @param signatureCheckCode
- * @return String
- * @throws Exception
- */
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal_extract.cer");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <HashInputData>\n" + " ";
- /*res += "<XMLContent xml:space=\"preserve\">"+readFileCR(
- configuration_.getProperty("baseDir")
- + "resources/testSimple.txt")+
- "</XMLContent>";*/
- res += "<Base64Content>"+readBinaryFileAsBase64_new((configuration_.getProperty("baseDir")+ "resources/testSimple.txt"))+"</Base64Content>";
-
- res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0");
-
- return res;
- }
-
- private String createResponseL(String x509cert, String testNumber, String signatureCheckCode,String filename) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal_extract.cer");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
-
- res += replaceString(vxBean.getFooterSignatureCheck(signatureCheckCode, "0"),"</HashInputData>","");
-
- return res;
- }
-
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode,int code) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal_extract.cer");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <SignatureCheck>\n" +
- " <Code>1</Code><Info><FailedReference>1</FailedReference></Info>\n" +
- " </SignatureCheck>\n" +
- " <CertificateCheck>\n" +
- " <Code>0</Code>\n" +
- " </CertificateCheck>\n" +
- "</VerifyXMLSignatureResponse>";;
-
- return res;
- }
-
-
- /**
- * Method createResponse.
- * @param testNumber
- * @param signatureCheckCode
- * @return String
- * @throws Exception
- */
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode,int code,String filename) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal_extract.cer");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <HashInputData>\n" + " ";
- /*res += "<XMLContent xml:space=\"preserve\">"+readFileCR(
- configuration_.getProperty("baseDir")
- + "resources/testSimple.txt")+
- "</XMLContent>";*/
- if(filename.startsWith("text:"))
- res += "<Base64Content>"+Base64Utils.encode(filename.substring(5).getBytes())+"</Base64Content>";
- else
- res += "<Base64Content>"+readBinaryFileAsBase64_new((configuration_.getProperty("baseDir")+ filename))+"</Base64Content>";
-
- res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0");
-
- return res;
- }
-
-/**
- * Method createResponse.
- * @param testNumber
- * @param signatureCheckCode
- * @return String
- * @throws Exception
- */
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode,String iss,String subject,String serial) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal_extract.cer");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += subject;
- res += " <dsig:X509IssuerSerial>\n";
- res += iss;
- res += serial;
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <HashInputData>\n" + " ";
- /*res += "<XMLContent xml:space=\"preserve\">"+readFileCR(
- configuration_.getProperty("baseDir")
- + "resources/testSimple.txt")+
- "</XMLContent>";*/
- res += "<Base64Content>"+readBinaryFileAsBase64_new((configuration_.getProperty("baseDir")+ "resources/testSimple.txt"))+"</Base64Content>";
-
- res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0");
-
- return res;
- }
-
-
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode, String hashData) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <HashInputData>\n";
- /* " <XMLContent xml:space=\"preserve\">"+
- hashData +
- "</XMLContent>\n";*/
- res += "<Base64Content>"+Base64Utils.encode(hashData.getBytes())+"</Base64Content>";
- System.out.println(res);
- res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0");
- System.out.println(res);
-
- return res;
- }
-
- private String createResponse(String x509cert, String testNumber, String signatureCheckCode, String hashData,String hashData2) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- res += " <HashInputData>\n";
- /* " <XMLContent xml:space=\"preserve\">"+
- hashData +
- "</XMLContent>\n";*/
- res += "<Base64Content>"+Base64Utils.encode(hashData.getBytes())+"</Base64Content>";
- res += "</HashInputData><HashInputData>";
- res += "<Base64Content>"+Base64Utils.encode(hashData2.getBytes())+"</Base64Content>";
- res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0");
-
- return res;
- }
-
- private String createResponseWithoutHashInputData(String x509cert, String testNumber, String signatureCheckCode,boolean dsig) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n"
- + " <SignatureCheck>\n" +
- " <Code>" + signatureCheckCode + "</Code>\n" +
- " </SignatureCheck>\n";
-
- if(dsig) res+=vxBean.createXMLDSIGManifestCheck("0","","1");
- res+= " <CertificateCheck>\n" +
- " <Code>0</Code>\n" +
- " </CertificateCheck>\n" +
- "</VerifyXMLSignatureResponse>";
-
- return res;
- }
-
- private String createResponseWithoutHashInputData(String x509cert, String testNumber, String signatureCheckCode) throws Exception {
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n"
- + x509cert
- + " </dsig:X509Data>\n"
- + " </SignerInfo>\n"
- + " <SignatureCheck>\n" +
- " <Code>" + signatureCheckCode + "</Code>\n" +
- " </SignatureCheck>\n" +
- " <CertificateCheck>\n" +
- " <Code>0</Code>\n" +
- " </CertificateCheck>\n" +
- "</VerifyXMLSignatureResponse>";
-
- return res;
- }
-
- private String createResponsePart(String x509cert) throws Exception {
-
- //
- vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der");
-
- String res = null;
-
- res = vxBean.getHeader();
- res += vxBean.getSubjectDN();
- res += " <dsig:X509IssuerSerial>\n";
- res += vxBean.getIssuerDN();
- res += vxBean.getSerialNumber();
- res += " </dsig:X509IssuerSerial>\n";
-
- res +=x509cert;
-
- res += " </dsig:X509Data>\n"
- + " </SignerInfo>\n";
- /*res += " <HashInputData>\n" + " <XMLContent>";
- res += readFile(
- configuration_.getProperty("baseDir")
- + "resources/testSimple.txt");
- */
- //res += vxBean.getFooterXMLDSIGManifestCheck(xmlDSIGManifestCheckCode,"0");
-
- return res;
- }
-
- public String readFileCR(String filename) throws Exception {
-
- /*StringBuffer data = new StringBuffer();
- String line = null;
- BufferedReader br = new BufferedReader(new FileReader(filename));
- while ((line = br.readLine()) != null) {
- data.append(line);
- data.append("\n");
- }
- */
- String response="";
- byte[] result;
-
- if (filename.substring(0,4).toLowerCase().equals("http"))
- {
-
- URL targetUrl = new URL(filename);
- HttpURLConnection h = (HttpURLConnection)targetUrl.openConnection();
- InputStream is = h.getInputStream();
-
- int size = 0;
-
- result = new byte[h.getContentLength()];
- for (int i = 0; i < result.length; i++) {
- byte[] b = new byte[1];
- is.read(b);
- result[i]=b[0];
- }
- is.close();
- }
- else
- {
- RandomAccessFile raf = new RandomAccessFile(filename, "r");
- if (raf.length() > Integer.MAX_VALUE)
- throw new IOException("file too big to fit in byte array.");
-
- result = new byte[(int) raf.length()];
- raf.read(result);
- raf.close();
-
- }
-
- byte[] temp = new byte[result.length];
- int s = 0;
- for (int t=0; t<result.length; t++)
- {
- temp[s] = result[t];
- s++;
- if (temp[s-1]==10)
- {
- if (temp[s-2]==13)
- {
- temp[s-2]=10;
- s--;
- }
- }
- }
- byte[] res = new byte[s];
- result = null;
-
- System.arraycopy(temp,0,res,0,s);
-
-
- response = new String(res);
-
- try {
- response = replaceString(response,"<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
- }
- catch (Exception e) {}
-
- return response;
- }
-
-private InputStream getHttpInputStream(String url) throws Exception
- {
- URL targetUrl = new URL(url);
- HttpURLConnection h = (HttpURLConnection)targetUrl.openConnection();
- return h.getInputStream();
- }
-
-private String convertManifestToString(Element e) throws Exception
- {
- String result =(new DOMWriterImpl(true)).writeToString(e);
- result = replaceString(result,"<?xml version=\"1.0\"?>","");
- result = replaceStringAll(result,"&apos;","'");
- result = replaceStringAll(result,"#sha1\"/><dsig:","#sha1\"></dsig:DigestMethod><dsig:");
-
- //result = replaceString(result," xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\"","");
- return result;
- }
-
- private String stripNLCR(String input)
- {
- String output = replaceStringAll(input,"\n","");
- output = replaceStringAll(output,"\r","");
- return output;
- }
-
- public static String replaceStringAll(
- String input,
- String oldPart,
- String newPart)
- {
-
- String erg = null;
-
- int pos = input.indexOf(oldPart);
- if(pos==-1) return input;
-
- while(true)
- {
-
- //First Part
- pos = input.indexOf(oldPart);
- if(pos==-1) break;
- erg = input.substring(0, pos);
-
- //Insert new Part
- erg += newPart;
-
- //insert REST
- erg
- += input.substring(
- input.indexOf(oldPart) + oldPart.length(),
- input.length());
-
- input = erg;
- }
- return erg;
- }
-
-
-}
-