summaryrefslogtreecommitdiffstats
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-05 15:21:02 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-05 16:25:13 +0100
commitf26019532bb03ea1a3d276be90adbecca6759a77 (patch)
tree3ffee763ea4699ce9f53da02bd76f52064b51d83 /xmlsecurity
parentResolves: tdf#97465 like scroll ignore wheel for sc input handler inputchanged (diff)
downloadcore-f26019532bb03ea1a3d276be90adbecca6759a77.tar.gz
core-f26019532bb03ea1a3d276be90adbecca6759a77.zip
xmlsecurity: write OOXML signature relations on export
_rels/origin.sigs.rels of the _xmlsignatures temporary storage now contains references to the individual signature streams. Change-Id: I619bd81989e3b62fc4282e0e72fbfa780d1fb8bd
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx2
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx5
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx22
3 files changed, 24 insertions, 5 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
index 4cb3002021ce..a7947ed8dade 100644
--- a/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
+++ b/xmlsecurity/inc/xmlsecurity/xmlsignaturehelper.hxx
@@ -185,7 +185,7 @@ public:
/// 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);
+ 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 6f395012d097..fa3f37734379 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -515,11 +515,12 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
else
{
// OOXML
- maSignatureHelper.EnsureSignaturesRelation(mxStore);
+ // Handle relations.
+ maSignatureHelper.EnsureSignaturesRelation(mxStore);
// Old signatures + the new one.
int nSignatureCount = maCurrentSignatureInformations.size() + 1;
- XMLSignatureHelper::ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
+ maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
// Flush objects.
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index cfd0c621c2c4..43afcdcfd55b 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -54,6 +54,7 @@
#define NS_DOCUMENTSIGNATURES "http://openoffice.org/2004/documentsignatures"
#define NS_DOCUMENTSIGNATURES_ODF_1_2 "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0"
#define OOXML_SIGNATURE_ORIGIN "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"
+#define OOXML_SIGNATURE_SIGNATURE "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -352,7 +353,7 @@ namespace
{
bool lcl_isSignatureType(const beans::StringPair& rPair)
{
- return rPair.First == "Type" && rPair.Second == "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature";
+ return rPair.First == "Type" && rPair.Second == OOXML_SIGNATURE_SIGNATURE;
}
bool lcl_isSignatureOriginType(const beans::StringPair& rPair)
{
@@ -465,13 +466,30 @@ void XMLSignatureHelper::EnsureSignaturesRelation(css::uno::Reference<css::embed
xTransact->commit();
}
-void XMLSignatureHelper::ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int /*nSignatureCount*/)
+void XMLSignatureHelper::ExportSignatureRelations(css::uno::Reference<css::embed::XStorage> xStorage, int nSignatureCount)
{
+ // Write the empty file, its relations will be the signatures.
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();
+
+ // Write the relations.
+ uno::Reference<embed::XStorage> xSubStorage(xStorage->openStorageElement("_rels", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xRelStream(xSubStorage->openStreamElement("origin.sigs.rels", nOpenMode), uno::UNO_QUERY);
+ std::vector< uno::Sequence<beans::StringPair> > aRelations;
+ for (int i = 0; i < nSignatureCount; ++i)
+ {
+ std::vector<beans::StringPair> aRelation;
+ aRelation.push_back(beans::StringPair("Id", "rId" + OUString::number(i + 1)));
+ aRelation.push_back(beans::StringPair("Type", OOXML_SIGNATURE_SIGNATURE));
+ aRelation.push_back(beans::StringPair("Target", "sig" + OUString::number(i + 1) + ".xml"));
+ aRelations.push_back(comphelper::containerToSequence(aRelation));
+ }
+ comphelper::OFOPXMLHelper::WriteRelationsInfoSequence(xRelStream, comphelper::containerToSequence(aRelations), mxCtx);
+ uno::Reference<embed::XTransactedObject> xTransact(xSubStorage, uno::UNO_QUERY);
+ xTransact->commit();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */