private IDictionary <string, string> GetFieldCollectionRules() { var policies = _privacyPolicyRepository.GetPolicies(_collectionName, false); var targetPolicies = new List <PrivacyPolicy>(); foreach (var policy in policies) { bool isTarget = _expressionService.Evaluate(policy.Target, _user, null, _environment); if (isTarget) { targetPolicies.Add(policy); } } var fieldCollectionRules = new Dictionary <string, string>(); foreach (var policy in targetPolicies) { foreach (var collectionField in policy.Rules) { bool isApplied = _expressionService.Evaluate(collectionField.Condition, _user, null, _environment); if (isApplied) { InsertPrivacyRule(fieldCollectionRules, collectionField.FieldEffects); } } } return(fieldCollectionRules); }
private EffectResult CollectionAccessControlProcess() { EffectResult result = EffectResult.NotApplicable; ICollection <AccessControlPolicy> collectionPolicies = _accessControlPolicyRepository.GetPolicies(_collectionName, _action, false); if (collectionPolicies.Count == 0) { return(EffectResult.NotApplicable); } string policyCombining = _accessControlPolicyRepository.GetPolicyCombining(collectionPolicies); var targetPolicies = new List <AccessControlPolicy>(); foreach (var policy in collectionPolicies) { bool isTarget = _expressionService.Evaluate(policy.Target, _user, null, _environment); if (isTarget) { targetPolicies.Add(policy); } } foreach (var policy in targetPolicies) { string policyEffect = String.Empty; foreach (var rule in policy.Rules) { bool isApplied = _expressionService.Evaluate(rule.Condition, _user, null, _environment); if (isApplied && rule.Effect.Equals("Permit") && policy.RuleCombining.Equals("permit-overrides")) { policyEffect = "Permit"; break; } if (isApplied && rule.Effect.Equals("Deny") && policy.RuleCombining.Equals("deny-overrides")) { policyEffect = "Deny"; break; } } if (policyEffect.Equals("Permit") && policyCombining.Equals("permit-overrides")) { result = EffectResult.Permit; break; } else if (policyEffect.Equals("Deny") && policyCombining.Equals("deny-overrides")) { result = EffectResult.Deny; break; } } return(result); }