aboutsummaryrefslogtreecommitdiff
path: root/spss.test/src/testgenerator/TestGeneratorCX0.java
diff options
context:
space:
mode:
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
commit057f884903954203339182649daa100ef4ce89e3 (patch)
tree7d6d5b0dc4aea4a63674b90800ebbf6ffcc0ca4d /spss.test/src/testgenerator/TestGeneratorCX0.java
parent92cca056c7935075012576b684c3678a9ec9f4ad (diff)
downloadmoa-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/TestGeneratorCX0.java')
-rw-r--r--spss.test/src/testgenerator/TestGeneratorCX0.java2940
1 files changed, 0 insertions, 2940 deletions
diff --git a/spss.test/src/testgenerator/TestGeneratorCX0.java b/spss.test/src/testgenerator/TestGeneratorCX0.java
deleted file mode 100644
index 31778c6a2..000000000
--- a/spss.test/src/testgenerator/TestGeneratorCX0.java
+++ /dev/null
@@ -1,2940 +0,0 @@
-
-package testgenerator;
-import iaik.apps.util.passphrase.PassphrasePrompt;
-import iaik.asn1.structures.Name;
-import iaik.ixsil.algorithms.CanonicalizationAlgorithmImplCanonicalXML;
-import iaik.ixsil.algorithms.DigestAlgorithmImplSHA1;
-import iaik.ixsil.algorithms.SignatureAlgorithmImplECDSA;
-import iaik.ixsil.algorithms.SignatureAlgorithmImplRSA;
-import iaik.ixsil.algorithms.TransformImplBase64Decode;
-import iaik.ixsil.core.Signer;
-import iaik.ixsil.core.SignerManifest;
-import iaik.ixsil.core.SignerReference;
-import iaik.ixsil.core.SignerSignature;
-import iaik.ixsil.core.SignerSignedInfo;
-import iaik.ixsil.init.IXSILConstants;
-import iaik.ixsil.init.IXSILInit;
-import iaik.ixsil.keyinfo.KeyManagerImpl;
-import iaik.ixsil.keyinfo.x509.KeyProviderImplX509Data;
-import iaik.ixsil.keyinfo.x509.X509Data;
-import iaik.ixsil.util.URI;
-import iaik.pkcs.pkcs11.objects.Certificate;
-import iaik.pkcs.pkcs11.objects.PrivateKey;
-import iaik.pkcs.pkcs11.objects.PublicKey;
-import iaik.pkcs.pkcs11.provider.IAIKPkcs11;
-import iaik.pkcs.pkcs11.provider.keys.IAIKPKCS11RsaPrivateKey;
-import iaik.pkcs.pkcs11.provider.keys.IAIKPKCS11RsaPublicKey;
-import iaik.pkcs.pkcs12.CertificateBag;
-import iaik.pkcs.pkcs12.PKCS12;
-import iaik.security.ecc.interfaces.ECDSAPrivateKey;
-import iaik.security.provider.IAIK;
-import iaik.utils.Base64OutputStream;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.RandomAccessFile;
-import java.net.URL;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.Security;
-import java.security.Signature;
-import java.security.cert.X509Certificate;
-import java.security.interfaces.RSAPrivateKey;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.xerces.dom.DocumentFragmentImpl;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import at.gv.egovernment.moa.util.Base64Utils;
-import at.gv.egovernment.moa.util.DOMUtils;
-
-import sun.misc.BASE64Encoder;
-
-/**
- * @author stephan
- */
-public class TestGeneratorCX0 extends TestCases {
-
- String datadirectory = "data/CX0/";
- String datadirectory_3 = "data/CX3/";
- String datadirectory_4 = "data/CX4/";
- String datadirectory_l = "data/LCX";
-
- public String defaultblock = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\">\n"+
- " <!-- Hint -->\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- public static void main(String[] args) throws Exception {
- TestGeneratorCX0 testcase = new TestGeneratorCX0();
-
- testcase.createConfig();
- testcase.create001();
- testcase.create002();
- testcase.create003();
- //testcase.create004();
- testcase.create005();
- //testcase.create006();
- testcase.create007();
- testcase.create008();
- testcase.create009();
- testcase.create010();
- testcase.create011();
- testcase.create012();
- testcase.create013();
- testcase.create014();
- testcase.create015();
- testcase.create016();
- testcase.create017();
- testcase.create018();
- testcase.create019();
-
- testcase.create051();
- testcase.create052();
- testcase.create053();
- testcase.create054();
- testcase.create055();
- testcase.create056();
- testcase.create057();
- testcase.create058();
- testcase.create059();
- testcase.create060();
- //testcase.create061();
- testcase.create062();
- //testcase.create063();
- testcase.create064();
- testcase.create065();
-
- //testcase.createL00();*/
-
- }
-
- /* ==================================================================================================== */
-
- public TestGeneratorCX0() throws Exception {
-
- super();
-
- // Set config properties
- configuration_.setProperty("TestClass", "TestGeneratorCX0");
-// 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.provider.IAIK.addAsJDK14Provider();
- iaik.security.ecc.provider.ECCProvider.addAsProvider();
- //iaik.security.ecc.provider.ECCProvider.addAsProvider();
- }
-
- /* ==================================================================================================== */
-
- public Document createECDSPKCS12Sig(String tn,String fileref) throws Exception
- {
- String TestNumber = tn;
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- // String res = "emtpy";
- // FileOutputStream resFOS = new FileOutputStream(resFile);
- // resFOS.write(res.getBytes());
-
- PKCS12 pkcs12 = decryptPKCS12(
- configuration_.getProperty("ECDSPKCS12file"),
- configuration_.getProperty("ECDSPKCS12password" ) );
-
- // Create signature generator
- URI baseURI = new URI(IXSILConstants.DUMMY_ABSURI_);
- Signer signer = new Signer(baseURI);
-
- // Configure signed information
-
- // Get interface for signed information
- SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();
-
- // Set canonicalization algorithm
- CanonicalizationAlgorithmImplCanonicalXML c14nAlg =
- new CanonicalizationAlgorithmImplCanonicalXML();
- signedInfo.setCanonicalizationAlgorithm(c14nAlg);
-
- CertificateBag cb[] = pkcs12.getCertificateBags();
- System.out.println("LEN:"+cb.length);
- iaik.x509.X509Certificate cert[] = cb[0].getCertificates(cb);
- System.out.println("LEN2:"+cert.length);
- System.out.println("CERT:"+(((Name)(cert[0].getIssuerDN())).getRFC2253String()));
-
-
- // Set signature algorithm
- /* TODO: Change to ECDS Impl */
- SignatureAlgorithmImplECDSA signatureAlg = new SignatureAlgorithmImplECDSA();
- ECDSAPrivateKey privateKey = getPrivateKeyECDS( pkcs12 );
- signatureAlg.setSignerKey(privateKey);
- signedInfo.setSignatureAlgorithm(signatureAlg);
-
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(fileref);
-
- SignerReference reference = signedInfo.createReference();
- reference.setURI(refURI);
- reference.setId("reference-1-1");
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- // Add reference to signature
- signedInfo.addReference(reference);
-
- // Create key information
- KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
-
- X509Certificate[] certs = getCertificates(pkcs12);
- X509Data x509Data = new X509Data();
- for (int i = 0; i < certs.length; i++)
- {
- x509Data.insertHintAt(certs[i], i);
- }
-
- KeyProviderImplX509Data x509DataKeyProvider = new KeyProviderImplX509Data(signer.toDocument());
- x509DataKeyProvider.insertX509DataAt(x509Data, 0);
-
- // X509Data key information (certificate chain)
- keyManager.addKeyProvider(x509DataKeyProvider);
-
- signer.getSignature().setKeyManager(keyManager);
- signer.getSignature().setId("signature-1-1");
- // Compute signature value
- signer.getSignature().sign();
- Document doc = signer.toDocument();
- System.out.println(doc.getDocumentElement().getNodeName());
-
- return doc;
- }
-
- public Document createPKCS12Sig(String tn,String fileref) throws Exception
- {
- return createPKCS12Sig(tn,fileref,false,false,null,false);
- }
-
- public Document createPKCS12Sig(String tn,String fileref,String id1,String id2) throws Exception
- {
- return createPKCS12Sig(tn,fileref,false,false,null,false,id1,id2);
- }
-
- public Document createPKCS12SigWithEnveloping(String TestNumber,String data) throws Exception
- {
- return createPKCS12Sig(TestNumber,data,true,false,null,false);
- }
-
- public Document createPKCS12Sig(String TestNumber,String data,boolean env,boolean mani) throws Exception
- {
- return createPKCS12Sig(TestNumber,data,env,mani,null,false);
- }
-
- public Document createPKCS12Sig(String TestNumber,String data,boolean env,boolean mani,String data2,boolean env2) throws Exception
- {
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- PKCS12 pkcs12 = decryptPKCS12(
- configuration_.getProperty("PKCS12file"),
- configuration_.getProperty("PKCS12password" ) );
-
- // Create signature generator
- URI baseURI = new URI(IXSILConstants.DUMMY_ABSURI_);
- Signer signer = new Signer(baseURI);
-
- // Configure signed information
-
- // Get interface for signed information
- SignerSignature signature = signer.getSignature();
- SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();
-
- // Set canonicalization algorithm
- CanonicalizationAlgorithmImplCanonicalXML c14nAlg =
- new CanonicalizationAlgorithmImplCanonicalXML();
- signedInfo.setCanonicalizationAlgorithm(c14nAlg);
-
- // Set signature algorithm
- SignatureAlgorithmImplRSA signatureAlg = new SignatureAlgorithmImplRSA();
- RSAPrivateKey privateKey = getPrivateKey( pkcs12 );
- signatureAlg.setSignerKey(privateKey);
- signedInfo.setSignatureAlgorithm(signatureAlg);
-
- if(!mani)
- {
- SignerReference reference = signedInfo.createReference();
- if(env)
- {
- iaik.ixsil.core.Object object = null;
- //object = signature.createObject(data);
- if(data.startsWith("<xml"))
- {
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(data.getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data.startsWith("<Testdaten"))
- {
-
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+data).getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data.startsWith("b64:"))
- {
- data = data.substring(4);
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.newDocument();
- Element root = doc.createElement("root");
- doc.appendChild(root);
- //String encoded = Base64Utils.encode(data.getBytes());
- String encoded = Base64Utils.encode(data.getBytes());
- /*encoded = replaceStringAll(encoded,"\n","");
- encoded = replaceStringAll(encoded,"\r","");*/
- Text textnode = doc.createTextNode(encoded);
-
- System.out.println("Encoded:"+encoded);
- //root.appendChild(textnode);
-
- DocumentFragment df = doc.createDocumentFragment();
-
- df.appendChild(textnode);
-
- object = signature.createObject(df);
-
- TransformImplBase64Decode trans = new TransformImplBase64Decode();
- InputStream s = new ByteArrayInputStream(encoded.getBytes());
- trans.setInput(s,null);
-
- reference.insertTransformAt(trans,0);
- }
- else
- {
- object = signature.createObject(data);
- }
-
- object.setId("signed-data-1-1-1");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- reference.setURI(new URI("#xpointer(id('signed-data-1-1-1')/node())"));
-
-
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- reference.setId("reference-1-1");
- signedInfo.addReference(reference);
- }
-
- if(data2!=null)
- {
- SignerReference reference = signedInfo.createReference();
- reference = signedInfo.createReference();
- if(env2)
- {
- iaik.ixsil.core.Object object = null;
- if(data2.startsWith("<xml"))
- {
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(data.getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data2.startsWith("<Testdaten"))
- {
-
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+data).getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else
- object = signature.createObject(data2);
-
- if(!env)
- object.setId("signed-data-1-2-1");
- else
- object.setId("signed-data-1-2-1");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- if(!env)
- reference.setURI(new URI("#xpointer(id('signed-data-1-2-1')/node())"));
- else
- reference.setURI(new URI("#xpointer(id('signed-data-1-2-1')/node())"));
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data2);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- reference.setId("reference-1-2");
- signedInfo.addReference(reference);
- }
-
- // Add reference to signature
-
-
-
- if(mani)
- {
-
- /*iaik.ixsil.core.Object object = null;
- if(env)
- object = signature.createObject(readFile(data));
- else
- object = signature.createObject(data);
-
- object.setId("envelopedData");
- signature.addObject(object);*/
- SignerReference reference = signedInfo.createReference();
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- manifestRef.setDigestAlgorithm(digestAlg);
-
- manifestRef.setURI(new URI(data));
- manifestRef.setId("reference-1-1");
-
- manifest.addReference(manifestRef);
- manifest.setId("dsig-manifest-1-1");
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- reference = signedInfo.createReference();
- reference.setURI(
- new URI("#dsig-manifest-1-1"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);
-
-
- /*Element envelopedDataElem =
- signer.toDocument().createElement("EnvelopedDataElement");
-
- if(env)
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(readFile(data)));
- }
- else
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(data));
- }
-
- iaik.ixsil.core.Object object = signature.createObject(envelopedDataElem);
- signature.addObject(object);
-
- // Create Manifest with a single reference pointing to the enveloped data
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
- manifestRef.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[1]/descendant::node())"));
- manifestRef.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
- manifest.addReference(manifestRef);
-
- // Add Manifest to signature structure (use an Object) and compute digest values for manifest reference
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- // Create and configure reference to manifest
- reference = signedInfo.createReference();
- reference.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[2]/dsig:Manifest)"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);*/
- }
-
- // Create key information
- KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
-
- X509Certificate[] certs = getCertificates(pkcs12);
- X509Data x509Data = new X509Data();
- x509Data.insertHintAt(certs[1], 0);
- /*for (int i = 0; i < certs.length; i++)
- {
-
- }*/
-
- KeyProviderImplX509Data x509DataKeyProvider = new KeyProviderImplX509Data(signer.toDocument());
- x509DataKeyProvider.insertX509DataAt(x509Data, 0);
-
- // X509Data key information (certificate chain)
- keyManager.addKeyProvider(x509DataKeyProvider);
-
- signer.getSignature().setKeyManager(keyManager);
- signer.getSignature().setId("signature-1-1");
- // Compute signature value
- signer.getSignature().sign();
-
- return signer.toDocument();
- }
-
- public Document createPKCS12Sig(String TestNumber,String data,boolean env,boolean mani,String data2,boolean env2,String id1,String id2) throws Exception
- {
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- PKCS12 pkcs12 = decryptPKCS12(
- configuration_.getProperty("PKCS12file"),
- configuration_.getProperty("PKCS12password" ) );
-
- // Create signature generator
- URI baseURI = new URI(IXSILConstants.DUMMY_ABSURI_);
- Signer signer = new Signer(baseURI);
-
- // Configure signed information
-
- // Get interface for signed information
- SignerSignature signature = signer.getSignature();
- SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();
-
- // Set canonicalization algorithm
- CanonicalizationAlgorithmImplCanonicalXML c14nAlg =
- new CanonicalizationAlgorithmImplCanonicalXML();
- signedInfo.setCanonicalizationAlgorithm(c14nAlg);
-
- // Set signature algorithm
- SignatureAlgorithmImplRSA signatureAlg = new SignatureAlgorithmImplRSA();
- RSAPrivateKey privateKey = getPrivateKey( pkcs12 );
- signatureAlg.setSignerKey(privateKey);
- signedInfo.setSignatureAlgorithm(signatureAlg);
-
- if(!mani)
- {
- SignerReference reference = signedInfo.createReference();
- if(env)
- {
- iaik.ixsil.core.Object object = null;
- //object = signature.createObject(data);
- if(data.startsWith("<xml"))
- {
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(data.getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data.startsWith("<Testdaten"))
- {
-
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+data).getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data.startsWith("b64:"))
- {
- data = data.substring(4);
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.newDocument();
- Element root = doc.createElement("root");
- doc.appendChild(root);
- //String encoded = Base64Utils.encode(data.getBytes());
- String encoded = Base64Utils.encode(data.getBytes());
- /*encoded = replaceStringAll(encoded,"\n","");
- encoded = replaceStringAll(encoded,"\r","");*/
- Text textnode = doc.createTextNode(encoded);
-
- System.out.println("Encoded:"+encoded);
- //root.appendChild(textnode);
-
- DocumentFragment df = doc.createDocumentFragment();
-
- df.appendChild(textnode);
-
- object = signature.createObject(df);
-
- TransformImplBase64Decode trans = new TransformImplBase64Decode();
- InputStream s = new ByteArrayInputStream(encoded.getBytes());
- trans.setInput(s,null);
-
- reference.insertTransformAt(trans,0);
- }
- else
- {
- object = signature.createObject(data);
- }
-
- object.setId("signed-data-1-1-1");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- reference.setURI(new URI("#xpointer(id('signed-data-1-1-1')/node())"));
-
-
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- reference.setId("reference-2-1");
- signedInfo.addReference(reference);
- }
-
- if(data2!=null)
- {
- SignerReference reference = signedInfo.createReference();
- reference = signedInfo.createReference();
- if(env2)
- {
- iaik.ixsil.core.Object object = null;
- if(data2.startsWith("<xml"))
- {
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(data.getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else if(data2.startsWith("<Testdaten"))
- {
-
- DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = db.parse(new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>"+data).getBytes()));
-
- object = signature.createObject(doc.getDocumentElement());
- }
- else
- object = signature.createObject(data2);
-
- if(!env)
- object.setId("signed-data-1-2-1");
- else
- object.setId("signed-data-1-2-1");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- if(!env)
- reference.setURI(new URI("#xpointer(id('signed-data-1-2-1')/node())"));
- else
- reference.setURI(new URI("#xpointer(id('signed-data-1-2-1')/node())"));
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data2);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- reference.setId("reference-1-2");
- signedInfo.addReference(reference);
- }
-
- // Add reference to signature
-
-
-
- if(mani)
- {
-
- /*iaik.ixsil.core.Object object = null;
- if(env)
- object = signature.createObject(readFile(data));
- else
- object = signature.createObject(data);
-
- object.setId("envelopedData");
- signature.addObject(object);*/
- SignerReference reference = signedInfo.createReference();
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- manifestRef.setDigestAlgorithm(digestAlg);
-
- manifestRef.setURI(new URI(data));
- manifestRef.setId("reference-1-1");
-
- manifest.addReference(manifestRef);
- manifest.setId("dsig-manifest-1-1");
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- reference = signedInfo.createReference();
- reference.setURI(
- new URI("#dsig-manifest-1-1"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);
-
-
- /*Element envelopedDataElem =
- signer.toDocument().createElement("EnvelopedDataElement");
-
- if(env)
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(readFile(data)));
- }
- else
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(data));
- }
-
- iaik.ixsil.core.Object object = signature.createObject(envelopedDataElem);
- signature.addObject(object);
-
- // Create Manifest with a single reference pointing to the enveloped data
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
- manifestRef.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[1]/descendant::node())"));
- manifestRef.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
- manifest.addReference(manifestRef);
-
- // Add Manifest to signature structure (use an Object) and compute digest values for manifest reference
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- // Create and configure reference to manifest
- reference = signedInfo.createReference();
- reference.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[2]/dsig:Manifest)"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);*/
- }
-
- // Create key information
- KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
-
- X509Certificate[] certs = getCertificates(pkcs12);
- X509Data x509Data = new X509Data();
- x509Data.insertHintAt(certs[1], 0);
- /*for (int i = 0; i < certs.length; i++)
- {
-
- }*/
-
- KeyProviderImplX509Data x509DataKeyProvider = new KeyProviderImplX509Data(signer.toDocument());
- x509DataKeyProvider.insertX509DataAt(x509Data, 0);
-
- // X509Data key information (certificate chain)
- keyManager.addKeyProvider(x509DataKeyProvider);
-
- signer.getSignature().setKeyManager(keyManager);
- signer.getSignature().setId("signature-2-1");
- // Compute signature value
- signer.getSignature().sign();
-
- return signer.toDocument();
- }
-
- public Document createHSMSig(String TestNumber,String data,boolean env,boolean mani,String data2,boolean env2) throws Exception
- {
- String keyId = null;
- String certId = null;
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- // Create signature generator
- URI baseURI = new URI(IXSILConstants.DUMMY_ABSURI_);
- Signer signer = new Signer(baseURI);
-
- // Configure signed information
-
- // Get interface for signed information
- SignerSignature signature = signer.getSignature();
- SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();
-
- // Set canonicalization algorithm
- CanonicalizationAlgorithmImplCanonicalXML c14nAlg =
- new CanonicalizationAlgorithmImplCanonicalXML();
- signedInfo.setCanonicalizationAlgorithm(c14nAlg);
-
- Properties config = new Properties();
- config.put("PKCS11_NATIVE_MODULE","cryptoki.dll");
- config.put("SLOT_ID","0");
- config.put("DEFAULT_PROMPT_DIALOG","testgenerator.Pass");
-
- Security.addProvider(new IAIK());
- IAIKPkcs11 pkcs11Provider_ = new IAIKPkcs11(config);
- Security.addProvider(pkcs11Provider_);
-
- // Set signature algorithm
- SignatureAlgorithmImplRSA signatureAlg = new SignatureAlgorithmImplRSA();
- signatureAlg.setJCEProviderName(pkcs11Provider_.getName());
-
- // HSM Action start
-
- // load the keystore of the PKCS#11 provider given via input stream
- KeyStore tokenKeyStore = pkcs11Provider_.getTokenManager().getKeyStore();
- tokenKeyStore.load(null,"1111".toCharArray());
-
- Enumeration enum = tokenKeyStore.aliases();
-
- String ali = null;
- while(enum.hasMoreElements())
- {
- //enum.nextElement();
- ali = (String)enum.nextElement();
- //ali = (String)enum.nextElement();
- System.out.println("Alias:"+ali);
- if(tokenKeyStore.containsAlias(ali)) System.out.println("ALIAS vorhanden");
- if(tokenKeyStore.isKeyEntry(ali)) System.out.println("KEYENTRY vorhanden");
- }
-
- Enumeration enum2 = tokenKeyStore.aliases();
-
- while (enum2.hasMoreElements()) {
- String alias = enum2.nextElement().toString();
-
- if (tokenKeyStore.isKeyEntry(alias)) {
- System.out.println("________________________________________________________________________________");
- System.out.println("Key entry with alias: " + alias);
- Key key = tokenKeyStore.getKey(alias, null);
- System.out.println(key);
- java.security.cert.Certificate[] certificateChain2 = tokenKeyStore.getCertificateChain(alias);
- if (certificateChain2 != null) {
- System.out.println("Certificate chain of length: " + certificateChain2.length);
- for (int i = 0; i < certificateChain2.length; i++) {
- System.out.println("--------------------------------------------------------------------------------");
- System.out.println(certificateChain2[i]);
- }
- } else {
- System.out.println("Certificate chain is null!");
- }
- System.out.println("________________________________________________________________________________");
- } else if (tokenKeyStore.isCertificateEntry(alias)) {
- System.out.println("________________________________________________________________________________");
- System.out.println("Certificate entry with alias: " + alias);
- java.security.cert.Certificate certificate = tokenKeyStore.getCertificate(alias);
- System.out.println(certificate);
- System.out.println("________________________________________________________________________________");
- } else {
- System.out.println("________________________________________________________________________________");
- System.out.println("ERROR! Unknown entry type with alias: " + alias);
- System.out.println("________________________________________________________________________________");
- }
- }
-
-
- IAIKPKCS11RsaPrivateKey privateKey = (IAIKPKCS11RsaPrivateKey)tokenKeyStore.getKey("MOAHSMRSAKEY_cert", null);
- keyId = new String(privateKey.getKeyID());
-
- System.out.println(new String(privateKey.getKeyID()));
- //System.out.println("got:"+signatureKey+" : "+signatureKey.getClass().getName());
-
- Signature signatureEngine = Signature.getInstance("ExternalSHA1WithRSA", pkcs11Provider_.getName());
- signatureEngine.initSign(privateKey);
- /*signatureEngine.update("This is some data to be signed.".getBytes());
- byte[] bytesig = signatureEngine.sign();
- System.out.println("SIG:"+new String(bytesig));
-
- System.out.println("KEY:\n"+privateKey);*/
- signatureAlg.setSignerKey(privateKey);
- signedInfo.setSignatureAlgorithm(signatureAlg);
-
- SignerReference reference = signedInfo.createReference();
-
- if(!mani)
- {
- if(env)
- {
- iaik.ixsil.core.Object object = null;
- object = signature.createObject(data);
- object.setId("signed-data-0-1");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- reference.setURI(new URI("#xpointer(id('signed-data-0-1')/node())"));
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- reference.setId("reference-1-1");
- signedInfo.addReference(reference);
- }
-
- if(data2!=null)
- {
- reference = signedInfo.createReference();
- if(env2)
- {
- iaik.ixsil.core.Object object = null;
- object = signature.createObject(data2);
- object.setId("signed-data-0-2");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- reference.setURI(new URI("#xpointer(id('signed-data-0-2')/node())"));
- }
- else
- {
- // Create and configure reference
- URI refURI = null;
- String baseDir = configuration_.getProperty("baseDir");
- refURI = new URI(data2);
-
-
- reference.setURI(refURI);
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
- }
- signedInfo.addReference(reference);
- }
-
- // Add reference to signature
-
-
-
- if(mani)
- {
-
- /*iaik.ixsil.core.Object object = null;
- if(env)
- object = signature.createObject(readFile(data));
- else
- object = signature.createObject(data);
-
- object.setId("envelopedData");
- signature.addObject(object);*/
-
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- manifestRef.setDigestAlgorithm(digestAlg);
-
- manifestRef.setURI(new URI(data));
-
- manifest.addReference(manifestRef);
- manifest.setId("manifest-1");
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- reference = signedInfo.createReference();
- reference.setURI(
- new URI("#xpointer(id('manifest-1'))"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);
-
-
- /*Element envelopedDataElem =
- signer.toDocument().createElement("EnvelopedDataElement");
-
- if(env)
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(readFile(data)));
- }
- else
- {
- envelopedDataElem.appendChild(
- signer.toDocument().createTextNode(data));
- }
-
- iaik.ixsil.core.Object object = signature.createObject(envelopedDataElem);
- signature.addObject(object);
-
- // Create Manifest with a single reference pointing to the enveloped data
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
- manifestRef.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[1]/descendant::node())"));
- manifestRef.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
- manifest.addReference(manifestRef);
-
- // Add Manifest to signature structure (use an Object) and compute digest values for manifest reference
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- // Create and configure reference to manifest
- reference = signedInfo.createReference();
- reference.setURI(
- new URI(
- null,
- null,
- null,
- null,
- "xmlns(dsig="
- + IXSILConstants.NAMESPACE_URI_XMLSIGNATURE_ELEM_
- + ") "
- + "xpointer(here()/ancestor::dsig:Signature[1]/dsig:Object[2]/dsig:Manifest)"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);*/
- }
-
- enum2 = tokenKeyStore.aliases();
-
- while(enum2.hasMoreElements())
- {
- System.out.println(enum2.nextElement());
- }
-
- enum2 = tokenKeyStore.aliases();
-
- while (enum2.hasMoreElements()) {
- String alias = enum2.nextElement().toString();
-
- if (tokenKeyStore.isKeyEntry(alias)) {
- System.out.println("________________________________________________________________________________");
- System.out.println("Key entry with alias: " + alias);
- Key key = tokenKeyStore.getKey(alias, null);
- System.out.println(key);
- java.security.cert.Certificate[] certificateChain2 = tokenKeyStore.getCertificateChain(alias);
- if (certificateChain2 != null) {
- System.out.println("Certificate chain of length: " + certificateChain2.length);
- for (int i = 0; i < certificateChain2.length; i++) {
- System.out.println("--------------------------------------------------------------------------------");
- System.out.println(certificateChain2[i]);
- }
- } else {
- System.out.println("Certificate chain is null!");
- }
- System.out.println("________________________________________________________________________________");
- } else if (tokenKeyStore.isCertificateEntry(alias)) {
- System.out.println("________________________________________________________________________________");
- System.out.println("Certificate entry with alias: " + alias);
- java.security.cert.Certificate certificate = tokenKeyStore.getCertificate(alias);
- System.out.println(certificate);
- System.out.println("________________________________________________________________________________");
- } else {
- System.out.println("________________________________________________________________________________");
- System.out.println("ERROR! Unknown entry type with alias: " + alias);
- System.out.println("________________________________________________________________________________");
- }
- }
-
- // Create key information
- KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
-
- //DOMUtils.serializeNode(keyManager.getKeyInfo());
-
- java.security.cert.Certificate[] certificateChain = tokenKeyStore.getCertificateChain("MOAHSMRSAKEY_cert");
-
- System.out.println("CERTLEN:"+certificateChain.length);
-
- X509Data x509Data = new X509Data();
- for (int i = 0; i < certificateChain.length; i++)
- {
- System.out.println("CERT:"+((Name)(((X509Certificate)certificateChain[i]).getIssuerDN())).getRFC2253String());
- x509Data.insertHintAt((X509Certificate)certificateChain[i], i);
- }
-
- KeyProviderImplX509Data x509DataKeyProvider = new KeyProviderImplX509Data(signer.toDocument());
- x509DataKeyProvider.insertX509DataAt(x509Data, 0);
-
- // X509Data key information (certificate chain)
- keyManager.addKeyProvider(x509DataKeyProvider);
-
- signer.getSignature().setKeyManager(keyManager);
- signer.getSignature().setId("signature-1-1");
-
- // Compute signature value
- signer.getSignature().sign();
-
- return signer.toDocument();
- }
-
- public Document createPKCS12SigSL(String TestNumber,String data) throws Exception
- {
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- PKCS12 pkcs12 = decryptPKCS12(
- configuration_.getProperty("PKCS12file"),
- configuration_.getProperty("PKCS12password" ) );
-
- // Create signature generator
- URI baseURI = new URI(IXSILConstants.DUMMY_ABSURI_);
- Signer signer = new Signer(baseURI);
-
- // Configure signed information
-
- // Get interface for signed information
- SignerSignature signature = signer.getSignature();
- SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();
-
- // Set canonicalization algorithm
- CanonicalizationAlgorithmImplCanonicalXML c14nAlg =
- new CanonicalizationAlgorithmImplCanonicalXML();
- signedInfo.setCanonicalizationAlgorithm(c14nAlg);
-
- // Set signature algorithm
- SignatureAlgorithmImplRSA signatureAlg = new SignatureAlgorithmImplRSA();
- RSAPrivateKey privateKey = getPrivateKey( pkcs12 );
- signatureAlg.setSignerKey(privateKey);
- signedInfo.setSignatureAlgorithm(signatureAlg);
-
- SignerReference reference = signedInfo.createReference();
-
- // env
- /*iaik.ixsil.core.Object object = null;
- object = signature.createObject(data);
- object.setId("envelopedData");
- signature.addObject(object);
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- reference.setURI(new URI("#xpointer(id('envelopedData')/node())"));*/
-
- // detached
- // Create and configure reference
- URI refURI = null;
- refURI = new URI(data);
-
- reference.setURI(refURI);
- reference.setId("reference-1-1");
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- signedInfo.addReference(reference);
-
- reference = signedInfo.createReference();
-
- refURI = null;
- refURI = new URI(data);
-
- //reference.setURI(new URI("#xpointer(id('ETSIProperties'))/*/*"));
- reference.setURI(new URI("#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-signed-1-1')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"));
- reference.setType(new URI("http://uri.etsi.org/01903/v1.1.1#SignedProperties"));
- digestAlg = new DigestAlgorithmImplSHA1();
- reference.setDigestAlgorithm(digestAlg);
-
- signedInfo.addReference(reference);
-
- /*iaik.ixsil.core.Object object = null;
- object = signature.createObject(data);
- object.setId("SLManifestObject");
-
- signature.addObject(object);*/
-
-
- /*SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
-
- digestAlg = new DigestAlgorithmImplSHA1();
- manifestRef.setDigestAlgorithm(digestAlg);
-
- manifestRef.setURI(new URI(data));
-
- manifest.addReference(manifestRef);
- manifest.setId("SLManifestObject");
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- reference = manifest.createReference();
- reference.setType(new URI("http://www.buergerkarte.at/specifications/Security-Layer/20020225#SignatureManifest"));
- reference.setURI(new URI("#SLManifestObject"));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);*/
-
- iaik.ixsil.core.Object object = null;
- object = signature.createObject(getElement("TEST"));
- object.setId("etsi-signed-1-1");
- signature.addObject(object);
-
-
-
- /*if(mani)
- {
-
- SignerManifest manifest = signer.createManifest();
- SignerReference manifestRef = manifest.createReference();
-
- DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
- manifestRef.setDigestAlgorithm(digestAlg);
-
- manifestRef.setURI(new URI(data));
-
- manifest.addReference(manifestRef);
- manifest.setId("manifestObject");
- iaik.ixsil.core.Object manifestObject = signature.createObject(manifest);
- signature.addObject(manifestObject);
- manifest.computeDigestValues();
-
- reference = signedInfo.createReference();
- reference.setURI(
- new URI("#xpointer(id('manifestObject'))"));
- reference.setType(new URI(IXSILConstants.REFERENCETYPE_ATTR_VALUE_MANIFEST_));
- reference.setDigestAlgorithm(new DigestAlgorithmImplSHA1());
-
- // Add reference to signature
- signedInfo.addReference(reference);
-
- }*/
-
- signature.setId("signature-1-1");
-
- // Create key information
- KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
-
- X509Certificate[] certs = getCertificates(pkcs12);
- X509Data x509Data = new X509Data();
- x509Data.insertHintAt(certs[1], 0);
-
- KeyProviderImplX509Data x509DataKeyProvider = new KeyProviderImplX509Data(signer.toDocument());
- x509DataKeyProvider.insertX509DataAt(x509Data, 0);
-
- // X509Data key information (certificate chain)
- keyManager.addKeyProvider(x509DataKeyProvider);
-
- signer.getSignature().setKeyManager(keyManager);
-
- // Compute signature value
- signer.getSignature().sign();
-
- return signer.toDocument();
- }
-
- public Element getElement(String data) throws Exception
- {
- String etsinamespace = "http://uri.etsi.org/01903/v1.1.1#";
-
- getX509Content();
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- //dbf.setNamespaceAware(true);
- //dbf.setValidating(true);
-
- Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
-
-
- Element qualprop = doc.createElementNS(etsinamespace,"etsi:QualifyingProperties");
- qualprop.setAttributeNS(null,"Target","#signature-1-1");
- qualprop.setAttributeNS(IXSILConstants.NAMESPACE_URI_NAMESPACES_,"xmlns:etsi",etsinamespace);
- //qualprop.setPrefix("etsi");*/
- //qualprop.setAttributeNodeNS(doc.createAttributeNS(etsinamespace,"etsi"));
- Element signprop = doc.createElementNS(etsinamespace,"etsi:SignedProperties");
- Element signsigprop = doc.createElementNS(etsinamespace,"etsi:SignedSignatureProperties");
- Element signdataobjectprop = doc.createElementNS(etsinamespace,"etsi:SignedDataObjectProperties");
- Element signdate = doc.createElementNS(etsinamespace,"etsi:SigningTime");
- Text datevalue = doc.createTextNode("2003-05-10T00:01:01");
- Element signcert = doc.createElementNS(etsinamespace,"etsi:SigningCertificate");
- Element cert = doc.createElementNS(etsinamespace,"etsi:Cert");
- Element signpolyident = doc.createElementNS(etsinamespace,"etsi:SignaturePolicyIdentifier");
- Element signpolyimp = doc.createElementNS(etsinamespace,"etsi:SignaturePolicyImplied");
- Element certdig = doc.createElementNS(etsinamespace,"etsi:CertDigest");
- Element digmeth = doc.createElementNS(etsinamespace,"etsi:DigestMethod");
- digmeth.setAttribute("Algorithm","http://www.w3.org/2000/09/xmldsig#sha1");
- Element digvalue = doc.createElementNS(etsinamespace,"etsi:DigestValue");
-
- ByteArrayOutputStream fos = new ByteArrayOutputStream();
- Base64OutputStream base64os = new Base64OutputStream(fos);
- base64os.write(this.X509hash.getBytes());
- base64os.flush();
-
- Text dig_value = doc.createTextNode(fos.toString());
- Element is = doc.createElementNS(etsinamespace,"etsi:IssuerSerial");
- Element i = doc.createElement("dsig:X509IssuerName");
- Text i_value = doc.createTextNode(this.X509name);
- Element s = doc.createElement("dsig:X509SerialNumber");
- Text s_value = doc.createTextNode(this.X509number.toString());
- Element dataobjformat = doc.createElementNS(etsinamespace,"etsi:DataObjectFormat");
- dataobjformat.setAttribute("ObjectReference","#reference-1-1");
- Element mimetype = doc.createElementNS(etsinamespace,"etsi:MimeType");
- //mimetype.setNodeValue("text/plain");
- Text mimevalue = doc.createTextNode("text/plain");
-
- qualprop.appendChild(signprop);
- signprop.appendChild(signsigprop);
- signsigprop.appendChild(signdate);
- signdate.appendChild(datevalue);
- signsigprop.appendChild(signcert);
- signcert.appendChild(cert);
- cert.appendChild(certdig);
- certdig.appendChild(digmeth);
- certdig.appendChild(digvalue);
- digvalue.appendChild(dig_value);
- cert.appendChild(is);
- is.appendChild(i);
- i.appendChild(i_value);
- is.appendChild(s);
- s.appendChild(s_value);
- signsigprop.appendChild(signpolyident);
- signpolyident.appendChild(signpolyimp);
- signprop.appendChild(signdataobjectprop);
- signdataobjectprop.appendChild(dataobjformat);
- dataobjformat.appendChild(mimetype);
- mimetype.appendChild(mimevalue);
-
-
-
- return qualprop;
- }
-
-
- 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=\"DSAinPKCS12\"> <Key id=\"DSA.512.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\"/>"+
-"</MOAConfiguration>";
-
-
- /*"<MOAConfiguration>\n"+
- " <KeyGroup id=\"PKCS12RSAKey1\"/> <!-- mapped auf \"test(1234).p12\" -->\n"+
- "</MOAConfiguration>\n"+
- "<!-- CanonicalizationMethod = http://www.w3.org/TR/2001/REC-xml-c14n-20010315 -->" +
- "<!-- SignatureMethod = http://www.w3.org/2000/09/xmldsig#rsa-sha1 -->";*/
-
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(config.getBytes());
- fos.flush();
- fos.close();
-
- String file_3 = configuration_.getProperty("baseDir") + datadirectory_3 +
- "TestGeneratorCX3" +
- ".Config.xml";
-
- fos = new FileOutputStream(file_3);
- fos.write(config.getBytes());
- fos.flush();
- fos.close();
-
- String file_4 = configuration_.getProperty("baseDir") + datadirectory_4 +
- "TestGeneratorCX4" +
- ".Config.xml";
-
- fos = new FileOutputStream(file_4);
- fos.write(config.getBytes());
- fos.flush();
- fos.close();
-
- }
-
- 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 =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/"+filename+".txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory_l+filename+"/" +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/"+filename+".txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
- }
-
- /* ==================================================================================================== */
-
- public void create001() throws Exception {
-
- String TestNumber = "001";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
-
- // CX3 wird gleich mit generiert
-
- String reqFile_3 = configuration_.getProperty("baseDir") + datadirectory_3 +
- "TestGeneratorCX3" +
- ".";
- String reqFile_4 = configuration_.getProperty("baseDir") + datadirectory_4 +
- "TestGeneratorCX4" +
- ".";
-
- writeFile(reqFile_3+"001" + ".Req.xml",req);
- writeFile(reqFile_4+"051" + ".Req.xml",req);
-
- req = replaceString(req,"PKCS12RSAKey1","PKCS12RSAKeyNotAllowed");
-
- writeFile(reqFile_3+"052" + ".Req.xml",req);
-
- String resFile_3 = configuration_.getProperty("baseDir") + datadirectory_3 +
- "TestGeneratorCX3" +
- "." ;
- String resFile_4 = configuration_.getProperty("baseDir") + datadirectory_4 +
- "TestGeneratorCX4" +
- "." ;
-
- writeFile(resFile_3+ "001" + ".Res.xml",erg);
- writeFile(resFile_4+ "051" + ".ErrRes.xml","0000");
- writeFile(resFile_3+ "052" + ".ErrRes.xml","2231");
-
- }
-
- public void writeFile(String filename,String data) throws Exception
- {
- BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
- bw.write(data);
- bw.close();
- }
-
-
- public void create002() throws Exception {
-
- String TestNumber = "002";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create003() throws Exception {
-
- String TestNumber = "003";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" ?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create004() throws Exception {
-
- /*Properties config = new Properties();
- config.put("PKCS11_NATIVE_MODULE","cryptoki.dll");
- config.put("SLOT_ID","0");
-
- Security.addProvider(new IAIK());
- IAIKPkcs11 pkcs11Provider_ = new IAIKPkcs11(config);
- Security.addProvider(pkcs11Provider_);
-
- // load the keystore of the PKCS#11 provider given via input stream
- KeyStore tokenKeyStore = pkcs11Provider_.getTokenManager().getKeyStore();
-
- Object signatureKey = tokenKeyStore.getKey("HSMRSAKEY", null);
- //System.out.println("got:"+signatureKey+" : "+signatureKey.getClass().getName());
- if(signatureKey instanceof IAIKPKCS11RsaPrivateKey)
- {
- System.out.println("GOT PRIVATE KEY:"+(IAIKPKCS11RsaPrivateKey)signatureKey);
- java.security.cert.Certificate[] certificateChain = tokenKeyStore.getCertificateChain("HSMRSAKEY");
- X509Certificate signerCertificate = (X509Certificate) certificateChain[0];
-
- }
- if(signatureKey instanceof IAIKPKCS11RsaPublicKey)
- {
- System.out.println("GOT PUBLIC KEY:"+(IAIKPKCS11RsaPublicKey)signatureKey);
- }*/
-
- String TestNumber = "004";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" ?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>MOAHSMRSAKEY</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createHSMSig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt",false,false,null,false);
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create005() throws Exception {
-
- String TestNumber = "005";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" ?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12ECDSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createECDSPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
-
- public void create006() throws Exception {
-
- String TestNumber = "006";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
-
- writeFile(reqFile,"");
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- writeFile(resFile,"0000");
- }
-
- public void create007() throws Exception {
-
- String TestNumber = "007";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\">\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create008() throws Exception {
-
- String TestNumber = "008";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\">\n"+
- " <Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg==</Base64Content>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
-
- /* ==================================================================================================== */
-
- public void create009() throws Exception {
-
- // based on create000()
-
- String TestNumber = "009";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12SigWithEnveloping(TestNumber,"b64:Dies sind Testdaten");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create010() throws Exception {
-
- // based on create000()
-
- String TestNumber = "010";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\" ChildOfManifest=\"false\">\n"+
- " <DataObject>\n"+
- " <XMLContent xml:space=\"preserve\"><Testdaten>Dies sind Testdaten</Testdaten></XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12SigWithEnveloping(TestNumber,"<Testdaten>Dies sind Testdaten</Testdaten>");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create011() throws Exception {
-
- // based on create000()
-
- String TestNumber = "011";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\" ChildOfManifest=\"false\">\n"+
- " <DataObject>\n"+
- " <Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg==</Base64Content>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12SigWithEnveloping(TestNumber,"b64:Dies sind Testdaten");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create012() throws Exception {
-
- // based on create000()
-
- String TestNumber = "012";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" >\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\">\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
-
- public void create013() throws Exception {
-
- // based on create000()
-
- String TestNumber = "013";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"true\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\" />\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt",false,true);
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create014() throws Exception {
-
- // based on create000()
-
- String TestNumber = "014";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"true\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testUTF8.txt\" />\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12SigSL(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testUTF8.txt");
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create015() throws Exception {
-
- // based on create000()
-
- String TestNumber = "015";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " <DataObjectInfo Structure=\"detached\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testSimple.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt",false,false,configuration_.getProperty("webbaseDir")+"resources/testSimple.txt",false);
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create016() throws Exception {
-
- // based on create000()
-
- String TestNumber = "016";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\">\n"+
- " <DataObject>\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " <DataObjectInfo Structure=\"enveloping\">\n"+
- " <DataObject>\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,"Dies sind Testdaten",true,false,"Dies sind Testdaten",true);
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create017() throws Exception {
-
- // based on create000()
-
- String TestNumber = "017";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " <DataObjectInfo Structure=\"enveloping\">\n"+
- " <DataObject>\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt",false,false,"Dies sind Testdaten",true);
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
-
- }
-
- public void create018() throws Exception {
-
- // based on create000()
-
- String TestNumber = "018";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt");
- Document signatureDoc2 = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt","id","id");
-
- String erg = makeOutputFile(signatureDoc,signatureDoc2);
-
- writeFile(resFile,erg);
-
- }
-
- public void create019() throws Exception {
-
- String TestNumber = "019";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testXML.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/xml</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Res.xml";
-
- Document signatureDoc = createPKCS12SigWithEnveloping(TestNumber,"b64:"+readFile(configuration_.getProperty("baseDir")+"resources/testXML.txt"));
-
- String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,erg);
- }
-
- public void create064() throws Exception {
-
- // based on create000()
-
- String TestNumber = "064";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"enveloping\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"testDatenFalsch.txt\">\n"+
- " <Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg==</Base64Content>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- //Document signatureDoc = createPKCS12SigWithEnveloping(TestNumber,"Dies sind Testdaten");
-
- //String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,"1110");
-
- }
-
-
- public void create051() throws Exception {
-
- String TestNumber = "051";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"/>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " <SuperExtraElementThatShouldNotBeValidWithTheSchema/>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"1100");
-
- }
-
- public void create052() throws Exception {
-
- String TestNumber = "052";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"version=\"1.0\"","");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"0000");
-
- }
-
- public void create053() throws Exception {
-
- String TestNumber = "053";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"version=\"1.0\"","version=\"5.0alpha3\"");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"0000");
-
- }
-
- public void create054() throws Exception {
-
- String TestNumber = "054";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"ISO-8859-1","SuperSvenEncoding:)");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"0000");
-
- }
-
- public void create055() throws Exception {
-
- String TestNumber = "055";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"","xmlns=\"http://www.w3.org/2000/09/svens_schema#\"");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"1100");
-
- }
-
- public void create056() throws Exception {
-
- String TestNumber = "056";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"PKCS12RSAKey1","wrong_value_KeyIdentifier");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"2231");
-
- }
-
- public void create057() throws Exception {
-
- String TestNumber = "057";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"PKCS12RSAKey1","PKCS12RSAKeyExpired");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"2220");
-
- }
-
- public void create058() throws Exception {
-
- String TestNumber = "058";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"PKCS12RSAKey1","DSAinPKCS12");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"2220");
-
- }
-
- public void create059() throws Exception {
-
- String TestNumber = "059";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt",configuration_.getProperty("webbaseDir")+"not_here.txt");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"2208");
-
- }
-
- /*
-
- public String defaultblock = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\">\n"+
- " <!-- Hint -->\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- */
-
- public void create060() throws Exception {
-
- String TestNumber = "060";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"","");
- /*req = this.replaceString(req,"<CreateTransformsInfoProfile>","");
- req = this.replaceString(req,"<CreateTransformsInfo>","");
- req = this.replaceString(req,"<FinalDataMetaInfo>","");
- req = this.replaceString(req,"<MimeType>text/plain</MimeType>","");
- req = this.replaceString(req,"</FinalDataMetaInfo>","");
- req = this.replaceString(req,"</CreateTransformsInfo>","");
- req = this.replaceString(req,"</CreateTransformsInfoProfile>","");*/
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"1102");
-
- }
-
- public void create061() throws Exception {
-
- String TestNumber = "061";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"","");
- req = this.replaceString(req,"<!-- Hint -->","<XMLContent xml:space=\"preserve\"><DieserTagIstNichtZu></XMLContent>");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"0000");
-
- }
-
- public void create062() throws Exception {
-
- String TestNumber = "062";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"Reference=\""+configuration_.getProperty("webbaseDir")+"resources/testDaten.txt\"","");
- req = this.replaceString(req,"<!-- Hint -->","<Base64Content>RGllcyBzaW5kIFRlc3RkYXRlbg=</Base64Content>");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"1100");
-
- }
-
- public void create063() throws Exception {
-
- String TestNumber = "063";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req = this.replaceString(defaultblock,"<MimeType>text/plain</MimeType>","<MimeType>something/some thing/something</MimeType>");
-
- writeFile(reqFile,req);
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- writeFile(resFile,"1100");
-
- }
-
- public void create065() throws Exception {
-
- String TestNumber = "065";
- String reqFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".Req.xml";
- String req =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<CreateXMLSignatureRequest\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\" >\n"+
- " <KeyIdentifier>PKCS12RSAKey1</KeyIdentifier>\n"+
- " <SingleSignatureInfo SecurityLayerConformity=\"false\">\n"+
- " <DataObjectInfo Structure=\"detached\" ChildOfManifest=\"false\">\n"+
- " <DataObject>\n"+
- " <XMLContent xml:space=\"preserve\">Dies sind Testdaten</XMLContent>\n"+
- " </DataObject>\n"+
- " <CreateTransformsInfoProfile>\n"+
- " <CreateTransformsInfo>\n"+
- " <FinalDataMetaInfo>\n"+
- " <MimeType>text/plain</MimeType>\n"+
- " </FinalDataMetaInfo>\n"+
- " </CreateTransformsInfo>\n"+
- " </CreateTransformsInfoProfile>\n"+
- " </DataObjectInfo>\n"+
- " </SingleSignatureInfo>\n"+
- "</CreateXMLSignatureRequest>";
-
- writeFile(reqFile,req);
-
- /* ---------------------------------------------------------------------------------------------------- */
-
- String resFile = configuration_.getProperty("baseDir") + datadirectory +
- configuration_.getProperty("TestClass") +
- "." + TestNumber + ".ErrRes.xml";
-
- //Document signatureDoc = createPKCS12Sig(TestNumber,configuration_.getProperty("webbaseDir")+"resources/testDaten.txt");
-
- //String erg = makeOutputFile(signatureDoc);
-
- writeFile(resFile,"1102");
-
- }
-
-
-
-
- public String makeOutputFile(Document signatureDoc) throws Exception
- {
- ArrayList foundNodes = new ArrayList();
- findNode(signatureDoc.getDocumentElement(),"dsig:Signature",foundNodes);
-
- Node outputNode = null;
-
- if(foundNodes.size()>0)
- {
- outputNode = (Node)foundNodes.get(0);
- }
-
- String erg = Node2String(outputNode);
-
- // remove the <?xml ?> Prologue
- int pos = erg.indexOf("<dsig");
- erg = erg.substring(pos);
-
- // insert the dsig:signature element in a MOA Response Message
- erg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
- "<CreateXMLSignatureResponse\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " >"+
- //" xmlns:etsi=\"http://uri.etsi.org/01903/v1.1.1#\">\n"+
- "<SignatureEnvironment>" +
- erg + "</SignatureEnvironment></CreateXMLSignatureResponse>";
-
- return erg;
- }
-
- public String makeOutputFile(Document signatureDoc,Document signatureDoc2) 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);
-
- foundNodes.clear();
- findNode(signatureDoc2.getDocumentElement(),"dsig:Signature",foundNodes);
-
- outputNode = null;
-
- if(foundNodes.size()>0)
- {
- outputNode = (Node)foundNodes.get(0);
- }
-
- String erg2 = Node2String(outputNode);
-
- // remove the <?xml ?> Prologue
- pos = erg2.indexOf("<dsig");
- erg2 = erg2.substring(pos);
-
- // insert the dsig:signature element in a MOA Response Message
- erg = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
- "<CreateXMLSignatureResponse\n" +
- " xmlns=\"http://reference.e-government.gv.at/namespace/moa/20020822#\"\n"+
- " >"+
- "<SignatureEnvironment>" +
- erg +"</SignatureEnvironment><SignatureEnvironment>"+erg2+"</SignatureEnvironment> </CreateXMLSignatureResponse>";
-
- //erg = replaceString(erg,"Id=\"signature-1-1\"","Id=\"signature-2-1\"");
- //erg = replaceString(erg,"Id=\"reference-1-1\"","Id=\"reference-2-1\"");
-
-
- return erg;
- }
-
- public String readFile(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");
- }
- return data.toString();*/
-
- RandomAccessFile raf = new RandomAccessFile(filename, "r");
- if (raf.length() > Integer.MAX_VALUE)
- throw new IOException("file too big to fit in byte array.");
-
- byte[] result = new byte[(int) raf.length()];
-
- raf.read(result);
-
- return new String(result);
-
- }
-
-}
-