nss: upgrade to release 3.73
[LibreOffice.git] / xmlsecurity / source / helper / ooxmlsecexporter.cxx
blob8a60279404f8e349b073467aca67f770e6b5df5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "ooxmlsecexporter.hxx"
12 #include <algorithm>
13 #include <memory>
14 #include <string_view>
16 #include <com/sun/star/embed/ElementModes.hpp>
17 #include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
18 #include <com/sun/star/embed/XStorage.hpp>
19 #include <com/sun/star/beans/StringPair.hpp>
20 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
22 #include <comphelper/ofopxmlhelper.hxx>
23 #include <rtl/ref.hxx>
24 #include <sal/log.hxx>
25 #include <svx/xoutbmp.hxx>
26 #include <unotools/datetime.hxx>
27 #include <vcl/salctype.hxx>
28 #include <xmloff/attrlist.hxx>
30 #include <documentsignaturehelper.hxx>
31 #include <xsecctl.hxx>
33 using namespace com::sun::star;
34 using namespace css::xml::sax;
36 struct OOXMLSecExporter::Impl
38 private:
39 const uno::Reference<uno::XComponentContext>& m_xComponentContext;
40 const uno::Reference<embed::XStorage>& m_xRootStorage;
41 const uno::Reference<xml::sax::XDocumentHandler>& m_xDocumentHandler;
42 const SignatureInformation& m_rInformation;
43 OUString m_aSignatureTimeValue;
45 public:
46 Impl(const uno::Reference<uno::XComponentContext>& xComponentContext,
47 const uno::Reference<embed::XStorage>& xRootStorage,
48 const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler,
49 const SignatureInformation& rInformation)
50 : m_xComponentContext(xComponentContext)
51 , m_xRootStorage(xRootStorage)
52 , m_xDocumentHandler(xDocumentHandler)
53 , m_rInformation(rInformation)
57 /// Should we intentionally not sign this stream?
58 static bool isOOXMLDenylist(const OUString& rStreamName);
59 /// Should we intentionally not sign this relation type?
60 static bool isOOXMLRelationDenylist(const OUString& rRelationName);
62 const uno::Reference<xml::sax::XDocumentHandler>& getDocumentHandler() const
64 return m_xDocumentHandler;
67 void writeSignedInfo();
68 void writeCanonicalizationMethod();
69 void writeCanonicalizationTransform();
70 void writeSignatureMethod();
71 void writeSignedInfoReferences();
72 void writeSignatureValue();
73 void writeKeyInfo();
74 void writePackageObject();
75 void writeManifest();
76 void writeRelationshipTransform(const OUString& rURI);
77 /// Writes <SignatureProperties> inside idPackageObject.
78 void writePackageObjectSignatureProperties();
79 /// Writes a single <Reference> inside <Manifest>.
80 void writeManifestReference(const SignatureReferenceInformation& rReference);
81 void writeOfficeObject();
82 /// Writes <SignatureInfoV1>.
83 void writeSignatureInfo();
84 void writePackageSignature();
85 void writeSignatureLineImages();
88 bool OOXMLSecExporter::Impl::isOOXMLDenylist(const OUString& rStreamName)
90 static const std::initializer_list<std::u16string_view> vDenylist
91 = { u"/%5BContent_Types%5D.xml", u"/docProps/app.xml", u"/docProps/core.xml",
92 // Don't attempt to sign other signatures for now.
93 u"/_xmlsignatures" };
94 // Just check the prefix, as we don't care about the content type part of the stream name.
95 return std::any_of(
96 vDenylist.begin(), vDenylist.end(),
97 [&](const std::u16string_view& rLiteral) { return rStreamName.startsWith(rLiteral); });
100 bool OOXMLSecExporter::Impl::isOOXMLRelationDenylist(const OUString& rRelationName)
102 static const std::initializer_list<std::u16string_view> vDenylist = {
103 u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
104 u"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
105 u"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
107 return std::find(vDenylist.begin(), vDenylist.end(), rRelationName) != vDenylist.end();
110 void OOXMLSecExporter::Impl::writeSignedInfo()
112 m_xDocumentHandler->startElement(
113 "SignedInfo", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
115 writeCanonicalizationMethod();
116 writeSignatureMethod();
117 writeSignedInfoReferences();
119 m_xDocumentHandler->endElement("SignedInfo");
122 void OOXMLSecExporter::Impl::writeCanonicalizationMethod()
124 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
125 pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
126 m_xDocumentHandler->startElement(
127 "CanonicalizationMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
128 m_xDocumentHandler->endElement("CanonicalizationMethod");
131 void OOXMLSecExporter::Impl::writeCanonicalizationTransform()
133 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
134 pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
135 m_xDocumentHandler->startElement(
136 "Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
137 m_xDocumentHandler->endElement("Transform");
140 void OOXMLSecExporter::Impl::writeSignatureMethod()
142 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
144 if (m_rInformation.eAlgorithmID == svl::crypto::SignatureMethodAlgorithm::ECDSA)
145 pAttributeList->AddAttribute("Algorithm", ALGO_ECDSASHA256);
146 else
147 pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256);
149 m_xDocumentHandler->startElement(
150 "SignatureMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
151 m_xDocumentHandler->endElement("SignatureMethod");
154 void OOXMLSecExporter::Impl::writeSignedInfoReferences()
156 const SignatureReferenceInformations& rReferences = m_rInformation.vSignatureReferenceInfors;
157 for (const SignatureReferenceInformation& rReference : rReferences)
159 if (rReference.nType == SignatureReferenceType::SAMEDOCUMENT)
162 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
163 if (rReference.ouURI != "idSignedProperties")
164 pAttributeList->AddAttribute("Type",
165 "http://www.w3.org/2000/09/xmldsig#Object");
166 else
167 pAttributeList->AddAttribute("Type",
168 "http://uri.etsi.org/01903#SignedProperties");
169 pAttributeList->AddAttribute("URI", "#" + rReference.ouURI);
170 m_xDocumentHandler->startElement(
171 "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
173 if (rReference.ouURI == "idSignedProperties")
175 m_xDocumentHandler->startElement(
176 "Transforms",
177 uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
178 writeCanonicalizationTransform();
179 m_xDocumentHandler->endElement("Transforms");
182 DocumentSignatureHelper::writeDigestMethod(m_xDocumentHandler);
183 m_xDocumentHandler->startElement(
184 "DigestValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
185 m_xDocumentHandler->characters(rReference.ouDigestValue);
186 m_xDocumentHandler->endElement("DigestValue");
187 m_xDocumentHandler->endElement("Reference");
192 void OOXMLSecExporter::Impl::writeSignatureValue()
194 m_xDocumentHandler->startElement(
195 "SignatureValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
196 m_xDocumentHandler->characters(m_rInformation.ouSignatureValue);
197 m_xDocumentHandler->endElement("SignatureValue");
200 void OOXMLSecExporter::Impl::writeKeyInfo()
202 m_xDocumentHandler->startElement(
203 "KeyInfo", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
204 assert(m_rInformation.GetSigningCertificate());
205 for (auto const& rData : m_rInformation.X509Datas)
207 m_xDocumentHandler->startElement(
208 "X509Data", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
209 for (auto const& it : rData)
211 m_xDocumentHandler->startElement(
212 "X509Certificate",
213 uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
214 m_xDocumentHandler->characters(it.X509Certificate);
215 m_xDocumentHandler->endElement("X509Certificate");
217 m_xDocumentHandler->endElement("X509Data");
219 m_xDocumentHandler->endElement("KeyInfo");
222 void OOXMLSecExporter::Impl::writePackageObject()
224 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
225 pAttributeList->AddAttribute("Id", "idPackageObject");
226 m_xDocumentHandler->startElement(
227 "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
229 writeManifest();
230 writePackageObjectSignatureProperties();
232 m_xDocumentHandler->endElement("Object");
235 void OOXMLSecExporter::Impl::writeManifest()
237 m_xDocumentHandler->startElement(
238 "Manifest", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
239 const SignatureReferenceInformations& rReferences = m_rInformation.vSignatureReferenceInfors;
240 for (const SignatureReferenceInformation& rReference : rReferences)
242 if (rReference.nType != SignatureReferenceType::SAMEDOCUMENT)
244 if (OOXMLSecExporter::Impl::isOOXMLDenylist(rReference.ouURI))
245 continue;
247 writeManifestReference(rReference);
250 m_xDocumentHandler->endElement("Manifest");
253 void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
255 uno::Reference<embed::XHierarchicalStorageAccess> xHierarchicalStorageAccess(m_xRootStorage,
256 uno::UNO_QUERY);
257 uno::Reference<io::XInputStream> xRelStream(
258 xHierarchicalStorageAccess->openStreamElementByHierarchicalName(rURI,
259 embed::ElementModes::READ),
260 uno::UNO_QUERY);
262 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
263 pAttributeList->AddAttribute("Algorithm", ALGO_RELATIONSHIP);
264 m_xDocumentHandler->startElement(
265 "Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
268 const uno::Sequence<uno::Sequence<beans::StringPair>> aRelationsInfo
269 = comphelper::OFOPXMLHelper::ReadRelationsInfoSequence(xRelStream, rURI,
270 m_xComponentContext);
271 for (const uno::Sequence<beans::StringPair>& rPairs : aRelationsInfo)
273 OUString aId;
274 OUString aType;
275 for (const beans::StringPair& rPair : rPairs)
277 if (rPair.First == "Id")
278 aId = rPair.Second;
279 else if (rPair.First == "Type")
280 aType = rPair.Second;
283 if (OOXMLSecExporter::Impl::isOOXMLRelationDenylist(aType))
284 continue;
286 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
287 pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
288 pAttributeList->AddAttribute("SourceId", aId);
289 m_xDocumentHandler->startElement(
290 "mdssi:RelationshipReference",
291 uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
292 m_xDocumentHandler->endElement("mdssi:RelationshipReference");
295 m_xDocumentHandler->endElement("Transform");
298 void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties()
300 m_xDocumentHandler->startElement(
301 "SignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
303 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
304 pAttributeList->AddAttribute("Id", "idSignatureTime");
305 pAttributeList->AddAttribute("Target", "#idPackageSignature");
306 m_xDocumentHandler->startElement(
307 "SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
310 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
311 pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
312 m_xDocumentHandler->startElement(
313 "mdssi:SignatureTime", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
315 m_xDocumentHandler->startElement(
316 "mdssi:Format", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
317 m_xDocumentHandler->characters("YYYY-MM-DDThh:mm:ssTZD");
318 m_xDocumentHandler->endElement("mdssi:Format");
320 m_xDocumentHandler->startElement(
321 "mdssi:Value", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
322 if (!m_rInformation.ouDateTime.isEmpty())
323 m_aSignatureTimeValue = m_rInformation.ouDateTime;
324 else
326 m_aSignatureTimeValue = utl::toISO8601(m_rInformation.stDateTime);
327 // Ignore sub-seconds.
328 sal_Int32 nCommaPos = m_aSignatureTimeValue.indexOf(',');
329 if (nCommaPos != -1)
331 m_aSignatureTimeValue = m_aSignatureTimeValue.copy(0, nCommaPos);
332 m_aSignatureTimeValue += "Z";
335 m_xDocumentHandler->characters(m_aSignatureTimeValue);
336 m_xDocumentHandler->endElement("mdssi:Value");
338 m_xDocumentHandler->endElement("mdssi:SignatureTime");
339 m_xDocumentHandler->endElement("SignatureProperty");
340 m_xDocumentHandler->endElement("SignatureProperties");
343 void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInformation& rReference)
345 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
346 pAttributeList->AddAttribute("URI", rReference.ouURI);
347 m_xDocumentHandler->startElement(
348 "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
350 // Transforms
351 if (rReference.ouURI.endsWith(
352 "?ContentType=application/vnd.openxmlformats-package.relationships+xml"))
354 OUString aURI = rReference.ouURI;
355 // Ignore leading slash.
356 if (aURI.startsWith("/"))
357 aURI = aURI.copy(1);
358 // Ignore query part of the URI.
359 sal_Int32 nQueryPos = aURI.indexOf('?');
360 if (nQueryPos != -1)
361 aURI = aURI.copy(0, nQueryPos);
363 m_xDocumentHandler->startElement(
364 "Transforms", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
366 writeRelationshipTransform(aURI);
367 writeCanonicalizationTransform();
369 m_xDocumentHandler->endElement("Transforms");
372 DocumentSignatureHelper::writeDigestMethod(m_xDocumentHandler);
373 m_xDocumentHandler->startElement(
374 "DigestValue", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
375 m_xDocumentHandler->characters(rReference.ouDigestValue);
376 m_xDocumentHandler->endElement("DigestValue");
377 m_xDocumentHandler->endElement("Reference");
380 void OOXMLSecExporter::Impl::writeOfficeObject()
383 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
384 pAttributeList->AddAttribute("Id", "idOfficeObject");
385 m_xDocumentHandler->startElement(
386 "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
388 m_xDocumentHandler->startElement(
389 "SignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
391 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
392 pAttributeList->AddAttribute("Id", "idOfficeV1Details");
393 pAttributeList->AddAttribute("Target", "#idPackageSignature");
394 m_xDocumentHandler->startElement(
395 "SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
397 writeSignatureInfo();
398 m_xDocumentHandler->endElement("SignatureProperty");
399 m_xDocumentHandler->endElement("SignatureProperties");
400 m_xDocumentHandler->endElement("Object");
403 void OOXMLSecExporter::Impl::writeSignatureInfo()
405 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
406 pAttributeList->AddAttribute("xmlns", "http://schemas.microsoft.com/office/2006/digsig");
407 m_xDocumentHandler->startElement(
408 "SignatureInfoV1", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
410 m_xDocumentHandler->startElement(
411 "SetupID", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
412 m_xDocumentHandler->characters(m_rInformation.ouSignatureLineId);
413 m_xDocumentHandler->endElement("SetupID");
414 m_xDocumentHandler->startElement(
415 "SignatureText", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
416 m_xDocumentHandler->endElement("SignatureText");
417 m_xDocumentHandler->startElement(
418 "SignatureImage", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
419 m_xDocumentHandler->endElement("SignatureImage");
420 m_xDocumentHandler->startElement(
421 "SignatureComments", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
422 m_xDocumentHandler->characters(m_rInformation.ouDescription);
423 m_xDocumentHandler->endElement("SignatureComments");
424 // Just hardcode something valid according to [MS-OFFCRYPTO].
425 m_xDocumentHandler->startElement(
426 "WindowsVersion", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
427 m_xDocumentHandler->characters("6.1");
428 m_xDocumentHandler->endElement("WindowsVersion");
429 m_xDocumentHandler->startElement(
430 "OfficeVersion", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
431 m_xDocumentHandler->characters("16.0");
432 m_xDocumentHandler->endElement("OfficeVersion");
433 m_xDocumentHandler->startElement(
434 "ApplicationVersion", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
435 m_xDocumentHandler->characters("16.0");
436 m_xDocumentHandler->endElement("ApplicationVersion");
437 m_xDocumentHandler->startElement(
438 "Monitors", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
439 m_xDocumentHandler->characters("1");
440 m_xDocumentHandler->endElement("Monitors");
441 m_xDocumentHandler->startElement(
442 "HorizontalResolution", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
443 m_xDocumentHandler->characters("1280");
444 m_xDocumentHandler->endElement("HorizontalResolution");
445 m_xDocumentHandler->startElement(
446 "VerticalResolution", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
447 m_xDocumentHandler->characters("800");
448 m_xDocumentHandler->endElement("VerticalResolution");
449 m_xDocumentHandler->startElement(
450 "ColorDepth", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
451 m_xDocumentHandler->characters("32");
452 m_xDocumentHandler->endElement("ColorDepth");
453 m_xDocumentHandler->startElement(
454 "SignatureProviderId", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
455 m_xDocumentHandler->characters("{00000000-0000-0000-0000-000000000000}");
456 m_xDocumentHandler->endElement("SignatureProviderId");
457 m_xDocumentHandler->startElement(
458 "SignatureProviderUrl", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
459 m_xDocumentHandler->endElement("SignatureProviderUrl");
460 m_xDocumentHandler->startElement(
461 "SignatureProviderDetails",
462 uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
463 m_xDocumentHandler->characters(
464 "9"); // This is what MSO 2016 writes, though [MS-OFFCRYPTO] doesn't document what the value means.
465 m_xDocumentHandler->endElement("SignatureProviderDetails");
466 m_xDocumentHandler->startElement(
467 "SignatureType", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
468 m_xDocumentHandler->characters("2");
469 m_xDocumentHandler->endElement("SignatureType");
471 m_xDocumentHandler->endElement("SignatureInfoV1");
474 void OOXMLSecExporter::Impl::writePackageSignature()
476 m_xDocumentHandler->startElement(
477 "Object", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
479 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
480 pAttributeList->AddAttribute("xmlns:xd", NS_XD);
481 pAttributeList->AddAttribute("Target", "#idPackageSignature");
482 m_xDocumentHandler->startElement(
483 "xd:QualifyingProperties",
484 uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
487 DocumentSignatureHelper::writeSignedProperties(m_xDocumentHandler, m_rInformation,
488 m_aSignatureTimeValue, false);
490 m_xDocumentHandler->endElement("xd:QualifyingProperties");
491 m_xDocumentHandler->endElement("Object");
494 void OOXMLSecExporter::Impl::writeSignatureLineImages()
496 if (m_rInformation.aValidSignatureImage.is())
498 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
499 pAttributeList->AddAttribute("Id", "idValidSigLnImg");
500 m_xDocumentHandler->startElement(
501 "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
502 OUString aGraphicInBase64;
503 Graphic aGraphic(m_rInformation.aValidSignatureImage);
504 if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
505 SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64");
506 m_xDocumentHandler->characters(aGraphicInBase64);
507 m_xDocumentHandler->endElement("Object");
509 if (!m_rInformation.aInvalidSignatureImage.is())
510 return;
512 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
513 pAttributeList->AddAttribute("Id", "idInvalidSigLnImg");
514 m_xDocumentHandler->startElement(
515 "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
516 OUString aGraphicInBase64;
517 Graphic aGraphic(m_rInformation.aInvalidSignatureImage);
518 if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
519 SAL_WARN("xmlsecurity.helper", "could not convert graphic to base64");
520 m_xDocumentHandler->characters(aGraphicInBase64);
521 m_xDocumentHandler->endElement("Object");
524 OOXMLSecExporter::OOXMLSecExporter(
525 const uno::Reference<uno::XComponentContext>& xComponentContext,
526 const uno::Reference<embed::XStorage>& xRootStorage,
527 const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler,
528 const SignatureInformation& rInformation)
529 : m_pImpl(
530 std::make_unique<Impl>(xComponentContext, xRootStorage, xDocumentHandler, rInformation))
534 OOXMLSecExporter::~OOXMLSecExporter() = default;
536 void OOXMLSecExporter::writeSignature()
538 rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
539 pAttributeList->AddAttribute("xmlns", NS_XMLDSIG);
540 pAttributeList->AddAttribute("Id", "idPackageSignature");
541 m_pImpl->getDocumentHandler()->startElement(
542 "Signature", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
544 m_pImpl->writeSignedInfo();
545 m_pImpl->writeSignatureValue();
546 m_pImpl->writeKeyInfo();
547 m_pImpl->writePackageObject();
548 m_pImpl->writeOfficeObject();
549 m_pImpl->writePackageSignature();
550 m_pImpl->writeSignatureLineImages();
552 m_pImpl->getDocumentHandler()->endElement("Signature");
555 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */