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

Tor Lillqvist tml at collabora.com
Mon Oct 24 14:29:03 UTC 2016


 xmlsecurity/source/helper/ooxmlsecexporter.cxx |    2 +-
 xmlsecurity/source/helper/xsecctl.cxx          |   20 ++++++++++----------
 xmlsecurity/source/helper/xsecctl.hxx          |   17 +++++------------
 xmlsecurity/source/helper/xsecparser.cxx       |   12 ++++++------
 xmlsecurity/source/helper/xsecsign.cxx         |    8 ++++----
 xmlsecurity/source/helper/xsecverify.cxx       |    4 ++--
 6 files changed, 28 insertions(+), 35 deletions(-)

New commits:
commit 34dc5ea5510df5692addbf4d8559e72085a4835b
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 24 12:10:27 2016 +0300

    Use an enum class
    
    Change-Id: If75874ee12197edd367f5527a37e467041005794

diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index 23df46f..87f65cf 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -61,7 +61,7 @@ XSecController::XSecController( const cssu::Reference<cssu::XComponentContext>&
     , m_bIsSAXEventKeeperConnected(false)
     , m_bIsCollectingElement(false)
     , m_bIsBlocking(false)
-    , m_nStatusOfSecurityComponents(UNINITIALIZED)
+    , m_eStatusOfSecurityComponents(InitializationState::UNINITIALIZED)
     , m_bIsSAXEventKeeperSticky(false)
     , m_pErrorMessage(nullptr)
     , m_nReservedSignatureId(0)
@@ -129,7 +129,7 @@ void XSecController::createXSecComponent( )
     /*
      * marks all security components are not available.
      */
-    m_nStatusOfSecurityComponents = FAILTOINITIALIZED;
+    m_eStatusOfSecurityComponents = InitializationState::FAILTOINITIALIZED;
     m_xXMLSignature = nullptr;
     m_xXMLDocumentWrapper = nullptr;
     m_xSAXEventKeeper = nullptr;
@@ -183,7 +183,7 @@ void XSecController::createXSecComponent( )
         xSAXEventKeeperStatusChangeBroadcaster
             ->addSAXEventKeeperStatusChangeListener( xStatusChangeListener );
 
-        m_nStatusOfSecurityComponents = INITIALIZED;
+        m_eStatusOfSecurityComponents = InitializationState::INITIALIZED;
     }
 }
 
