Ejemplo n.º 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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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 == Consts.Schema1.RuleElement.Rule &&
                ValidateSchema(reader, schemaVersion))
            {
                // Read the attributes
                _id = reader.GetAttribute(Consts.Schema1.RuleElement.RuleId);

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

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

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

                    case Consts.Schema1.RuleElement.Condition:
                        _condition = new ConditionElementReadWrite(reader, schemaVersion);
                        break;
                    }
                    if (reader.LocalName == Consts.Schema1.RuleElement.Rule &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
Ejemplo n.º 4
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 TreeNodes.FunctionExecution(condition));
            tvwCondition.ExpandAll();

            foreach (FieldInfo field in typeof(Consts.Schema1.InternalDataTypes).GetFields())
            {
                cmbDataType.Items.Add(field.GetValue(null));
            }
            foreach (FieldInfo field in typeof(Consts.Schema1.InternalFunctions).GetFields())
            {
                cmbInternalFunctions.Items.Add(field.GetValue(null));
            }
        }
Ejemplo n.º 5
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 TreeNodes.FunctionExecution( condition ) );
            tvwCondition.ExpandAll();

            foreach( FieldInfo field in typeof(Consts.Schema1.InternalDataTypes).GetFields() )
            {
                cmbDataType.Items.Add( field.GetValue( null ) );
            }
            foreach( FieldInfo field in typeof(Consts.Schema1.InternalFunctions).GetFields() )
            {
                cmbInternalFunctions.Items.Add( field.GetValue( null ) );
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="condition"></param>
        public Condition(pol.ConditionElementReadWrite condition)
        {
            _condition = condition;

            this.Text = "Condition";
        }
Ejemplo n.º 7
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 == Consts.Schema1.RuleElement.Rule &&
                ValidateSchema(reader, schemaVersion))
            {
                // Read the attributes
                _id = reader.GetAttribute(Consts.Schema1.RuleElement.RuleId);

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

                // Read the rule contents.
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                        case Consts.Schema1.RuleElement.Description:
                            _description = reader.ReadElementString();
                            break;
                        case Consts.Schema1.RuleElement.Target:
                            _target = new TargetElementReadWrite(reader, schemaVersion);
                            break;
                        case Consts.Schema1.RuleElement.Condition:
                            _condition = new ConditionElementReadWrite(reader, schemaVersion);
                            break;
                    }
                    if (reader.LocalName == Consts.Schema1.RuleElement.Rule &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
Ejemplo n.º 8
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 RuleElement(string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion)
     : base(id, description, target, condition, effect, schemaVersion)
 {
 }
Ejemplo n.º 9
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 RuleElement(string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion)
     : base(id, description, target, condition, effect, schemaVersion)
 {
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="condition"></param>
        public Condition( pol.ConditionElementReadWrite condition )
        {
            _condition = condition;

            this.Text = "Condition";
        }