sfx2/qa/cppunit/view.cxx | 13 +++++++++++-- sfx2/source/view/lokhelper.cxx | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-)
New commits: commit 4626c05dcae30821368e3f9d3a59ba817f2ca8de Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 21 08:58:06 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Nov 21 11:21:17 2024 +0100 cool#9992 doc electronic sign: make return type for .uno:Signature consistent It turns out the majority of getCommandValues() return values specify a commandName and a commandValues key, which is helpful when we don't track the request for this reply. Fix .uno:Signature to do the same for consistency. Change-Id: I46ffe5c36047ef2b59113d0221a1874ba28d335b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176896 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/qa/cppunit/view.cxx b/sfx2/qa/cppunit/view.cxx index 17d9d2bd3e00..9a380db1a1d0 100644 --- a/sfx2/qa/cppunit/view.cxx +++ b/sfx2/qa/cppunit/view.cxx @@ -129,8 +129,14 @@ CPPUNIT_TEST_FIXTURE(Sfx2ViewTest, testLokHelperCommandValuesSignature) std::stringstream aStream{ std::string(aJson) }; boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); + auto it = aTree.find("commandName"); + CPPUNIT_ASSERT(it != aTree.not_found()); + CPPUNIT_ASSERT_EQUAL(std::string(".uno:Signature"), it->second.get_value<std::string>()); + it = aTree.find("commandValues"); + CPPUNIT_ASSERT(it != aTree.not_found()); + aTree = it->second; // Non-zero timestamp: - auto it = aTree.find("signatureTime"); + it = aTree.find("signatureTime"); CPPUNIT_ASSERT(it != aTree.not_found()); auto nSignatureTime = it->second.get_value<sal_Int64>(); CPPUNIT_ASSERT(nSignatureTime != 0); @@ -154,7 +160,10 @@ OUString GetSignatureHash() std::stringstream aStream{ std::string(aJson) }; boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); - auto it = aTree.find("digest"); + auto it = aTree.find("commandValues"); + CPPUNIT_ASSERT(it != aTree.not_found()); + aTree = it->second; + it = aTree.find("digest"); CPPUNIT_ASSERT(it != aTree.not_found()); return OUString::fromUtf8(it->second.get_value<std::string>()); } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 5f31fcba8ebc..972a1ca623a9 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -1030,7 +1030,7 @@ std::map<OUString, OUString> SfxLokHelper::parseCommandParameters(std::u16string void SfxLokHelper::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) { - static constexpr OStringLiteral aSignature(".uno:Signature"); + static constexpr OString aSignature(".uno:Signature"_ostr); if (!o3tl::starts_with(rCommand, aSignature)) { return; @@ -1052,6 +1052,9 @@ void SfxLokHelper::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_ aSigningContext.m_nSignatureTime = it->second.toInt64(); } pObjectShell->SignDocumentContentUsingCertificate(aSigningContext); + // Set commandName, this is a reply to a request. + rJsonWriter.put("commandName", aSignature); + auto aCommandValues = rJsonWriter.startNode("commandValues"); rJsonWriter.put("signatureTime", aSigningContext.m_nSignatureTime); uno::Sequence<sal_Int8> aDigest(reinterpret_cast<sal_Int8*>(aSigningContext.m_aDigest.data()),