コード例 #1
0
        /// <summary>
        /// Creates a new instance of the Rule using the rule defined in the policy document.
        /// </summary>
        /// <param name="rule">The rule defined in the policy document.</param>
        public Rule(pol.RuleElement rule)
        {
            if (rule == null)
            {
                throw new ArgumentNullException("rule");
            }
            _rule = rule;
            if (_rule.SchemaVersion == XacmlVersion.Version10 || _rule.SchemaVersion == XacmlVersion.Version11)
            {
                _condition = new Condition((pol.ConditionElement)_rule.Condition);
            }
            else if (_rule.SchemaVersion == XacmlVersion.Version20)
            {
                _condition = new Condition2((pol.ConditionElement)_rule.Condition);
            }

            if (rule.Target != null)
            {
                _target = new Target((pol.TargetElement)rule.Target);

                // Load all the resources for the elements within this rule.
                foreach (pol.ResourceElement resource in rule.Target.Resources.ItemsList)
                {
                    foreach (pol.ResourceMatchElement rmatch in resource.Match)
                    {
                        if (!_allResources.Contains(rmatch.AttributeValue.Contents))
                        {
                            _allResources.Add(rmatch.AttributeValue.Contents);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Rule.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Creates a new instance of the Rule using the rule defined in the policy document.
		/// </summary>
		/// <param name="rule">The rule defined in the policy document.</param>
		public Rule( pol.RuleElement rule )
		{
            if (rule == null) throw new ArgumentNullException("rule");
			_rule = rule;
			if( _rule.SchemaVersion == XacmlVersion.Version10 || _rule.SchemaVersion == XacmlVersion.Version11 )
			{
				_condition = new Condition( (pol.ConditionElement)_rule.Condition );
			}
			else if( _rule.SchemaVersion == XacmlVersion.Version20 )
			{
				_condition = new Condition2( (pol.ConditionElement)_rule.Condition );
			}
		
			if( rule.Target != null )
			{
				_target = new Target( (pol.TargetElement)rule.Target );

				// Load all the resources for the elements within this rule.
				foreach( pol.ResourceElement resource in rule.Target.Resources.ItemsList )
				{
					foreach( pol.ResourceMatchElement rmatch in resource.Match )
					{
						if( !_allResources.Contains( rmatch.AttributeValue.Contents ) )
						{
							_allResources.Add( rmatch.AttributeValue.Contents );
						}
					}
				}
			}
		}