summaryrefslogtreecommitdiffstats
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-05 14:39:28 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-05 15:03:14 +0100
commit976ec559d9f7e3ed42d445884a7037cf898bf636 (patch)
tree1fa3d269190a9c40b09b494c0db722ebc8cbbdfd /xmlsecurity
parentfirebird compat issue with macosx 10.11 was fixed by sberg some time ago (diff)
downloadcore-976ec559d9f7e3ed42d445884a7037cf898bf636.tar.gz
core-976ec559d9f7e3ed42d445884a7037cf898bf636.zip
xmlsecurity: write origin.sigs when exporting OOXML signature
It's an empty file, with the only purpose to have relations, referencing the individual signature streams. The only tricky part is that a temp file needs closeOutput() to flush its contents, flush() is not enough. Change-Id: I92ac61bce201c97a727ff02b1bb74599573a1807
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx2
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx10
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx9
3 files changed, 21 insertions, 0 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
index 543ec618f919..4cb3002021ce 100644
--- a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
+++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
@@ -184,6 +184,8 @@ public:
bool ReadAndVerifySignatureStorageStream(const css::uno::Reference<css::io::XInputStream>& xInputStream);
/// Adds an OOXML digital signature relation to _rels/.rels if there wasn't any before.
void EnsureSignaturesRelation(css::uno::Reference<css::embed::XStorage> xStorage);
+ /// Given that xStorage is an OOXML _xmlsignatures storage, create origin.sigs and its relations.
+ static void ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureCount);
};
#endif // INCLUDED_XMLSECURITY_INC_XMLSECURITY_XMLSIGNATUREHELPER_HXX
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 6641c0d6df3c..6f395012d097 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -516,6 +516,16 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
{
// OOXML
maSignatureHelper.EnsureSignaturesRelation(mxStore);
+
+ // Old signatures + the new one.
+ int nSignatureCount = maCurrentSignatureInformations.size() + 1;
+ XMLSignatureHelper::ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
+
+ // Flush objects.
+ uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
+ xTransact->commit();
+ uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
+ xOutputStream->closeOutput();
}
maSignatureHelper.EndMission();
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 4d2293c4b6d9..cfd0c621c2c4 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -465,4 +465,13 @@ void XMLSignatureHelper::EnsureSignaturesRelation(css::uno::Reference<css::embed
xTransact->commit();
}
+void XMLSignatureHelper::ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int /*nSignatureCount*/)
+{
+ sal_Int32 nOpenMode = embed::ElementModes::READWRITE;
+ uno::Reference<io::XOutputStream> xOriginStream(xStorage->openStreamElement("origin.sigs", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XTruncate> xTruncate(xOriginStream, uno::UNO_QUERY);
+ xTruncate->truncate();
+ xOriginStream->closeOutput();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */