示例#1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="targetItems"></param>
		protected void FillTargetItems( pol.TargetItemsBaseReadWrite targetItems )
		{
			if( targetItems.IsAny )
			{
				if( targetItems is pol.ActionsElementReadWrite )
				{
					this.Nodes.Add( new AnyAction() );
				}
				else if( targetItems is pol.SubjectsElementReadWrite )
				{
					this.Nodes.Add( new AnySubject() );
				}
				else if( targetItems is pol.ResourcesElementReadWrite )
				{
					this.Nodes.Add( new AnyResource() );
				}
			}
			else
			{
				foreach( pol.TargetItemBaseReadWrite targetItem in targetItems.ItemsList )
				{
					this.Nodes.Add( new TargetItem( targetItem ) );
				}
			}
		}
示例#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 );
						}
					}
				}
			}
		}
示例#3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="apply"></param>
		public FunctionExecution( pol.ApplyBaseReadWrite apply )
		{
			_apply = apply;

			//TODO: find the function data type.
			this.Text = "[" + "dataType" + "] " + apply.FunctionId; 
			
			foreach( inf.IExpression arg in apply.Arguments )
			{
				if( arg is pol.ApplyBaseReadWrite )
				{
					this.Nodes.Add( new FunctionExecution( (pol.ApplyBaseReadWrite)arg ) );
				}
				else if( arg is pol.FunctionElementReadWrite )
				{
					this.Nodes.Add( new FunctionParameter( (pol.FunctionElementReadWrite)arg ) );
				}
				else if( arg is pol.AttributeValueElementReadWrite )
				{
					this.Nodes.Add( new AttributeValue( (pol.AttributeValueElementReadWrite)arg ) );
				}
				else if( arg is pol.AttributeDesignatorBase )
				{
					this.Nodes.Add( new AttributeDesignator( (pol.AttributeDesignatorBase)arg ) );
				}
				else if( arg is pol.AttributeSelectorElement )
				{
					this.Nodes.Add( new AttributeSelector( (pol.AttributeSelectorElement)arg ) );
				}
			}
		}
示例#4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="targetItem"></param>
		public TargetItem( pol.TargetItemBaseReadWrite targetItem )
		{
			_targetItem = targetItem;

			if( targetItem is pol.ActionElementReadWrite )
			{
				this.Text = "Action";
				this.SelectedImageIndex = 2;
				this.ImageIndex = 2;
			}
			else if( targetItem is pol.SubjectElementReadWrite )
			{
				this.Text = "Subject";
				this.SelectedImageIndex = 1;
				this.ImageIndex = 1;
			}
			else if( targetItem is pol.ResourceElementReadWrite )
			{
				this.Text = "Resource";
				this.SelectedImageIndex = 3;
				this.ImageIndex = 3;
			}

			this.Text += " (" + targetItem.Match.Count + " match/es)";
		}
示例#5
0
		/// <summary>
		/// Creates a runtime evaluable target.
		/// </summary>
		/// <param name="target"></param>
		public Target( pol.TargetElement target )
		{
			_target = target;
			_resources = new ResourceTargetItems( (pol.ResourcesElement)_target.Resources );
			_subjects = new SubjectTargetItems( (pol.SubjectsElement)_target.Subjects );
			_actions = new ActionTargetItems( (pol.ActionsElement)_target.Actions );
		}
示例#6
0
		/// <summary>
		/// Creates a new control that points to the policy set element specified.
		/// </summary>
		/// <param name="policySet"></param>
		public PolicySet( pol.PolicySetElementReadWrite policySet )
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			_policySet = policySet;

			LoadingData = true;

			cmbPolicyCombiningAlgorithm.Items.Add( PolicyCombiningAlgorithms.DenyOverrides );
			cmbPolicyCombiningAlgorithm.Items.Add( PolicyCombiningAlgorithms.PermitOverrides );
			cmbPolicyCombiningAlgorithm.Items.Add( PolicyCombiningAlgorithms.FirstApplicable );
			cmbPolicyCombiningAlgorithm.Items.Add( PolicyCombiningAlgorithms.OnlyOneApplicable );

			txtDescription.Text = _policySet.Description;
			txtPolicySetId.Text = _policySet.Id;
			txtXPathVersion.Text = _policySet.XPathVersion;
			cmbPolicyCombiningAlgorithm.SelectedText = _policySet.PolicyCombiningAlgorithm;

			txtDescription.DataBindings.Add( "Text", _policySet, "Description" );
			txtPolicySetId.DataBindings.Add( "Text", _policySet, "Id" );
			if(_policySet.XPathVersion != null)
				txtXPathVersion.DataBindings.Add( "Text", _policySet, "XPathVersion" );
			cmbPolicyCombiningAlgorithm.DataBindings.Add( "SelectedValue", policySet, "PolicyCombiningAlgorithm" );

			LoadingData = false;
			
		}
示例#7
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="target"></param>
		public Target( pol.TargetElementReadWrite target )
		{
			_target = target;

			this.Text = "Target";
			this.SelectedImageIndex = 4;
			this.ImageIndex = 4;

			FillTargetItems( _target.Subjects );
			FillTargetItems( _target.Resources );
			FillTargetItems( _target.Actions );
		}
示例#8
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="policyDocument"></param>
		public PolicyDocument( pol.PolicyDocumentReadWrite policyDocument )
		{
			_policyDocument = policyDocument;

			this.Text = "Policy Document";

			if( _policyDocument.Policy != null )
			{
				this.Nodes.Add( new Policy( _policyDocument.Policy ) );
			}
			else if( _policyDocument.PolicySet != null )
			{
				this.Nodes.Add( new PolicySet( _policyDocument.PolicySet ) );
			}
			this.Expand();
		}
示例#9
0
文件: Rule.cs 项目: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		/// <param name="rule"></param>
		public Rule( pol.RuleElementReadWrite rule )
		{
			_rule = rule;

			if( _rule.Target == null )
			{
				this.Nodes.Add( new AnyTarget() );
			}
			else
			{
				this.Nodes.Add( new Target( _rule.Target ) );
			}

			if( _rule.Condition != null )
			{
				this.Nodes.Add( new Condition( _rule.Condition ) );
			}

			this.Text = string.Format( "Rule ({0})", rule.Id );
		}
示例#10
0
文件: Rule.cs 项目: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		public Rule( pol.RuleElementReadWrite rule )
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			_rule = rule;

			LoadingData = true;

			cmbEffect.Items.Add( pol.Effect.Deny );
			cmbEffect.Items.Add( pol.Effect.Permit );

			txtDescription.Text = _rule.Description;
			txtPolicyId.Text = _rule.Id;
			cmbEffect.SelectedIndex = cmbEffect.FindStringExact( _rule.Effect.ToString() );

			txtDescription.DataBindings.Add( "Text", _rule, "Description" );
			txtPolicyId.DataBindings.Add( "Text", _rule, "Id" );
			cmbEffect.DataBindings.Add( "SelectedValue", _rule, "Effect" );

			LoadingData = false;
		}
示例#11
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="policySet"></param>
		public PolicySet( pol.PolicySetElementReadWrite policySet )
		{
			_policySet = policySet;

			this.Text = string.Format( "PolicySet ( {0} )", _policySet.Id );

			if( _policySet.Target == null )
			{
				this.Nodes.Add( new AnyTarget() );
			}
			else
			{
				this.Nodes.Add( new Target( _policySet.Target ) );
			}

			foreach( object policy in _policySet.Policies )
			{
				if( policy is pol.PolicyElementReadWrite )
				{
					this.Nodes.Add( new Policy( (pol.PolicyElementReadWrite)policy ) );
				}
				else if( policy is pol.PolicySetElementReadWrite )
				{
					this.Nodes.Add( new PolicySet( (pol.PolicySetElementReadWrite)policy ) );
				}
				else if( policy is pol.PolicyIdReferenceElementReadWrite )
				{
					this.Nodes.Add( new PolicyIdReference( (pol.PolicyIdReferenceElementReadWrite)policy ) );
				}
				else if( policy is pol.PolicySetIdReferenceElementReadWrite )
				{
					this.Nodes.Add( new PolicySetIdReference( (pol.PolicySetIdReferenceElementReadWrite)policy ) );
				}
			}
		
			this.Nodes.Add( new Obligations( _policySet.Obligations ) );
			this.Expand();
		}
示例#12
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="policy"></param>
		public Policy( pol.PolicyElementReadWrite policy )
		{
			_policy = policy;

			this.Text = string.Format( "Policy ( {0} )", policy.Id );

			if( policy.Target == null )
			{
				this.Nodes.Add( new AnyTarget() );
			}
			else
			{
				this.Nodes.Add( new Target( policy.Target ) );
			}

			foreach( pol.RuleElementReadWrite rule in policy.Rules )
			{
				this.Nodes.Add( new Rule( rule ) );
			}
			
			this.Nodes.Add( new Obligations( _policy.Obligations ) );
			this.Expand();
		}
