diff options
author | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2004-06-28 20:46:16 +0000 |
---|---|---|
committer | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2004-06-28 20:46:16 +0000 |
commit | da5f70c20ef4bfea21c9d228e1d6891616887958 (patch) | |
tree | d05130206e29d13c6fd42003896afb2b31320999 /spss.test/src/testgenerator/TestGeneratorVXErrors.java | |
parent | 4dd1877ef3771633e096509dae7b8c99fee9ce4b (diff) | |
download | moa-id-spss-tags/MOA-ID1_2d05.tar.gz moa-id-spss-tags/MOA-ID1_2d05.tar.bz2 moa-id-spss-tags/MOA-ID1_2d05.zip |
This commit was manufactured by cvs2svn to create tag 'MOA-ID1_2d05'.tags/MOA-ID1_2d05
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/MOA-ID1_2d05@145 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.test/src/testgenerator/TestGeneratorVXErrors.java')
-rw-r--r-- | spss.test/src/testgenerator/TestGeneratorVXErrors.java | 1775 |
1 files changed, 0 insertions, 1775 deletions
diff --git a/spss.test/src/testgenerator/TestGeneratorVXErrors.java b/spss.test/src/testgenerator/TestGeneratorVXErrors.java deleted file mode 100644 index 3c9db0dad..000000000 --- a/spss.test/src/testgenerator/TestGeneratorVXErrors.java +++ /dev/null @@ -1,1775 +0,0 @@ -package testgenerator; -import iaik.ixsil.algorithms.DigestAlgorithmImplSHA1; -import iaik.ixsil.algorithms.Transform; -import iaik.ixsil.algorithms.TransformImplBase64Decode; -import iaik.ixsil.algorithms.TransformImplXSLT; -import iaik.ixsil.util.URI; -import iaik.utils.Base64OutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -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; - -/** - * @author stephan - */ -public class TestGeneratorVXErrors 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 { - - etsiURI = new URI("http://uri.etsi.org/01903/v1.1.1#SignedProperties"); - - vxBean = new VXResponseBean(); - - TestGeneratorVXErrors testcase = new TestGeneratorVXErrors(); - testcase.createVXConfig(); - - - //testcase.create051(); - testcase.create052(); - testcase.create053(); - testcase.create054(); - testcase.create055(); - - testcase.create151(); - //testcase.create152(); - testcase.create153(); - testcase.create154(); -//N.A.: testcase.create155(); - - testcase.create251(); - //testcase.create252(); - //testcase.create252_2(); - testcase.create253(); - //testcase.create254(); - //testcase.create255(); - //testcase.create256(); - - testcase.create351(); - testcase.create352(); - //testcase.create353(); - testcase.create354(); - //testcase.create355(); - testcase.create356(); - testcase.create357(); - //testcase.create358(); - testcase.create359(); - testcase.create360(); - testcase.create360_2(); - //testcase.create361(); - testcase.create362(); - testcase.create363(); - testcase.create364(); - testcase.create365(); - testcase.create366(); - testcase.create367(); - //testcase.create368(); - testcase.create369(); - testcase.create370(); - - - } - - /* ==================================================================================================== */ - - public TestGeneratorVXErrors() 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 create051() throws Exception { - String testNumber = "051"; - //Create a Request with number 051, Time in the future (+24 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/testDaten.txt"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,24), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"0000"); - - } - /** - * Method create052. - * @throws Exception - */ - public void create052() throws Exception { - String testNumber = "052"; - //Create a Request with number 052, with current Time (+0 hours) - // and with the Date and ReturnHashInputDate Elements present - - // BUT there is in invalid Element to crash validation against XMLDsig - // </dsig:SignedInfo> is replaces by </dsig:NoValidDSigSignedInfo> - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = - replaceString( - request, - "<dsig:SignedInfo>", - "<dsig:NoValidDSigSignedInfo>"); - request = - replaceString( - request, - "</dsig:SignedInfo>", - "</dsig:NoValidDSigSignedInfo>"); - - writeFile(vxReqFile(testNumber), request); - writeFile(vxResErrFile(testNumber),"1100"); - } - - /** - * Method create053. - * @throws Exception - */ - public void create053() throws Exception { - String testNumber = "053"; - //Create a Request with number 053, with current Time (+0 hours) - // and with the Date and ReturnHashInputDate Elements present - - // BUT with an invalid XPath expression - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = - replaceString( - request, - "<VerifySignatureLocation>//dsig:Signature</VerifySignatureLocation>", - "<VerifySignatureLocation>//invalid XPath Expression</VerifySignatureLocation>"); - - writeFile(vxReqFile(testNumber), request); - writeFile(vxResErrFile(testNumber),"2212"); - } - /** - * Method create054. - * @throws Exception - */ - public void create054() throws Exception { - String testNumber = "054"; - - //Create a Request with number 053, with current Time (+0 hours) - // and with the Date and ReturnHashInputDate Elements present - - // BUT with an valid XPath expression not referencing a valid element - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = - replaceString(request, "//dsig:Signature", "//dsig:NoValidElement"); - writeFile(vxReqFile(testNumber), request); - writeFile(vxResErrFile(testNumber),"2212"); - } - public void create055() throws Exception { - - String testNumber = "055"; - - //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/testDaten.txt"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = - replaceString(request, - "TrustProfile1", "InvalidProfile"); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2203"); - - - // writeFile(vxResFile(testNumber), createResponse(testNumber,"0")); - } - public void create151() throws Exception { - - String testNumber = "151"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - - String requestEnd = createSignatureInfoEnd()+ - createRequestShortEnd(false); - - String request = - makeOutputFile( - createRequestStart(testNumber + " an URI referenced in dsig:Signature does not resolve and no SupplementProfile is available",true,0), - cpkcs.returnSig(), - requestEnd); - - request = replaceString(request, configuration_.getProperty("webbaseDir")+"resources/testDaten.txt","http://no.uritoresolve.com" ); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2264"); - - } - public void create152() throws Exception { - - String testNumber = "152"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - Supplement supp = new Supplement(); - supp.addMetaInfo("text/plain","http://www.buergerkarte.at"); - supp.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt", - readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testDaten.txt")); - supp.closeSupplement(); - //supp.addProfileID("Some ID"); - - String requestEnd = createSignatureInfoEnd()+ - supp.getSupplement() + createRequestShortEnd(false); - - String request = - makeOutputFile( - createRequestStart(testNumber + "- MimeType",true,0), - cpkcs.returnSig(), - requestEnd); - - request = replaceString(request, "text/plain","no valid MIME-Type" ); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"1100"); - } - - public void create153() throws Exception { - - String testNumber = "153"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - String requestEnd = - createSignatureInfoEnd()+ - "<SupplementProfileID>NO VALID SUPPLEMENT PROFILE ID</SupplementProfileID>" + - createRequestShortEnd(false); - - String request = - makeOutputFile( - createRequestStart(testNumber + " - invalid SupplementProfileID",true,0), - cpkcs.returnSig(), - requestEnd); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2267"); - } - - public void create154() throws Exception { - - String testNumber = "154"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - Supplement supp = new Supplement(); - supp.addMetaInfo("text/plain","http://www.buergerkarte.at"); - supp.addBase64Content(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt", - readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/testDaten.txt")); - supp.closeSupplement(); - //supp.addProfileID("Some ID"); - - String requestEnd = createSignatureInfoEnd()+ - supp.getSupplement() + createRequestShortEnd(false); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - requestEnd); - request = replaceString(request,"<Base64Content>","<Base64Content>AAAAAAAAAAAAAAAAAA"); - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"1100"); - } - -public void create155() throws Exception { - String testNumber = "155"; -/* CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - Supplement supp = new Supplement(); - supp.addXMLContent(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt", readFileCR(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt")); - supp.closeSupplement(); - - String requestEnd = - createSignatureInfoEnd()+ - supp.getSupplement()+ - createRequestShortEnd(false); - - String request = - makeOutputFile( - createRequestStart(testNumber+" - Supplement/Content/XMLContent does not match to the signature",true,0), - cpkcs.returnSig(), - requestEnd); -*/ -// request = replaceString(request,"<XMLContent>","<XMLContent><OPEN_ELEMENT>"); - - writeFile(vxReqFile(testNumber),"N.A."); - writeFile(vxResErrFile(testNumber),"0000"); - } - - - -public void create251() throws Exception - { String testNumber = "251"; - - 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("InvalidTransformsProfile"); - - String request = - makeOutputFile( - createRequestStart("251 - VerifyTransformsInfoID: invalidID",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() + smcp.returnDoc() - + createRequestShortEnd(false)); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2268"); - } - - - public void create252() throws Exception - { String testNumber = "252"; - - 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(),"</SignatureManifestCheckParams>","") + - replaceString(smcp2.returnDoc(),"<SignatureManifestCheckParams>",""); - - String request = - makeOutputFile( - createRequestStart("252 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"); - } - -public void create252_2() throws Exception - { String testNumber = "252_2"; - - 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("252_2 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"); - } - -public void create253() throws Exception - { String testNumber = "253"; - - 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("Base64Content",readBinaryFileAsBase64_new(configuration_.getProperty("baseDir")+"resources/"+ filename)); - - String request = - makeOutputFile( - createRequestStart("253 mismatching dsig:Transform/@Algorithm and dsig:Transform content",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() + smcp.returnDoc() - + createRequestShortEnd(false)); - - request = replaceString(request, - "http://www.w3.org/TR/1999/REC-xslt-19991116","MismatchingTransformAlgorithm"); - request = replaceString(request, - "http://www.w3.org/TR/1999/REC-xslt-19991116","http://www.w3.org/TR/1999/REC-xpath-19991116"); - request = replaceString(request,"MismatchingTransformAlgorithm", - "http://www.w3.org/TR/1999/REC-xslt-19991116"); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2202"); - } -public void create254() throws Exception - { String testNumber = "254"; - - 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("webbaseDir")+"resources/" + filename)); - - String request = - makeOutputFile( - createRequestStart("254 - TransformParameter/@URI resolves but Hash does not match - which hashing algorithm?",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() + smcp.returnDoc() - + createRequestShortEnd(false)); - - request = replaceString(request,"<Hash><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><dsig:DigestValue>", - "<Hash><dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><dsig:DigestValue>abcd"); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2205"); - } - -public void create255() throws Exception - { String testNumber = "255"; - - 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("255 kein TransformParameter element obwohl in Transforms URIs referenziert werden",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() + smcp.returnDoc() - + createRequestShortEnd(false)); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2204"); - } - -public void create256() throws Exception - { String testNumber = "256"; - - 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("256 1 VerifyTransformsInfoID ==> Passt aber nicht zur Transformation (XSLT <==> Canonisiserung)",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() + smcp.returnDoc() - + createRequestShortEnd(false)); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2204"); - } - -public void create351() throws Exception { - - String testNumber = "351"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - String request = - makeOutputFile( createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - request = replaceString( request, - "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", - "http://www.w3.org/TR/2001/unknownCanonicalzationMethod"); - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2240"); - } - - -public void create352() throws Exception { - - String testNumber = "352"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - String request = - makeOutputFile( createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - request = replaceString( request, - "http://www.w3.org/2000/09/xmldsig#rsa-sha1", - "http://www.w3.org/TR/2001/unknownSignatureMethod"); - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2240"); - } -public void create353()throws Exception { - - String testNumber = "353"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,"#xpointer(id('envelopedData'))"); - cpkcs.createEnvelopedDataObject("envelopedData",readFileCR(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt")); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = - replaceString( - request, - "#xpointer(id('envelopedData'))", - "#xpointer(id('unknownURITarget'))"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2264"); - } - public void create354() throws Exception { - - String testNumber = "354"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - String request = - makeOutputFile( createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - request = replaceString( request, - "http://www.w3.org/2000/09/xmldsig#sha1", - "http://www.w3.org/TR/2001/unknownDigestMethod"); - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2240"); - } - public void create355() throws Exception { - - String testNumber = "355"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt")); - cpkcs.setKeyInformation(); - String request = - makeOutputFile( createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - request = replaceString( request, - "<dsig:DigestValue>", - "<dsig:DigestValue>WrongData and the original:"); - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"0000"); - } - public void create356() throws Exception { - - String testNumber = "356"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - //Erzeugen der Base64-Daten -// String tmp = readBinaryFileAsBase64(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - - URI target = new URI(configuration_.getProperty("webbaseDir")+"resources/testDaten.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)); - request = replaceString( request, - "http://www.w3.org/2000/09/xmldsig#base64", - "http://www.w3.org/TR/2001/unknownTransformsMethod"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - public void create357() throws Exception { - - String testNumber = "357"; - - 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.setKeyInformation(); - - - String request = - makeOutputFile( - createRequestStart("357 nicht zu Reference/Transforms/Transform/@Algorithm passender Inha",true,0), - cpkcs.returnSig(), - createSignatureInfoEnd() - + createRequestShortEnd(false)); - - request = replaceString(request, "http://www.w3.org/TR/1999/REC-xslt-19991116", - "http://www.w3.org/TR/1999/REC-xpath-19991116"); - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create358() throws Exception { - - String testNumber = "358"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - //cpkcs.createReference(true,"Dies sind testdaten"); - - URI target = new URI(configuration_.getProperty("webbaseDir")+"resources/testDaten.txtBase64.enc"); - - // cpkcs.createEnvelopedDataObject("envelopedData",readBinaryFileAsBase64(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt")); - - Transform[] tr = new Transform[1]; - tr[0] = new TransformImplBase64Decode(); - InputStream s = getHttpInputStream(target.toString()); - tr[0].setInput(s,null); - - cpkcs.createReferenceWithTransforms(target,tr); - //cpkcs.createReference(false, "file:/"+ configuration_.getProperty("webbaseDir")+"resources/test_wo_canonicalisation.XML"); - //cpkcs.createReference(false, "file:/"+ configuration_.getProperty("webbaseDir")+"resources/test_w_canonicalisation.XML"); -// cpkcs.createReferenceWithManifest(new URI("file:/"+ configuration_.getProperty("webbaseDir")+"resources/test_w_canonicalisation.XML"),"canonicalizedData"); - - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request, - "<dsig:SignatureValue>","<dsig:SignatureValue>abcd"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create359() throws Exception { - - String testNumber = "359"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:KeyInfo>",""); - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>",""); - request = replaceString(request,"</dsig:KeyInfo>",""); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2243"); - } - public void create360() throws Exception { - - String testNumber = "360"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>", - "<dsig:X509Data><dsig:X509SubjectName>Some kind of Subject</dsig:X509SubjectName></dsig:X509Data>"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create360_2() throws Exception { - - String testNumber = "360_2"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>", - "<dsig:KeyName>Some kind of string as KeyName</dsig:KeyName>"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create361() throws Exception { - - String testNumber = "361"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>", - " <dsig:X509Data>\n"+ - " <dsig:X509Certificate>"+ - readFileCR(configuration_.getProperty("webbaseDir") + "resources/tests.cer.b64") + - "</dsig:X509Certificate>\n"+ - " </dsig:X509Data>\n"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2243"); - } - - public void create362() throws Exception { - - String testNumber = "362"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>", - " <dsig:X509Data>\n"+ - " <dsig:X509Certificate>"+ - readFileCR(configuration_.getProperty("webbaseDir")+"resources/testDaten.txtbase64.enc") + - "</dsig:X509Certificate>\n"+ - " </dsig:X509Data>\n"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - public void create363() throws Exception { - - String testNumber = "363"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request,"<dsig:RetrievalMethod Type=\"http://www.w3.org/2000/09/xmldsig#X509Data\" URI=\""+configuration_.getProperty("webbaseDir") + "resources/X509Data.xml\"/>", - " <dsig:X509Data>\n"+ - " <dsig:X509Certificate>"+ - "( no BASE64 data )" + - "</dsig:X509Certificate>\n"+ - " </dsig:X509Data>\n"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"1100"); - } - - public void create364() throws Exception { - - String testNumber = "364"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request, - "http://www.w3.org/2000/09/xmldsig#X509Data", - "http://www.w3.org/2000/09/noValidRetrievalMethodType"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - public void create365() throws Exception { - - String testNumber = "365"; - - URI fileURI = new URI(configuration_.getProperty("webbaseDir") + "resources/X509Data.xml"); - URI typeURI = new URI("http://www.w3.org/2000/09/xmldsig#X509Data"); - - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(true,readFileCR(configuration_.getProperty("webbaseDir") + "resources/testDaten.txt")); - cpkcs.setKeyInformation(false, fileURI, typeURI, null); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request, - configuration_.getProperty("webbaseDir") + "resources/X509Data.xml", - configuration_.getProperty("webbaseDir") + "resources/test-ee2003_normal.der"); - - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create366() throws Exception { - - String testNumber = "366"; - - 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/testDaten.txt"); - - //DER-encoded RAW-Zertifikat zu Binary64 konvertieren - // String tmp = readBinaryFileAsBase64(fileURI.getPath()); - //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)); - - request = replaceString(request, "http://www.w3.org/2000/09/xmldsig#base64", - "http://Invalid.URI.com"); - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - public void create367() throws Exception { - - String testNumber = "367"; - - 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/testDaten.txt"); - - //DER-encoded RAW-Zertifikat zu Binary64 konvertieren - // String tmp = readBinaryFileAsBase64(fileURI.getPath()); - //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)); - - request = replaceString(request, "http://www.w3.org/2000/09/xmldsig#rawX509Certificate", - "http://www.w3.org/2000/09/xmldsig#X509Data"); - writeFile(vxReqFile(testNumber),request); - - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create368() throws Exception { - String testNumber = "368"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - URI fileURI1 = new URI(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.createReferenceWithManifest(fileURI1,"manifestObject"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request, "http://www.w3.org/2000/09/xmldsig#Manifest", - "http://No.valid_manifest_URI.com"); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2240"); - } - - public void create369() throws Exception { - String testNumber = "369"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - URI fileURI1 = new URI(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.createReferenceWithManifest(fileURI1,"manifestObject"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - request = replaceString(request, "#xpointer(id('manifestObject'))", - "#xpointer(id('NoValidManifestObject'))"); - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2262"); - } - public void create370() throws Exception { - String testNumber = "370"; - - CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - URI fileURI1 = new URI(configuration_.getProperty("webbaseDir")+"resources/testDaten.txt"); - cpkcs.createReferenceWithManifest(fileURI1,"manifestObject"); - cpkcs.setKeyInformation(); - - String request = - makeOutputFile( - createRequestStart(testNumber,true,0), - cpkcs.returnSig(), - createRequestEnd(true,false,null)); - - //Hier wird der DigestAlg vom Reference-Objekt im SignedInfo verändert - request = replaceString(request, - "http://www.w3.org/2000/09/xmldsig#sha1", - "noValidDigestAlg"); - //Hier wird der DigestAlg vom Reference-Objekt im Manifset verändert - request = replaceString(request, - "http://www.w3.org/2000/09/xmldsig#sha1", - "noValidDigestAlg"); - //Hier wird der DigestAlg vom Reference-Objekt im SignedInfo zurück geändert - request = replaceString(request, - "noValidDigestAlg", - "http://www.w3.org/2000/09/xmldsig#sha1"); - - - writeFile(vxReqFile(testNumber),request); - writeFile(vxResErrFile(testNumber),"2262"); } - - - /** - * 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) - {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" - + "<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>\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 += " <Supplement>\n" + - " <Content Reference=\"file:/" + supplementReference.toString() + "\">\n" + - " <XMLContent>"+readFileCR(supplementReference.toString())+"</XMLContent>\n" + - " </Content>\n" + - " </Supplement>\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 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" - + " </dsig:X509Data>\n" - + " </SignerInfo>\n"; - res += " <HashInputData>\n" + " <XMLContent xml:space=\"preserve\">"; - res += readFileCR( - configuration_.getProperty("webbaseDir") - + "resources/testDaten.txt")+ - "</XMLContent>"; - - 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 += " <dsig:X509IssuerSerial>\n"; - res += vxBean.getIssuerDN(); - res += vxBean.getSerialNumber(); - res += " </dsig:X509IssuerSerial>\n" - + " </dsig:X509Data>\n" - + " </SignerInfo>\n"; - res += " <HashInputData>\n" + - " <XMLContent xml:space=\"preserve\">"+ - hashData + - "</XMLContent>\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 += " <dsig:X509IssuerSerial>\n"; - res += vxBean.getIssuerDN(); - res += vxBean.getSerialNumber(); - res += " </dsig:X509IssuerSerial>\n" - + " </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 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 += " <dsig:X509IssuerSerial>\n"; - res += vxBean.getIssuerDN(); - res += vxBean.getSerialNumber(); - res += " </dsig:X509IssuerSerial>\n" - + " </dsig:X509Data>\n" - + " </SignerInfo>\n"; - res += " <HashInputData>\n" + " <XMLContent>"; - res += readFile( - configuration_.getProperty("webbaseDir") - + "resources/testDaten.txt"); - - res += vxBean.getFooterXMLDSIGManifestCheck(xmlDSIGManifestCheckCode,"0"); - - return res; - }*/ - - private String createResponsePart() 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" - + " </dsig:X509Data>\n" - + " </SignerInfo>\n"; - 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(); - } - -public String vxResErrFile(String testNumber) - { - return configuration_.getProperty("baseDir") + - "/data/VX0/"+ - configuration_.getProperty("TestClass") + - "." + - testNumber + - ".ErrRes.xml"; - } -private String getBase64Hash(String filename) throws Exception - { - DigestAlgorithmImplSHA1 dig = new DigestAlgorithmImplSHA1(); - InputStream s = getHttpInputStream(filename); - - dig.setInput(s); - - InputStream erg = dig.digest(); - String result = ""; - - byte[] b = new byte[1]; - erg.read(b); - while (erg.available() > 0) - { - result += new String(b); - erg.read(b); - } - result += new String(b); - - ByteArrayOutputStream fos = new ByteArrayOutputStream(); - Base64OutputStream base64os = new Base64OutputStream(fos); - base64os.write(result.getBytes()); - base64os.flush(); - - return fos.toString(); - } -} |