Skip to content

Commit

Permalink
cool#10630 doc electronic sign: support per-server private info durin…
Browse files Browse the repository at this point in the history
…g 'make run'

Now that esign settings are no longer under UserPrivateInfo,
cypress-deskop's draw/esign_spec.js can't set the esign settings for the
test.

The problem is that ServerPrivateInfo's sub-keys should be set, but the
JSON file based mechanism for 'make run' can only set UserPrivateInfo
sub-keys.

Fix this by loading all keys from a <document>.wopi.json file (if
exists) and then keep setting the rest of the keys from code, as before.

This allows setting UserPrivateInfo, ServerPrivateInfo and other
toplevel keys from .wopi.json files next to documents.

Signed-off-by: Miklos Vajna <vmiklos@collabora.com>
Change-Id: Iacbe7aa438d5b30170c96e23df069ec99e496945
  • Loading branch information
vmiklos authored and caolanm committed Dec 16, 2024
1 parent e1e6a08 commit 8d043c3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 24 deletions.

This file was deleted.

7 changes: 7 additions & 0 deletions cypress_test/data/desktop/draw/esign.pdf.wopi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ServerPrivateInfo": {
"ESignatureBaseUrl": "https://test.eideasy.com",
"ESignatureSecret": "56RkLgZREDi1H0HZAvzOSAVlxu1Flx41",
"ESignatureClientId": "2IaeiZXbcKzlP1KvjZH9ghty2IJKM8Lg"
}
}

This file was deleted.

7 changes: 7 additions & 0 deletions cypress_test/data/desktop/writer/sign.odt.wopi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"UserPrivateInfo": {
"SignatureCert": "-----BEGIN CERTIFICATE-----\nMIIFGDCCAwCgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwaTELMAkGA1UEBhMCVUsx\nEDAOBgNVBAgMB0VuZ2xhbmQxHTAbBgNVBAoMFFhtbHNlY3VyaXR5IFJTQSBUZXN0\nMSkwJwYDVQQDDCBYbWxzZWN1cml0eSBJbnRlcm1lZGlhdGUgUm9vdCBDQTAgFw0y\nNDA5MTcxMzMxNDBaGA8yMTI0MDgyNDEzMzE0MFowazELMAkGA1UEBhMC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aeZsLYsZQ/DeJF\nGk65vYhXZWsYG8PjxedVFDuzJZZ3eC4hvZwnx3mDf09RrGPhJHxBeZXVr/fsGXzK\nrNBNGMf22X438aoDL7+77azvGwIDAQABo2MwYTAdBgNVHQ4EFgQUOepOT/LFc1dj\nY+ZAw5TMPNmLXIQwHwYDVR0jBBgwFoAUOepOT/LFc1djY+ZAw5TMPNmLXIQwDwYD\nVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIB\nAK70Z5Gi4/93tbOygDc/ZuK/j+kPNYS9A2cxvoa6zBqnJC1ZotWsIv92S2osJV1a\nvzdMsQwlDkPXwXPEQRSAH8CUd5dtZjSP7/dsPBzeu3ryVVsh9hR7wAfW4emQ+Igw\n0zm4C0pQr3Cy4skJ8/jX2kTbHORUvQ6/60gilIs2T6K8VRlKXBy5le4VObWz2+U0\nH7ztp08JRYfJ7xqqknF8Bv37/YIV/sSoQHIIHCgYzDZRXsvmGqDNjQTNodd6anjW\n3bTyh+VHIcaHQPxDtt5tsv+3CIPyEFhvP62hbuNUfZgrNCPvW3FCHPfhoPldwAaq\nNZsXutbmpy0GI25tbJHp9bWKSc+w6upf1RSPlfFLTjNdsVhbvwb5tMgXr9rq0yHd\nj2Jfa+nvGc85CFRXYCvEJ14ooxJEiahl1//JtCqLXpbtmGOW5whzBY9Jg+XUEpWj\nI6Pgf7+bJgeB2YDs7b9ELSG8Gc76Jain+OvmBtFFmeVKvOeZiAznd37Q9HGHnUI4\n16T6AUbyW6rOgUNqjD+bxGKkeBtYnieJpk7aMHh+DR4rkG7qfgcdzlaw5nEXZMbN\nJ5v1HNyN10JZRTWHAZUHkNJMf5/EruWTIOTQY8R2/ElGNVyVGo/4krXMdaOprUF6\nv3SgfBSAsfz08wjEc48NAmrQc+QIKB40sXquOAIm8FCt\n-----END CERTIFICATE-----\n"
}
}
2 changes: 1 addition & 1 deletion cypress_test/integration_tests/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function setupDocument(filePath, copyCertificates = false) {

copyFile(filePath, newFilePath);
if (copyCertificates) {
const suffix = '.user-private-info.json';
const suffix = '.wopi.json';
copyFile(filePath + suffix, newFilePath + suffix);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cypress_test/integration_tests/desktop/draw/esign_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var helper = require('../../common/helper');

describe(['tagdesktop'], 'Electronic sign operations.', function() {

it.skip('Create an electronic signature.', { env: { 'pdf-view': true } }, function() {
it('Create an electronic signature.', { env: { 'pdf-view': true } }, function() {
// Given a document that can be signed:
helper.setupAndLoadDocument('draw/esign.pdf', /*isMultiUser=*/false, /*copyCertificates=*/true);

Expand Down
23 changes: 11 additions & 12 deletions wsd/FileServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,17 @@ bool FileServerRequestHandler::isAdminLoggedIn(const HTTPRequest& request, http:
std::string userNameString = "LocalUser#" + userId;
Poco::JSON::Object::Ptr fileInfo = new Poco::JSON::Object();

Poco::JSON::Object::Ptr wopi = new Poco::JSON::Object();
// If there is matching WOPI data next to the file to be loaded, use it.
std::string wopiString = readFileToString(localPath + ".wopi.json");
if (!wopiString.empty())
{
if (JsonUtil::parseJSON(wopiString, wopi))
{
fileInfo = wopi;
}
}

std::string postMessageOrigin;
ConfigUtil::isSslEnabled() ? postMessageOrigin = "https://"
: postMessageOrigin = "http://";
Expand All @@ -438,18 +449,6 @@ bool FileServerRequestHandler::isAdminLoggedIn(const HTTPRequest& request, http:
fileInfo->set("OwnerId", "test");
fileInfo->set("UserId", userId);
fileInfo->set("UserFriendlyName", userNameString);

Poco::JSON::Object::Ptr userPrivateInfo = new Poco::JSON::Object();
// If there is matching user private info data next to the file to be loaded, use it.
std::string userPrivateInfoString = readFileToString(localPath + ".user-private-info.json");
if (!userPrivateInfoString.empty())
{
if (JsonUtil::parseJSON(userPrivateInfoString, userPrivateInfo))
{
fileInfo->set("UserPrivateInfo", userPrivateInfo);
}
}

fileInfo->set("UserCanWrite", (requestDetails.getParam("permission") != "readonly") ? "true": "false");
fileInfo->set("PostMessageOrigin", postMessageOrigin);
fileInfo->set("LastModifiedTime", localFile->getLastModifiedTime());
Expand Down

0 comments on commit 8d043c3

Please sign in to comment.