Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / xmlsecurity / source / helper / documentsignaturemanager.cxx
blob4718555d54c2fcbb169966bec9f3128a675b032e
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <documentsignaturemanager.hxx>
21 #include "gpg/SEInitializer.hxx"
23 #include <com/sun/star/embed/StorageFormats.hpp>
24 #include <com/sun/star/embed/ElementModes.hpp>
25 #include <com/sun/star/io/TempFile.hpp>
26 #include <com/sun/star/io/XTruncate.hpp>
27 #include <com/sun/star/embed/XTransactedObject.hpp>
28 #include <com/sun/star/xml/crypto/SEInitializer.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <comphelper/storagehelper.hxx>
32 #include <rtl/ustrbuf.hxx>
33 #include <sax/tools/converter.hxx>
34 #include <tools/date.hxx>
35 #include <tools/time.hxx>
36 #include <o3tl/make_unique.hxx>
38 #include <certificate.hxx>
39 #include <biginteger.hxx>
41 #include <xmlsec/xmlsec_init.hxx>
43 using namespace css;
45 DocumentSignatureManager::DocumentSignatureManager(const uno::Reference<uno::XComponentContext>& xContext, DocumentSignatureMode eMode)
46 : mxContext(xContext),
47 maSignatureHelper(xContext),
48 meSignatureMode(eMode)
52 DocumentSignatureManager::~DocumentSignatureManager()
54 deInitXmlSec();
57 bool DocumentSignatureManager::init()
59 SAL_WARN_IF(mxSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSEInitializer already set!");
60 SAL_WARN_IF(mxSecurityContext.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSecurityContext already set!");
61 SAL_WARN_IF(mxGpgSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxGpgSEInitializer already set!");
63 // xmlsec is needed by both services, so init before those
64 initXmlSec();
66 mxSEInitializer = xml::crypto::SEInitializer::create(mxContext);
67 #if !defined(MACOSX) && !defined(WNT)
68 mxGpgSEInitializer.set(new SEInitializerGpg());
69 #endif
71 if (mxSEInitializer.is())
72 mxSecurityContext = mxSEInitializer->createSecurityContext(OUString());
74 #if !defined(MACOSX) && !defined(WNT)
75 if (mxGpgSEInitializer.is())
76 mxGpgSecurityContext = mxGpgSEInitializer->createSecurityContext(OUString());
78 return mxSecurityContext.is() || mxGpgSecurityContext.is();
79 #else
80 return mxSecurityContext.is();
81 #endif
84 PDFSignatureHelper& DocumentSignatureManager::getPDFSignatureHelper()
86 bool bInit = true;
87 if (!mxSecurityContext.is())
88 bInit = init();
90 SAL_WARN_IF(!bInit, "xmlsecurity.comp", "Error initializing security context!");
92 if (!mpPDFSignatureHelper)
93 mpPDFSignatureHelper = o3tl::make_unique<PDFSignatureHelper>();
95 return *mpPDFSignatureHelper;
98 #if 0 // For some reason does not work
99 bool DocumentSignatureManager::IsXAdESRelevant()
101 if (mxStore.is())
103 // ZIP-based: ODF or OOXML.
104 maSignatureHelper.StartMission();
106 SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::READ, /*bUseTempStream=*/true);
107 if (aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
109 maSignatureHelper.EndMission();
110 return false;
112 // FIXME: How to figure out if it is ODF 1.2?
113 maSignatureHelper.EndMission();
114 return true;
116 return false;
118 #endif
120 /* Using the zip storage, we cannot get the properties "MediaType" and "IsEncrypted"
121 We use the manifest to find out if a file is xml and if it is encrypted.
122 The parameter is an encoded uri. However, the manifest contains paths. Therefore
123 the path is encoded as uri, so they can be compared.
125 bool DocumentSignatureManager::isXML(const OUString& rURI)
127 SAL_WARN_IF(!mxStore.is(), "xmlsecurity.helper", "empty storage reference");
129 bool bIsXML = false;
130 bool bPropsAvailable = false;
131 const OUString sPropFullPath("FullPath");
132 const OUString sPropMediaType("MediaType");
133 const OUString sPropDigest("Digest");
135 for (int i = 0; i < m_manifest.getLength(); i++)
137 const uno::Sequence<beans::PropertyValue>& entry = m_manifest[i];
138 OUString sPath, sMediaType;
139 bool bEncrypted = false;
140 for (int j = 0; j < entry.getLength(); j++)
142 const beans::PropertyValue& prop = entry[j];
144 if (prop.Name.equals(sPropFullPath))
145 prop.Value >>= sPath;
146 else if (prop.Name.equals(sPropMediaType))
147 prop.Value >>= sMediaType;
148 else if (prop.Name.equals(sPropDigest))
149 bEncrypted = true;
151 if (DocumentSignatureHelper::equalsReferenceUriManifestPath(rURI, sPath))
153 bIsXML = sMediaType == "text/xml" && ! bEncrypted;
154 bPropsAvailable = true;
155 break;
158 if (!bPropsAvailable)
160 //This would be the case for at least mimetype, META-INF/manifest.xml
161 //META-INF/macrosignatures.xml.
162 //Files can only be encrypted if they are in the manifest.xml.
163 //That is, the current file cannot be encrypted, otherwise bPropsAvailable
164 //would be true.
165 OUString aXMLExt("XML");
166 sal_Int32 nSep = rURI.lastIndexOf('.');
167 if (nSep != (-1))
169 OUString aExt = rURI.copy(nSep+1);
170 if (aExt.equalsIgnoreAsciiCase(aXMLExt))
171 bIsXML = true;
174 return bIsXML;
177 //If bTempStream is true, then a temporary stream is return. If it is false then, the actual
178 //signature stream is used.
179 //Every time the user presses Add a new temporary stream is created.
180 //We keep the temporary stream as member because ImplGetSignatureInformations
181 //will later access the stream to create DocumentSignatureInformation objects
182 //which are stored in maCurrentSignatureInformations.
183 SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int32 nStreamOpenMode, bool bTempStream)
185 SignatureStreamHelper aHelper;
186 if (mxStore.is())
188 uno::Reference<container::XNameAccess> xNameAccess(mxStore, uno::UNO_QUERY);
189 if (xNameAccess.is() && xNameAccess->hasByName("[Content_Types].xml"))
190 aHelper.nStorageFormat = embed::StorageFormats::OFOPXML;
193 if (bTempStream)
195 if (nStreamOpenMode & embed::ElementModes::TRUNCATE)
197 //We write always into a new temporary stream.
198 mxTempSignatureStream.set(io::TempFile::create(mxContext), uno::UNO_QUERY_THROW);
199 if (aHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
200 aHelper.xSignatureStream = mxTempSignatureStream;
201 else
203 mxTempSignatureStorage = comphelper::OStorageHelper::GetStorageOfFormatFromStream(ZIP_STORAGE_FORMAT_STRING, mxTempSignatureStream);
204 aHelper.xSignatureStorage = mxTempSignatureStorage;
207 else
209 //When we read from the temp stream, then we must have previously
210 //created one.
211 SAL_WARN_IF(!mxTempSignatureStream.is(), "xmlsecurity.helper", "empty temp. signature stream reference");
213 aHelper.xSignatureStream = mxTempSignatureStream;
214 if (aHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
215 aHelper.xSignatureStorage = mxTempSignatureStorage;
217 else
219 //No temporary stream
220 if (!mxSignatureStream.is())
222 //We may not have a dedicated stream for writing the signature
223 //So we take one directly from the storage
224 //Or DocumentDigitalSignatures::showDocumentContentSignatures was called,
225 //in which case Add/Remove is not allowed. This is done, for example, if the
226 //document is readonly
227 aHelper = DocumentSignatureHelper::OpenSignatureStream(mxStore, nStreamOpenMode, meSignatureMode);
229 else
231 aHelper.xSignatureStream = mxSignatureStream;
235 if (nStreamOpenMode & embed::ElementModes::TRUNCATE)
237 if (aHelper.xSignatureStream.is() && aHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
239 uno::Reference<io::XTruncate> xTruncate(aHelper.xSignatureStream, uno::UNO_QUERY_THROW);
240 xTruncate->truncate();
243 else if (bTempStream || mxSignatureStream.is())
245 //In case we read the signature stream from the storage directly,
246 //which is the case when DocumentDigitalSignatures::showDocumentContentSignatures
247 //then XSeakable is not supported
248 uno::Reference<io::XSeekable> xSeek(aHelper.xSignatureStream, uno::UNO_QUERY_THROW);
249 xSeek->seek(0);
252 return aHelper;
255 bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>& xCert,
256 const uno::Reference<xml::crypto::XXMLSecurityContext>& xSecurityContext,
257 const OUString& rDescription,
258 sal_Int32& nSecurityId,
259 bool bAdESCompliant)
261 if (!xCert.is())
263 SAL_WARN("xmlsecurity.helper", "no certificate selected");
264 return false;
267 // GPG or X509 key?
268 uno::Reference< lang::XServiceInfo > xServiceInfo(xSecurityContext, uno::UNO_QUERY);
269 if (xServiceInfo->getImplementationName() == "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl")
271 // GPG keys only really have PGPKeyId and PGPKeyPacket
272 if (!mxStore.is())
274 SAL_WARN("xmlsecurity.helper", "cannot sign pdfs with GPG keys");
275 return false;
278 maSignatureHelper.StartMission(xSecurityContext);
280 nSecurityId = maSignatureHelper.GetNewSecurityId();
282 OUStringBuffer aStrBuffer;
283 sax::Converter::encodeBase64(aStrBuffer, xCert->getEncoded());
285 OUString aKeyId;
286 if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get()))
288 OUStringBuffer aBuffer;
289 sax::Converter::encodeBase64(aBuffer, pCertificate->getSHA256Thumbprint());
290 aKeyId = aBuffer.makeStringAndClear();
292 else
293 SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one");
295 maSignatureHelper.SetGpgCertificate(nSecurityId, aKeyId, aStrBuffer.makeStringAndClear(), xCert->getIssuerName());
297 else
299 OUString aCertSerial = xmlsecurity::bigIntegerToNumericString(xCert->getSerialNumber());
300 if (aCertSerial.isEmpty())
302 SAL_WARN("xmlsecurity.helper", "Error in Certificate, problem with serial number!");
303 return false;
306 if (!mxStore.is())
308 // Something not ZIP based, try PDF.
309 nSecurityId = getPDFSignatureHelper().GetNewSecurityId();
310 getPDFSignatureHelper().SetX509Certificate(xCert);
311 getPDFSignatureHelper().SetDescription(rDescription);
312 uno::Reference<io::XInputStream> xInputStream(mxSignatureStream, uno::UNO_QUERY);
313 if (!getPDFSignatureHelper().Sign(xInputStream, bAdESCompliant))
315 SAL_WARN("xmlsecurity.helper", "PDFSignatureHelper::Sign() failed");
316 return false;
318 return true;
321 maSignatureHelper.StartMission(xSecurityContext);
323 nSecurityId = maSignatureHelper.GetNewSecurityId();
325 OUStringBuffer aStrBuffer;
326 sax::Converter::encodeBase64(aStrBuffer, xCert->getEncoded());
328 OUString aCertDigest;
329 if (auto pCertificate = dynamic_cast<xmlsecurity::Certificate*>(xCert.get()))
331 OUStringBuffer aBuffer;
332 sax::Converter::encodeBase64(aBuffer, pCertificate->getSHA256Thumbprint());
333 aCertDigest = aBuffer.makeStringAndClear();
335 else
336 SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one");
338 maSignatureHelper.SetX509Certificate(nSecurityId, xCert->getIssuerName(), aCertSerial, aStrBuffer.makeStringAndClear(), aCertDigest);
342 uno::Sequence< uno::Reference< security::XCertificate > > aCertPath = xSecurityContext->getSecurityEnvironment()->buildCertificatePath(xCert);
343 const uno::Reference< security::XCertificate >* pCertPath = aCertPath.getConstArray();
344 sal_Int32 nCnt = aCertPath.getLength();
346 OUStringBuffer aStrBuffer;
347 for (int i = 0; i < nCnt; i++)
349 sax::Converter::encodeBase64(aStrBuffer, pCertPath[i]->getEncoded());
350 maSignatureHelper.AddEncapsulatedX509Certificate(aStrBuffer.makeStringAndClear());
354 std::vector< OUString > aElements = DocumentSignatureHelper::CreateElementList(mxStore, meSignatureMode, DocumentSignatureAlgorithm::OOo3_2);
355 DocumentSignatureHelper::AppendContentTypes(mxStore, aElements);
357 sal_Int32 nElements = aElements.size();
358 for (sal_Int32 n = 0; n < nElements; n++)
360 bool bBinaryMode = !isXML(aElements[n]);
361 maSignatureHelper.AddForSigning(nSecurityId, aElements[n], bBinaryMode, bAdESCompliant);
364 maSignatureHelper.SetDateTime(nSecurityId, Date(Date::SYSTEM), tools::Time(tools::Time::SYSTEM));
365 maSignatureHelper.SetDescription(nSecurityId, rDescription);
367 // We open a signature stream in which the existing and the new
368 //signature is written. ImplGetSignatureInformation (later in this function) will
369 //then read the stream an will fill maCurrentSignatureInformations. The final signature
370 //is written when the user presses OK. Then only maCurrentSignatureInformation and
371 //a sax writer are used to write the information.
372 SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, true);
374 if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
376 uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY_THROW);
377 uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
379 // Export old signatures...
380 uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
381 std::size_t nInfos = maCurrentSignatureInformations.size();
382 for (std::size_t n = 0; n < nInfos; n++)
383 XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], bAdESCompliant);
385 // Create a new one...
386 maSignatureHelper.CreateAndWriteSignature(xDocumentHandler, bAdESCompliant);
388 // That's it...
389 XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
391 else
393 // OOXML
395 // Handle relations.
396 maSignatureHelper.EnsureSignaturesRelation(mxStore, /*bAdd=*/true);
397 // Old signatures + the new one.
398 int nSignatureCount = maCurrentSignatureInformations.size() + 1;
399 maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
401 // Export old signatures.
402 for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
403 maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
405 // Create a new signature.
406 maSignatureHelper.CreateAndWriteOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, nSignatureCount);
408 // Flush objects.
409 uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
410 xTransact->commit();
411 uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
412 xOutputStream->closeOutput();
414 uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
415 SAL_INFO("xmlsecurity.helper", "DocumentSignatureManager::add temporary storage at " << xTempFile->getUri());
418 maSignatureHelper.EndMission();
419 return true;
422 void DocumentSignatureManager::remove(sal_uInt16 nPosition)
424 if (!mxStore.is())
426 // Something not ZIP based, try PDF.
427 uno::Reference<io::XInputStream> xInputStream(mxSignatureStream, uno::UNO_QUERY);
428 if (!PDFSignatureHelper::RemoveSignature(xInputStream, nPosition))
430 SAL_WARN("xmlsecurity.helper", "PDFSignatureHelper::RemoveSignature() failed");
431 return;
434 // Only erase when the removal was successful, it may fail for PDF.
435 // Also, erase the requested and all following signatures, as PDF signatures are always chained.
436 maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition, maCurrentSignatureInformations.end());
437 return;
440 maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition);
442 // Export all other signatures...
443 SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, /*bTempStream=*/true);
445 if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
447 uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY_THROW);
448 uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
450 uno::Reference< xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
451 std::size_t nInfos = maCurrentSignatureInformations.size();
452 for (std::size_t n = 0 ; n < nInfos ; ++n)
453 XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], false /* ??? */);
455 XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
457 else
459 // OOXML
461 // Handle relations.
462 int nSignatureCount = maCurrentSignatureInformations.size();
463 maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
465 // Export old signatures.
466 for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
467 maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
469 // Flush objects.
470 uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
471 xTransact->commit();
472 uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
473 xOutputStream->closeOutput();
475 uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
476 SAL_INFO("xmlsecurity.helper", "DocumentSignatureManager::remove: temporary storage is at " << xTempFile->getUri());
480 void DocumentSignatureManager::read(bool bUseTempStream, bool bCacheLastSignature)
482 maCurrentSignatureInformations.clear();
484 if (mxStore.is())
486 // ZIP-based: ODF or OOXML.
487 maSignatureHelper.StartMission(mxSecurityContext);
489 SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::READ, bUseTempStream);
490 if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML && aStreamHelper.xSignatureStream.is())
492 uno::Reference< io::XInputStream > xInputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
493 maSignatureHelper.ReadAndVerifySignature(xInputStream);
495 else if (aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML && aStreamHelper.xSignatureStorage.is())
496 maSignatureHelper.ReadAndVerifySignatureStorage(aStreamHelper.xSignatureStorage, bCacheLastSignature);
497 maSignatureHelper.EndMission();
499 maCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations();
501 else
503 // Something not ZIP based, try PDF.
504 uno::Reference<io::XInputStream> xInputStream(mxSignatureStream, uno::UNO_QUERY);
505 if (getPDFSignatureHelper().ReadAndVerifySignature(xInputStream))
506 maCurrentSignatureInformations = getPDFSignatureHelper().GetSignatureInformations();
510 void DocumentSignatureManager::write(bool bXAdESCompliantIfODF)
512 if (!mxStore.is())
514 // Something not ZIP based, assume PDF, which is written directly in add() already.
515 return;
518 // Export all other signatures...
519 SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, false);
521 if (aStreamHelper.xSignatureStream.is() && aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
523 // ODF
524 uno::Reference< io::XOutputStream > xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
525 uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
527 uno::Reference< xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
528 std::size_t nInfos = maCurrentSignatureInformations.size();
529 for (std::size_t n = 0 ; n < nInfos ; ++n)
530 XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], bXAdESCompliantIfODF);
532 XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
535 else if (aStreamHelper.xSignatureStorage.is() && aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
537 // OOXML
538 std::size_t nSignatureCount = maCurrentSignatureInformations.size();
539 maSignatureHelper.ExportSignatureContentTypes(mxStore, nSignatureCount);
540 if (nSignatureCount > 0)
541 maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
542 else
544 // Removing all signatures: then need to remove the signature relation as well.
545 maSignatureHelper.EnsureSignaturesRelation(mxStore, /*bAdd=*/false);
546 // Also remove the whole signature sub-storage: release our read-write reference + remove the element.
547 aStreamHelper = SignatureStreamHelper();
548 mxStore->removeElement("_xmlsignatures");
551 for (std::size_t i = 0; i < nSignatureCount; ++i)
552 maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
555 // If stream was not provided, we are responsible for committing it....
556 if (!mxSignatureStream.is() && aStreamHelper.xSignatureStorage.is())
558 uno::Reference<embed::XTransactedObject> xTrans(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
559 xTrans->commit();
563 uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getSecurityEnvironment()
565 return mxSecurityContext.is() ? mxSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
568 uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getGpgSecurityEnvironment()
570 return mxGpgSecurityContext.is() ? mxGpgSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
573 uno::Reference<xml::crypto::XXMLSecurityContext> DocumentSignatureManager::getSecurityContext()
575 return mxSecurityContext;
578 uno::Reference<xml::crypto::XXMLSecurityContext> DocumentSignatureManager::getGpgSecurityContext()
580 return mxGpgSecurityContext;
584 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */