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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 18 07:17:48 UTC 2021


 xmlsecurity/source/framework/signaturecreatorimpl.cxx  |    2 
 xmlsecurity/source/framework/signatureverifierimpl.cxx |    2 
 xmlsecurity/source/helper/documentsignaturehelper.cxx  |    6 -
 xmlsecurity/source/helper/ooxmlsecexporter.cxx         |   66 ++++++++---------
 xmlsecurity/source/helper/xsecctl.cxx                  |    4 -
 xmlsecurity/source/helper/xsecsign.cxx                 |    6 -
 xmlsecurity/source/xmlsec/nss/ciphercontext.cxx        |    2 
 7 files changed, 43 insertions(+), 45 deletions(-)

New commits:
commit 9cc2b07ff5e610258aad2ec2b72e6b1ea15fd5e2
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Wed Feb 17 18:23:54 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Feb 18 08:17:13 2021 +0100

    loplugin:referencecasting in xmlsecurity
    
    Change-Id: I038c4f85250b4d8d8fef605fd90f6fa53bbffe9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111079
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmlsecurity/source/framework/signaturecreatorimpl.cxx b/xmlsecurity/source/framework/signaturecreatorimpl.cxx
index a3d8cd45814e..bba7b9eb3933 100644
--- a/xmlsecurity/source/framework/signaturecreatorimpl.cxx
+++ b/xmlsecurity/source/framework/signaturecreatorimpl.cxx
@@ -73,7 +73,7 @@ void SignatureCreatorImpl::startEngine(const rtl::Reference<XMLSignatureTemplate
     css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > xResultTemplate;
     try
     {
-        xResultTemplate = m_xXMLSignature->generate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate.get()), m_xSecurityEnvironment);
+        xResultTemplate = m_xXMLSignature->generate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate), m_xSecurityEnvironment);
         m_nStatus = xResultTemplate->getStatus();
     }
     catch( css::uno::Exception& )
