Ejemplo n.º 1
0
		/// <summary>
		/// Gets the data type of the value.
		/// </summary>
		/// <param name="context">The evaluation context.</param>
		/// <returns>The data type descriptor.</returns>
		public inf.IDataType GetType( rtm.EvaluationContext context )
		{ 
			return rtm.EvaluationEngine.GetDataType( DataTypeValue );
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Creates a new Result using the provided information.
		/// </summary>
		/// <param name="resourceId">The resource id for this result.</param>
		/// <param name="decision">The decission of the evaluation.</param>
		/// <param name="status">The status with information about the execution.</param>
		/// <param name="obligations">The list of obligations</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public ResultElement( string resourceId, rtm.Decision decision, StatusElement status, pol.ObligationCollection obligations, XacmlVersion schemaVersion )
			: base( XacmlSchema.Context, schemaVersion )
		{
			_resourceId = resourceId;
			_decision = decision;

			// If the status is null, create an empty status
			if( status == null )
			{
				_status = new StatusElement( null, null, null, schemaVersion );
			}
			else
			{
				_status = status;
			}

			// If the obligations are null, leave the empty ObligationCollection.
			if( obligations != null )
			{
				_obligations = obligations;
			}
		}
Ejemplo n.º 3
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;
		}