[Libreoffice-commits] core.git: 4 commits - xmlsecurity/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 14 00:45:29 PST 2016


 xmlsecurity/source/helper/ooxmlsecparser.cxx |   70 +++++++++++++++++++++++----
 xmlsecurity/source/helper/ooxmlsecparser.hxx |    8 +++
 2 files changed, 69 insertions(+), 9 deletions(-)

New commits:
commit 7ccffbf566c34f68dbad786f31032af97f91f08f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 14 09:27:30 2016 +0100

    xmlsecurity: import OOXML <X509Certificate>
    
    Change-Id: I051b3b0f69567cf7bcf4837ab6ccda221142b49e

diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
index 28eaeaa..e47f9dd 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -13,9 +13,10 @@
 using namespace com::sun::star;
 
 OOXMLSecParser::OOXMLSecParser(XSecController* pXSecController)
-    : m_pXSecController(pXSecController),
-      m_bInDigestValue(false),
-      m_bInSignatureValue(false)
+    : m_pXSecController(pXSecController)
+    ,m_bInDigestValue(false)
+    ,m_bInSignatureValue(false)
+    ,m_bInX509Certificate(false)
 {
 }
 
@@ -65,6 +66,11 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
         m_aSignatureValue.clear();
         m_bInSignatureValue = true;
     }
+    else if (rName == "X509Certificate")
+    {
+        m_aX509Certificate.clear();
+        m_bInX509Certificate = true;
+    }
 
     if (m_xNextHandler.is())
         m_xNextHandler->startElement(rName, xAttribs);
@@ -83,6 +89,11 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax:
         m_pXSecController->setSignatureValue(m_aSignatureValue);
         m_bInSignatureValue = false;
     }
+    else if (rName == "X509Certificate")
+    {
+        m_pXSecController->setX509Certificate(m_aX509Certificate);
+        m_bInX509Certificate = false;
+    }
 
     if (m_xNextHandler.is())
         m_xNextHandler->endElement(rName);
@@ -94,6 +105,8 @@ void SAL_CALL OOXMLSecParser::characters(const OUString& rChars) throw (xml::sax
         m_aDigestValue += rChars;
     else if (m_bInSignatureValue)
         m_aSignatureValue += rChars;
+    else if (m_bInX509Certificate)
+        m_aX509Certificate += rChars;
 
     if (m_xNextHandler.is())
         m_xNextHandler->characters(rChars);
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
index 7b39cce..54c522b 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.hxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -33,6 +33,8 @@ class OOXMLSecParser: public cppu::WeakImplHelper
     OUString m_aDigestValue;
     bool m_bInSignatureValue;
     OUString m_aSignatureValue;
+    bool m_bInX509Certificate;
+    OUString m_aX509Certificate;
 
 public:
     OOXMLSecParser(XSecController* pXSecController);
commit 4ab8711c1ca8b474aa23e97ef236ee02add6259a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 14 09:26:06 2016 +0100

    xmlsecurity: import OOXML <SignatureValue>
    
    Change-Id: I96479457d6740ec69bddbf3feabd3c1dc815f197

diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
index 6c5e1ab..28eaeaa 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -14,7 +14,8 @@ using namespace com::sun::star;
 
 OOXMLSecParser::OOXMLSecParser(XSecController* pXSecController)
     : m_pXSecController(pXSecController),
-      m_bInDigestValue(false)
+      m_bInDigestValue(false),
+      m_bInSignatureValue(false)
 {
 }
 
@@ -59,6 +60,11 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
         m_aDigestValue.clear();
         m_bInDigestValue = true;
     }
+    else if (rName == "SignatureValue")
+    {
+        m_aSignatureValue.clear();
+        m_bInSignatureValue = true;
+    }
 
     if (m_xNextHandler.is())
         m_xNextHandler->startElement(rName, xAttribs);
@@ -72,6 +78,11 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax:
         m_pXSecController->setDigestValue(m_aDigestValue);
     else if (rName == "DigestValue")
         m_bInDigestValue = false;
+    else if (rName == "SignatureValue")
+    {
+        m_pXSecController->setSignatureValue(m_aSignatureValue);
+        m_bInSignatureValue = false;
+    }
 
     if (m_xNextHandler.is())
         m_xNextHandler->endElement(rName);
@@ -81,6 +92,8 @@ void SAL_CALL OOXMLSecParser::characters(const OUString& rChars) throw (xml::sax
 {
     if (m_bInDigestValue)
         m_aDigestValue += rChars;
+    else if (m_bInSignatureValue)
+        m_aSignatureValue += rChars;
 
     if (m_xNextHandler.is())
         m_xNextHandler->characters(rChars);
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
index b561862..7b39cce 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.hxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -31,6 +31,8 @@ class OOXMLSecParser: public cppu::WeakImplHelper
 
     bool m_bInDigestValue;
     OUString m_aDigestValue;
+    bool m_bInSignatureValue;
+    OUString m_aSignatureValue;
 
 public:
     OOXMLSecParser(XSecController* pXSecController);
commit 7834dd22938c9052e962473dc6f5efd1b7b2e0a5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 14 09:25:06 2016 +0100

    xmlsecurity: implement XInitialization for OOXMLSecParser
    
    addSignature() can't be called without this, as later it'll try to
    examine the keeped SAX events, which are expected to be remembered by
    the next handler.
    
    Change-Id: Id6677fff791cc65e514e43fba169fc2f71a69e33

diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
index 4966fd6..6c5e1ab 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -24,10 +24,14 @@ OOXMLSecParser::~OOXMLSecParser()
 
 void SAL_CALL OOXMLSecParser::startDocument() throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
+    if (m_xNextHandler.is())
+        m_xNextHandler->startDocument();
 }
 
 void SAL_CALL OOXMLSecParser::endDocument() throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
+    if (m_xNextHandler.is())
+        m_xNextHandler->endDocument();
 }
 
 void SAL_CALL OOXMLSecParser::startElement(const OUString& rName, const uno::Reference<xml::sax::XAttributeList>& xAttribs)
