From 8c769bae2d6d71677ce71a299d618957029ab4ac Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> Date: Mon, 10 Apr 2006 08:46:26 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'Build_ID-1_3_1'. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build_ID-1_3_1@704 d688527b-c9ab-4aba-bd8d-4036d912da1d --- spss.test/src/testgenerator/TestGeneratorCX1.java | 1054 --------------------- 1 file changed, 1054 deletions(-) delete mode 100644 spss.test/src/testgenerator/TestGeneratorCX1.java (limited to 'spss.test/src/testgenerator/TestGeneratorCX1.java') diff --git a/spss.test/src/testgenerator/TestGeneratorCX1.java b/spss.test/src/testgenerator/TestGeneratorCX1.java deleted file mode 100644 index 44670742b..000000000 --- a/spss.test/src/testgenerator/TestGeneratorCX1.java +++ /dev/null @@ -1,1054 +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.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.HashMap; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -import at.gv.egovernment.moa.util.Base64Utils; -import at.gv.egovernment.moa.util.DOMUtils; - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class TestGeneratorCX1 extends TestCases { - - String datadirectory = "data/CX1/"; - - String base64content = "RGllcyBzaW5kIFRlc3RkYXRlbg=="; - - String defaultblock = - ""+ - ""+ - "PKCS12RSAKey1"+ - ""+ - ""+ - ""+ - ""+ - ""+ - "Gesundheitliche Auswirkungen elektronischer Signaturen"+ - "Ellipse"+ - "Kurvenreich"+ - "1951-04-16"+ - "Hinterm Berg"+ - "6-930-21512-12"+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "text/html"+ - "http://www.description.com"+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""; - - private static final int canAlgCanXML = 1; - private static final int canAlgCanXMLwithCom = 2; - private static final int canAlgExcXML = 3; - private static final int canAlgExcXMLwithCom = 4; - - - public String fileprefix = null; - public String filesuffix = null; - - public TestGeneratorCX1() throws Exception { - - super(); - - // Set config properties - configuration_.setProperty("TestClass", "TestGeneratorCX1"); -// configuration_.setProperty("privateKeyFile", baseDir + "additionalFiles/keys/RSAPrivateKey.der"); -// configuration_.setProperty("publicKeyFile", baseDir + "additionalFiles/keys/RSAPublicKey.der"); -// configuration_.setProperty("signatureFile", baseDir + "additionalFiles/signatures/Signature.unit1.xml"); - - iaik.security.provider.IAIK.addAsProvider(); - iaik.security.ecc.provider.ECCProvider.addAsProvider(); - } - - public static void main(String[] args) throws Exception { - TestGeneratorCX1 testcase = new TestGeneratorCX1(); - - testcase.createConfig(); - testcase.create001(); - testcase.create002(); - testcase.create003(); - testcase.create004(); - testcase.create005(); - testcase.create006(); - testcase.create007(); - testcase.create008(); - testcase.create009(); - testcase.create010(); - testcase.create011(); - testcase.create012(); - testcase.create013(); - testcase.create014(); - - testcase.create051(); - testcase.create052(); - testcase.create053(); - testcase.create054(); - testcase.create055(); - - } - - public void createConfig() throws Exception { - - String file = configuration_.getProperty("baseDir") + datadirectory + - configuration_.getProperty("TestClass") + - ".Config.xml"; - String config = - - ""+ - " "+ - " "+ - - " "+ - " "+ - " "+ - " "+ - " "+ - " "+ - " "+ - ""; - - - /*""+ - " "+ - ""+ - "" + - "";*/ - - FileOutputStream fos = new FileOutputStream(file); - fos.write(config.getBytes()); - fos.flush(); - fos.close(); - - fileprefix = configuration_.getProperty("baseDir")+ datadirectory + configuration_.getProperty("TestClass") + "."; - filesuffix = ".xml"; - } - - public void create001() throws Exception { - - String TestNumber = "001"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - "

Buch:

"+ - "
"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXSLT trans = new TransformImplXSLT(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - trans.setStyleSheet(s,null); - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create002() throws Exception { - - String TestNumber = "002"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
"+ - "
"); - - req = replaceString(req,"SecurityLayerConformity=\"false\"","SecurityLayerConformity=\"true\""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXSLT trans = new TransformImplXSLT(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - trans.setStyleSheet(s,null); - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - //cpkcs.createReferenceWithManifest(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),"manifestObject"); - cpkcs.createETSIObjects("file:/"+configuration_.getProperty("webbaseDir")+"resources/BookData.xml"); - cpkcs.setKeyInformation(1); - - cpkcs.signer.getSignature().setId("signature-1-1"); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create003() throws Exception { - - String TestNumber = "003"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - "//data:book/data:first-name"+ - ""); - - req = replaceString(req,"text/html","text/plain"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXPath trans = new TransformImplXPath(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/BookData.xml"); - trans.setInput(s,null); - trans.addNSDeclaration("data",new URI("http://uri.data.org")); - trans.setXPath("//data:book/data:first-name"); - //trans.setXPath("ancestor-or-self::data:first-name"); - - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - output = replaceString(output,"",""); // workaround - - writeFile(resFile, output); - - } - - public void create004() throws Exception { - - String TestNumber = "004"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - "//data:book/data:first-name"+ - ""); - - req = replaceString(req,"text/html","text/xml"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXPath2 trans = new TransformImplXPath2(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/BookData.xml"); - trans.setInput(s,null); - //trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - //trans.setXPath("/data:book/data:first-name/node()"); - 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; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - output = replaceString(output,"", - ""); - - req = replaceString(req,"text/html","text/xml"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplCanonicalXML trans = new TransformImplCanonicalXML(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create006() throws Exception { - - String TestNumber = "006"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""); - - req = replaceString(req,"text/html","text/xml"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplCanonicalXMLWithComments trans = new TransformImplCanonicalXMLWithComments(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create007() throws Exception { - - String TestNumber = "007"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""); - - req = replaceString(req,"text/html","text/xml"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplExclusiveCanonicalXML trans = new TransformImplExclusiveCanonicalXML(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - trans.setInclusiveNamespacePrefixes("dsig"); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create008() throws Exception { - - String TestNumber = "008"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""); - - req = replaceString(req,"text/html","text/xml"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplExclusiveCanonicalXMLWithComments trans = new TransformImplExclusiveCanonicalXMLWithComments(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - trans.setInclusiveNamespacePrefixes("dsig"); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create009() throws Exception { - - String TestNumber = "009"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""); - - req = replaceString(req,""+ - ""+ - "Gesundheitliche Auswirkungen elektronischer Signaturen"+ - "Ellipse"+ - "Kurvenreich"+ - "1951-04-16"+ - "Hinterm Berg"+ - "6-930-21512-12"+ - ""+ - "",""); - - req = replaceString(req, - "", - ""); - - //req = replaceString(req,"Structure=\"detached\"","Structure=\"enveloping\""); - - - req = replaceString(req,"", - "Text//env:Document"); - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - InputStream bis = new ByteArrayInputStream(("Text").getBytes()); - //Document-Builder holen - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - DocumentBuilder builder = factory.newDocumentBuilder(); - //Dokument Parsen - Document reqDoc = builder.parse(bis); - - System.out.println(DOMUtils.serializeNode(reqDoc.getDocumentElement())); - //Position für die Signatur angeben - String xPath_Pos = "/node()"; - //XPAth-Prefixe deklarieren - String xPath_Prefix = "env xmlns:env=\"http://uri.env.org\""; - Position pos = new Position(xPath_Pos, xPath_Prefix,0); - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(reqDoc,pos,"signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplEnvelopedSignature trans = new TransformImplEnvelopedSignature(); - - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(""),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - output = replaceString(output,"Text",""); - - - - writeFile(resFile, output); - - } - - public void create010() throws Exception { - - String TestNumber = "010"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
"+ - "
"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[2]; - TransformImplCanonicalXML trans = new TransformImplCanonicalXML(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - TransformImplXSLT tr2 = new TransformImplXSLT(); - InputStream s2 = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - tr2.setInput(s2,null); - tr2.setStyleSheet(s2,null); - tr[1] = tr2; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create011() throws Exception { - - String TestNumber = "011"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""); - - req = replaceString(req,"", - ""+ - ""+ - ""+ - Base64Utils.encode((""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
").getBytes())+ - "
"+ - "
"+ - "
"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXSLT trans = new TransformImplXSLT(); - URL u = new URL(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref_not_here.xsl"); - URLConnection hu = u.openConnection(); - //trans.setInput(s,null); - trans.setStyleSheet(hu.getInputStream(),new URI(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref_not_here.xsl")); - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - //cpkcs.createReferenceWithManifest(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),"manifestObject"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - } - - public void create012() throws Exception { - - String TestNumber = "012"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""); - - req = replaceString(req,"", - ""+ - ""+ - ""+ - ""+ - "Gesundheitliche Auswirkungen elektronischer Signaturen"+ - "Ellipse"+ - "Kurvenreich"+ - "1951-04-16"+ - "Hinterm Berg"+ - "6-930-21512-12"+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "text/html"+ - ""+ - ""+ - ""+ - ""+ - ""+ - Base64Utils.encode((""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
").getBytes())+ - "
"+ - "
"+ - "
"+ - "
"+ - "
"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXSLT trans = new TransformImplXSLT(); - URL u = new URL(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref_not_here.xsl"); - URLConnection hu = u.openConnection(); - //trans.setInput(s,null); - trans.setStyleSheet(hu.getInputStream(),new URI(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref_not_here.xsl")); - - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-2"); - //cpkcs.createReferenceWithManifest(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),"manifestObject"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create013() throws Exception { - - String TestNumber = "013"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock, - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "text/html"+ - "http://www.description.com"+ - ""+ - ""+ - ""+ - "", - "CreateTransformsInfoProfile1"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplXSLT trans = new TransformImplXSLT(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"); - trans.setInput(s,null); - trans.setStyleSheet(s,null); - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1-1"); - //cpkcs.createReferenceWithManifest(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),"manifestObject"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create014() throws Exception { - - String TestNumber = "014"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""); - - req = replaceString(req, - "", - ""); - - req = replaceString(req, - ""+ - ""+ - "Gesundheitliche Auswirkungen elektronischer Signaturen"+ - "Ellipse"+ - "Kurvenreich"+ - "1951-04-16"+ - "Hinterm Berg"+ - "6-930-21512-12"+ - ""+ - "", - /*"RGllcyBzaW5kIFRlc3RkYXRlbg=="*/""); - - req = replaceString(req,"text/html","text/plain"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init("signature-1-1"); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - Transform[] tr = new Transform[1]; - TransformImplBase64Decode trans = new TransformImplBase64Decode(); - InputStream s = new FileInputStream(configuration_.getProperty("baseDir")+"resources/testBase64.txt"); - trans.setInput(s,null); - /*trans.addNSDeclaration("data",new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml")); - trans.setXPath("/data:book/data:first-name/node()"); - trans.*/ - tr[0] = trans; - - cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/testBase64.txt"),tr,"reference-1-1"); - cpkcs.setKeyInformation(1); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc); - - writeFile(resFile, output); - - } - - public void create051() throws Exception { - - String TestNumber = "051"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
"+ - "
"); - - req = replaceString(req,"SecurityLayerConformity=\"false\"","SecurityLayerConformity=\"true\""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2202"); - } - - public void create052() throws Exception { - - String TestNumber = "052"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - "/data:book/data:first-name/node()"+ - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2215"); - - - } - - public void create053() throws Exception { - - String TestNumber = "053"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - " "+ - " "+ - " "+ - " "+ - " "); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2220"); - - } - - public void create054() throws Exception { - - String TestNumber = "054"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock, - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "text/html"+ - "http://www.description.com"+ - ""+ - ""+ - ""+ - "", - "CreateTransformsInfoProfileNonValid"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2234"); - - } - - public void create055() throws Exception { - - String TestNumber = "055"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"", - ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - "

Buch: "+ - "

"+ - ""+ - ""+ - "
"+ - "
"+ - "
"); - - req = replaceString(req,"SecurityLayerConformity=\"false\"","SecurityLayerConformity=\"true\""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2216"); - } - - public void writeFile(String filename,String data) throws Exception - { - BufferedWriter bw = new BufferedWriter(new FileWriter(filename)); - bw.write(data); - bw.close(); - } - - public String makeOutputFile(Document signatureDoc) throws Exception - { - ArrayList foundNodes = new ArrayList(); - findNode(signatureDoc.getDocumentElement(),"dsig:Signature",foundNodes); - - Node outputNode = null; - - if(foundNodes.size()>0) - { - outputNode = (Node)foundNodes.get(0); - } - - String erg = Node2String(outputNode); - - // remove the Prologue - int pos = erg.indexOf(""+ - ""+ - //" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\">"+ - "" + - erg + " "; - - return erg; - } -} -- cgit v1.2.3