diff options
author | JackLivio <jack@livio.io> | 2018-10-03 14:49:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 14:49:40 -0400 |
commit | b6e2a1812deb8e583db7f1ae145c6243ef7cbf24 (patch) | |
tree | 788d10d80ba93b58f255ded530c1770b7bec2c3d /src/components/policy/policy_external/src | |
parent | 486610a54ae35b6cebf62b5ff4cc07f0ee9d1543 (diff) | |
parent | 26a38d0af466e3d19272046485cf8a11866f5e64 (diff) | |
download | sdl_core-b6e2a1812deb8e583db7f1ae145c6243ef7cbf24.tar.gz |
Merge pull request #2648 from JackLivio/fix/allow_user_consent_for_default_groups
Allows User Consent for Default Functional Groups
Diffstat (limited to 'src/components/policy/policy_external/src')
-rw-r--r-- | src/components/policy/policy_external/src/policy_helper.cc | 41 | ||||
-rw-r--r-- | src/components/policy/policy_external/src/policy_manager_impl.cc | 15 |
2 files changed, 31 insertions, 25 deletions
diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 2358c54bef..c9df969bd1 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -299,9 +299,20 @@ void CheckAppPolicy::AddResult(const std::string& app_id, out_results_.insert(std::make_pair(app_id, result)); } +void CheckAppPolicy::InsertPermission(const std::string& app_id, + const AppPermissions& permissions_diff) { + pm_->app_permissions_diff_lock_.Acquire(); + auto result = pm_->app_permissions_diff_.insert( + std::make_pair(app_id, permissions_diff)); + if (!result.second) { + LOG4CXX_ERROR(logger_, "App ID: " << app_id << " already exists in map."); + } + pm_->app_permissions_diff_lock_.Release(); +} + bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { const std::string app_id = app_policy.first; - + AppPermissions permissions_diff(app_id); if (!IsKnownAppication(app_id)) { LOG4CXX_WARN(logger_, "Application:" << app_id << " is not present in snapshot."); @@ -309,14 +320,17 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } if (!IsPredefinedApp(app_policy) && IsAppRevoked(app_policy)) { - SetPendingPermissions(app_policy, RESULT_APP_REVOKED); + SetPendingPermissions(app_policy, RESULT_APP_REVOKED, permissions_diff); AddResult(app_id, RESULT_APP_REVOKED); + InsertPermission(app_id, permissions_diff); return true; } if (!IsPredefinedApp(app_policy) && !NicknamesMatch(app_policy)) { - SetPendingPermissions(app_policy, RESULT_NICKNAME_MISMATCH); + SetPendingPermissions( + app_policy, RESULT_NICKNAME_MISMATCH, permissions_diff); AddResult(app_id, RESULT_NICKNAME_MISMATCH); + InsertPermission(app_id, permissions_diff); return true; } @@ -328,14 +342,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { if (is_request_type_changed) { LOG4CXX_TRACE(logger_, "Request types were changed for application: " << app_id); - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + SetPendingPermissions( + app_policy, RESULT_REQUEST_TYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + result = + (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_TYPE_CHANGED : result; } if (is_request_subtype_changed) { LOG4CXX_TRACE( logger_, "Request subtypes were changed for application: " << app_id); - SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + SetPendingPermissions( + app_policy, RESULT_REQUEST_SUBTYPE_CHANGED, permissions_diff); AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); + result = (RESULT_NO_CHANGES == result) ? RESULT_REQUEST_SUBTYPE_CHANGED + : result; } } @@ -352,19 +372,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { << " have been changed."); if (!IsPredefinedApp(app_policy)) { - SetPendingPermissions(app_policy, result); + SetPendingPermissions(app_policy, result, permissions_diff); AddResult(app_id, result); } + InsertPermission(app_id, permissions_diff); return true; } void policy::CheckAppPolicy::SetPendingPermissions( const AppPoliciesValueType& app_policy, - PermissionsCheckResult result) const { + PermissionsCheckResult result, + AppPermissions& permissions_diff) const { using namespace rpc::policy_table_interface_base; const std::string app_id = app_policy.first; - AppPermissions permissions_diff(app_id); const std::string priority = policy_table::EnumToJsonString(app_policy.second.priority); @@ -421,10 +442,6 @@ void policy::CheckAppPolicy::SetPendingPermissions( if (need_send_priority) { permissions_diff.priority = priority; } - - pm_->app_permissions_diff_lock_.Acquire(); - pm_->app_permissions_diff_.insert(std::make_pair(app_id, permissions_diff)); - pm_->app_permissions_diff_lock_.Release(); } PermissionsCheckResult CheckAppPolicy::CheckPermissionsChanges( diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 95304f45a6..a603f122e2 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -1246,10 +1246,6 @@ void PolicyManagerImpl::GetUserConsentForApp( FunctionalGroupIDs preconsented_groups = group_types[kTypePreconsented]; FunctionalGroupIDs consent_allowed_groups = group_types[kTypeAllowed]; FunctionalGroupIDs consent_disallowed_groups = group_types[kTypeDisallowed]; - FunctionalGroupIDs default_groups = group_types[kTypeDefault]; - FunctionalGroupIDs predataconsented_groups = - group_types[kTypePreDataConsented]; - FunctionalGroupIDs device_groups = group_types[kTypeDevice]; // Sorting groups by consent FunctionalGroupIDs preconsented_wo_auto = @@ -1261,15 +1257,8 @@ void PolicyManagerImpl::GetUserConsentForApp( FunctionalGroupIDs allowed_groups = Merge(consent_allowed_groups, preconsented_wo_disallowed_auto); - FunctionalGroupIDs merged_stage_1 = - Merge(default_groups, predataconsented_groups); - - FunctionalGroupIDs merged_stage_2 = Merge(merged_stage_1, device_groups); - - FunctionalGroupIDs merged_stage_3 = - Merge(merged_stage_2, auto_allowed_groups); - - FunctionalGroupIDs excluded_stage_1 = ExcludeSame(all_groups, merged_stage_3); + FunctionalGroupIDs excluded_stage_1 = + ExcludeSame(all_groups, auto_allowed_groups); FunctionalGroupIDs excluded_stage_2 = ExcludeSame(excluded_stage_1, consent_disallowed_groups); |