[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/LOOLWSD.cpp loolwsd/Storage.cpp loolwsd/Storage.hpp
Pranav Kant
pranavk at collabora.co.uk
Mon Aug 29 14:12:39 UTC 2016
loolwsd/DocumentBroker.cpp | 8 ++++++--
loolwsd/DocumentBroker.hpp | 2 +-
loolwsd/LOOLWSD.cpp | 4 ++--
loolwsd/Storage.cpp | 10 +++++++---
loolwsd/Storage.hpp | 2 ++
5 files changed, 18 insertions(+), 8 deletions(-)
New commits:
commit f8ebb54af0948dbd4b9cb7bdceb44d90b190f4f9
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Aug 29 19:11:37 2016 +0530
loolwsd: Receive WOPI userid, username
Change-Id: I0bd5e5a155b8f8486fbeffb1c1413d5e9c177fc3
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index e3f1954..d119f9c 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -122,16 +122,20 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
Log::info("DocumentBroker [" + _uriPublic.toString() + "] created. DocKey: [" + _docKey + "]");
}
-void DocumentBroker::validate(const Poco::URI& uri)
+const StorageBase::FileInfo DocumentBroker::validate(const Poco::URI& uri)
{
Log::info("Validating: " + uri.toString());
try
{
auto storage = StorageBase::create("", "", uri);
- if (storage == nullptr || !storage->getFileInfo(uri).isValid())
+ auto fileinfo = storage->getFileInfo(uri);
+ Log::info("After checkfileinfo: " + fileinfo._filename);
+ if (storage == nullptr || !fileinfo.isValid())
{
throw BadRequestException("Invalid URI or access denied.");
}
+
+ return fileinfo;
}
catch (const std::exception&)
{
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 1324005..e404e82 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -148,7 +148,7 @@ public:
<< " sessions left." << Log::end;
}
- void validate(const Poco::URI& uri);
+ const StorageBase::FileInfo validate(const Poco::URI& uri);
/// Loads a document from the public URI into the jail.
bool load(const std::string& jailId);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 9a38e9a..21e867b 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -641,8 +641,8 @@ private:
}
// Validate the URI and Storage before moving on.
- docBroker->validate(uriPublic);
- Log::debug("Validated [" + uriPublic.toString() + "].");
+ const auto fileinfo = docBroker->validate(uriPublic);
+ Log::debug("Validated [" + uriPublic.toString() + "] requested with userid [" + fileinfo._userId + "] and username [" + fileinfo._userName + "]");
if (newDoc)
{
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index f44482e..7deba6a 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -175,7 +175,7 @@ StorageBase::FileInfo LocalStorage::getFileInfo(const Poco::URI& uri)
const auto file = Poco::File(path);
const auto lastModified = file.getLastModified();
const auto size = file.getSize();
- return FileInfo({filename, lastModified, size});
+ return FileInfo({filename, lastModified, size, "localhost", "Local Host"});
}
std::string LocalStorage::loadStorageFileToLocal()
@@ -276,6 +276,8 @@ StorageBase::FileInfo WopiStorage::getFileInfo(const Poco::URI& uri)
// Parse the response.
std::string filename;
size_t size = 0;
+ std::string userId;
+ std::string userName;
std::string resMsg;
Poco::StreamCopier::copyToString(rs, resMsg);
Log::debug("WOPI::CheckFileInfo returned: " + resMsg);
@@ -288,10 +290,12 @@ StorageBase::FileInfo WopiStorage::getFileInfo(const Poco::URI& uri)
const auto& object = result.extract<Poco::JSON::Object::Ptr>();
filename = object->get("BaseFileName").toString();
size = std::stoul (object->get("Size").toString(), nullptr, 0);
+ userId = object->get("UserId").toString();
+ userName = object->get("UserFriendlyName").toString();
}
// WOPI doesn't support file last modified time.
- return FileInfo({filename, Poco::Timestamp(), size});
+ return FileInfo({filename, Poco::Timestamp(), size, userId, userName});
}
/// uri format: http://server/<...>/wopi*/files/<id>/content
@@ -387,7 +391,7 @@ StorageBase::FileInfo WebDAVStorage::getFileInfo(const Poco::URI& uri)
Log::debug("Getting info for webdav uri [" + uri.toString() + "].");
(void)uri;
assert(false && "Not Implemented!");
- return FileInfo({"bazinga", Poco::Timestamp(), 0});
+ return FileInfo({"bazinga", Poco::Timestamp(), 0, "admin", "admin"});
}
std::string WebDAVStorage::loadStorageFileToLocal()
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index d4db4e4..4f7e120 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -39,6 +39,8 @@ public:
std::string _filename;
Poco::Timestamp _modifiedTime;
size_t _size;
+ std::string _userId;
+ std::string _userName;
};
/// localStorePath the absolute root path of the chroot.
More information about the Libreoffice-commits
mailing list