From 81588a6408b6e93d772512553834e42eda3ccfd7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 10 Feb 2016 14:44:57 +0100 Subject: xmlsecurity OOXML export: write signature time Change-Id: I88b0be8b375b7698224e08768d867b767c3a98ad (cherry picked from commit a2779756374d9e71e9ed6a1d7665f64cc5eacb0f) --- xmlsecurity/source/helper/xsecctl.cxx | 40 +++++++++++++++++++++++++++++++++++ xmlsecurity/source/helper/xsecctl.hxx | 3 +++ 2 files changed, 43 insertions(+) (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx index 79581a103856..afe28cd7644e 100644 --- a/xmlsecurity/source/helper/xsecctl.cxx +++ b/xmlsecurity/source/helper/xsecctl.cxx @@ -1177,6 +1177,46 @@ void XSecController::exportOOXMLSignature(const uno::Reference& } } xDocumentHandler->endElement(TAG_MANIFEST); + + // SignatureProperties + xDocumentHandler->startElement(TAG_SIGNATUREPROPERTIES, uno::Reference(new SvXMLAttributeList())); + { + rtl::Reference pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute(ATTR_ID, "idSignatureTime"); + pAttributeList->AddAttribute(ATTR_TARGET, "#idPackageSignature"); + xDocumentHandler->startElement(TAG_SIGNATUREPROPERTY, uno::Reference(pAttributeList.get())); + } + { + rtl::Reference pAttributeList(new SvXMLAttributeList()); + pAttributeList->AddAttribute(ATTR_XMLNS ":" NSTAG_MDSSI, NS_MDSSI); + xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_SIGNATURETIME, uno::Reference(pAttributeList.get())); + } + xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_FORMAT, uno::Reference(new SvXMLAttributeList())); + xDocumentHandler->characters("YYYY-MM-DDThh:mm:ssTZD"); + xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_FORMAT); + + xDocumentHandler->startElement(NSTAG_MDSSI ":" TAG_VALUE, uno::Reference(new SvXMLAttributeList())); + OUString aSignatureTimeValue; + if (!rInformation.ouDateTime.isEmpty()) + aSignatureTimeValue = rInformation.ouDateTime; + else + { + aSignatureTimeValue = utl::toISO8601(rInformation.stDateTime); + // Ignore sub-seconds. + sal_Int32 nCommaPos = aSignatureTimeValue.indexOf(','); + if (nCommaPos != -1) + { + aSignatureTimeValue = aSignatureTimeValue.copy(0, nCommaPos); + aSignatureTimeValue += "Z"; + } + } + xDocumentHandler->characters(aSignatureTimeValue); + xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_VALUE); + + xDocumentHandler->endElement(NSTAG_MDSSI ":" TAG_SIGNATURETIME); + xDocumentHandler->endElement(TAG_SIGNATUREPROPERTY); + xDocumentHandler->endElement(TAG_SIGNATUREPROPERTIES); + xDocumentHandler->endElement(TAG_OBJECT); { diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx index d2af2459fb5f..7146d886047e 100644 --- a/xmlsecurity/source/helper/xsecctl.hxx +++ b/xmlsecurity/source/helper/xsecctl.hxx @@ -85,6 +85,9 @@ #define TAG_QUALIFYINGPROPERTIES "QualifyingProperties" #define TAG_SIGNEDPROPERTIES "SignedProperties" #define TAG_RELATIONSHIPREFERENCE "RelationshipReference" +#define TAG_SIGNATURETIME "SignatureTime" +#define TAG_FORMAT "Format" +#define TAG_VALUE "Value" #define ATTR_XMLNS "xmlns" #define ATTR_ALGORITHM "Algorithm" -- cgit v1.2.3