sfx2/qa/cppunit/view.cxx | 13 +++++++++++-- sfx2/source/view/lokhelper.cxx | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-)
New commits: commit b88c6b77103139ca966eeba1a8a0a7bd77a3a9c2 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Nov 21 08:58:06 2024 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Dec 6 09:56:38 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/+/177857 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 0a535147f9bed7856e7ab3513fe3f6c38549a099) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177897 diff --git a/sfx2/qa/cppunit/view.cxx b/sfx2/qa/cppunit/view.cxx index d2c81d6e9a6e..8c5be5920a07 100644 --- a/sfx2/qa/cppunit/view.cxx +++ b/sfx2/qa/cppunit/view.cxx @@ -132,8 +132,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); @@ -157,7 +163,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 19891df77ce4..5eec80fba576 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()),