summaryrefslogtreecommitdiff
path: root/src/components/policy/policy_regular/include/policy
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/policy/policy_regular/include/policy')
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_helper.h46
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h26
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_types.h25
3 files changed, 82 insertions, 15 deletions
diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h
index 887493f415..dfd12e7874 100644
--- a/src/components/policy/policy_regular/include/policy/policy_helper.h
+++ b/src/components/policy/policy_regular/include/policy/policy_helper.h
@@ -83,22 +83,11 @@ bool operator!=(const policy_table::ApplicationParams& first,
struct CheckAppPolicy {
CheckAppPolicy(PolicyManagerImpl* pm,
const std::shared_ptr<policy_table::Table> update,
- const std::shared_ptr<policy_table::Table> snapshot);
+ const std::shared_ptr<policy_table::Table> snapshot,
+ CheckAppPolicyResults& out_results);
bool operator()(const AppPoliciesValueType& app_policy);
private:
- enum PermissionsCheckResult {
- RESULT_NO_CHANGES,
- RESULT_APP_REVOKED,
- RESULT_NICKNAME_MISMATCH,
- RESULT_PERMISSIONS_REVOKED,
- RESULT_CONSENT_NEEDED,
- RESULT_CONSENT_NOT_REQIURED,
- RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
- RESULT_REQUEST_TYPE_CHANGED,
- RESULT_REQUEST_SUBTYPE_CHANGED
- };
-
void SetPendingPermissions(const AppPoliciesValueType& app_policy,
PermissionsCheckResult result) const;
PermissionsCheckResult CheckPermissionsChanges(
@@ -119,6 +108,16 @@ struct CheckAppPolicy {
const policy_table::Strings& groups) const;
bool IsAppRevoked(const AppPoliciesValueType& app_policy) const;
bool NicknamesMatch(const AppPoliciesValueType& app_policy) const;
+
+ /**
+ * @brief Check of current policy against incoming updated policy is
+ * performed.
+ * This function adds result code of this check to container.
+ * @param app_id Application id
+ * @param result Result value
+ */
+ void AddResult(const std::string& app_id, PermissionsCheckResult result);
+
/**
* @brief Allows to check if appropriate group requires any consent.
* @param group_name the group for which consent will be checked.
@@ -129,10 +128,31 @@ struct CheckAppPolicy {
bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const;
bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const;
+ bool IsEncryptionRequiredFlagChanged(
+ const AppPoliciesValueType& app_policy) const;
+
private:
PolicyManagerImpl* pm_;
const std::shared_ptr<policy_table::Table> update_;
const std::shared_ptr<policy_table::Table> snapshot_;
+ CheckAppPolicyResults& out_results_;
+};
+
+/**
+ * @brief Helper struct for filling actions to be done for processed application
+ * using CheckAppPolicyResults data as a source
+ */
+struct FillActionsForAppPolicies {
+ FillActionsForAppPolicies(
+ ApplicationsPoliciesActions& actions,
+ const policy_table::ApplicationPolicies& app_policies)
+ : actions_(actions), app_policies_(app_policies) {}
+
+ void operator()(const policy::CheckAppPolicyResults::value_type& value);
+
+ private:
+ ApplicationsPoliciesActions& actions_;
+ const policy_table::ApplicationPolicies& app_policies_;
};
/*
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index 86eb91b67f..9294e0e273 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -132,6 +132,21 @@ class PolicyManagerImpl : public PolicyManager {
bool LoadPT(const std::string& file,
const BinaryMessage& pt_content) OVERRIDE;
+ typedef policy_table::ApplicationPolicies::value_type AppPoliciesValueType;
+
+ /**
+ * @brief Notifies system by sending OnAppPermissionChanged notification
+ * @param app_policy Reference to application policy
+ */
+ void NotifySystem(const AppPoliciesValueType& app_policy) const;
+
+ /**
+ * @brief Sends OnPermissionChange notification to application if its
+ * currently registered
+ * @param app_policy Reference to application policy
+ */
+ void SendPermissionsToApp(const AppPoliciesValueType& app_policy);
+
/**
* @brief Resets Policy Table
* @param file_name Path to preloaded PT file
@@ -876,10 +891,19 @@ class PolicyManagerImpl : public PolicyManager {
* @param snapshot Shared pointer to current copy of policy table
* @return Collection per-application results
*/
- void CheckPermissionsChanges(
+ CheckAppPolicyResults CheckPermissionsChanges(
const std::shared_ptr<policy_table::Table> update,
const std::shared_ptr<policy_table::Table> snapshot);
+ void ProcessAppPolicyCheckResults(
+ const CheckAppPolicyResults& results,
+ const rpc::policy_table_interface_base::ApplicationPolicies&
+ app_policies);
+
+ void ProcessActionsForAppPolicies(
+ const ApplicationsPoliciesActions& actions,
+ const policy_table::ApplicationPolicies& app_policies);
+
/**
* @brief Compares current policies to the updated one.
* Trigger actions in case if certain fields after update were changed.
diff --git a/src/components/policy/policy_regular/include/policy/policy_types.h b/src/components/policy/policy_regular/include/policy/policy_types.h
index e08d6d503e..d2858f3c59 100644
--- a/src/components/policy/policy_regular/include/policy/policy_types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_types.h
@@ -431,6 +431,28 @@ struct ExternalConsentStatusItemSorter {
};
/**
+ * @brief The ApplicationPolicyActions struct contains actions which should be
+ * done for some application
+ */
+struct ApplicationPolicyActions {
+ ApplicationPolicyActions()
+ : is_notify_system(false)
+ , is_send_permissions_to_app(false)
+ , is_consent_needed(false) {}
+
+ bool is_notify_system;
+ bool is_send_permissions_to_app;
+ bool is_consent_needed;
+};
+
+/**
+ * @brief ApplicationsPoliciesActions map of actions to be done for every
+ * application
+ */
+typedef std::map<std::string, ApplicationPolicyActions>
+ ApplicationsPoliciesActions;
+
+/**
* @brief Customer connectivity settings status
*/
typedef std::set<ExternalConsentStatusItem, ExternalConsentStatusItemSorter>
@@ -479,7 +501,8 @@ enum PermissionsCheckResult {
RESULT_CONSENT_NOT_REQIURED,
RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED,
RESULT_REQUEST_TYPE_CHANGED,
- RESULT_REQUEST_SUBTYPE_CHANGED
+ RESULT_REQUEST_SUBTYPE_CHANGED,
+ RESULT_ENCRYPTION_REQUIRED_FLAG_CHANGED
};
/**