summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-08 12:41:07 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-08 13:53:45 +0100
commit95d45e8a19babfc319b3e92ee89bb13fd9924631 (patch)
tree0a489f7a3078c5489ec309a7a1e5fa0e545d231c /xmlsecurity
parent1eda4ad5bab6ac65c0c61bbbef6946129566b7cc (diff)
xmlsecurity: export OOXML <SignedInfo>
Change-Id: I1cac26d1133722285abe038085ad81dc16be6d8f
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/helper/xsecctl.cxx6
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx2
-rw-r--r--xmlsecurity/source/helper/xsecsign.cxx51
3 files changed, 58 insertions, 1 deletions
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index cc6a2e14cd68..fcbd8284247a 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -975,6 +975,12 @@ void XSecController::exportSignature(
xDocumentHandler->endElement( tag_Signature );
}
+void XSecController::exportOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& /*rInformation*/)
+{
+ xDocumentHandler->startElement(TAG_SIGNEDINFO, uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
+ xDocumentHandler->endElement(TAG_SIGNEDINFO);
+}
+
SignatureInformation XSecController::getSignatureInformation( sal_Int32 nSecurityId ) const
{
SignatureInformation aInf( 0 );
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index ff7ee0e72890..967e6036e5e7 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -506,6 +506,8 @@ public:
/// Writes XML elements inside a single OOXML signature's <Signature> element.
bool WriteOOXMLSignature(const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler);
+ /// Exports an OOXML signature, called by WriteOOXMLSignature().
+ static void exportOOXMLSignature(const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler, const SignatureInformation& rInformation);
};
#endif
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 8b658df31cb2..4f1e523a526c 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -357,10 +357,59 @@ bool XSecController::WriteSignature(
return rc;
}
-bool XSecController::WriteOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& /*xDocumentHandler*/)
+bool XSecController::WriteOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& xDocumentHandler)
{
bool bRet = false;
+ SAL_WARN_IF(!xDocumentHandler.is(), "xmlsecurity.helper", "empty xDocumentHandler reference");
+
+ // Chain the SAXEventKeeper to the SAX chain.
+ chainOn(/*bRetrievingLastEvent=*/true);
+
+ if (m_nStatusOfSecurityComponents == INITIALIZED)
+ {
+ m_bIsSAXEventKeeperSticky = true;
+ m_xSAXEventKeeper->setNextHandler(xDocumentHandler);
+
+ try
+ {
+ // Export the signature template.
+ cssu::Reference<xml::sax::XDocumentHandler> xSEKHandler(m_xSAXEventKeeper, uno::UNO_QUERY);
+
+ for (size_t i = 0; i < m_vInternalSignatureInformations.size(); ++i)
+ {
+ InternalSignatureInformation& rInformation = m_vInternalSignatureInformations[i];
+
+ // Prepare the signature creator.
+ rInformation.xReferenceResolvedListener = prepareSignatureToWrite(rInformation);
+
+ exportOOXMLSignature(xSEKHandler, rInformation.signatureInfor);
+ }
+
+ m_bIsSAXEventKeeperSticky = false;
+ chainOff();
+
+ bRet = true;
+ }
+ catch (const xml::sax::SAXException&)
+ {
+ m_pErrorMessage = ERROR_SAXEXCEPTIONDURINGCREATION;
+ }
+ catch(const io::IOException&)
+ {
+ m_pErrorMessage = ERROR_IOEXCEPTIONDURINGCREATION;
+ }
+ catch(const uno::Exception&)
+ {
+ m_pErrorMessage = ERROR_EXCEPTIONDURINGCREATION;
+ }
+
+ m_xSAXEventKeeper->setNextHandler(nullptr);
+ m_bIsSAXEventKeeperSticky = false;
+ }
+ else
+ m_pErrorMessage = ERROR_CANNOTCREATEXMLSECURITYCOMPONENT;
+
return bRet;
}