示例#13
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="targetItem"></param>
		/// <param name="match"></param>
		/// <param name="index"></param>
		public Match( pol.TargetItemBaseReadWrite targetItem, pol.TargetMatchBaseReadWrite match, int index )
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			LoadingData = true;

			foreach( FieldInfo field in typeof(InternalDataTypes).GetFields() )
			{
				cmbASDataType.Items.Add( field.GetValue( null ) );
				cmbADDataType.Items.Add( field.GetValue( null ) );
				cmbAVDataType.Items.Add( field.GetValue( null ) );
			}
			
			foreach( FieldInfo field in typeof(InternalFunctions).GetFields() )
			{
				cmbFunctions.Items.Add( field.GetValue( null ) );
			}

			txtSubjectCategory.Visible = false;
			lblSubjectCategory.Visible = false;

			_match = match;
			_index = index;

			if( targetItem is pol.ActionElementReadWrite )
			{
				_targetItemName = "Action";
			}
			else if( targetItem is pol.SubjectElementReadWrite )
			{
				_targetItemName = "Subject";
				txtSubjectCategory.Visible = true;
				lblSubjectCategory.Visible = true;
			}
			else if( targetItem is pol.ResourceElementReadWrite )
			{
				_targetItemName = "Resource";
			}

			grpMatch.Text = _targetItemName + "Match";

			cmbFunctions.SelectedIndex = cmbFunctions.FindStringExact( _match.MatchId );
			cmbFunctions.DataBindings.Add( "SelectedItem", _match, "MatchId" );
		
			cmbAVDataType.SelectedIndex = cmbAVDataType.FindStringExact( match.AttributeValue.DataType );
			cmbAVDataType.DataBindings.Add( "SelectedItem", _match.AttributeValue, "DataType" );

			txtAttributeValue.Text = match.AttributeValue.Contents;
			txtAttributeValue.DataBindings.Add( "Text", _match.AttributeValue, "Contents" );
			
			if( match.AttributeReference is pol.AttributeDesignatorBase )
			{
				rdbAttributeDesignator.Checked = true;
				rdbAttributeSelector.Checked = false;

				cmbADDataType.SelectedIndex = cmbADDataType.FindStringExact( match.AttributeReference.DataType );
				cmbADDataType.DataBindings.Add( "SelectedItem", _match.AttributeReference, "DataType" );

				chkADMustBePresent.Checked = match.AttributeReference.MustBePresent;
				chkADMustBePresent.DataBindings.Add( "Checked", _match.AttributeReference, "MustBePresent" );
				
				pol.AttributeDesignatorBase attributeDesignator = (pol.AttributeDesignatorBase)match.AttributeReference;
				txtAttributeId.Text = attributeDesignator.AttributeId;
				txtAttributeId.DataBindings.Add( "Text", _match.AttributeReference, "AttributeId" );

				txtIssuer.Text = attributeDesignator.Issuer;
				txtIssuer.DataBindings.Add( "Text", _match.AttributeReference, "Issuer" );
			}
			else if( match.AttributeReference is pol.AttributeSelectorElement )
			{
				rdbAttributeDesignator.Checked = false;
				rdbAttributeSelector.Checked = true;

				cmbASDataType.SelectedIndex = cmbASDataType.FindStringExact( match.AttributeReference.DataType );
				cmbASDataType.DataBindings.Add( "SelectedItem", _match.AttributeReference, "DataType" );

				chkASMustBePresent.Checked = match.AttributeReference.MustBePresent;
				chkASMustBePresent.DataBindings.Add( "Checked", _match.AttributeReference, "MustBePresent" );

				txtRequestContextPath.Text = ((pol.AttributeSelectorElement)match.AttributeReference).RequestContextPath;
				txtRequestContextPath.DataBindings.Add( "Text", _match.AttributeReference, "RequestContextPath" );
			}

			LoadingData = false;
		}
示例#14
0
		/// <summary>
		/// Creates a new Condition using the reference to the condition definition in the policy document.
		/// </summary>
		/// <param name="condition">The condition definition of the policy document.</param>
		public Condition( pol.ConditionElement condition ) : base( condition )
		{
		}
