package testgenerator; import iaik.ixsil.algorithms.DigestAlgorithmImplSHA1; import iaik.ixsil.algorithms.Transform; import iaik.ixsil.algorithms.TransformImplCanonicalXML; import iaik.ixsil.algorithms.TransformImplXSLT; import iaik.ixsil.util.URI; import java.io.ByteArrayInputStream; import java.io.FileInputStream; 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 org.w3c.dom.Document; import org.w3c.dom.Node; import at.gv.egovernment.moa.util.Base64Utils; /** * @author stephan */ public class TestGeneratorVX2 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; private static String etsiPropertyName = "ETSIProperties"; private static URI etsiURI; public static void main(String[] args) throws Exception { vxBean = new VXResponseBean(); TestGeneratorVX2 testcase = new TestGeneratorVX2(); etsiURI = new URI("http://uri.etsi.org/01903/v1.1.1#SignedProperties"); testcase.create201(); testcase.create202(); testcase.create203(); testcase.create205(); testcase.create206(); testcase.create208(); testcase.create209(); testcase.create210(); testcase.create211(); testcase.create212(); testcase.create213(); testcase.create214(); testcase.create215(); testcase.create216(); testcase.create217(); } /* ==================================================================================================== */ public TestGeneratorVX2() 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(); } /* ==================================================================================================== */ /** * Method create001. * @throws Exception */ /* ===================================================================================================================== */ /* ===================================================================================================================== */ /* ===================================================================================================================== */ public void create201() throws Exception { String testNumber = "201"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename + "")); String request = makeOutputFile( createRequestStart("201 a simple request w/ SignatureManifestCheckParams (but w/o Supplement)",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); // int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create202() throws Exception { String testNumber = "202"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams(null); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); String request = makeOutputFile( createRequestStart("202 no SignatureManifestCheckParams/@ReturnReferenceInputData" ,true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create203() throws Exception { String testNumber = "203"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("false"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); String request = makeOutputFile( createRequestStart("203 SignatureManifestCheckParams/@ReturnReferenceInputData = false",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); String response = createResponsePart(cpkcs.getX509CertString()) + vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create205() throws Exception { String testNumber = "205"; String filename = "CX1_book.xsl"; CreatePKCSSignature cpkcs = new CreatePKCSSignature(); cpkcs.init("signature"); cpkcs.setCanoncialization(canAlgCanXML); Transform[] tr = new Transform[2]; TransformImplCanonicalXML trans0 = new TransformImplCanonicalXML(); InputStream s = getHttpInputStream(configuration_.getProperty("webbaseDir")+"resources/CX1_bookref.xsl"); trans0.setInput(s,new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_bookref.xsl")); tr[0] = trans0; TransformImplXSLT trans = new TransformImplXSLT(); 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[1] = trans; cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1"); cpkcs.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename )); String request = makeOutputFile( createRequestStart("206 - 2 dsig:Transform elements ==> Canonisierung + Stylesheet",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create206() throws Exception { String testNumber = "206"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Hash",getBase64Hash(configuration_.getProperty("baseDir")+"resources/" + filename)); String request = makeOutputFile( createRequestStart("206 TransformParameter/Hash statt TransformParameter/Base64Content (Der Hash wird von " + filename + " gebildet)",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create208() throws Exception { String testNumber = "208"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_book.xsl"); String request = makeOutputFile( createRequestStart("208 - weder Base64Content noch Hash wird verwendet ",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create209() throws Exception { String testNumber = "209"; 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_book.xsl"); trans.setStyleSheet(s,new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_book.xsl")); tr[0] = trans; cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1"); // cpkcs.createReferenceWithManifest( // new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), // "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); String request = makeOutputFile( createRequestStart("209 0 TransformParameter ==> ganzes Element raus und direkt auf CX1_book.xsl verweisen (in der Transformations-Referenz)",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); /*int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("2")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create210() throws Exception { String testNumber = "210"; 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/VX2_bookref2includes.xsl"); trans.setStyleSheet(s,new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX2_bookref2includes.xsl")); trans.setInput(s,null); tr[0] = trans; //System.out.println(getTransformsResult(tr)); cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1"); cpkcs.createReferencesWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX2_book0.xsl"), "Manifest",new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX2_book1.xsl"), "http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX2_book0.xsl"); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/VX2_book0.xsl")); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/VX2_book1.xsl"); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/VX2_book1.xsl")); String request = makeOutputFile( createRequestStart("210 2 includes",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create211() throws Exception { String testNumber = "211"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); /*for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/CX1_book.xsl"); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/CX1_book.xsl"));*/ smcp.addTransformsProfileID("TransformsInfoProfile1"); smcp.addTransformsProfileID("TransformsInfoProfile2"); String request = makeOutputFile( createRequestStart("211 2 VerifyTransformsInfoID ==> Statt TransformsInfoProfile , in ein IntoProfileID auf Datei mit orig.Daten des TransInfoProfile verweisen, das andere auf ein Transforms, das nur Canonisiserung enthaelt",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create212() throws Exception { String testNumber = "212"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-2"); cpkcs.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); ets.addDataObjectFormat("#reference-2"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); //2. DataObject Format cpkcs.createReference(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('ETSIProperties')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"),etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename )); SignatureManifestCheckParams smcp2 = new SignatureManifestCheckParams(null); for (int trNr=0; trNr < tr.length; trNr++) smcp2.addDisgTransform(tr[trNr].toElement(smcp2.getDoc())); smcp2.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp2.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename )); String signManiDoc = replaceString(smcp.returnDoc(),"","") + replaceString(smcp2.returnDoc(),"",""); String request = makeOutputFile( createRequestStart("212 2 ReferenceInfo (for 2 dsig:Reference (pplus Manifest + SignedProperties) : etsi:DataObjectFormat 2mal, Reference 2mal, Manifest 1mal, ReferenceInfo 2mal)",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + signManiDoc + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("0")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create213() throws Exception { String testNumber = "213"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xpointer(id('" + etsiPropertyName + "'))/*/*"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); String request = makeOutputFile( createRequestStart("213 kein TransformParameter element obwohl in Transforms URIs referenziert werden",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""); pos_2 = request.substring(pos_1).indexOf(""); String etsi = request.substring(pos_1,pos_1+pos_2+"".length()); etsi = replaceString(etsi,"",""); String response = createResponsePart(cpkcs.getX509CertString()) + ""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("1","1")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create214() throws Exception { String testNumber = "214"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xpointer(id('" + etsiPropertyName + "'))/*/*"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); smcp.addTransformsProfileID("TransformsInfoProfile2"); String request = makeOutputFile( createRequestStart("214 1 VerifyTransformsInfoID ==> Passt aber nicht zur Transformation (XSLT <==> Canonisiserung)",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); pos_2 = request.substring(pos_1).indexOf(""); String etsi = request.substring(pos_1,pos_1+pos_2+"".length()); etsi = replaceString(etsi,"",""); String response = createResponsePart(cpkcs.getX509CertString()) + ""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("1","1")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create215() throws Exception { String testNumber = "215"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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; //Reference 1 cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1"); cpkcs.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); //ets.addDataObjectFormat("#reference-2"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xpointer(id('" + etsiPropertyName + "')/*/*)"),etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); SignatureManifestCheckParams smcp2 = new SignatureManifestCheckParams(null); for (int trNr=0; trNr < tr.length; trNr++) smcp2.addDisgTransform(tr[trNr].toElement(smcp2.getDoc())); smcp2.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp2.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); String signManiDoc = replaceString(smcp.returnDoc(),"","") + replaceString(smcp2.returnDoc(),"",""); String request = makeOutputFile( createRequestStart("215 number of ReferenceInfo is different from number of dsig:Reference in the signature",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + signManiDoc + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); //writeFile(vxResErrFile(testNumber),"2271"); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("1")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create216() throws Exception { String testNumber = "216"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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; //Reference 1 cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-1"); cpkcs.createReferenceWithTransforms(new URI(configuration_.getProperty("webbaseDir")+"resources/BookData.xml"),tr,"reference-2"); cpkcs.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); ets.addDataObjectFormat("#reference-2"); cpkcs.createEnvelopedDataObject( etsiPropertyName,ets.getQualProp()); cpkcs.createReference(new URI("#xpointer(id('" + etsiPropertyName + "')/*/*)"),etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); String request = makeOutputFile( createRequestStart("216 number of References id bigger then number of ReferenceInfos",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); writeFile(vxReqFile(testNumber),request); //writeFile(vxResErrFile(testNumber),"2271"); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); String etsi = request.substring(pos_1,pos_2+"".length()); //etsi = replaceStringAll(etsi,"etsi:","ns1:"); etsi = replaceString(etsi,""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("1")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } public void create217() throws Exception { String testNumber = "217"; String filepath = configuration_.getProperty("webbaseDir")+"resources/"; String filename = "CX1_book.xsl"; 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.createReferenceWithManifest( new URI("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/" + filename), "Manifest","http://www.buergerkarte.at/specifications/Securitylayer/20020225#SignatureManifest"); EtsiProperties ets = new EtsiProperties(); ets.addDataObjectFormat("#reference-1"); cpkcs.createEnvelopedDataObject(etsiPropertyName, ets.getQualProp()); cpkcs.createReference(new URI("#xpointer(id('" + etsiPropertyName + "'))/*/*"), etsiURI); cpkcs.setKeyInformation(); SignatureManifestCheckParams smcp = new SignatureManifestCheckParams("true"); for (int trNr=0; trNr < tr.length; trNr++) smcp.addDisgTransform(tr[trNr].toElement(smcp.getDoc())); smcp.addTransPara("http://moa-test.brz.intra.gv.at/TestDatenGenerator/resources/"+ filename); smcp.addTransParaElement("Hash",getBase64Hash(configuration_.getProperty("baseDir")+"resources/" + filename)); String request = makeOutputFile( createRequestStart("217 - TransformParameter/@URI resolves but Hash does not match - which hashing algorithm?",true,0), cpkcs.returnSig(), createSignatureInfoEnd() + smcp.returnDoc() + createRequestShortEnd(false)); request = replaceString(request,"", "abcd"); writeFile(vxReqFile(testNumber),request); //writeFile(vxResErrFile(testNumber),"2205"); int pos_1 = request.indexOf(""); String manifest = request.substring(pos_1,pos_2+"".length()); manifest = replaceString(manifest,""); pos_2 = request.substring(pos_1).indexOf(""); String etsi = request.substring(pos_1,pos_1+pos_2+"".length()); etsi = replaceString(etsi,"",""); String response = createResponsePart(cpkcs.getX509CertString()) + ""+ readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/BookData.xml")+ ""+ ""+manifest+""+ ""+etsi+""+ vxBean.createSignatureCheck("0")+ vxBean.createSignatureManifestCheck("1","1")+ vxBean.createCertificateCheck("0")+ ""; writeFile(vxResFile(testNumber), response); } /** * 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 Prologue int pos = erg.indexOf("" + "\n" + "\n"; if (useDate) { reqStart += " " + getDate(changeHours) + "\n"; } reqStart += " \n" + " \n" + " " ; 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 0) { result += new String(b); is.read(b); } result += new String(b); return result; } private String getBase64Hash(String filename) throws Exception { DigestAlgorithmImplSHA1 dig = new DigestAlgorithmImplSHA1(); dig.setInput(new FileInputStream(filename)); InputStream erg = dig.digest(); String result = ""; int size = erg.available(); byte[] b = new byte[size]; erg.read(b); return Base64Utils.encode(b); } /** * 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 = "\n" + " #xpointer(/VerifyXMLSignatureRequest/VerifySignatureInfo/VerifySignatureEnvironment/dsig:Signature)\n" + " \n"; */ reqEnd =""+ "\n" + " //dsig:Signature\n" + " \n"; if (useSupplement) { reqEnd += " \n" + " \n" + " "+readFile(supplementReference.toString())+"\n" + " \n" + " \n"; } if (useReturnHashInputData) { reqEnd += " \n"; } reqEnd += " TrustProfile1\n" + "\n"; return reqEnd; } private String createSignatureInfoEnd() throws Exception { return ""+"\n" + " //dsig:Signature\n" + " \n"; } private String createRequestShortEnd(boolean useReturnHashInputData) throws Exception { String reqEnd = ""; if (useReturnHashInputData) reqEnd = " \n"; reqEnd += " TrustProfile1\n" + "\n"; return reqEnd; } /** * Method createResponse. * @param testNumber * @param signatureCheckCode * @return String * @throws Exception */ private String createResponse(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 += " \n"; res += vxBean.getIssuerDN(); res += vxBean.getSerialNumber(); res += " \n" + " \n" + " \n"; res += " \n" + " "; res += readFile( configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")+ ""; res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0"); return res; } private String createResponse(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 += " \n"; res += vxBean.getIssuerDN(); res += vxBean.getSerialNumber(); res += " \n" + " \n" + " \n"; res += " \n" + " "+ hashData + "\n"; res += vxBean.getFooterSignatureCheck(signatureCheckCode, "0"); return res; } private String createResponseWithoutHashInputData(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 += " \n"; res += vxBean.getIssuerDN(); res += vxBean.getSerialNumber(); res += " \n" + " \n" + " \n" + " \n" + " " + signatureCheckCode + "\n" + " \n" + " \n" + " 0\n" + " \n" + ""; return res; } /* private String createResponseXMLDsigCheck(String testNumber, String xmlDSIGManifestCheckCode) throws Exception { // vxBean.init(configuration_.getProperty("webbaseDir")+ "resources/" + "test-ee2003_normal.der"); String res = null; res = vxBean.getHeader(); res += vxBean.getSubjectDN(); res += " \n"; res += vxBean.getIssuerDN(); res += vxBean.getSerialNumber(); res += " \n" + " \n" + " \n"; res += " \n" + " "; res += readFile( configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); res += vxBean.getFooterXMLDSIGManifestCheck(xmlDSIGManifestCheckCode,"0"); 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 += " \n"; res += vxBean.getIssuerDN(); res += vxBean.getSerialNumber(); res += " \n" + x509cert + " \n" + " \n"; /*res += " \n" + " "; res += readFile( configuration_.getProperty("webbaseDir") + "resources/testDaten.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",""); } catch (Exception e) {} return response; } private InputStream getHttpInputStream(String url) throws Exception { return ((HttpURLConnection)new URL(url).openConnection()).getInputStream(); } }