Ejemplo n.º 1
0
        /// <summary>
        /// Method called by the EvaluationEngine when the evaluation is executed without a policy document, this
        /// method search in the policy repository and return the first policy that matches its target with the
        /// context document specified.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <returns>The policy document ready to be used by the evaluation engine.</returns>
        public pol.PolicyDocument Match(rtm.EvaluationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            pol.PolicyDocument polEv = null;

            //Search if there is a policySet which target matches the context document
            foreach (pol.PolicyDocument policy in _policySets.Values)
            {
                rtm.PolicySet tempPolicy = new rtm.PolicySet(context.Engine, (pol.PolicySetElement)policy.PolicySet);

                rtm.EvaluationContext tempContext = new rtm.EvaluationContext(context.Engine, policy, context.ContextDocument);

                // Match the policy set target with the context document
                if (tempPolicy.Match(tempContext) == rtm.TargetEvaluationValue.Match)
                {
                    if (polEv == null)
                    {
                        polEv = policy;
                    }
                    else
                    {
                        throw new EvaluationException(Resource.ResourceManager[Resource.MessageKey.exc_duplicated_policy_in_repository]);
                    }
                }
            }

            //Search if there is a policy which target matches the context document
            foreach (pol.PolicyDocument policy in _policies.Values)
            {
                rtm.Policy tempPolicy = new rtm.Policy((pol.PolicyElement)policy.Policy);

                rtm.EvaluationContext tempContext = new rtm.EvaluationContext(context.Engine, policy, context.ContextDocument);

                // Match the policy target with the context document
                if (tempPolicy.Match(tempContext) == rtm.TargetEvaluationValue.Match)
                {
                    if (polEv == null)
                    {
                        polEv = policy;
                    }
                    else
                    {
                        throw new EvaluationException(Resource.ResourceManager[Resource.MessageKey.exc_duplicated_policy_in_repository]);
                    }
                }
            }
            return(polEv);
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Method called by the EvaluationEngine when the evaluation is executed without a policy document, this 
		/// method search in the policy repository and return the first policy that matches its target with the
		/// context document specified.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <returns>The policy document ready to be used by the evaluation engine.</returns>
		public pol.PolicyDocument Match( rtm.EvaluationContext context )
		{
            if (context == null) throw new ArgumentNullException("context");
			pol.PolicyDocument polEv = null;
 
			//Search if there is a policySet which target matches the context document
			foreach( pol.PolicyDocument policy in _policySets.Values )
			{
				rtm.PolicySet tempPolicy = new rtm.PolicySet( context.Engine, (pol.PolicySetElement)policy.PolicySet );

				rtm.EvaluationContext tempContext = new rtm.EvaluationContext( context.Engine, policy, context.ContextDocument );

				// Match the policy set target with the context document
				if( tempPolicy.Match( tempContext ) == rtm.TargetEvaluationValue.Match )
				{
					if( polEv == null )
					{
						polEv = policy;
					}
					else
					{
						throw new EvaluationException( Resource.ResourceManager[ Resource.MessageKey.exc_duplicated_policy_in_repository ] );
					}
				}
			}

			//Search if there is a policy which target matches the context document
			foreach( pol.PolicyDocument policy in _policies.Values )
			{
				rtm.Policy tempPolicy = new rtm.Policy( (pol.PolicyElement)policy.Policy );

				rtm.EvaluationContext tempContext = new rtm.EvaluationContext( context.Engine, policy, context.ContextDocument );

				// Match the policy target with the context document
				if( tempPolicy.Match( tempContext ) == rtm.TargetEvaluationValue.Match )
				{
					if( polEv == null )
					{
						polEv = policy;
					}
					else
					{
						throw new EvaluationException( Resource.ResourceManager[ Resource.MessageKey.exc_duplicated_policy_in_repository ] );
					}
				}
			}
			return polEv;
		}