示例#15
0
		/// <summary>
		/// Creates a new runtime policy evaluation.
		/// </summary>
		/// <param name="policy">The policy document.</param>
		public Policy( pol.PolicyElement policy )
		{
            if (policy == null) throw new ArgumentNullException("policy");
			_policy = policy;
			
			// Chechs the target for this policy.
			if( policy.Target != null )
			{
				_target = new Target( (pol.TargetElement)policy.Target );

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

			// Load all the Rules and creates a new runtime rule.
			foreach( pol.RuleElement rule in policy.Rules )
			{
				Rule ruleEv = new Rule( rule );
				_rules.Add( ruleEv );

				foreach( string rName in ruleEv.AllResources )
				{
					if( !_allResources.Contains( rName ) )
					{
						_allResources.Add( rName );
					}
				}
			}
		}
		/// <summary>
		/// Matches the designator within the values of this attribute element.
		/// </summary>
		/// <param name="attributeDesignator">The attribute designator instance.</param>
		/// <returns><c>true</c> if the designator matches with this attribute.</returns>
		public bool Match( pol.AttributeDesignatorBase attributeDesignator )
		{
            if (attributeDesignator == null) throw new ArgumentNullException("attributeDesignator");
			if( AttributeId == attributeDesignator.AttributeId && DataType == attributeDesignator.DataType )
			{
				if( attributeDesignator.Issuer != null && attributeDesignator.Issuer.Length != 0 )
				{
					if( Issuer == attributeDesignator.Issuer )
					{
						return true;
					}
					else
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}
示例#17
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="variableDefinition">The variable definition in the policy document.</param>
		public VariableDefinition( pol.VariableDefinitionElement variableDefinition )
		{
			_variableDefinition = variableDefinition;
		}
示例#18
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="attributeDesignator"></param>
		public AttributeDesignator( pol.AttributeDesignatorBase attributeDesignator )
		{
			_attributeDesignator = attributeDesignator;

			this.Text = "[" + attributeDesignator.DataType + "]:" + attributeDesignator.AttributeId;
		}
示例#19
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="function"></param>
		public FunctionParameter( pol.FunctionElementReadWrite function )
		{
			_function = function;

			this.Text = "Function: " + _function.FunctionId;
		}
示例#20
0
		/// <summary>
		/// THe argument processing method resolves all the attribute designators, attribute 
		/// selectors. If there is an internal Apply it will be evaulated within this method.
		/// </summary>
		/// <remarks>All the processed arguments are converted into an IFunctionParameter instance
		/// because this is the only value that can be used to call a function.</remarks>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="arguments">The arguments to process.</param>
		/// <returns>A list of arguments ready to be used by a function.</returns>
		private IFunctionParameterCollection ProcessArguments( EvaluationContext context, pol.IExpressionCollection arguments )
		{
			context.Trace( "Processing arguments" );
			context.AddIndent();

			// Create a list to return the processed values.
			IFunctionParameterCollection processedArguments = new IFunctionParameterCollection();

			// Iterate through the arguments, the IExpressionType is a mark interface
			foreach( inf.IExpression arg in arguments )
			{
				if( arg is pol.ApplyElement )
				{
					context.Trace( "Nested apply" );

					// There is a nested apply un this policy a new Apply will be created and also 
					// evaluated. It's return value will be used as the processed argument.
					Apply _childApply = new Apply( (pol.ApplyElement)arg );

					// Evaluate the Apply
					EvaluationValue retVal = _childApply.Evaluate( context );

					context.TraceContextValues();

					// If the results were Indeterminate the Indeterminate value will be placed in 
					// the processed arguments, later another method will validate the parameters
					// and cancel the evaluation propperly.
					if( !retVal.IsIndeterminate )
					{
						if( !context.IsMissingAttribute )
						{
							processedArguments.Add( retVal );
						}
					}
					else
					{
						processedArguments.Add( retVal );
					}
				}
				else if( arg is pol.FunctionElementReadWrite )
				{
					// Search for the function and place it in the processed arguments.
					pol.FunctionElement functionId = new pol.FunctionElement( ((pol.FunctionElementReadWrite)arg).FunctionId, ((pol.FunctionElementReadWrite)arg).SchemaVersion );

					context.Trace( "Function {0}", functionId.FunctionId );
					inf.IFunction function = EvaluationEngine.GetFunction( functionId.FunctionId );
					if( function == null )
					{
						context.Trace( "ERR: function not found {0}", _applyBase.FunctionId );
						context.ProcessingError = true;
						processedArguments.Add( EvaluationValue.Indeterminate );
					}
					else
					{
						processedArguments.Add( function );
					}
				}
				else if( arg is pol.VariableReferenceElement )
				{
					pol.VariableReferenceElement variableRef = arg as pol.VariableReferenceElement;
					VariableDefinition variableDef = context.CurrentPolicy.VariableDefinition[ variableRef.VariableId ] as VariableDefinition;

					context.TraceContextValues();

					if( !variableDef.IsEvaluated )
					{
						processedArguments.Add( variableDef.Evaluate( context ) );
					}
					else
					{
						processedArguments.Add( variableDef.Value );
					}
				}
				else if( arg is pol.AttributeValueElementReadWrite )
				{
					// The AttributeValue does not need to be processed
					context.Trace( "Attribute value {0}", arg.ToString() );
					processedArguments.Add( new pol.AttributeValueElement( ((pol.AttributeValueElementReadWrite)arg).DataType, ((pol.AttributeValueElementReadWrite)arg).Contents, ((pol.AttributeValueElementReadWrite)arg).SchemaVersion ));
				}
				else if( arg is pol.AttributeDesignatorBase )
				{
					// Resolve the AttributeDesignator using the EvaluationEngine public methods.
					context.Trace( "Processing attribute designator: {0}", arg.ToString() );

					pol.AttributeDesignatorBase attrDes = (pol.AttributeDesignatorBase)arg;
					BagValue bag = EvaluationEngine.Resolve( context, attrDes );

					// If the attribute was not resolved by the EvaluationEngine search the 
					// attribute in the context document, also using the EvaluationEngine public 
					// methods.
					if( bag.BagSize == 0 )
					{
						if( arg is pol.SubjectAttributeDesignatorElement )
						{
							ctx.AttributeElement attrib = EvaluationEngine.GetAttribute( context, attrDes );
							if( attrib != null )
							{
								context.Trace( "Adding subject attribute designator: {0}", attrib.ToString() );
								bag.Add( attrib );
								break;
							}
						}
						else if( arg is pol.ResourceAttributeDesignatorElement )
						{
							ctx.AttributeElement attrib = EvaluationEngine.GetAttribute( context, attrDes );
							if( attrib != null )
							{
								context.Trace( "Adding resource attribute designator {0}", attrib.ToString() );
								bag.Add( attrib );
							}
						}
						else if( arg is pol.ActionAttributeDesignatorElement )
						{
							ctx.AttributeElement attrib = EvaluationEngine.GetAttribute( context, attrDes );
							if( attrib != null )
							{
								context.Trace( "Adding action attribute designator {0}", attrib.ToString() );
								bag.Add( attrib );
							}
						}
						else if( arg is pol.EnvironmentAttributeDesignatorElement )
						{
							ctx.AttributeElement attrib = EvaluationEngine.GetAttribute( context, attrDes );
							if( attrib != null )
							{
								context.Trace( "Adding environment attribute designator {0}", attrib.ToString() );
								bag.Add( attrib );
							}
						}
					}

					// If the argument was not found and the attribute must be present this is 
					// a MissingAttribute situation so set the flag. Otherwise add the attribute 
					// to the processed arguments.
					if( bag.BagSize == 0 && attrDes.MustBePresent )
					{
						context.Trace( "Attribute is missing" );
						context.IsMissingAttribute = true;
						context.AddMissingAttribute( attrDes );
					}
					else
					{
						processedArguments.Add( bag );
					}
				}
				else if( arg is pol.AttributeSelectorElement )
				{
					// Resolve the XPath query using the EvaluationEngine public methods.
					context.Trace( "Attribute selector" );
					try
					{
						BagValue bag = EvaluationEngine.Resolve( context, (pol.AttributeSelectorElement)arg );
						if( bag.Elements.Count == 0 && ((pol.AttributeSelectorElement)arg).MustBePresent )
						{
							context.Trace( "Attribute is missing" );
							context.IsMissingAttribute = true;
							context.AddMissingAttribute( (pol.AttributeReferenceBase)arg );
						}
						else
						{
							processedArguments.Add( bag );
						}
					}
					catch( EvaluationException e )
					{
						context.Trace( Resource.TRACE_ERROR, e.Message );
						processedArguments.Add( EvaluationValue.Indeterminate );
						context.ProcessingError = true;
					}
				}
			}
			context.RemoveIndent();

			return processedArguments;
		}
示例#21
0
		/// <summary>
		/// Creates a new ApplyBase using the ApplyBase form the policy document.
		/// </summary>
		/// <param name="apply"></param>
		protected ApplyBase( pol.ApplyBaseReadWrite apply )
		{
			_applyBase = apply;
		}
		/// <summary>
		/// Method called by the EvaluationEngine when an attribute is not found.
		/// </summary>
		/// <param name="context">The evaluation context instance.</param>
		/// <param name="designator">The attribute designator.</param>
		/// <returns>An instance of an Attribute with it's value.</returns>
		public ctx.AttributeElement GetAttribute( rtm.EvaluationContext context, pol.AttributeDesignatorBase designator )
		{
            if (context == null) throw new ArgumentNullException("context");
            if (designator == null) throw new ArgumentNullException("designator");
			foreach( ctx.AttributeElement attrib in _attributes )
			{
				if( attrib.AttributeId == designator.AttributeId )
				{
					if( designator.Issuer != null && designator.Issuer.Length != 0 )
					{
						if( designator.Issuer == attrib.Issuer )
						{
							return attrib;
						}
					}
					else
					{
						return attrib;
					}
				}
			}
			return null;
		}
示例#23
0
		/// <summary>
		/// Creates a new instance of the evaluaion context.
		/// </summary>
		/// <param name="engine">The engine instance.</param>
		/// <param name="policyDocument">The policy document instance.</param>
		/// <param name="contextDocument">The context document instance.</param>
		public EvaluationContext( EvaluationEngine engine, pol.PolicyDocument policyDocument, ctx.ContextDocument contextDocument )
			: this()
		{
			ctx.AttributeReadWriteCollection attributes = new ctx.AttributeReadWriteCollection();
			foreach( ctx.AttributeElementReadWrite attribute in contextDocument.Request.Resources[0].Attributes )
			{
				attributes.Add( new ctx.AttributeElementReadWrite( attribute ) );
			}

			ctx.ResourceContentElement resourceContent = null;
			if( contextDocument.Request.Resources[0].ResourceContent != null )
			{
				resourceContent = new ctx.ResourceContentElement( 
						contextDocument.Request.Resources[0].ResourceContent.XmlDocument, 
						contextDocument.Request.Resources[0].ResourceContent.SchemaVersion );
			}

			_engine = engine;
			_policyDocument = policyDocument;
			_contextDocument = contextDocument;
			_currentResource = new ctx.ResourceElementReadWrite( 
				resourceContent,
				contextDocument.Request.Resources[0].ResourceScopeValue, 
				attributes, 
				contextDocument.Request.Resources[0].SchemaVersion );
		}
示例#24
0
		/// <summary>
		/// Adds an attribute designator to the missing attributes list.
		/// </summary>
		/// <param name="attrDes"></param>
		public void AddMissingAttribute( pol.AttributeReferenceBase attrDes )
		{
			_missingAttributes.Add( attrDes );
		}
示例#25
0
		/// <summary>
		/// Creates a new instance of the Aubjects class using the policy subjects definition.
		/// </summary>
		/// <param name="subjects">The policy subjects definition.</param>
		public SubjectTargetItems( pol.SubjectsElement subjects ) : base( subjects )
		{
		}
示例#26
0
		/// <summary>
		/// Creates a new instance of any target item.
		/// </summary>
		protected TargetItems( pol.TargetItemsBaseReadWrite targetItems )
		{
			_targetItems = targetItems;
		}
示例#27
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="obligations"></param>
		public Obligations( pol.ObligationReadWriteCollection obligations )
		{
			_obligations = obligations;

			this.Text = "Obligations";
		}
示例#28
0
		/// <summary>
		/// Creates a new instance of the Actions class using the policy actions definition.
		/// </summary>
		/// <param name="actions">The policy actions definition.</param>
		public ActionTargetItems( pol.ActionsElement actions ) : base( actions )
		{
		}
示例#29
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="policySetIdReference"></param>
		public PolicySetIdReference( pol.PolicySetIdReferenceElementReadWrite policySetIdReference )
		{
			_policySetIdReference = policySetIdReference;

			this.Text = string.Format( "PolicySetIdReference: {0}", policySetIdReference.PolicySetId );
		}
示例#30
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="condition"></param>
		public Condition( pol.ConditionElementReadWrite condition )
		{
			_condition = condition;

			this.Text = "Condition";
		}