@@ -228,12 +228,12 @@ bool XSecController::chainOn( bool bRetrievingLastEvent )
 
     if (!m_bIsSAXEventKeeperSticky && !m_bIsSAXEventKeeperConnected)
     {
-        if ( m_nStatusOfSecurityComponents == UNINITIALIZED )
+        if ( m_eStatusOfSecurityComponents == InitializationState::UNINITIALIZED )
         {
             createXSecComponent();
         }
 
-        if ( m_nStatusOfSecurityComponents == INITIALIZED )
+        if ( m_eStatusOfSecurityComponents == InitializationState::INITIALIZED )
         /*
          * if all security components are ready, chains on the SAXEventKeeper
          */
@@ -455,7 +455,7 @@ void XSecController::startMission(
 {
     m_xUriBinding = xUriBinding;
 
-    m_nStatusOfSecurityComponents = UNINITIALIZED;
+    m_eStatusOfSecurityComponents = InitializationState::UNINITIALIZED;
     m_xSecurityContext = xSecurityContext;
     m_pErrorMessage = nullptr;
 
@@ -534,7 +534,7 @@ void XSecController::endMission()
 
     for (int i=0; i<size; ++i)
     {
-        if ( m_nStatusOfSecurityComponents == INITIALIZED )
+        if ( m_eStatusOfSecurityComponents == InitializationState::INITIALIZED )
         /*
          * ResolvedListener only exist when the security components are created.
          */
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 3ecf391..faa6118 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -113,13 +113,6 @@
 #define ALGO_XMLDSIGSHA256 "http://www.w3.org/2001/04/xmlenc#sha256"
 #define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform"
 
-/*
- * status of security related components
- */
-#define UNINITIALIZED     0
-#define INITIALIZED       1
-#define FAILTOINITIALIZED 2
-
 class XSecParser;
 
 class InternalSignatureInformation
@@ -292,7 +285,11 @@ private:
      * a flag representing the current status of security related
      * components.
      */
-    sal_Int32 m_nStatusOfSecurityComponents;
+
+    /*
+     * status of security related components
+     */
+    enum class InitializationState { UNINITIALIZED, INITIALIZED, FAILTOINITIALIZED } m_eStatusOfSecurityComponents;
 
     /*
      * a flag representing whether the SAXEventKeeper need to be
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index 6791d40..4a5fb3d 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -313,7 +313,7 @@ bool XSecController::WriteSignature(
      */
     chainOn(true);
 
-    if ( m_nStatusOfSecurityComponents == INITIALIZED )
+    if ( m_eStatusOfSecurityComponents == InitializationState::INITIALIZED )
     /*
      * if all security components are ready, add the signature
      * stream.
@@ -383,7 +383,7 @@ bool XSecController::WriteOOXMLSignature(const uno::Reference<embed::XStorage>&
     // Chain the SAXEventKeeper to the SAX chain.
     chainOn(/*bRetrievingLastEvent=*/true);
 
-    if (m_nStatusOfSecurityComponents == INITIALIZED)
+    if (m_eStatusOfSecurityComponents == InitializationState::INITIALIZED)
     {
         m_bIsSAXEventKeeperSticky = true;
         m_xSAXEventKeeper->setNextHandler(xDocumentHandler);
diff --git a/xmlsecurity/source/helper/xsecverify.cxx b/xmlsecurity/source/helper/xsecverify.cxx
index bded4f8..46946fe 100644
--- a/xmlsecurity/source/helper/xsecverify.cxx
+++ b/xmlsecurity/source/helper/xsecverify.cxx
@@ -46,7 +46,7 @@ namespace cssxs = com::sun::star::xml::sax;
 cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepareSignatureToRead(
     sal_Int32 nSecurityId)
 {
-    if ( m_nStatusOfSecurityComponents != INITIALIZED )
+    if ( m_eStatusOfSecurityComponents != InitializationState::INITIALIZED )
     {
         return nullptr;
     }
@@ -329,7 +329,7 @@ void XSecController::collectToVerify( const OUString& referenceId )
 {
     /* SAL_WARN_IF( !m_xSAXEventKeeper.is(), "xmlsecurity", "the SAXEventKeeper is NULL" ); */
 
-    if ( m_nStatusOfSecurityComponents == INITIALIZED )
+    if ( m_eStatusOfSecurityComponents == InitializationState::INITIALIZED )
     /*
      * if all security components are ready, verify the signature.
      */
commit ec52bc6a570b93d1913d0514d451a5c72070ddc2
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 24 12:01:37 2016 +0300

    Bin pointless macro
    
    Change-Id: I460d5e7c431d2613999db86a73d4e14663ff038d

diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
index 9b71c3c..38ca141 100644
--- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
@@ -164,7 +164,7 @@ void OOXMLSecExporter::Impl::writeSignedInfoReferences()
                     pAttributeList->AddAttribute("Type", "http://www.w3.org/2000/09/xmldsig#Object");
                 else
                     pAttributeList->AddAttribute("Type", "http://uri.etsi.org/01903#SignedProperties");
-                pAttributeList->AddAttribute(ATTR_URI, CHAR_FRAGMENT + rReference.ouURI);
+                pAttributeList->AddAttribute(ATTR_URI, "#" + rReference.ouURI);
                 m_xDocumentHandler->startElement(TAG_REFERENCE, uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
             }
             if (rReference.ouURI == "idSignedProperties")
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index aa2528a..23df46f 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -672,7 +672,7 @@ void XSecController::exportSignature(
                 {
                     pAttributeList->AddAttribute(
                         ATTR_URI,
-                        CHAR_FRAGMENT+refInfor.ouURI);
+                        "#" + refInfor.ouURI);
                 }
 
                 xDocumentHandler->startElement( tag_Reference, cssu::Reference< cssxs::XAttributeList > (pAttributeList) );
@@ -790,7 +790,7 @@ void XSecController::exportSignature(
                     signatureInfo.ouPropertyId);
                 pAttributeList->AddAttribute(
                     ATTR_TARGET,
-                    CHAR_FRAGMENT+signatureInfo.ouSignatureId);
+                    "#" + signatureInfo.ouSignatureId);
                 xDocumentHandler->startElement(
                     tag_SignatureProperty,
                     cssu::Reference< cssxs::XAttributeList > (pAttributeList));
@@ -831,7 +831,7 @@ void XSecController::exportSignature(
                 // SignatureProperty element.
                 pAttributeList = new SvXMLAttributeList();
                 pAttributeList->AddAttribute(ATTR_ID, signatureInfo.ouDescriptionPropertyId);
-                pAttributeList->AddAttribute(ATTR_TARGET, CHAR_FRAGMENT + signatureInfo.ouSignatureId);
+                pAttributeList->AddAttribute(ATTR_TARGET, "#" + signatureInfo.ouSignatureId);
                 xDocumentHandler->startElement(tag_SignatureProperty, uno::Reference<xml::sax::XAttributeList>(pAttributeList));
 
                 {
diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index d559041..3ecf391 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -113,9 +113,6 @@
 #define ALGO_XMLDSIGSHA256 "http://www.w3.org/2001/04/xmlenc#sha256"
 #define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform"
 
-#define CHAR_FRAGMENT           "#"
-
-
 /*
  * status of security related components
  */
diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index b9466c4..cd99376 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -109,7 +109,7 @@ void SAL_CALL XSecParser::startElement(
             OUString ouUri = xAttribs->getValueByName(ATTR_URI);
             SAL_WARN_IF( ouUri == nullptr, "xmlsecurity.helper", "URI == NULL" );
 
-            if (ouUri.startsWith(CHAR_FRAGMENT))
+            if (ouUri.startsWith("#"))
             {
                 /*
                 * remove the first character '#' from the attribute value
commit cb5444eadc2cdb3122b28dca70faa442c29ead90
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 24 11:58:58 2016 +0300

    Bin pointless macro
    
    Change-Id: Ia5829219eda13832857848267afae25167a31ab8

diff --git a/xmlsecurity/source/helper/xsecctl.hxx b/xmlsecurity/source/helper/xsecctl.hxx
index 3595278..d559041 100644
--- a/xmlsecurity/source/helper/xsecctl.hxx
+++ b/xmlsecurity/source/helper/xsecctl.hxx
@@ -114,7 +114,6 @@
 #define ALGO_RELATIONSHIP "http://schemas.openxmlformats.org/package/2006/RelationshipTransform"
 
 #define CHAR_FRAGMENT           "#"
-#define CHAR_BLANK          " "
 
 
 /*
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index c91c467..6791d40 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -196,10 +196,10 @@ cssu::Reference< cssxc::sax::XReferenceResolvedListener > XSecController::prepar
     for(i=0; i<size; ++i)
     {
         SignatureReferenceInformation& refInfor = vReferenceInfors[i];
-        refInfor.ouDigestValue = CHAR_BLANK;
+        refInfor.ouDigestValue = " ";
     }
 
-    internalSignatureInfor.signatureInfor.ouSignatureValue = CHAR_BLANK;
+    internalSignatureInfor.signatureInfor.ouSignatureValue = " ";
 
     return xReferenceResolvedListener;
 }
commit 5938596a3ea24f46e403f693d52aaab0770dfafa
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Oct 24 11:56:01 2016 +0300

    Indentation fixes
    
    Change-Id: Ie0116a7c9c51268204647499b26f4247e55e0523

diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx
index ac3eddf..b9466c4 100644
--- a/xmlsecurity/source/helper/xsecparser.cxx
+++ b/xmlsecurity/source/helper/xsecparser.cxx
@@ -210,9 +210,9 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
     try
     {
         if (aName == TAG_DIGESTVALUE)
-            {
-                m_bInDigestValue = false;
-            }
+        {
+            m_bInDigestValue = false;
+        }
         else if ( aName == TAG_REFERENCE )
         {
             if ( m_bReferenceUnresolved )
@@ -233,7 +233,7 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
         else if ( aName == TAG_SIGNATUREVALUE )
         {
             m_pXSecController->setSignatureValue( m_ouSignatureValue );
-                m_bInSignatureValue = false;
+            m_bInSignatureValue = false;
         }
         else if (aName == TAG_X509ISSUERNAME)
         {
@@ -253,7 +253,7 @@ void SAL_CALL XSecParser::endElement( const OUString& aName )
         else if (aName == NSTAG_DC ":" TAG_DATE)
         {
             m_pXSecController->setDate( m_ouDate );
-                m_bInDate = false;
+            m_bInDate = false;
         }
         else if (aName == NSTAG_DC ":" TAG_DESCRIPTION)
         {


More information about the Libreoffice-commits mailing list