diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2016-11-18 13:18:56 +0200 |
---|---|---|
committer | Alexander Kutsan <AKutsan@luxoft.com> | 2016-12-05 09:33:20 +0200 |
commit | 4f1195fd93c9c121efb78542fc84b7e974c3f08d (patch) | |
tree | 2b29479182e4c5b30b378eeaad90742737e5e2d1 /src/components/include/policy | |
parent | b131de6358fa6f74c66d7b00142cdd6fa34a9671 (diff) | |
download | sdl_core-4f1195fd93c9c121efb78542fc84b7e974c3f08d.tar.gz |
Move old policies to new folder structure
Diffstat (limited to 'src/components/include/policy')
3 files changed, 439 insertions, 0 deletions
diff --git a/src/components/include/policy/policy_regular/policy/policy_settings.h b/src/components/include/policy/policy_regular/policy/policy_settings.h new file mode 100644 index 0000000000..7e5b7d6f93 --- /dev/null +++ b/src/components/include/policy/policy_regular/policy/policy_settings.h @@ -0,0 +1,42 @@ +#ifndef POLICY_HANDLER_SETTINGS_H +#define POLICY_HANDLER_SETTINGS_H +#include <string> +#include <stdint.h> + +namespace policy { +class PolicySettings { + public: + /** + * @brief Should Policy be turned off? (Library not loaded) + * @return Flag + */ + virtual bool enable_policy() const = 0; + /* + * @brief Path to preloaded policy file + */ + virtual const std::string& preloaded_pt_file() const = 0; + + /** + * @brief Returns application storage path + */ + virtual const std::string& app_storage_folder() const = 0; + + virtual uint16_t attempts_to_open_policy_db() const = 0; + + virtual uint16_t open_attempt_timeout_ms() const = 0; + + /** + * @brief Path to policies snapshot file + * @return file path + */ + virtual const std::string& policies_snapshot_file_name() const = 0; + + /** + * @brief Returns system files folder path + */ + virtual const std::string& system_files_path() const = 0; + + virtual ~PolicySettings() {} +}; +} // namespace policy +#endif // POLICY_HANDLER_SETTINGS_H diff --git a/src/components/include/policy/policy_regular/policy/policy_types.h b/src/components/include/policy/policy_regular/policy/policy_types.h new file mode 100644 index 0000000000..f725f1c619 --- /dev/null +++ b/src/components/include/policy/policy_regular/policy/policy_types.h @@ -0,0 +1,318 @@ +/* + Copyright (c) 2013, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_ +#define SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_ + +#include <string> +#include <vector> +#include <map> +#include <set> +#include "utils/shared_ptr.h" +#include "utils/helpers.h" + +namespace policy { + +// TODO(PV): specify errors +enum PolicyErrorEnum {}; + +const std::string kDefaultDeviceMacAddress = "00:00:00:00:00:00"; +const std::string kDefaultDeviceName = "MyDevice"; +const std::string kDefaultDeviceConnectionType = "UNKNOWN"; + +/** + * @brief Constants for special ids in application policies section of + * policy table + */ +const std::string kPreDataConsentId = "pre_DataConsent"; +const std::string kDefaultId = "default"; +const std::string kDeviceId = "device"; + +/* + * @brief Status of policy table update + */ +enum PolicyTableStatus { + StatusUpToDate = 0, + StatusUpdatePending, + StatusUpdateRequired, + StatusUnknown +}; + +// Code generator uses String class name, so this typedef was renamed to PTSring +typedef std::string PTString; +typedef std::vector<uint8_t> BinaryMessage; +typedef utils::SharedPtr<BinaryMessage> BinaryMessageSptr; + +typedef std::string HMILevel; +typedef std::string Parameter; +typedef std::string RpcName; +typedef std::set<std::string> RPCParams; + +typedef std::map<std::string, std::set<policy::HMILevel> > HMIPermissions; +typedef std::map<std::string, std::set<policy::Parameter> > + ParameterPermissions; + +struct RpcPermissions { + HMIPermissions hmi_permissions; + ParameterPermissions parameter_permissions; +}; + +typedef std::map<RpcName, RpcPermissions> Permissions; + +/** + * @brief Typedef for use with AllowApp request/notification + */ +typedef std::vector<std::string> PermissionsList; + +/** + * @brief Typedef for getting initial application data, e.g. nickname list + */ +typedef std::vector<std::string> StringArray; + +enum PermitResult { kRpcAllowed = 0, kRpcDisallowed, kRpcUserDisallowed }; + +/** + * @struct Stores result of check: + * if HMI Level was allowed for RPC to work in + * and list of parameters allowed for RPC if specified in PT. + */ +struct CheckPermissionResult { + CheckPermissionResult() : hmi_level_permitted(kRpcDisallowed) {} + + PermitResult hmi_level_permitted; + RPCParams list_of_allowed_params; + RPCParams list_of_disallowed_params; + RPCParams list_of_undefined_params; +}; + +/** + @struct Holds Url string and optional policy app id. + */ +struct EndpointData { + explicit EndpointData(const std::string& url_string = "") + : app_id("default") { + if (false == url_string.empty()) { + url.push_back(url_string); + } + } + std::vector<std::string> url; + std::string app_id; +}; + +typedef std::vector<EndpointData> EndpointUrls; + +/** + * @brief Struct contains device data to be used for dialogs, generation of IDs + */ +struct DeviceParams { + DeviceParams() + : device_name(kDefaultDeviceName) + , device_mac_address(kDefaultDeviceMacAddress) + , device_connection_type(kDefaultDeviceConnectionType) + , device_handle(0) {} + + std::string device_name; + std::string device_mac_address; + std::string device_connection_type; + uint32_t device_handle; +}; + +/** + * @brief User consent for device data usage + */ +enum DeviceConsent { + kDeviceAllowed = 0, + kDeviceDisallowed, + kDeviceHasNoConsent +}; + +/** + * @brief Struct contains parameters, which can be received during application + * registration and should be stored in policy table + */ +struct DeviceInfo { + DeviceInfo() : max_number_rfcom_ports(0) {} + + std::string hardware; + std::string firmware_rev; + std::string os; + std::string os_ver; + std::string carrier; + uint32_t max_number_rfcom_ports; + std::string connection_type; + + void AdoptDeviceType(const std::string& deviceType) { + connection_type = "USB_serial_number"; + using namespace helpers; + static const std::string bluetooth("BLUETOOTH"); + static const std::string wifi("WIFI"); + if (Compare<std::string, EQ, ONE>(deviceType, bluetooth, wifi)) { + connection_type.assign("BTMAC"); + } + } +}; + +/** + * @brief User consent for functional group + */ +enum GroupConsent { kGroupAllowed = 0, kGroupDisallowed, kGroupUndefined }; + +/** + * @brief Contains user permission for RPC functional group with specific name + * and id from DB + */ +struct FunctionalGroupPermission { + FunctionalGroupPermission() : group_id(0), state(kGroupUndefined) {} + + bool operator==(const FunctionalGroupPermission& rhs) { + if (this->group_id == rhs.group_id && + this->group_alias == rhs.group_alias && + this->group_name == rhs.group_name) { + return true; + } + return false; + } + + std::string group_alias; + std::string group_name; + int32_t group_id; + GroupConsent state; +}; + +/** + * @brief Stores data to be sent to HMI on application permissions change + */ +struct AppPermissions { + AppPermissions(const std::string& app_id) + : application_id(app_id) + , isAppPermissionsRevoked(false) + , appRevoked(false) + , appPermissionsConsentNeeded(false) + , appUnauthorized(false) + , requestTypeChanged(false) {} + + std::string application_id; + bool isAppPermissionsRevoked; + std::vector<policy::FunctionalGroupPermission> appRevokedPermissions; + bool appRevoked; + bool appPermissionsConsentNeeded; + bool appUnauthorized; + bool isSDLAllowed; + std::string priority; + DeviceParams deviceInfo; + bool requestTypeChanged; + std::vector<std::string> requestType; +}; + +/** + * @brief Contains parameters for user-defined consent for appication + * functional groups on given device + */ +struct PermissionConsent { + std::string device_id; + std::string policy_app_id; + std::vector<FunctionalGroupPermission> group_permissions; + std::string consent_source; +}; + +/** + * @brief Contain data for GetUserFriendyMessage response + */ +struct UserFriendlyMessage { + std::string message_code; +}; + +/** + * @brief Types of functional groups in policy table + */ +enum GroupType { + kTypeDefault = 0, // groups assigned to 'default' permissions section + kTypeAllowed, // groups allowed by user for specific application + kTypeDisallowed, // groups disallowed by user for specific application + kTypeUnconsented, // groups disallowed by default but consent may be changed + // by user + kTypePreconsented, // groups allowed for specific application without + // user consent by default (could be changed by user) + kTypeGeneral, // groups assigned to specific application + kTypePreDataConsented, // groups assigned to 'pre_DataConsent' permissions + // section + kTypeDevice // groups assigned to 'device' permissions section +}; + +/** + * @brief Array of functional group id from DB + */ +typedef std::vector<int32_t> FunctionalGroupIDs; + +/** + * @brief Array of functional group ids sorted by types + */ +typedef std::map<GroupType, FunctionalGroupIDs> FunctionalIdType; + +/** + * @brief Array of functional group ids binded to user_consent_prompt (e.g. + * VehicleData) and group name (e.g. VehicleData-4) + */ +typedef std::map<uint32_t, std::pair<std::string, std::string> > + FunctionalGroupNames; + +/** + * @brief Array of device ids, which are an identifiers in policy table + */ +typedef std::vector<std::string> DeviceIds; + +/** + * @brief Counters that calculated on receiving of succesful update + */ +enum Counters { KILOMETERS, DAYS_AFTER_EPOCH }; + +/** + * @struct Vehicle information + */ +struct VehicleInfo { + std::string vehicle_make; + std::string vehicle_model; + std::string vehicle_year; +}; + +/** + * @brief The MetaInfo information + */ +struct MetaInfo { + std::string ccpu_version; + std::string wers_country_code; + std::string language; +}; + +} // namespace policy + +#endif // SRC_COMPONENTS_POLICY_INCLUDE_POLICY_POLICY_TYPES_H_ diff --git a/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h new file mode 100644 index 0000000000..2b2c875d11 --- /dev/null +++ b/src/components/include/policy/policy_regular/policy/usage_statistics/statistics_manager.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2016, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_ +#define SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_ + +#include <stdint.h> +#include <string> + +namespace usage_statistics { + +enum GlobalCounterId { IAP_BUFFER_FULL, SYNC_OUT_OF_MEMORY, SYNC_REBOOTS }; + +enum AppInfoId { LANGUAGE_GUI, LANGUAGE_VUI }; + +enum AppStopwatchId { + SECONDS_HMI_FULL, + SECONDS_HMI_LIMITED, + SECONDS_HMI_BACKGROUND, + SECONDS_HMI_NONE +}; + +enum AppCounterId { + USER_SELECTIONS, + REJECTIONS_SYNC_OUT_OF_MEMORY, + REJECTIONS_NICKNAME_MISMATCH, + REJECTIONS_DUPLICATE_NAME, + REJECTED_RPC_CALLS, + RPCS_IN_HMI_NONE, + REMOVALS_MISBEHAVED, + RUN_ATTEMPTS_WHILE_REVOKED, + COUNT_OF_TLS_ERRORS, +}; + +class StatisticsManager { + public: + virtual ~StatisticsManager() {} + virtual void Increment(GlobalCounterId type) = 0; + virtual void Increment(const std::string& app_id, AppCounterId type) = 0; + virtual void Set(const std::string& app_id, + AppInfoId type, + const std::string& value) = 0; + virtual void Add(const std::string& app_id, + AppStopwatchId type, + int32_t timespan_seconds) = 0; +}; + +} // namespace usage_statistics + +#endif // SRC_COMPONENTS_INCLUDE_POLICY_USAGE_STATISTICS_STATISTICS_MANAGER_H_ |