[Libreoffice-commits] core.git: 2 commits - xmlsecurity/source
Miklos Vajna
vmiklos at collabora.co.uk
Mon Feb 8 12:54:51 UTC 2016
xmlsecurity/source/helper/xmlsignaturehelper.cxx | 3 +
xmlsecurity/source/helper/xsecctl.cxx | 6 ++
xmlsecurity/source/helper/xsecctl.hxx | 5 ++
xmlsecurity/source/helper/xsecsign.cxx | 57 +++++++++++++++++++++++
4 files changed, 71 insertions(+)
New commits:
commit 95d45e8a19babfc319b3e92ee89bb13fd9924631
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Feb 8 12:41:07 2016 +0100
xmlsecurity: export OOXML <SignedInfo>
Change-Id: I1cac26d1133722285abe038085ad81dc16be6d8f
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index cc6a2e1..fcbd828 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 ff7ee0e..967e603 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 8b658df..4f1e523 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;
}
commit 1eda4ad5bab6ac65c0c61bbbef6946129566b7cc
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Feb 8 12:29:28 2016 +0100
xmlsecurity: initial WriteOOXMLSignature()
Change-Id: I368a0254a8c8eff0ec7c56ecec4c0a462ae32252
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index bea6ed7..f653248 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -506,6 +506,9 @@ bool XMLSignatureHelper::CreateAndWriteOOXMLSignature(css::uno::Reference<css::e
xSaxWriter->startElement(TAG_SIGNATURE, uno::Reference<xml::sax::XAttributeList>(pAttributeList));
mbError = false;
+ uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY);
+ if (!mpXSecController->WriteOOXMLSignature(xDocumentHandler))
+ mbError = true;
xSaxWriter->endElement(TAG_SIGNATURE);
xSaxWriter->endDocument();
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 769e6b2..ff7ee0e 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -503,6 +503,9 @@ public:
*/
virtual void SAL_CALL signatureVerified( sal_Int32 securityId, com::sun::star::xml::crypto::SecurityOperationStatus nResult )
throw (com::sun::star::uno::RuntimeException, std::exception) override;
+
+ /// Writes XML elements inside a single OOXML signature's <Signature> element.
+ bool WriteOOXMLSignature(const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler);
};
#endif
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 29ea604..8b658df 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -32,6 +32,7 @@
#include <stdio.h>
+using namespace com::sun::star;
namespace cssu = com::sun::star::uno;
namespace cssl = com::sun::star::lang;
namespace cssxc = com::sun::star::xml::crypto;
@@ -356,4 +357,11 @@ bool XSecController::WriteSignature(
return rc;
}
+bool XSecController::WriteOOXMLSignature(const uno::Reference<xml::sax::XDocumentHandler>& /*xDocumentHandler*/)
+{
+ bool bRet = false;
+
+ return bRet;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list