@@ -39,7 +43,7 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 
     if (rName == "Signature")
     {
-        //m_pXSecController->addSignature();
+        m_pXSecController->addSignature();
         if (!aId.isEmpty())
             m_pXSecController->setId(aId);
     }
@@ -55,6 +59,9 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
         m_aDigestValue.clear();
         m_bInDigestValue = true;
     }
+
+    if (m_xNextHandler.is())
+        m_xNextHandler->startElement(rName, xAttribs);
 }
 
 void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
@@ -65,28 +72,41 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax:
         m_pXSecController->setDigestValue(m_aDigestValue);
     else if (rName == "DigestValue")
         m_bInDigestValue = false;
+
+    if (m_xNextHandler.is())
+        m_xNextHandler->endElement(rName);
 }
 
 void SAL_CALL OOXMLSecParser::characters(const OUString& rChars) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
     if (m_bInDigestValue)
         m_aDigestValue += rChars;
+
+    if (m_xNextHandler.is())
+        m_xNextHandler->characters(rChars);
 }
 
-void SAL_CALL OOXMLSecParser::ignorableWhitespace(const OUString& /*rWhitespace*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+void SAL_CALL OOXMLSecParser::ignorableWhitespace(const OUString& rWhitespace) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
+    if (m_xNextHandler.is())
+        m_xNextHandler->ignorableWhitespace(rWhitespace);
 }
 
-void SAL_CALL OOXMLSecParser::processingInstruction(const OUString& /*rTarget*/, const OUString& /*rData*/) 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)
 {
+    if (m_xNextHandler.is())
+        m_xNextHandler->processingInstruction(rTarget, rData);
 }
 
-void SAL_CALL OOXMLSecParser::setDocumentLocator(const uno::Reference<xml::sax::XLocator>& /*xLocator*/) 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)
 {
+    if (m_xNextHandler.is())
+        m_xNextHandler->setDocumentLocator(xLocator);
 }
 
-void SAL_CALL OOXMLSecParser::initialize(const uno::Sequence<uno::Any>& /*rArguments*/) throw (uno::Exception, uno::RuntimeException, std::exception)
+void SAL_CALL OOXMLSecParser::initialize(const uno::Sequence<uno::Any>& rArguments) throw (uno::Exception, uno::RuntimeException, std::exception)
 {
+    rArguments[0] >>= m_xNextHandler;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
index 40fb7b3..b561862 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.hxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -27,6 +27,7 @@ class OOXMLSecParser: public cppu::WeakImplHelper
     >
 {
     XSecController* m_pXSecController;
+    css::uno::Reference<css::xml::sax::XDocumentHandler> m_xNextHandler;
 
     bool m_bInDigestValue;
     OUString m_aDigestValue;
commit 87f52aeec107544cea1db48809a8da6d00e3e5d2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 14 09:24:13 2016 +0100

    xmlsecurity: import OOXML <DigestValue>
    
    Change-Id: I2ca893aba65a9b9ffd5ffaddbcb6accc13fca755

diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx
index 6f71a39..4966fd6 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx
@@ -13,7 +13,8 @@
 using namespace com::sun::star;
 
 OOXMLSecParser::OOXMLSecParser(XSecController* pXSecController)
-    : m_pXSecController(pXSecController)
+    : m_pXSecController(pXSecController),
+      m_bInDigestValue(false)
 {
 }
 
@@ -49,6 +50,11 @@ throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
             m_pXSecController->addReference(aURI.copy(1));
         // TODO else
     }
+    else if (rName == "DigestValue")
+    {
+        m_aDigestValue.clear();
+        m_bInDigestValue = true;
+    }
 }
 
 void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
@@ -56,15 +62,15 @@ void SAL_CALL OOXMLSecParser::endElement(const OUString& rName) throw (xml::sax:
     if (rName == "SignedInfo")
         m_pXSecController->setReferenceCount();
     else if (rName == "Reference")
-    {
-        // TODO import digest value
-        OUString aDigestValue;
-        m_pXSecController->setDigestValue(aDigestValue);
-    }
+        m_pXSecController->setDigestValue(m_aDigestValue);
+    else if (rName == "DigestValue")
+        m_bInDigestValue = false;
 }
 
-void SAL_CALL OOXMLSecParser::characters(const OUString& /*rChars*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
+void SAL_CALL OOXMLSecParser::characters(const OUString& rChars) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
+    if (m_bInDigestValue)
+        m_aDigestValue += rChars;
 }
 
 void SAL_CALL OOXMLSecParser::ignorableWhitespace(const OUString& /*rWhitespace*/) throw (xml::sax::SAXException, uno::RuntimeException, std::exception)
diff --git a/xmlsecurity/source/helper/ooxmlsecparser.hxx b/xmlsecurity/source/helper/ooxmlsecparser.hxx
index 84ce2fc..40fb7b3 100644
--- a/xmlsecurity/source/helper/ooxmlsecparser.hxx
+++ b/xmlsecurity/source/helper/ooxmlsecparser.hxx
@@ -28,6 +28,9 @@ class OOXMLSecParser: public cppu::WeakImplHelper
 {
     XSecController* m_pXSecController;
 
+    bool m_bInDigestValue;
+    OUString m_aDigestValue;
+
 public:
     OOXMLSecParser(XSecController* pXSecController);
     virtual ~OOXMLSecParser();


More information about the Libreoffice-commits mailing list