Exemple #1
0
        /// <summary>
        /// The evaluation implementation in the pseudo-code described in the specification.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <param name="policies">The policies that must be evaluated.</param>
        /// <returns>The final decission for the combination of the policy evaluation.</returns>
        public Decision Evaluate(EvaluationContext context, IMatchEvaluableCollection policies)
        {
            foreach (IMatchEvaluable policy in policies)
            {
                Decision decision = policy.Evaluate(context);

                context.TraceContextValues();

                if (decision == Decision.Deny)
                {
                    context.ProcessingError    = false;
                    context.IsMissingAttribute = false;
                    return(Decision.Deny);
                }
                if (decision == Decision.Permit)
                {
                    context.ProcessingError    = false;
                    context.IsMissingAttribute = false;
                    return(Decision.Permit);
                }
                if (decision == Decision.NotApplicable)
                {
                    continue;
                }
                if (decision == Decision.Indeterminate)
                {
                    return(Decision.Indeterminate);
                }
            }
            return(Decision.NotApplicable);
        }
		/// <summary>
		/// The evaluation implementation in the pseudo-code described in the specification.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="policies">The policies that must be evaluated.</param>
		/// <returns>The final decission for the combination of the policy evaluation.</returns>
		public Decision Evaluate( EvaluationContext context, IMatchEvaluableCollection policies )
		{
			foreach( IMatchEvaluable policy in policies )
			{
				Decision decision = policy.Evaluate( context );

				context.TraceContextValues();

				if( decision == Decision.Deny )
				{
					context.ProcessingError = false;
					context.IsMissingAttribute = false;
					return Decision.Deny;
				}
				if( decision == Decision.Permit )
				{
					context.ProcessingError = false;
					context.IsMissingAttribute = false;
					return Decision.Permit;
				}
				if( decision == Decision.NotApplicable )
				{
					continue;
				}
				if( decision == Decision.Indeterminate )
				{
					return Decision.Indeterminate;
				}
			}
			return Decision.NotApplicable;
		}
        /// <summary>
        /// The evaluation implementation in the pseudo-code described in the specification.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <param name="policies">The policies that must be evaluated.</param>
        /// <returns>The final decission for the combination of the policy evaluation.</returns>
        public Decision Evaluate(EvaluationContext context, IMatchEvaluableCollection policies)
        {
            Boolean atLeastOne     = false;
            Policy  selectedPolicy = null;
            TargetEvaluationValue appResult;

            for (int i = 0; i < policies.Count; i++)
            {
                Policy tempPolicy = (Policy)policies[i];
                appResult = appResult = tempPolicy.Match(context);
                if (appResult == TargetEvaluationValue.Indeterminate)
                {
                    context.ProcessingError = true;
                    context.TraceContextValues();
                    return(Decision.Indeterminate);
                }
                if (appResult == TargetEvaluationValue.Match)
                {
                    if (atLeastOne)
                    {
                        context.ProcessingError = true;
                        context.TraceContextValues();
                        return(Decision.Indeterminate);
                    }
                    else
                    {
                        atLeastOne     = true;
                        selectedPolicy = (Policy)policies[i];
                    }
                }
                if (appResult == TargetEvaluationValue.NoMatch)
                {
                    continue;
                }
            }
            if (atLeastOne)
            {
                Decision retValue = selectedPolicy.Evaluate(context);

                context.TraceContextValues();

                if (retValue == Decision.Deny || retValue == Decision.Permit)
                {
                    context.ProcessingError    = false;
                    context.IsMissingAttribute = false;
                }
                return(retValue);
            }
            else
            {
                return(Decision.NotApplicable);
            }
        }
		/// <summary>
		/// The evaluation implementation in the pseudo-code described in the specification.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="policies">The policies that must be evaluated.</param>
		/// <returns>The final decission for the combination of the policy evaluation.</returns>
		public Decision Evaluate( EvaluationContext context, IMatchEvaluableCollection policies )
		{
			Boolean atLeastOne = false;
			Policy selectedPolicy = null;
			TargetEvaluationValue appResult;
			for( int i = 0; i < policies.Count; i++ )
			{
				Policy tempPolicy = (Policy)policies[ i ];
				appResult = appResult = tempPolicy.Match( context );
				if( appResult == TargetEvaluationValue.Indeterminate )
				{
					context.ProcessingError = true;
					context.TraceContextValues();
					return Decision.Indeterminate;
				}
				if( appResult == TargetEvaluationValue.Match )
				{
					if ( atLeastOne )
					{
						context.ProcessingError = true;
						context.TraceContextValues();
						return Decision.Indeterminate;
					}
					else
					{
						atLeastOne = true;
						selectedPolicy = (Policy)policies[i];
					}
				}
				if ( appResult == TargetEvaluationValue.NoMatch )
				{
					continue;
				}
			}
			if ( atLeastOne )
			{
				Decision retValue = selectedPolicy.Evaluate( context );
				
				context.TraceContextValues();

				if( retValue == Decision.Deny || retValue == Decision.Permit )
				{
					context.ProcessingError = false;
					context.IsMissingAttribute = false;
				}
				return retValue;
			}
			else
			{
				return Decision.NotApplicable;
			}
		}
        /// <summary>
        /// The evaluation implementation in the pseudo-code described in the specification.
        /// </summary>
        /// <param name="context">The evaluation context instance.</param>
        /// <param name="policies">The policies that must be evaluated.</param>
        /// <returns>The final decission for the combination of the policy evaluation.</returns>
        public Decision Evaluate(EvaluationContext context, IMatchEvaluableCollection policies)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (policies == null)
            {
                throw new ArgumentNullException("policies");
            }
            bool atLeastOnePermit = false;

            foreach (IMatchEvaluable policy in policies)
            {
                Decision decision = policy.Evaluate(context);
                if (decision == Decision.Deny)
                {
                    context.ProcessingError    = false;
                    context.IsMissingAttribute = false;
                    return(Decision.Deny);
                }
                if (decision == Decision.Permit)
                {
                    atLeastOnePermit = true;
                    continue;
                }
                if (decision == Decision.NotApplicable)
                {
                    continue;
                }
                if (decision == Decision.Indeterminate)
                {
                    context.ProcessingError    = false;
                    context.IsMissingAttribute = false;
                    return(Decision.Deny);
                }
            }
            if (atLeastOnePermit)
            {
                context.ProcessingError    = false;
                context.IsMissingAttribute = false;
                return(Decision.Permit);
            }
            return(Decision.NotApplicable);
        }
		/// <summary>
		/// The evaluation implementation in the pseudo-code described in the specification.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="policies">The policies that must be evaluated.</param>
		/// <returns>The final decission for the combination of the policy evaluation.</returns>
		public Decision Evaluate( EvaluationContext context, IMatchEvaluableCollection policies )
		{
            if (context == null) throw new ArgumentNullException("context");
            if (policies == null) throw new ArgumentNullException("policies");
			bool atLeastOnePermit = false;
			foreach( IMatchEvaluable policy in policies )
			{
				Decision decision = policy.Evaluate( context );
				if( decision == Decision.Deny )
				{
					context.ProcessingError = false;
					context.IsMissingAttribute = false;
					return Decision.Deny;
				}
				if( decision == Decision.Permit )
				{
					atLeastOnePermit = true;
					continue;
				}
				if( decision == Decision.NotApplicable )
				{
					continue;
				}
				if( decision == Decision.Indeterminate )
				{
					context.ProcessingError = false;
					context.IsMissingAttribute = false;
					return Decision.Deny;
				}
			}
			if( atLeastOnePermit )
			{
				context.ProcessingError = false;
				context.IsMissingAttribute = false;
				return Decision.Permit;
			}
			return Decision.NotApplicable;
		}