diff --git a/xmlsecurity/source/framework/signatureverifierimpl.cxx b/xmlsecurity/source/framework/signatureverifierimpl.cxx
index 4daf8d203c6a..c00086adee9b 100644
--- a/xmlsecurity/source/framework/signatureverifierimpl.cxx
+++ b/xmlsecurity/source/framework/signatureverifierimpl.cxx
@@ -64,7 +64,7 @@ void SignatureVerifierImpl::startEngine( const rtl::Reference<XMLSignatureTempla
     css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > xResultTemplate;
     try
     {
-        xResultTemplate = m_xXMLSignature->validate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate.get()), m_xXMLSecurityContext);
+        xResultTemplate = m_xXMLSignature->validate(css::uno::Reference<css::xml::crypto::XXMLSignatureTemplate>(xSignatureTemplate), m_xXMLSecurityContext);
         m_nStatus = xResultTemplate->getStatus();
     }
     catch( css::uno::Exception& )
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index 5ff74dcd325c..2784298acf8c 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -494,7 +494,7 @@ void DocumentSignatureHelper::writeDigestMethod(
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("Algorithm", ALGO_XMLDSIGSHA256);
-    xDocumentHandler->startElement("DigestMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    xDocumentHandler->startElement("DigestMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     xDocumentHandler->endElement("DigestMethod");
 }
 
@@ -506,7 +506,7 @@ void DocumentSignatureHelper::writeSignedProperties(
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idSignedProperties");
-        xDocumentHandler->startElement("xd:SignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        xDocumentHandler->startElement("xd:SignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
 
     xDocumentHandler->startElement("xd:SignedSignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -548,7 +548,7 @@ void DocumentSignatureHelper::writeSignedProperties(
             "xmlns:loext", "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0");
         xDocumentHandler->startElement(
             "loext:SignatureLine",
-            Reference<XAttributeList>(pAttributeList.get()));
+            Reference<XAttributeList>(pAttributeList));
 
         {
             // Write SignatureLineId element
diff --git a/xmlsecurity/source/helper/ooxmlsecexporter.cxx b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
index f09c388686aa..43a89811619b 100644
--- a/xmlsecurity/source/helper/ooxmlsecexporter.cxx
+++ b/xmlsecurity/source/helper/ooxmlsecexporter.cxx
@@ -123,8 +123,8 @@ void OOXMLSecExporter::Impl::writeCanonicalizationMethod()
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
-    m_xDocumentHandler->startElement(
-        "CanonicalizationMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("CanonicalizationMethod",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     m_xDocumentHandler->endElement("CanonicalizationMethod");
 }
 
@@ -132,8 +132,8 @@ void OOXMLSecExporter::Impl::writeCanonicalizationTransform()
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("Algorithm", ALGO_C14N);
-    m_xDocumentHandler->startElement(
-        "Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("Transform",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     m_xDocumentHandler->endElement("Transform");
 }
 
@@ -146,8 +146,8 @@ void OOXMLSecExporter::Impl::writeSignatureMethod()
     else
         pAttributeList->AddAttribute("Algorithm", ALGO_RSASHA256);
 
-    m_xDocumentHandler->startElement(
-        "SignatureMethod", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("SignatureMethod",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     m_xDocumentHandler->endElement("SignatureMethod");
 }
 
@@ -168,7 +168,7 @@ void OOXMLSecExporter::Impl::writeSignedInfoReferences()
                                                  "http://uri.etsi.org/01903#SignedProperties");
                 pAttributeList->AddAttribute("URI", "#" + rReference.ouURI);
                 m_xDocumentHandler->startElement(
-                    "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+                    "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
             }
             if (rReference.ouURI == "idSignedProperties")
             {
@@ -215,8 +215,8 @@ void OOXMLSecExporter::Impl::writePackageObject()
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("Id", "idPackageObject");
-    m_xDocumentHandler->startElement(
-        "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("Object",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
 
     writeManifest();
     writePackageObjectSignatureProperties();
@@ -253,8 +253,8 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Algorithm", ALGO_RELATIONSHIP);
-        m_xDocumentHandler->startElement(
-            "Transform", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("Transform",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
 
     const uno::Sequence<uno::Sequence<beans::StringPair>> aRelationsInfo
@@ -278,9 +278,8 @@ void OOXMLSecExporter::Impl::writeRelationshipTransform(const OUString& rURI)
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
         pAttributeList->AddAttribute("SourceId", aId);
-        m_xDocumentHandler->startElement(
-            "mdssi:RelationshipReference",
-            uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("mdssi:RelationshipReference",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
         m_xDocumentHandler->endElement("mdssi:RelationshipReference");
     }
 
@@ -295,14 +294,14 @@ void OOXMLSecExporter::Impl::writePackageObjectSignatureProperties()
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idSignatureTime");
         pAttributeList->AddAttribute("Target", "#idPackageSignature");
-        m_xDocumentHandler->startElement(
-            "SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("SignatureProperty",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("xmlns:mdssi", NS_MDSSI);
-        m_xDocumentHandler->startElement(
-            "mdssi:SignatureTime", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("mdssi:SignatureTime",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
     m_xDocumentHandler->startElement(
         "mdssi:Format", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -336,8 +335,8 @@ void OOXMLSecExporter::Impl::writeManifestReference(const SignatureReferenceInfo
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("URI", rReference.ouURI);
-    m_xDocumentHandler->startElement(
-        "Reference", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("Reference",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
 
     // Transforms
     if (rReference.ouURI.endsWith(
@@ -374,8 +373,8 @@ void OOXMLSecExporter::Impl::writeOfficeObject()
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idOfficeObject");
-        m_xDocumentHandler->startElement(
-            "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("Object",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
     m_xDocumentHandler->startElement(
         "SignatureProperties", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -383,8 +382,8 @@ void OOXMLSecExporter::Impl::writeOfficeObject()
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idOfficeV1Details");
         pAttributeList->AddAttribute("Target", "#idPackageSignature");
-        m_xDocumentHandler->startElement(
-            "SignatureProperty", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("SignatureProperty",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
     writeSignatureInfo();
     m_xDocumentHandler->endElement("SignatureProperty");
@@ -396,8 +395,8 @@ void OOXMLSecExporter::Impl::writeSignatureInfo()
 {
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("xmlns", "http://schemas.microsoft.com/office/2006/digsig");
-    m_xDocumentHandler->startElement(
-        "SignatureInfoV1", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("SignatureInfoV1",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
 
     m_xDocumentHandler->startElement(
         "SetupID", uno::Reference<xml::sax::XAttributeList>(new SvXMLAttributeList()));
@@ -471,9 +470,8 @@ void OOXMLSecExporter::Impl::writePackageSignature()
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("xmlns:xd", NS_XD);
         pAttributeList->AddAttribute("Target", "#idPackageSignature");
-        m_xDocumentHandler->startElement(
-            "xd:QualifyingProperties",
-            uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("xd:QualifyingProperties",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
 
     DocumentSignatureHelper::writeSignedProperties(m_xDocumentHandler, m_rInformation,
@@ -489,8 +487,8 @@ void OOXMLSecExporter::Impl::writeSignatureLineImages()
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idValidSigLnImg");
-        m_xDocumentHandler->startElement(
-            "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        m_xDocumentHandler->startElement("Object",
+                                         uno::Reference<xml::sax::XAttributeList>(pAttributeList));
         OUString aGraphicInBase64;
         Graphic aGraphic(m_rInformation.aValidSignatureImage);
         if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
@@ -503,8 +501,8 @@ void OOXMLSecExporter::Impl::writeSignatureLineImages()
 
     rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
     pAttributeList->AddAttribute("Id", "idInvalidSigLnImg");
-    m_xDocumentHandler->startElement(
-        "Object", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+    m_xDocumentHandler->startElement("Object",
+                                     uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     OUString aGraphicInBase64;
     Graphic aGraphic(m_rInformation.aInvalidSignatureImage);
     if (!XOutBitmap::GraphicToBase64(aGraphic, aGraphicInBase64, false, ConvertDataFormat::EMF))
@@ -531,7 +529,7 @@ void OOXMLSecExporter::writeSignature()
     pAttributeList->AddAttribute("xmlns", NS_XMLDSIG);
     pAttributeList->AddAttribute("Id", "idPackageSignature");
     m_pImpl->getDocumentHandler()->startElement(
-        "Signature", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        "Signature", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
 
     m_pImpl->writeSignedInfo();
     m_pImpl->writeSignatureValue();
diff --git a/xmlsecurity/source/helper/xsecctl.cxx b/xmlsecurity/source/helper/xsecctl.cxx
index af9776b9dcc1..1607539bb9d5 100644
--- a/xmlsecurity/source/helper/xsecctl.cxx
+++ b/xmlsecurity/source/helper/xsecctl.cxx
@@ -203,7 +203,7 @@ void XSecController::createXSecComponent( )
         return;
 
     css::uno::Sequence <css::uno::Any> arg(1);
-    arg[0] <<= uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper.get());
+    arg[0] <<= uno::Reference<xml::wrapper::XXMLDocumentWrapper>(m_xXMLDocumentWrapper);
     m_xSAXEventKeeper->initialize(arg);
 
     css::uno::Reference< css::xml::crypto::sax::XSAXEventKeeperStatusChangeListener >
@@ -533,7 +533,7 @@ void writeUnsignedProperties(
     {
         rtl::Reference<SvXMLAttributeList> pAttributeList(new SvXMLAttributeList());
         pAttributeList->AddAttribute("Id", "idUnsignedProperties");
-        xDocumentHandler->startElement("xd:UnsignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList.get()));
+        xDocumentHandler->startElement("xd:UnsignedProperties", uno::Reference<xml::sax::XAttributeList>(pAttributeList));
     }
 
     {
diff --git a/xmlsecurity/source/helper/xsecsign.cxx b/xmlsecurity/source/helper/xsecsign.cxx
index b9648ed64397..f93e2c454414 100644
--- a/xmlsecurity/source/helper/xsecsign.cxx
+++ b/xmlsecurity/source/helper/xsecsign.cxx
@@ -85,7 +85,7 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon
 
     xSignatureCreator->addSignatureCreationResultListener(this);
 
-    m_xSAXEventKeeper->addReferenceResolvedListener(nIdOfSignatureElementCollector, xSignatureCreator.get());
+    m_xSAXEventKeeper->addReferenceResolvedListener(nIdOfSignatureElementCollector, xSignatureCreator);
 
     int size = vReferenceInfors.size();
     sal_Int32 nReferenceCount = 0;
@@ -97,7 +97,7 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon
         if ( keeperId != -1)
         {
             m_xSAXEventKeeper->setSecurityId(keeperId, nSecurityId);
-            m_xSAXEventKeeper->addReferenceResolvedListener( keeperId, xSignatureCreator.get());
+            m_xSAXEventKeeper->addReferenceResolvedListener( keeperId, xSignatureCreator);
             xSignatureCreator->setReferenceId( keeperId );
             nReferenceCount++;
         }
@@ -168,7 +168,7 @@ css::uno::Reference< css::xml::crypto::sax::XReferenceResolvedListener > XSecCon
 
     internalSignatureInfor.signatureInfor.ouSignatureValue = " ";
 
-    return xSignatureCreator.get();
+    return xSignatureCreator;
 }
 
 void XSecController::signAStream( sal_Int32 securityId, const OUString& uri, bool isBinary, bool bXAdESCompliantIfODF)
diff --git a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
index 104414f815de..c36de660df4e 100644
--- a/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
+++ b/xmlsecurity/source/xmlsec/nss/ciphercontext.cxx
@@ -52,7 +52,7 @@ uno::Reference< xml::crypto::XCipherContext > OCipherContext::Create( CK_MECHANI
                     xResult->m_bPadding = bW3CPadding || ( PK11_GetPadMechanism( nNSSCipherID ) == nNSSCipherID );
                     xResult->m_nBlockSize = PK11_GetBlockSize( nNSSCipherID, xResult->m_pSecParam );
                     if ( xResult->m_nBlockSize <= SAL_MAX_INT8 )
-                        return xResult.get();
+                        return xResult;
                 }
             }
         }


More information about the Libreoffice-commits mailing list