diff options
author | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-12-22 17:28:21 +0000 |
---|---|---|
committer | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2003-12-22 17:28:21 +0000 |
commit | 057f884903954203339182649daa100ef4ce89e3 (patch) | |
tree | 7d6d5b0dc4aea4a63674b90800ebbf6ffcc0ca4d /spss.test/src/testgenerator/TestGeneratorVC0.java | |
parent | 92cca056c7935075012576b684c3678a9ec9f4ad (diff) | |
download | moa-id-spss-057f884903954203339182649daa100ef4ce89e3.tar.gz moa-id-spss-057f884903954203339182649daa100ef4ce89e3.tar.bz2 moa-id-spss-057f884903954203339182649daa100ef4ce89e3.zip |
This commit was manufactured by cvs2svn to create tag 'Build_001'.tags/Build_001
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build_001@85 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.test/src/testgenerator/TestGeneratorVC0.java')
-rw-r--r-- | spss.test/src/testgenerator/TestGeneratorVC0.java | 1057 |
1 files changed, 0 insertions, 1057 deletions
diff --git a/spss.test/src/testgenerator/TestGeneratorVC0.java b/spss.test/src/testgenerator/TestGeneratorVC0.java deleted file mode 100644 index f54689875..000000000 --- a/spss.test/src/testgenerator/TestGeneratorVC0.java +++ /dev/null @@ -1,1057 +0,0 @@ -package testgenerator; - -import iaik.asn1.ASN1Object; -import iaik.asn1.CodingException; -import iaik.asn1.DerCoder; -import iaik.asn1.ObjectID; -import iaik.asn1.structures.AlgorithmID; -import iaik.asn1.structures.Attribute; -import iaik.asn1.structures.ChoiceOfTime; -import iaik.asn1.structures.Name; -import iaik.cms.CMSException; -import iaik.cms.ContentInfoStream; -import iaik.cms.SignedDataStream; -import iaik.cms.SignerInfo; -import iaik.security.random.SecRandom; -import iaik.utils.StreamCopier; -import iaik.x509.X509Certificate; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.PrivateKey; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.Security; -import java.security.SignatureException; - -import sun.misc.BASE64Encoder; - - -/** - * @author Administrator - * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. - */ -public class TestGeneratorVC0 extends TestCases { - - String datadirectory = "data/VC0/"; - String datadirectory_l = "data/LVC"; - - public String defaultblock = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ - "<VerifyCMSSignatureRequest xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" Signatories=\"1\">"+ - "<DateTime>2003-04-04T09:30:47-05:00</DateTime>"+ - "<CMSSignature><!-- insert data --></CMSSignature>"+ - "<DataObject>"+ - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>anyURI</Description>"+ - "</MetaInfo>"+ - "<Content>"+ - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - "</Content>"+ - "</DataObject>"+ - "<TrustProfileID>TrustProfile1</TrustProfileID>"+ - "</VerifyCMSSignatureRequest>"; - - public String defaultresponse = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ - "<VerifyCMSSignatureResponse xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" >"+ - "<SignerInfo>"+ - "<dsig:X509Data xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+ - "<dsig:X509SubjectName><!-- subn --></dsig:X509SubjectName>"+ - "<dsig:X509IssuerSerial>"+ - "<dsig:X509IssuerName><!-- in --></dsig:X509IssuerName>"+ - "<dsig:X509SerialNumber><!-- sn --></dsig:X509SerialNumber>"+ - "</dsig:X509IssuerSerial>"+ - "<dsig:X509Certificate><!-- cert --></dsig:X509Certificate>"+ - "<!-- cert2 -->"+ - "</dsig:X509Data>"+ - "</SignerInfo>"+ - "<SignatureCheck>"+ - "<Code><!-- sc_code --></Code>"+ - "</SignatureCheck>"+ - "<CertificateCheck>"+ - "<Code><!-- cc_code --></Code>"+ - "</CertificateCheck>"+ - "</VerifyCMSSignatureResponse>"; - - public String defaultresponse2 = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ - "<VerifyCMSSignatureResponse xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\" >"+ - "<SignerInfo>"+ - "<dsig:X509Data xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+ - "<dsig:X509SubjectName><!-- subn --></dsig:X509SubjectName>"+ - "<dsig:X509IssuerSerial>"+ - "<dsig:X509IssuerName><!-- in --></dsig:X509IssuerName>"+ - "<dsig:X509SerialNumber><!-- sn --></dsig:X509SerialNumber>"+ - "</dsig:X509IssuerSerial>"+ - "<dsig:X509Certificate><!-- cert --></dsig:X509Certificate>"+ - "</dsig:X509Data>"+ - "</SignerInfo>"+ - "<SignatureCheck>"+ - "<Code><!-- sc_code --></Code>"+ - "</SignatureCheck>"+ - "<CertificateCheck>"+ - "<Code><!-- cc_code --></Code>"+ - "</CertificateCheck>"+ - "<SignerInfo>"+ - "<dsig:X509Data xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">"+ - "<dsig:X509SubjectName><!-- subn --></dsig:X509SubjectName>"+ - "<dsig:X509IssuerSerial>"+ - "<dsig:X509IssuerName><!-- in --></dsig:X509IssuerName>"+ - "<dsig:X509SerialNumber><!-- sn --></dsig:X509SerialNumber>"+ - "</dsig:X509IssuerSerial>"+ - "<dsig:X509Certificate><!-- cert --></dsig:X509Certificate>"+ - "</dsig:X509Data>"+ - "</SignerInfo>"+ - "<SignatureCheck>"+ - "<Code><!-- sc_code --></Code>"+ - "</SignatureCheck>"+ - "<CertificateCheck>"+ - "<Code><!-- cc_code --></Code>"+ - "</CertificateCheck>"+ - "</VerifyCMSSignatureResponse>"; - - /* - <!-- in --> - <!-- sn --> - <!-- subn --> - <!-- sc_code --> - <!-- cc_code --> - */ - - public String b64_der_data = null; - public String b64_der_data_two = null; - public String b64_der_data_exp = null; - public String b64_der_data_exp_two = null; - public String b64_der_data_max = null; - - public String b64_der_data_1kb = null; - public String b64_der_data_10kb = null; - public String b64_der_data_100kb = null; - public String b64_der_data_1mb = null; - public String b64_der_data_10mb = null; - - public String cert_file_data = null; - public String cert_max_file_data = null; - public String cert_root_file_data = null; - - - public String fileprefix = null; - public String filesuffix = null; - - // signing certificate of user 2 - X509Certificate user2_sign; - // signing private key of user 2 - PrivateKey user2_sign_pk; - - // encryption certificate of user 2 - X509Certificate user2_crypt; - // encryption private key of user 2 - PrivateKey user2_crypt_pk; - // a certificate chain containing the user certs + CA - - X509Certificate[] certificates; - // secure random number generator - SecureRandom random; - - public TestGeneratorVC0() throws Exception - { - super(); - // Set config properties - configuration_.setProperty("TestClass", "TestGeneratorVC0"); - - - configuration_.setProperty( - "PKCS12file_maxmustermann", - (configuration_.getProperty("baseDir") + "/resources/Max_Mustermann (max).p12")); - - configuration_.setProperty("PKCS12password_maxmustermann", "max"); - - configuration_.setProperty( - "CERT_maxmustermann", - (configuration_.getProperty("baseDir") + "resources/Max_Mustermann.cer")); - - configuration_.setProperty( - "CERT_ROOT", - (configuration_.getProperty("baseDir") + "resources/IAIKRootMusterbehoerde.cer")); - - Provider [] list = Security.getProviders(); - for(int counter=0;counter<list.length;counter++) - { - System.out.println(list[counter].getName()); - } - - iaik.security.provider.IAIK.addAsProvider(); - iaik.security.ecc.provider.ECCProvider.addAsProvider(); - - X509Certificate[] certs = CMSKeyStore.getCertificateChain(CMSKeyStore.RSA, CMSKeyStore.SZ_1024_SIGN); - user2_sign = CMSKeyStore.getCertificateChain(CMSKeyStore.RSA, CMSKeyStore.SZ_2048_SIGN)[0]; - user2_sign_pk = CMSKeyStore.getPrivateKey(CMSKeyStore.RSA, CMSKeyStore.SZ_2048_SIGN); - certificates = new X509Certificate[certs.length+1]; - System.arraycopy(certs, 0, certificates, 0, certs.length); - certificates[certs.length] = user2_sign; - - // encryption certs - user2_crypt = CMSKeyStore.getCertificateChain(CMSKeyStore.RSA, CMSKeyStore.SZ_2048_CRYPT)[0]; - user2_crypt_pk = CMSKeyStore.getPrivateKey(CMSKeyStore.RSA, CMSKeyStore.SZ_2048_CRYPT); - - random = SecRandom.getDefault(); - - byte[] received_message = null; - ASN1Object obj = null; - - String m = readFile(configuration_.getProperty("baseDir")+"resources/testDaten.txt"); - //String m = "This is a message"; - System.out.println("*"+m+"*"); - byte[] message = m.getBytes(); - - System.out.println("Implicit SignedData demo [create]:"); - obj = createSignedCMSData(message, SignedDataStream.IMPLICIT,false); - byte[] sig = DerCoder.encode(obj); - writeFileBinary("testimpl.ber",sig); - b64_der_data = (new BASE64Encoder()).encode(sig); - - obj = createSignedCMSData(message, SignedDataStream.IMPLICIT,true); - sig = DerCoder.encode(obj); - writeFileBinary("testimpl2.ber",sig); - b64_der_data_two = (new BASE64Encoder()).encode(sig); - - obj = createSignedCMSData(message, SignedDataStream.EXPLICIT,false); - sig = DerCoder.encode(obj); - writeFileBinary("testexp.ber",sig); - b64_der_data_exp = (new BASE64Encoder()).encode(sig); - - String output = getSignedDataStream(sig,message,false); - System.out.println("Output:"+output); - - obj = createSignedCMSData(message, SignedDataStream.EXPLICIT,true); - sig = DerCoder.encode(obj); - writeFileBinary("testexp2.ber",sig); - b64_der_data_exp_two = (new BASE64Encoder()).encode(sig); - - cert_file_data = readBinaryFileAsBase64_new(configuration_.getProperty("CERT")); - cert_max_file_data = readBinaryFileAsBase64_new(configuration_.getProperty("CERT_maxmustermann")); - cert_root_file_data = readBinaryFileAsBase64_new(configuration_.getProperty("CERT_ROOT")); - - // transmit data - /*System.out.println("Implicit SignedData demo [parse]:"); - received_message = getSignedData(obj, null,true); - System.out.print("Signed content: "); - System.out.println(new String(received_message));*/ - - //readBinaryFileAsBase64(configuration_.getProperty("baseDir")+"resources/testDaten.txt"); - } - - public String getCMSData(String filename) throws Exception - { - ASN1Object obj = null; - obj = createSignedCMSData(readFile(configuration_.getProperty("baseDir") + "resources/"+filename+".txt").getBytes(), SignedDataStream.EXPLICIT,true); - byte[] sig = DerCoder.encode(obj); - //writeFileBinary("testexp2.ber",sig); - return (new BASE64Encoder()).encode(sig); - } - - public String getSignedDataStream(byte[] signedData, byte[] message,boolean two_users) throws CMSException, IOException { - - // we are testing the stream interface - ByteArrayInputStream is = new ByteArrayInputStream(signedData); - // create the ContentInfo object - ContentInfoStream cis = new ContentInfoStream(is); - System.out.println("This ContentInfo holds content of type " + cis.getContentType().getName()); - SignedDataStream signed_data = null; - - if (message == null) { - // implicitly signed; get the content - signed_data = (SignedDataStream)cis.getContent(); - } - else { - // explicitly signed; set the data stream for digesting the message - AlgorithmID[] algIDs = { AlgorithmID.sha1, AlgorithmID.md5 }; - signed_data = new SignedDataStream(new ByteArrayInputStream(message), algIDs); - - } - - // get an InputStream for reading the signed content - InputStream data = signed_data.getInputStream(); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - StreamCopier sc = new StreamCopier(data, os); - sc.copyStream(); - - - if (message != null) { - // if explicitly signed read now the DER encoded object - // an explicit S/MIME signed message also consits of message|signature - signed_data.decode(cis.getContentInputStream()); - } - - System.out.println("SignedData contains the following signer information:"); - SignerInfo[] signer_infos = signed_data.getSignerInfos(); - - for (int i=0; i<signer_infos.length; i++) { - try { - // verify the signed data using the SignerInfo at index i - X509Certificate signer_cert = signed_data.verify(i); - // if the signature is OK the certificate of the signer is returned - System.out.println("Signature OK from signer: "+signer_cert.getSubjectDN()); - Attribute signingTime = signer_infos[i].getSignedAttribute(ObjectID.signingTime); - if (signingTime != null) { - ChoiceOfTime cot = new ChoiceOfTime(signingTime.getValue()[0]); - System.out.println("This message has been signed at " + cot.getDate()); - } - Attribute contentType = signer_infos[i].getSignedAttribute(ObjectID.contentType); - if (contentType != null) { - System.out.println("The content has CMS content type " + contentType.getValue()[0]); - } - - } catch (SignatureException ex) { - // if the signature is not OK a SignatureException is thrown - System.out.println("Signature ERROR from signer: "+signed_data.getCertificate((signer_infos[i].getSignerIdentifier())).getSubjectDN()); - } catch (CodingException ex) { - System.out.println("Attribute decoding error: " + ex.getMessage()); - } - } - // now check alternative signature verification - System.out.println("Now check the signature assuming that no certs have been included:"); - try { - SignerInfo signer_info = signed_data.verify(user1_sign); - // if the signature is OK the certificate of the signer is returned - System.out.println("Signature OK from signer: "+signed_data.getCertificate(signer_info.getSignerIdentifier()).getSubjectDN()); - - } catch (SignatureException ex) { - // if the signature is not OK a SignatureException is thrown - System.out.println("Signature ERROR from signer: "+user1_sign.getSubjectDN()); - } - - if(two_users) - try { - SignerInfo signer_info = signed_data.verify(user2_sign); - // if the signature is OK the certificate of the signer is returned - System.out.println("Signature OK from signer: "+signed_data.getCertificate(signer_info.getSignerIdentifier()).getSubjectDN()); - - } catch (SignatureException ex) { - // if the signature is not OK a SignatureException is thrown - System.out.println("Signature ERROR from signer: "+user2_sign.getSubjectDN()); - } - - - return os.toString(); - } - - public void createConfig() throws Exception { - - String file = configuration_.getProperty("baseDir") + datadirectory + - configuration_.getProperty("TestClass") + - ".Config.xml"; - String config = - - "<MOAConfiguration xmlns=\"http://reference.e-government.gv.at/namespace/moaconfig/20021122#\">"+ - " <KeyGroup id=\"PKCS12RSAKey1\"> <Key id=\"resources/test-ee2003_normal(buergerkarte).p12\"/> </KeyGroup>"+ - " <KeyGroup id=\"PKCS12RSAKeyExpired\"> <Key id=\"sicher-demo(buergerkarte).p12\"/> </KeyGroup>"+ - " <KeyGroup id=\"PKCS12ECDSAKey1\"> <Key id=\"ecc.p12\"/> </KeyGroup> "+ - " <KeyGroup id=\"HSMRSAKey1\"> <Key id=\"???\"/> </KeyGroup>"+ - " <KeyGroup id=\"HSMECDSAKey1\"> <Key id=\"???\"/> </KeyGroup>"+ - " <DigestMethodAlgorithm name=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>"+ - " <SignatureAlgorithm name=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>"+ - " <CanonicalizationAlgorithm name=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>"+ - " <CreateSignatureEnvironmentProfile id=\"CreateSignatureEnvironmentProfile1\" filename=\""+"file:/"+configuration_.getProperty("baseDir")+"resources/csep.xml\"/>"+ - " <TrustProfile id=\"validTrustProfileID1\" uri=\""+"file:/"+configuration_.getProperty("baseDir")+"TrustProfile1/\"/>"+ - "</MOAConfiguration>"; - - FileOutputStream fos = new FileOutputStream(file); - fos.write(config.getBytes()); - fos.flush(); - fos.close(); - - fileprefix = configuration_.getProperty("baseDir")+ datadirectory + configuration_.getProperty("TestClass") + "."; - filesuffix = ".xml"; - - } - - public static void main(String[] args) throws Exception { - TestGeneratorVC0 testcase = new TestGeneratorVC0(); - - testcase.createConfig(); - testcase.create001(); - testcase.create002(); - testcase.create003(); - testcase.create004(); - testcase.create005(); - testcase.create006(); - testcase.create007(); - testcase.create008(); - testcase.create009(); - testcase.create010(); - //testcase.create011(); - testcase.create012(); - - testcase.create051(); - testcase.create052(); - //testcase.create053(); - testcase.create054(); - testcase.create055(); - testcase.create056(); - testcase.create057(); - testcase.create058(); - - //testcase.createL00(); - - } - - public void createL00() throws Exception { - createL001("1kb"); - createL001("10kb"); - createL001("20kb"); - createL001("50kb"); - createL001("100kb"); - createL001("500kb"); - createL001("1mb"); - createL001("10mb"); - } - - public void createL001(String filename) throws Exception - { - String TestNumber = "001"; - - String reqFile = configuration_.getProperty("baseDir")+ datadirectory_l+filename+"/" + configuration_.getProperty("TestClass") + "." + TestNumber + ".Req.xml"; - - String req = replaceString(defaultblock,"<!-- insert data -->",getCMSData(filename)); - req = replaceString(req,"<Content>","<Content Reference=\"anyURI\">"); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/"+filename+".txt"); - req = replaceString(req, - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>", - ""); - - writeFile(reqFile,req); - - String resFile = configuration_.getProperty("baseDir")+ datadirectory_l+filename+"/" + configuration_.getProperty("TestClass") + "." + TestNumber + ".Res.xml"; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - //res = replaceString(res,"<dsig:X509Certificate><!-- cert --></dsig:X509Certificate>",""); - - - writeFile(resFile,res); - - - } - - public void create001() throws Exception - { - String TestNumber = "001"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - /*CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,"file:/"+configuration_.getProperty("baseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc,"<data:Document xmlns:data=\"uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testDaten.txt")+"</data:Document>"); - - writeFile(resFile, output);*/ - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - //res = replaceString(res,"<dsig:X509Certificate><!-- cert --></dsig:X509Certificate>",""); - - - writeFile(resFile,res); - - - } - - public void create002() throws Exception - { - String TestNumber = "002"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp_two); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "Signatories=\"1\"", - "Signatories=\"1 2\""); - - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceStringAll(defaultresponse2,"<!-- in -->",this.X509name); - res = replaceStringAll(res,"<!-- sn -->",this.X509number.toString()); - res = replaceStringAll(res,"<!-- subn -->",this.X509sub); - res = replaceStringAll(res,"<!-- sc_code -->","0"); - res = replaceStringAll(res,"<!-- cc_code -->","0"); - res = replaceStringAll(res,"<!-- cert -->",cert_file_data); - //res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create003() throws Exception - { - String TestNumber = "003"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "Signatories=\"1\"", - "Signatories=\"all\""); - - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create004() throws Exception - { - String TestNumber = "004"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DateTime>2003-04-04T09:30:47-05:00</DateTime>", - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create005() throws Exception - { - String TestNumber = "005"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DateTime>2003-04-04T09:30:47-05:00</DateTime>", - "<DateTime>2003-04-04T09:30:47-05:00</DateTime>"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create006() throws Exception - { - String TestNumber = "006"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DataObject>"+ - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>"+configuration_.getProperty("webbaseDir") + "resources/testDaten.txt</Description>"+ - "</MetaInfo>"+ - "<Content>"+ - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - "</Content>"+ - "</DataObject>", - ""); - - //req = replaceString(defaultblock, - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create007() throws Exception - { - String TestNumber = "007"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>"+configuration_.getProperty("webbaseDir") + "resources/testDaten.txt</Description>"+ - "</MetaInfo>", - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create008() throws Exception - { - String TestNumber = "008"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create009() throws Exception - { - String TestNumber = "009"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceString(req,"<Content>","<Content Reference=\"anyURI\">"); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>", - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - writeFile(resFile,res); - } - - public void create011() throws Exception - { - String TestNumber = "011"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",readFile(configuration_.getProperty("baseDir") + "resources/VC0.011.cms.ber.b64.txt")); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DataObject>"+ - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>"+configuration_.getProperty("webbaseDir") + "resources/testDaten.txt</Description>"+ - "</MetaInfo>"+ - "<Content>"+ - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - "</Content>"+ - "</DataObject>", - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->","CN=a-sign-TEST-Premium-Enc-01,OU=a-sign-TEST-Premium-Enc-01,O=A-Trust Ges. f. Sicherheitssysteme im elektr. Datenverkehr GmbH,C=AT"); - res = replaceString(res,"<!-- sn -->","6455"); - res = replaceString(res,"<!-- subn -->","Seriennummer=790187461633,G=Testperson MOA4,SN=BRZ,CN=Testperson MOA4 BRZ,C=AT"); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - res = replaceString(res, - "</dsig:X509Data>", - "<sl11:QualifiedCertificate xmlns:sl11=\"http://www.buergerkarte.at/namespaces/securitylayer/20020831#\"/>"+ - "</dsig:X509Data>"); - - - writeFile(resFile,res); - } - - public void create012() throws Exception - { - String TestNumber = "012"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(configuration_.getProperty("CERT_maxmustermann"))); - iaik.x509.X509Certificate cert = new iaik.x509.X509Certificate(bis); - X509name = ((Name)(cert.getIssuerDN())).getRFC2253String(); - X509number = cert.getSerialNumber(); - X509hash = new String(cert.getFingerprintSHA()); - X509sub = ((Name)(cert.getSubjectDN())).getRFC2253String(); - - String m = "This is a message"; - System.out.println("*"+m+"*"); - byte[] message = m.getBytes(); - - ASN1Object obj = null; - obj = createSignedCMSData(message, SignedDataStream.IMPLICIT,false,"PKCS12file_maxmustermann","PKCS12password_maxmustermann","CERT_maxmustermann"); - byte[] sig = DerCoder.encode(obj); - writeFileBinary("testimplmax.ber",sig); - b64_der_data_max = (new BASE64Encoder()).encode(sig); - - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_max); - - req = replaceString(req, - "<DataObject>"+ - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>anyURI</Description>"+ - "</MetaInfo>"+ - "<Content>"+ - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - "</Content>"+ - "</DataObject>", - ""); - - //req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - /*CreatePKCSSignature cpkcs = new CreatePKCSSignature(); - cpkcs.init(); - cpkcs.setCanoncialization(canAlgCanXML); - cpkcs.createReference(false,"file:/"+configuration_.getProperty("baseDir")+"resources/testDaten.txt"); - cpkcs.setKeyInformation(); - - Document doc = cpkcs.returnSig(); - - String output = makeOutputFile(doc,"<data:Document xmlns:data=\"uri.data.org\">",readFile(configuration_.getProperty("baseDir")+"resources/testDaten.txt")+"</data:Document>"); - - writeFile(resFile, output);*/ - - - String res = replaceString(defaultresponse,"<!-- in -->",X509name); - res = replaceString(res,"<!-- sn -->",X509number.toString()); - res = replaceString(res,"<!-- subn -->",X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_max_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - res = replaceString(res, - "</dsig:X509Data>", - "<PublicAuthority>"+ - "<Code>Musterbehörde</Code>"+ - //"<Code>Musterbehörde</Code>"+ - "</PublicAuthority>"+ - "</dsig:X509Data>"); - - - writeFile(resFile,res); - - - } - - public void create051() throws Exception - { - String TestNumber = "051"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "Signatories=\"1\"", - "Signatories=\"0\""); - - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"1100"); - } - - public void create052() throws Exception - { - String TestNumber = "052"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "Signatories=\"1\"", - "Signatories=\"10\""); - - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2249"); - } - - public void create053() throws Exception - { - String TestNumber = "053"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DateTime>2003-04-04T09:30:47-05:00</DateTime>", - "<DateTime>"+getDate(1*34*24)+"</DateTime>"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"0000"); - } - - public void create054() throws Exception - { - String TestNumber = "054"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock, - "<CMSSignature><!-- insert data --></CMSSignature>", - "<CMSSignature>this is no Base64 Data</CMSSignature>"); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"1100"); - - } - - public void create055() throws Exception - { - String TestNumber = "055"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<DataObject>"+ - "<MetaInfo>"+ - "<MimeType>text/plain</MimeType>"+ - "<Description>"+configuration_.getProperty("webbaseDir") + "resources/testDaten.txt</Description>"+ - "</MetaInfo>"+ - "<Content>"+ - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - "</Content>"+ - "</DataObject>", - ""); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2248"); - - } - - - - public void create010() throws Exception - { - String TestNumber = "010"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceString(req,"<Content>","<Content Reference=\"anyURI\">"); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>", - ""); - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".Res"+filesuffix; - - String res = replaceString(defaultresponse,"<!-- in -->",this.X509name); - res = replaceString(res,"<!-- sn -->",this.X509number.toString()); - res = replaceString(res,"<!-- subn -->",this.X509sub); - res = replaceString(res,"<!-- sc_code -->","0"); - res = replaceString(res,"<!-- cc_code -->","0"); - res = replaceString(res,"<!-- cert -->",cert_file_data); - res = replaceString(res,"<!-- cert2 -->",""); - - writeFile(resFile,res); - - } - - public void create056() throws Exception - { - String TestNumber = "056"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - req = replaceString(req, - "<TrustProfileID>TrustProfile1</TrustProfileID>", - "<TrustProfileID>notvalidTrustProfileID</TrustProfileID>"); - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2203"); - - } - - - public void create057() throws Exception - { - String TestNumber = "057"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - - configuration_.setProperty( - "PKCS12file_maxmustermann", - (configuration_.getProperty("baseDir") + "/resources/Max_Mustermann (max).p12")); - - configuration_.setProperty("PKCS12password_maxmustermann", "max"); - - configuration_.setProperty( - "CERT_maxmustermann", - (configuration_.getProperty("baseDir") + "resources/Max_Mustermann.cer")); - - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(configuration_.getProperty("CERT_maxmustermann"))); - iaik.x509.X509Certificate cert = new iaik.x509.X509Certificate(bis); - X509name = ((Name)(cert.getIssuerDN())).getRFC2253String(); - X509number = cert.getSerialNumber(); - X509hash = new String(cert.getFingerprintSHA()); - X509sub = ((Name)(cert.getSubjectDN())).getRFC2253String(); - - String m = "This is a message"; - System.out.println("*"+m+"*"); - byte[] message = m.getBytes(); - - ASN1Object obj = null; - obj = createSignedCMSData(message, SignedDataStream.IMPLICIT,false,"PKCS12file_maxmustermann","PKCS12password_maxmustermann","CERT_maxmustermann"); - byte[] sig = DerCoder.encode(obj); - writeFileBinary("testimplmax.ber",sig); - b64_der_data_max = (new BASE64Encoder()).encode(sig); - - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_max); - - /*req = replaceString(req, - " <DataObject>"+ - " <MetaInfo>"+ - " <MimeType>text/plain</MimeType>"+ - " <Description>anyURI</Description>"+ - " </MetaInfo>"+ - " <Content Reference=\"anyURI\">"+ - " <Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=</Base64Content>"+ - " </Content>"+ - " </DataObject>", - "");*/ - - //req = replaceString(req,"Reference=\"anyURI\"",""); - - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - - - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"2248"); - - - } - - public void create058() throws Exception - { - String TestNumber = "058"; - String reqFile = fileprefix + TestNumber + ".Req"+filesuffix; - - String req = replaceString(defaultblock,"<!-- insert data -->",b64_der_data_exp); - req = replaceStringAll(req,"anyURI",configuration_.getProperty("webbaseDir") + "resources/testDaten.txt"); - - req = replaceString(req,"RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=","RGllcyBzaW5kIFRlc3RkYXRlbg0KMi4gWmVpbGUNCjMuIFplaWxlDQphdXM=()"); - writeFile(reqFile,req); - - String resFile = fileprefix + TestNumber + ".ErrRes"+filesuffix; - - writeFile(resFile,"1100"); - - } - - - - - - - -} |