2021-05-29 07:31:33 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2021-07-05 05:18:21 -05:00
|
|
|
#pragma once
|
2021-05-29 07:31:33 -05:00
|
|
|
|
|
|
|
#include <string>
|
2021-09-17 08:49:06 -05:00
|
|
|
#include <unordered_set>
|
2021-05-29 07:31:33 -05:00
|
|
|
#include "ConfigUtil.hpp"
|
2022-02-07 23:50:09 -06:00
|
|
|
#include <Poco/Util/LayeredConfiguration.h>
|
2021-05-29 07:31:33 -05:00
|
|
|
|
2021-09-13 14:24:50 -05:00
|
|
|
namespace CommandControl
|
2021-05-29 07:31:33 -05:00
|
|
|
{
|
2022-02-10 05:22:47 -06:00
|
|
|
class LockManager
|
2021-05-29 07:31:33 -05:00
|
|
|
{
|
2022-02-10 05:22:47 -06:00
|
|
|
static std::unordered_set<std::string> LockedCommandList;
|
|
|
|
static bool _isLockedUser;
|
2022-02-07 23:50:09 -06:00
|
|
|
static bool _isHostReadOnly;
|
2022-02-10 05:22:47 -06:00
|
|
|
static std::string LockedCommandListString;
|
2021-05-29 07:31:33 -05:00
|
|
|
|
2022-02-10 05:22:47 -06:00
|
|
|
static void generateLockedCommandList();
|
2021-05-29 07:31:33 -05:00
|
|
|
|
|
|
|
public:
|
2022-02-10 05:22:47 -06:00
|
|
|
LockManager();
|
|
|
|
static const std::unordered_set<std::string>& getLockedCommandList();
|
|
|
|
static const std::string getLockedCommandListString();
|
|
|
|
|
2022-02-07 23:50:09 -06:00
|
|
|
// Allow/deny Locked hosts
|
|
|
|
static Util::RegexListMatcher readOnlyWopiHosts;
|
|
|
|
static Util::RegexListMatcher disabledCommandWopiHosts;
|
|
|
|
static bool lockHostEnabled;
|
|
|
|
|
|
|
|
static void parseLockedHost(Poco::Util::LayeredConfiguration& conf);
|
|
|
|
|
2022-02-10 05:22:47 -06:00
|
|
|
static bool isLockedUser() { return _isLockedUser; }
|
2022-02-07 23:50:09 -06:00
|
|
|
static bool isLockReadOnly()
|
|
|
|
{
|
|
|
|
return config::getBool("feature_lock.is_lock_readonly", false) || isHostReadOnly();
|
|
|
|
}
|
|
|
|
static bool isHostReadOnly() { return _isHostReadOnly; };
|
2022-02-10 05:22:47 -06:00
|
|
|
static bool isLockedReadOnlyUser() { return isLockedUser() && isLockReadOnly(); }
|
|
|
|
|
2022-02-07 23:50:09 -06:00
|
|
|
static bool isHostReadOnly(const std::string& host);
|
|
|
|
static bool isHostCommandDisabled(const std::string& host);
|
|
|
|
static bool hostExist(const std::string& host);
|
|
|
|
|
2022-02-10 05:22:47 -06:00
|
|
|
static void setLockedUser(bool isLocked) { _isLockedUser = isLocked; }
|
2022-02-07 23:50:09 -06:00
|
|
|
static void setHostReadOnly(bool isReadOnly) { _isHostReadOnly = isReadOnly; }
|
2022-02-10 05:22:47 -06:00
|
|
|
|
|
|
|
static std::string getUnlockTitle()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.unlock_title", "");
|
|
|
|
}
|
|
|
|
static std::string getUnlockLink() { return config::getString("feature_lock.unlock_link", ""); }
|
|
|
|
static std::string getUnlockDescription()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.unlock_description", "");
|
|
|
|
}
|
|
|
|
static std::string getWriterHighlights()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.writer_unlock_highlights", "");
|
|
|
|
}
|
|
|
|
static std::string getCalcHighlights()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.calc_unlock_highlights", "");
|
|
|
|
}
|
|
|
|
static std::string getImpressHighlights()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.impress_unlock_highlights", "");
|
|
|
|
}
|
|
|
|
static std::string getDrawHighlights()
|
|
|
|
{
|
|
|
|
return config::getString("feature_lock.draw_unlock_highlights", "");
|
|
|
|
}
|
2021-05-29 07:31:33 -05:00
|
|
|
};
|
2021-09-13 15:02:43 -05:00
|
|
|
|
|
|
|
class RestrictionManager
|
|
|
|
{
|
2021-09-17 08:49:06 -05:00
|
|
|
static std::unordered_set<std::string> RestrictedCommandList;
|
2021-09-13 15:02:43 -05:00
|
|
|
static bool _isRestrictedUser;
|
|
|
|
static std::string RestrictedCommandListString;
|
|
|
|
|
|
|
|
static void generateRestrictedCommandList();
|
|
|
|
|
|
|
|
public:
|
|
|
|
RestrictionManager();
|
2021-09-17 08:49:06 -05:00
|
|
|
static const std::unordered_set<std::string>& getRestrictedCommandList();
|
2021-09-13 15:02:43 -05:00
|
|
|
static const std::string getRestrictedCommandListString();
|
|
|
|
|
|
|
|
static bool isRestrictedUser() { return _isRestrictedUser; }
|
|
|
|
|
|
|
|
static void setRestrictedUser(bool isRestrictedUser) { _isRestrictedUser = isRestrictedUser; }
|
|
|
|
};
|
2021-09-13 14:24:50 -05:00
|
|
|
} // namespace CommandControl
|
2021-05-29 07:31:33 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|