diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-10-29 23:34:14 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-11-09 09:06:02 +0100 |
commit | 852ed5d9819feb54a7f70a879dd89e9d071bfebf (patch) | |
tree | 288ebb0bf7f179b78ae4639c06865205692ee2da | |
parent | 0ff045609e4103e780e9dc68361a8c3982a70d91 (diff) |
handle signature status and prepare document signing in WSD
This adds handling of signature status (manually request for the
status or as a callback) in WSD.
In addition prepare support for signing of document, but don't yet
trigger the actual LOKit function (needs the JS building blocks
set up first to know how to handle the payload - certificate and
private key)
Change-Id: Ic76baa5847bb52adde616338187d5979e0093c6d
Reviewed-on: https://gerrit.libreoffice.org/62533
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | kit/ChildSession.cpp | 26 | ||||
-rw-r--r-- | kit/ChildSession.hpp | 2 | ||||
-rw-r--r-- | tools/KitClient.cpp | 1 | ||||
-rw-r--r-- | wsd/ClientSession.cpp | 4 | ||||
-rw-r--r-- | wsd/protocol.txt | 19 |
5 files changed, 51 insertions, 1 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 3e6a904ce..4e6c3ef7a 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -331,6 +331,14 @@ bool ChildSession::_handleInput(const char *buffer, int length) { sendWindowCommand(buffer, length, tokens); } + else if (tokens[0] == "signdocument") + { + signDocumentContent(buffer, length, tokens); + } + else if (tokens[0] == "asksignaturestatus") + { + askSignatureStatus(buffer, length, tokens); + } else { assert(false && "Unknown command token."); @@ -1104,6 +1112,21 @@ bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, con return true; } +bool ChildSession::signDocumentContent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& /*tokens*/) +{ + return true; +} + +bool ChildSession::askSignatureStatus(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& /*tokens*/) +{ + std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex()); + + int nStatus = getLOKitDocument()->getSignatureState(); + + sendTextFrame("signaturestatus: " + nStatus); + return true; +} + bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) { int type, x, y; @@ -1586,6 +1609,9 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) sendTextFrame("clipboardchanged: " + selection); break; } + case LOK_CALLBACK_SIGNATURE_STATUS: + sendTextFrame("signaturestatus: " + payload); + break; default: LOG_ERR("Unknown callback event (" << type << "): " << payload); } diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index b67a18980..292614ff1 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -230,6 +230,8 @@ private: bool setClientPart(const char* buffer, int length, const std::vector<std::string>& tokens); bool setPage(const char* buffer, int length, const std::vector<std::string>& tokens); bool sendWindowCommand(const char* buffer, int length, const std::vector<std::string>& tokens); + bool signDocumentContent(const char* buffer, int length, const std::vector<std::string>& tokens); + bool askSignatureStatus(const char* buffer, int length, const std::vector<std::string>& tokens); void rememberEventsForInactiveUser(const int type, const std::string& payload); diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index bc756b1d7..cdceb8a7b 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -82,6 +82,7 @@ extern "C" CASE(WINDOW); CASE(VALIDITY_LIST_BUTTON); CASE(CLIPBOARD_CHANGED); + CASE(SIGNATURE_STATUS); #undef CASE } std::cout << " payload: " << payload << std::endl; diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 9101c7237..896163360 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -171,7 +171,9 @@ bool ClientSession::_handleInput(const char *buffer, int length) tokens[0] != "useractive" && tokens[0] != "userinactive" && tokens[0] != "paintwindow" && - tokens[0] != "windowcommand") + tokens[0] != "windowcommand" && + tokens[0] != "signdocument" && + tokens[0] != "asksignaturestatus") { sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown"); return false; diff --git a/wsd/protocol.txt b/wsd/protocol.txt index 8bd29e638..bafebd452 100644 --- a/wsd/protocol.txt +++ b/wsd/protocol.txt @@ -223,6 +223,15 @@ versionrestore <action> - prerestore: The storage is about restore the document to an earlier revision. +asksignaturestatus + + Requests a signing status of the document. + +signdocument + + Sign the current document with the input cetificate and private key. + + server -> client ================ @@ -474,6 +483,16 @@ versionrestore: <action> - prerestore_ack: The host can go ahead with restoring the document to an earlier revision. +signaturestatus: <sign status> + Possible values: + 0xffff - Unknown + 0 - NOSIGNATURES + 1 - OK + 2 - BROKEN + 3 - INVALID (signature is OK, but doc is modified now) + 4 - NOTVALIDATED (signature is OK, but certificate could not be validated) + 5 - PARTIAL_OK (signature and certificate are ok, but not all files are signed - old documents only) + child -> parent =============== |