Пример #1
0
        public override AccessRight RightsFor(ElementRequest request, IEnumerable <IFieldAccessRule> securityRules, IEnumerable <IFieldAccessRule> logicRules)
        {
            var report = new FieldAccessReport(request.Accessor.Name);

            _debugReport.AddDetails(report);
            var securityRulesList = securityRules.ToArray();
            var logicRulesList    = logicRules.ToArray();

            securityRulesList.Each(rule => report.AddVote("Authorization", rule.ToString(), rule.RightsFor(request).Name));
            if (securityRulesList.Length > 1)
            {
                report.AddVote("Authorization", "Decision (most permissive wins)", getSecurityRights(request, securityRulesList).Name);
            }

            logicRulesList.Each(rule => report.AddVote("Logic", rule.ToString(), rule.RightsFor(request).Name));
            if (logicRulesList.Length > 1)
            {
                report.AddVote("Logic", "Decision (most restrictive wins)", getLogicRights(request, logicRulesList).Name);
            }

            var decision = base.RightsFor(request, securityRulesList, logicRulesList);

            report.AddVote("Effective", "(more restrictive of Logic and Authorization)", decision.Name);
            return(decision);
        }
        public override AccessRight RightsFor(ElementRequest request, IEnumerable<IFieldAccessRule> securityRules, IEnumerable<IFieldAccessRule> logicRules)
        {
            var report = new FieldAccessReport(request.Accessor.Name);
            _debugReport.AddDetails(report);
            var securityRulesList = securityRules.ToArray();
            var logicRulesList = logicRules.ToArray();
            securityRulesList.Each(rule => report.AddVote("Authorization", rule.ToString(), rule.RightsFor(request).Name));
            if (securityRulesList.Length > 1)
            {
                report.AddVote("Authorization","Decision (most permissive wins)", getSecurityRights(request, securityRulesList).Name);
            }

            logicRulesList.Each(rule => report.AddVote("Logic", rule.ToString(), rule.RightsFor(request).Name));
            if (logicRulesList.Length > 1)
            {
                report.AddVote("Logic", "Decision (most restrictive wins)", getLogicRights(request, logicRulesList).Name);
            }

            var decision = base.RightsFor(request, securityRulesList, logicRulesList);
            report.AddVote("Effective", "(more restrictive of Logic and Authorization)", decision.Name);
            return decision;
        }