summaryrefslogtreecommitdiffstats
path: root/xmlsecurity/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-12 18:54:29 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-13 15:24:00 +0100
commit829e236d39707437475b7d7fd599a385ed3cf5e4 (patch)
treee404fff457986ea76e0f7ff0e21e17549f26cb42 /xmlsecurity/source
parentsal: as always C++ is too stupid to deduce parameter types of min (diff)
downloadcore-829e236d39707437475b7d7fd599a385ed3cf5e4.tar.gz
core-829e236d39707437475b7d7fd599a385ed3cf5e4.zip
xmlsecurity: initial OOXMLSecParser
Change-Id: Idba2eb384756e72c8b60cb2e810110d6b95b66ad
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r--xmlsecurity/source/helper/ooxmlsecparser.cxx61
-rw-r--r--xmlsecurity/source/helper/ooxmlsecparser.hxx60
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx3
-rw-r--r--xmlsecurity/source/helper/xsecctl.hxx2
-rw-r--r--xmlsecurity/source/helper/xsecverify.cxx9
5 files changed, 131 insertions, 4 deletions
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
new file mode 100644
index 000000000000..671a680a733d
--- /dev/null
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+#include "ooxmlsecparser.hxx"
+
+using namespace com::sun::star;
+
+OOXMLSecParser::OOXMLSecParser(XSecController* pXSecController)
+ : m_pXSecController(pXSecController)
+{
+}
+
+OOXMLSecParser::~OOXMLSecParser()
+{
+}
+
+void SAL_CALL OOXMLSecParser::startDocument() throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::endDocument() throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::startElement(const OUString& /*rName*/, const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/)
+throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::endElement(const OUString& /*rName*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::characters(const OUString& /*rChars*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::ignorableWhitespace(const OUString& /*rWhitespace*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::processingInstruction(const OUString& /*rTarget*/, const OUString& /*rData*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::setDocumentLocator(const uno::Reference<xml::sax::XLocator>& /*xLocator*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+{
+}
+
+void SAL_CALL OOXMLSecParser::initialize(const uno::Sequence<uno::Any>& /*rArguments*/) throw (uno::Exception, uno::RuntimeException, std::exception)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
new file mode 100644
index 000000000000..84ce2fc5adb9
--- /dev/null
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_XMLSECURITY_SOURCE_HELPER_OOXMLSECPARSER_HXX
+#define INCLUDED_XMLSECURITY_SOURCE_HELPER_OOXMLSECPARSER_HXX
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+
+#include <cppuhelper/implbase.hxx>
+
+#include "xsecctl.hxx"
+
+/// Parses an OOXML digital signature.
+class OOXMLSecParser: public cppu::WeakImplHelper
+ <
+ css::xml::sax::XDocumentHandler,
+ css::lang::XInitialization
+ >
+{
+ XSecController* m_pXSecController;
+
+public:
+ OOXMLSecParser(XSecController* pXSecController);
+ virtual ~OOXMLSecParser();
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument() throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL endDocument() throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL startElement(const OUString& aName, const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs)
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL endElement(const OUString& aName) throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL characters(const OUString& aChars) throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL processingInstruction(const OUString& aTarget, const OUString& aData) throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ virtual void SAL_CALL setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator)
+ throw (css::xml::sax::SAXException, css::uno::RuntimeException, std::exception) override;
+
+ // XInitialization
+ virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 95f26e3f54de..e2f60f574406 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/xml/crypto/SEInitializer.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <tools/date.hxx>
#include <tools/time.hxx>
@@ -390,7 +391,7 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorageStream(const css::uno::Ref
uno::Reference<xml::sax::XParser> xParser = xml::sax::Parser::create(mxCtx);
// Create the signature reader.
- uno::Reference<xml::sax::XDocumentHandler> xHandler = mpXSecController->createSignatureReader();
+ uno::Reference<xml::sax::XDocumentHandler> xHandler = mpXSecController->createSignatureReader(embed::StorageFormats::OFOPXML);
// Create the signature listener.
ImplXMLSignatureListener* pSignatureListener = new ImplXMLSignatureListener(
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 734ecdb4b75a..8e9d1f9c2d62 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -463,7 +463,7 @@ public:
*/
void collectToVerify( const OUString& referenceId );
void addSignature( sal_Int32 nSignatureId );
- com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > createSignatureReader();
+ com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > createSignatureReader(sal_Int32 nType = 0);
void releaseSignatureReader();
public:
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index ba89bad64939..856fdf7636da 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -20,6 +20,7 @@
#include "xsecctl.hxx"
#include "xsecparser.hxx"
+#include "ooxmlsecparser.hxx"
#include <tools/debug.hxx>
#include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
@@ -28,6 +29,7 @@
#include <com/sun/star/xml/crypto/sax/XReferenceCollector.hpp>
#include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <sal/log.hxx>
#include <unotools/datetime.hxx>
@@ -378,9 +380,12 @@ void XSecController::addSignature( sal_Int32 nSignatureId )
m_bVerifyCurrentSignature = true;
}
-cssu::Reference< cssxs::XDocumentHandler > XSecController::createSignatureReader()
+cssu::Reference< cssxs::XDocumentHandler > XSecController::createSignatureReader(sal_Int32 nType)
{
- m_xSecParser = new XSecParser( this, nullptr );
+ if (nType == embed::StorageFormats::OFOPXML)
+ m_xSecParser = new OOXMLSecParser(this);
+ else
+ m_xSecParser = new XSecParser( this, nullptr );
cssu::Reference< cssl::XInitialization > xInitialization(m_xSecParser, uno::UNO_QUERY);
setSAXChainConnector(xInitialization, nullptr, nullptr);