aboutsummaryrefslogtreecommitdiff
path: root/spss.test/src/testgenerator/EtsiProperties.java
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-11-11 22:36:36 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2003-11-11 22:36:36 +0000
commit643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc (patch)
tree9e750c9103ad923b291820bc85fcbd669c2e7900 /spss.test/src/testgenerator/EtsiProperties.java
parentbc620256eb9b4dc6a33244b1105e58773358dbe6 (diff)
downloadmoa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.tar.gz
moa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.tar.bz2
moa-id-spss-643b4096cdd0f0ed98f21c9b5b681ed89bcb08dc.zip
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@51 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.test/src/testgenerator/EtsiProperties.java')
-rw-r--r--spss.test/src/testgenerator/EtsiProperties.java113
1 files changed, 113 insertions, 0 deletions
diff --git a/spss.test/src/testgenerator/EtsiProperties.java b/spss.test/src/testgenerator/EtsiProperties.java
new file mode 100644
index 000000000..c306ddeb6
--- /dev/null
+++ b/spss.test/src/testgenerator/EtsiProperties.java
@@ -0,0 +1,113 @@
+package testgenerator;
+
+import iaik.ixsil.init.IXSILConstants;
+
+import iaik.utils.Base64OutputStream;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+/**
+ * @author knirschs
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class EtsiProperties extends TestCases {
+
+ /**
+ * Constructor for EtsiProperties.
+ *
+ */
+ private Element qualprop;
+ private Element signdataobjectprop;
+ private static String etsinamespace = "http://uri.etsi.org/01903/v1.1.1#";
+ private Document doc;
+
+ public EtsiProperties() throws Exception{
+
+ getX509Content();
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ //dbf.setNamespaceAware(true);
+ //dbf.setValidating(true);
+
+ doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+
+
+ qualprop = doc.createElementNS(etsinamespace,"etsi:QualifyingProperties");
+ qualprop.setAttributeNS(null,"Target","#signature");
+ 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");
+ signdataobjectprop = doc.createElementNS(etsinamespace,"etsi:SignedDataObjectProperties");
+ Element signdate = doc.createElementNS(etsinamespace,"etsi:SigningTime");
+ Text datevalue = doc.createTextNode("2003-03-01T00: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());
+
+
+ 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);
+
+
+ }
+ public Element getQualProp()
+ {
+ return qualprop;
+ }
+ public void addDataObjectFormat(String reference) throws Exception
+ {
+ Element dataobjformat = doc.createElementNS(etsinamespace,"etsi:DataObjectFormat");
+ dataobjformat.setAttribute("ObjectReference",reference);
+ Element mimetype = doc.createElementNS(etsinamespace,"etsi:MimeType");
+ //mimetype.setNodeValue("text/plain");
+ Text mimevalue = doc.createTextNode("text/html");
+ signdataobjectprop.appendChild(dataobjformat);
+ dataobjformat.appendChild(mimetype);
+ mimetype.appendChild(mimevalue);
+ }
+
+}