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()); + 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(); 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()); } 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 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 aDigest(reinterpret_cast(aSigningContext.m_aDigest.data()),