コード例 #1
0
 /// <summary>
 /// Creates a new Rule using the provided argument values.
 /// </summary>
 /// <param name="id">The rule id.</param>
 /// <param name="description">The rule description.</param>
 /// <param name="target">The target instance for this rule.</param>
 /// <param name="condition">The condition for this rule.</param>
 /// <param name="effect">The effect of this rule.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public RuleElementReadWrite(string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _id          = id;
     _description = description;
     _target      = target;
     _condition   = condition;
     _effect      = effect;
 }
コード例 #2
0
        /// <summary>
        /// Creates a new Rule using the XmlReader instance provided.
        /// </summary>
        /// <param name="reader">THe XmlReader instance positioned at the Rule node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public RuleElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName == PolicySchema1.RuleElement.Rule &&
                ValidateSchema(reader, schemaVersion))
            {
                // Read the attributes
                _id = reader.GetAttribute(PolicySchema1.RuleElement.RuleId);

                // The parsing should not fail because the document have been validated by an
                // Xsd schema.
                string temp = reader.GetAttribute(PolicySchema1.RuleElement.Effect);
                _effect = (Effect)Enum.Parse(
                    typeof(Effect),
                    temp,
                    false);

                // Read the rule contents.
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                    case PolicySchema1.RuleElement.Description:
                        _description = reader.ReadElementString();
                        break;

                    case PolicySchema1.RuleElement.Target:
                        _target = new TargetElementReadWrite(reader, schemaVersion);
                        break;

                    case PolicySchema1.RuleElement.Condition:
                        _condition = new ConditionElementReadWrite(reader, schemaVersion);
                        break;
                    }
                    if (reader.LocalName == PolicySchema1.RuleElement.Rule &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public Condition(pol.ConditionElementReadWrite condition)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            _condition = condition;

            tvwCondition.Nodes.Add(new FunctionExecution(condition));
            tvwCondition.ExpandAll();

            foreach (FieldInfo field in typeof(InternalDataTypes).GetFields())
            {
                cmbDataType.Items.Add(field.GetValue(null));
            }
            foreach (FieldInfo field in typeof(InternalFunctions).GetFields())
            {
                cmbInternalFunctions.Items.Add(field.GetValue(null));
            }
        }
コード例 #4
0
ファイル: Condition.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		public Condition( pol.ConditionElementReadWrite condition )
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			_condition = condition;

			tvwCondition.Nodes.Add( new FunctionExecution( condition ) );
			tvwCondition.ExpandAll();

			foreach( FieldInfo field in typeof(InternalDataTypes).GetFields() )
			{
				cmbDataType.Items.Add( field.GetValue( null ) );
			}
			foreach( FieldInfo field in typeof(InternalFunctions).GetFields() )
			{
				cmbInternalFunctions.Items.Add( field.GetValue( null ) );
			}
		}
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="condition"></param>
        public Condition(pol.ConditionElementReadWrite condition)
        {
            _condition = condition;

            this.Text = "Condition";
        }
コード例 #6
0
ファイル: RuleElement.cs プロジェクト: OsvaldoJ/XACML.NET
 /// <summary>
 /// Creates a new Rule using the provided argument values.
 /// </summary>
 /// <param name="id">The rule id.</param>
 /// <param name="description">The rule description.</param>
 /// <param name="target">The target instance for this rule.</param>
 /// <param name="condition">The condition for this rule.</param>
 /// <param name="effect">The effect of this rule.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public RuleElement(string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion)
     : base(id, description, target, condition, effect, schemaVersion)
 {
 }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void CreateCondition( object sender, EventArgs args )
		{
			Condition newConditionNode = null;
			TreeNode parentNode = null;

			pol.ConditionElementReadWrite condition = new pol.ConditionElementReadWrite( "urn:new_function", new pol.IExpressionReadWriteCollection(), XacmlVersion.Version11 );

			newConditionNode = new Condition( condition );

			parentNode = mainTree.SelectedNode;

			pol.RuleElementReadWrite rule = ((Rule)parentNode).RuleDefinition;

			rule.Condition = condition;


			parentNode.Nodes.Add( newConditionNode );
			/*if( newConditionNode != null && parentNode != null )
			{
				int idx = -1;
				
				// Search the previous node
				foreach( TreeNode node in parentNode.Nodes )
				{
					if( node is TreeNodes.Condition )
					{
						idx = parentNode.Nodes.IndexOf( node );
						break;
					}
				}

				if( idx != -1 )
				{
					// Set the font to the node
					newConditionNode.NodeFont = new Font( mainTree.Font, FontStyle.Bold );

					// Remove the previous condition node
					parentNode.Nodes.RemoveAt( idx );

					// Add the node to the node.
					parentNode.Nodes.Insert( idx, newConditionNode);
				}
			}*/
		}
コード例 #8
0
ファイル: Condition.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// 
		/// </summary>
		/// <param name="condition"></param>
		public Condition( pol.ConditionElementReadWrite condition )
		{
			_condition = condition;

			this.Text = "Condition";
		}
コード例 #9
0
ファイル: RuleElement.cs プロジェクト: Condeti/XACML.NET
		/// <summary>
		/// Creates a new Rule using the provided argument values.
		/// </summary>
		/// <param name="id">The rule id.</param>
		/// <param name="description">The rule description.</param>
		/// <param name="target">The target instance for this rule.</param>
		/// <param name="condition">The condition for this rule.</param>
		/// <param name="effect">The effect of this rule.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public RuleElement( string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion )
			: base( id, description, target, condition, effect, schemaVersion )
		{
		}
コード例 #10
0
		/// <summary>
		/// Creates a new Rule using the provided argument values.
		/// </summary>
		/// <param name="id">The rule id.</param>
		/// <param name="description">The rule description.</param>
		/// <param name="target">The target instance for this rule.</param>
		/// <param name="condition">The condition for this rule.</param>
		/// <param name="effect">The effect of this rule.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public RuleElementReadWrite( string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
			_id = id;
			_description = description;
			_target = target;
			_condition = condition;
			_effect = effect;
		}
コード例 #11
0
		/// <summary>
		/// Creates a new Rule using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">THe XmlReader instance positioned at the Rule node.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public RuleElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if( reader.LocalName == PolicySchema1.RuleElement.Rule && 
				ValidateSchema( reader, schemaVersion ) )
			{
				// Read the attributes
				_id = reader.GetAttribute( PolicySchema1.RuleElement.RuleId );

				// The parsing should not fail because the document have been validated by an
				// Xsd schema.
				string temp = reader.GetAttribute( PolicySchema1.RuleElement.Effect );
				_effect = (Effect)Enum.Parse( 
					typeof(Effect), 
					temp,
					false );

				// Read the rule contents.
				while( reader.Read() )
				{
					switch( reader.LocalName )
					{
						case PolicySchema1.RuleElement.Description:
							_description = reader.ReadElementString();
							break;
						case PolicySchema1.RuleElement.Target:
							_target = new TargetElementReadWrite( reader, schemaVersion );
							break;
						case PolicySchema1.RuleElement.Condition:
							_condition = new ConditionElementReadWrite( reader, schemaVersion );
							break;
					}
					if( reader.LocalName == PolicySchema1.RuleElement.Rule && 
						reader.NodeType == XmlNodeType.EndElement )
					{
						break;
					}
				}
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}