Exemplo 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;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new policySet using the arguments provided.
 /// </summary>
 /// <param name="id">The policy set id.</param>
 /// <param name="description">The description of the policy set.</param>
 /// <param name="target">The target for this policy set.</param>
 /// <param name="policies">All the policies inside this policy set.</param>
 /// <param name="policyCombiningAlgorithm">The policy combining algorithm for this policy set.</param>
 /// <param name="obligations">The obligations.</param>
 /// <param name="xpathVersion">The XPath version supported.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public PolicySetElementReadWrite(string id, string description, TargetElementReadWrite target, ArrayList policies, string policyCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _id          = id;
     _description = description;
     _target      = target;
     _policies    = policies;
     _policyCombiningAlgorithm = policyCombiningAlgorithm;
     _obligations  = obligations;
     _xpathVersion = xpathVersion;
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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 );
		}
Exemplo n.º 5
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]);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new Policy with the specified arguments.
 /// </summary>
 /// <param name="id">The policy id.</param>
 /// <param name="description">The policy description.</param>
 /// <param name="target">The policy target.</param>
 /// <param name="rules">The rules for this policy.</param>
 /// <param name="ruleCombiningAlgorithm">The rule combining algorithm.</param>
 /// <param name="obligations">The Obligations for this policy.</param>
 /// <param name="xpathVersion">The XPath version supported.</param>
 /// <param name="combinerParameters">The combiner parameters in this policy.</param>
 /// <param name="ruleCombinerParameters">The rule parameters in this policy.</param>
 /// <param name="variableDefinitions">The variable definitions of this policy.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public PolicyElementReadWrite(string id, string description, TargetElementReadWrite target, RuleReadWriteCollection rules, string ruleCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion,
                               ArrayList combinerParameters, ArrayList ruleCombinerParameters, IDictionary variableDefinitions, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _id                     = id;
     _description            = description;
     _target                 = target;
     _rules                  = rules;
     _ruleCombiningAlgorithm = ruleCombiningAlgorithm;
     _obligations            = obligations;
     _combinerParameters     = combinerParameters;
     _ruleCombinerParameters = ruleCombinerParameters;
     _variableDefinitions    = variableDefinitions;
     _xpathVersion           = xpathVersion;
 }
Exemplo n.º 7
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)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a new policySet using the arguments provided.
 /// </summary>
 /// <param name="id">The policy set id.</param>
 /// <param name="description">The description of the policy set.</param>
 /// <param name="target">The target for this policy set.</param>
 /// <param name="policies">All the policies inside this policy set.</param>
 /// <param name="policyCombiningAlgorithm">The policy combining algorithm for this policy set.</param>
 /// <param name="obligations">The obligations.</param>
 /// <param name="xpathVersion">The XPath version supported.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public PolicySetElement(string id, string description, TargetElementReadWrite target, ArrayList policies, string policyCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, XacmlVersion schemaVersion)
     : base(id, description, target, policies, policyCombiningAlgorithm, obligations, xpathVersion, schemaVersion)
 {
 }
Exemplo n.º 9
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 ] );
			}
		}
Exemplo n.º 10
0
		/// <summary>
		/// Creates a new Policy with the specified arguments.
		/// </summary>
		/// <param name="id">The policy id.</param>
		/// <param name="description">THe policy description.</param>
		/// <param name="target">THe policy target.</param>
		/// <param name="rules">THe rules for this policy.</param>
		/// <param name="ruleCombiningAlgorithm">THe rule combining algorithm.</param>
		/// <param name="obligations">The Obligations for this policy.</param>
		/// <param name="xpathVersion">The XPath version supported.</param>
		/// <param name="combinerParameters">The combiner parameters in this policy.</param>
		/// <param name="ruleCombinerParameters">The rule parameters in this policy.</param>
		/// <param name="variableDefinitions">The variable definitions of this policy.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicyElement( string id, string description, TargetElementReadWrite target, RuleReadWriteCollection rules, string ruleCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, 
			ArrayList combinerParameters, ArrayList ruleCombinerParameters, IDictionary variableDefinitions, XacmlVersion schemaVersion )
			: base( id, description, target, rules, ruleCombiningAlgorithm, obligations, xpathVersion, 
			combinerParameters, ruleCombinerParameters, variableDefinitions, schemaVersion )
		{
		}
Exemplo n.º 11
0
 /// <summary>
 /// Creates a new Policy with the specified arguments.
 /// </summary>
 /// <param name="id">The policy id.</param>
 /// <param name="description">THe policy description.</param>
 /// <param name="target">THe policy target.</param>
 /// <param name="rules">THe rules for this policy.</param>
 /// <param name="ruleCombiningAlgorithm">THe rule combining algorithm.</param>
 /// <param name="obligations">The Obligations for this policy.</param>
 /// <param name="xpathVersion">The XPath version supported.</param>
 /// <param name="combinerParameters">The combiner parameters in this policy.</param>
 /// <param name="ruleCombinerParameters">The rule parameters in this policy.</param>
 /// <param name="variableDefinitions">The variable definitions of this policy.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public PolicyElement(string id, string description, TargetElementReadWrite target, RuleReadWriteCollection rules, string ruleCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion,
                      ArrayList combinerParameters, ArrayList ruleCombinerParameters, IDictionary variableDefinitions, XacmlVersion schemaVersion)
     : base(id, description, target, rules, ruleCombiningAlgorithm, obligations, xpathVersion,
            combinerParameters, ruleCombinerParameters, variableDefinitions, schemaVersion)
 {
 }
Exemplo n.º 12
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void CreateTarget( object sender, EventArgs args )
		{
			Target newTargetNode = null;
			TreeNode parentNode = null;

			// Create the target
			pol.TargetElementReadWrite target = new pol.TargetElementReadWrite( 
				new pol.ResourcesElementReadWrite( true, new pol.TargetItemReadWriteCollection(), XacmlVersion.Version11 ), //TODO: check version
				new pol.SubjectsElementReadWrite( true, new pol.TargetItemReadWriteCollection(), XacmlVersion.Version11 ), //TODO: check version 
				new pol.ActionsElementReadWrite( true, new pol.TargetItemReadWriteCollection(), XacmlVersion.Version11 ), //TODO: check version
				new pol.EnvironmentsElementReadWrite( true, new pol.TargetItemReadWriteCollection(), XacmlVersion.Version11 ), //TODO: check version
				XacmlVersion.Version11 ); //TODO: check version

			// Create the node
			newTargetNode = new Target( target );

			if( mainTree.SelectedNode is PolicySet )
			{
				parentNode = mainTree.SelectedNode;
				pol.PolicySetElementReadWrite policySet = ((PolicySet)parentNode).PolicySetDefinition;

				// Set the target
				policySet.Target = target;
			}
			else if ( mainTree.SelectedNode is Policy )
			{
				parentNode = mainTree.SelectedNode;
				pol.PolicyElementReadWrite policy = ((Policy)parentNode).PolicyDefinition;

				// Set the target
				policy.Target = target;
			}
			else if ( mainTree.SelectedNode is Rule )
			{
				parentNode = mainTree.SelectedNode;
				pol.RuleElementReadWrite rule = ((Rule)parentNode).RuleDefinition;

				// Set the target
				rule.Target = target;
			}
			else if ( mainTree.SelectedNode is AnyTarget )
			{
				parentNode = mainTree.SelectedNode.Parent;

				// Set the target
				if( parentNode is PolicySet )
				{
					((PolicySet)parentNode).PolicySetDefinition.Target = target;
				}
				else if ( parentNode is Policy )
				{
					((Policy)parentNode).PolicyDefinition.Target = target;
				}
				else if ( parentNode is Rule )
				{
					((Rule)parentNode).RuleDefinition.Target = target;
				}
			}

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

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

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

					// Add the node to the node.
					parentNode.Nodes.Insert( idx, newTargetNode );
				}
			}
		}
Exemplo n.º 13
0
        /// <summary>
        /// Creates a new PolicySet using the XmlReader instance provided.
        /// </summary>
        /// <param name="reader">The XmlReder positioned at the PolicySet element.</param>
        /// <param name="schemaVersion">The version of the schema that will be used to validate.</param>
        public PolicySetElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            // Validates the current node name
            if (reader.LocalName == PolicySchema1.PolicySetElement.PolicySet &&
                ValidateSchema(reader, schemaVersion))
            {
                // Get the attributes
                _id = reader.GetAttribute(PolicySchema1.PolicySetElement.PolicySetId);
                _policyCombiningAlgorithm = reader.GetAttribute(PolicySchema1.PolicySetElement.PolicyCombiningAlgorithmId);

                // Read the inner nodes
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                    case PolicySchema1.PolicySetElement.Description:
                        _description = reader.ReadElementString();
                        break;

                    case PolicySchema1.PolicySetElement.PolicySetDefaults:
                        if (reader.Read() && reader.Read())
                        {
                            if (reader.LocalName == PolicySetDefaultsElement.XPathVersion &&
                                ValidateSchema(reader, schemaVersion))
                            {
                                _xpathVersion = reader.ReadElementString();
                                if (_xpathVersion != null && _xpathVersion.Length != 0 && _xpathVersion != Namespaces.XPath10)
                                {
                                    throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_unsupported_xpath_version, _xpathVersion]);
                                }
                            }
                            reader.Read();
                        }
                        break;

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

                    case PolicySchema1.PolicySetElement.PolicySet:
                        if (!reader.IsEmptyElement && reader.NodeType != XmlNodeType.EndElement)
                        {
                            _policies.Add(new PolicySetElementReadWrite(reader, schemaVersion));
                        }
                        break;

                    case PolicySchema1.PolicyElement.Policy:
                        _policies.Add(new PolicyElementReadWrite(reader, schemaVersion));
                        break;

                    case PolicySchema1.PolicySetIdReferenceElement.PolicySetIdReference:
                        _policies.Add(new PolicySetIdReferenceElementReadWrite(reader, schemaVersion));
                        break;

                    case PolicySchema1.PolicyIdReferenceElement.PolicyIdReference:
                        _policies.Add(new PolicyIdReferenceElement(reader, schemaVersion));
                        break;

                    case PolicySchema1.PolicySetElement.Obligations:
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema1.ObligationElement.Obligation:
                                _obligations.Add(new ObligationElementReadWrite(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == ObligationsElement.Obligations &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicySetElement.CombinerParameters:
                        // Read all the combiner parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema2.CombinerParameterElement.CombinerParameter:
                                _combinerParameters.Add(new CombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == PolicySchema2.PolicySetElement.CombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicySetElement.PolicyCombinerParameters:
                        // Read all the policy combiner parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema2.PolicyCombinerParameterElement.PolicyCombinerParameter:
                                _policyCombinerParameters.Add(new PolicyCombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == PolicySchema2.PolicySetElement.PolicyCombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicySetElement.PolicySetCombinerParameters:
                        // Read all the policy set combiner parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema2.PolicySetCombinerParameterElement.PolicySetCombinerParameter:
                                _policySetCombinerParameters.Add(new PolicySetCombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == PolicySchema2.PolicySetElement.PolicySetCombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;
                    }
                    if (reader.LocalName == PolicySchema1.PolicySetElement.PolicySet &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        reader.Read();
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a new Policy with the specified arguments.
 /// </summary>
 /// <param name="id">The policy id.</param>
 /// <param name="description">The policy description.</param>
 /// <param name="target">The policy target.</param>
 /// <param name="rules">The rules for this policy.</param>
 /// <param name="ruleCombiningAlgorithm">The rule combining algorithm.</param>
 /// <param name="obligations">The Obligations for this policy.</param>
 /// <param name="xpathVersion">The XPath version supported.</param>
 /// <param name="combinerParameters">The combiner parameters in this policy.</param>
 /// <param name="ruleCombinerParameters">The rule parameters in this policy.</param>
 /// <param name="variableDefinitions">The variable definitions of this policy.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public PolicyElementReadWrite(string id, string description, TargetElementReadWrite target, RuleReadWriteCollection rules, string ruleCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion,
     ArrayList combinerParameters, ArrayList ruleCombinerParameters, IDictionary variableDefinitions, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _id = id;
     _description = description;
     _target = target;
     _rules = rules;
     _ruleCombiningAlgorithm = ruleCombiningAlgorithm;
     _obligations = obligations;
     _combinerParameters = combinerParameters;
     _ruleCombinerParameters = ruleCombinerParameters;
     _variableDefinitions = variableDefinitions;
     _xpathVersion = xpathVersion;
 }
Exemplo n.º 15
0
		/// <summary>
		/// Creates a new policySet using the arguments provided.
		/// </summary>
		/// <param name="id">The policy set id.</param>
		/// <param name="description">The description of the policy set.</param>
		/// <param name="target">The target for this policy set.</param>
		/// <param name="policies">All the policies inside this policy set.</param>
		/// <param name="policyCombiningAlgorithm">The policy combining algorithm for this policy set.</param>
		/// <param name="obligations">The obligations.</param>
		/// <param name="xpathVersion">The XPath version supported.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicySetElement( string id, string description, TargetElementReadWrite target, ArrayList policies, string policyCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, XacmlVersion schemaVersion )
			: base( id, description, target, policies, policyCombiningAlgorithm, obligations, xpathVersion, schemaVersion )
		{
		}
Exemplo n.º 16
0
		/// <summary>
		/// Creates a new PolicySet using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReder positioned at the PolicySet element.</param>
		/// <param name="schemaVersion">The version of the schema that will be used to validate.</param>
		public PolicySetElementReadWrite( XmlReader reader, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
			// Validates the current node name
			if( reader.LocalName == PolicySchema1.PolicySetElement.PolicySet && 
				ValidateSchema( reader, schemaVersion ) )
			{
				// Get the attributes
				_id = reader.GetAttribute( PolicySchema1.PolicySetElement.PolicySetId ); 
				_policyCombiningAlgorithm = reader.GetAttribute( PolicySchema1.PolicySetElement.PolicyCombiningAlgorithmId );

				// Read the inner nodes
				while( reader.Read() )
				{
					switch( reader.LocalName )
					{
						case PolicySchema1.PolicySetElement.Description:
							_description = reader.ReadElementString();
							break;
						case PolicySchema1.PolicySetElement.PolicySetDefaults:
							if( reader.Read() && reader.Read() )
							{
								if( reader.LocalName == PolicySetDefaultsElement.XPathVersion && 
									ValidateSchema( reader, schemaVersion ) )
								{
									_xpathVersion = reader.ReadElementString();
									if( _xpathVersion != null && _xpathVersion.Length != 0 && _xpathVersion != Namespaces.XPath10 )
									{
										throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_unsupported_xpath_version, _xpathVersion ] );
									}
								}
								reader.Read();
							}
							break;
						case PolicySchema1.TargetElement.Target:
							_target = new TargetElementReadWrite( reader, schemaVersion );
							break;
						case PolicySchema1.PolicySetElement.PolicySet:
							if( !reader.IsEmptyElement && reader.NodeType != XmlNodeType.EndElement )
							{
								_policies.Add( new PolicySetElementReadWrite( reader, schemaVersion ) );
							}
							break;
						case PolicySchema1.PolicyElement.Policy:
							_policies.Add( new PolicyElementReadWrite( reader, schemaVersion ) );
							break;
						case PolicySchema1.PolicySetIdReferenceElement.PolicySetIdReference:
							_policies.Add( new PolicySetIdReferenceElementReadWrite( reader, schemaVersion ) );
							break;
						case PolicySchema1.PolicyIdReferenceElement.PolicyIdReference:
							_policies.Add( new PolicyIdReferenceElement( reader, schemaVersion ) );
							break;
						case PolicySchema1.PolicySetElement.Obligations:
							while( reader.Read() )
							{
								switch( reader.LocalName )
								{
									case PolicySchema1.ObligationElement.Obligation:
										_obligations.Add( new ObligationElementReadWrite( reader, schemaVersion ) );
										break;
								}
								if( reader.LocalName == ObligationsElement.Obligations && 
									reader.NodeType == XmlNodeType.EndElement )
								{
									reader.Read();
									break;
								}		
							}
							break;
						case PolicySchema2.PolicySetElement.CombinerParameters:
							// Read all the combiner parameters
							while( reader.Read() )
							{
								switch( reader.LocalName )
								{
									case PolicySchema2.CombinerParameterElement.CombinerParameter:
										_combinerParameters.Add( new CombinerParameterElement( reader, schemaVersion ) );
										break;
								}
								if( reader.LocalName == PolicySchema2.PolicySetElement.CombinerParameters && 
									reader.NodeType == XmlNodeType.EndElement )
								{
									reader.Read();
									break;
								}		
							}
							break;
						case PolicySchema2.PolicySetElement.PolicyCombinerParameters:
							// Read all the policy combiner parameters
							while( reader.Read() )
							{
								switch( reader.LocalName )
								{
									case PolicySchema2.PolicyCombinerParameterElement.PolicyCombinerParameter:
										_policyCombinerParameters.Add( new PolicyCombinerParameterElement( reader, schemaVersion ) );
										break;
								}
								if( reader.LocalName == PolicySchema2.PolicySetElement.PolicyCombinerParameters && 
									reader.NodeType == XmlNodeType.EndElement )
								{
									reader.Read();
									break;
								}		
							}
							break;
						case PolicySchema2.PolicySetElement.PolicySetCombinerParameters:
							// Read all the policy set combiner parameters
							while( reader.Read() )
							{
								switch( reader.LocalName )
								{
									case PolicySchema2.PolicySetCombinerParameterElement.PolicySetCombinerParameter:
										_policySetCombinerParameters.Add( new PolicySetCombinerParameterElement( reader, schemaVersion ) );
										break;
								}
								if( reader.LocalName == PolicySchema2.PolicySetElement.PolicySetCombinerParameters && 
									reader.NodeType == XmlNodeType.EndElement )
								{
									reader.Read();
									break;
								}		
							}
							break;
					}
					if( reader.LocalName == PolicySchema1.PolicySetElement.PolicySet && 
						reader.NodeType == XmlNodeType.EndElement )
					{
						reader.Read();
						break;
					}
				}
			}
			else
			{
				throw new Exception( Resource.ResourceManager[ Resource.MessageKey.exc_invalid_node_name, reader.LocalName ] );
			}
		}
Exemplo n.º 17
0
		/// <summary>
		/// Creates a new policySet using the arguments provided.
		/// </summary>
		/// <param name="id">The policy set id.</param>
		/// <param name="description">The description of the policy set.</param>
		/// <param name="target">The target for this policy set.</param>
		/// <param name="policies">All the policies inside this policy set.</param>
		/// <param name="policyCombiningAlgorithm">The policy combining algorithm for this policy set.</param>
		/// <param name="obligations">The obligations.</param>
		/// <param name="xpathVersion">The XPath version supported.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public PolicySetElementReadWrite( string id, string description, TargetElementReadWrite target, ArrayList policies, string policyCombiningAlgorithm, ObligationReadWriteCollection obligations, string xpathVersion, XacmlVersion schemaVersion )
			: base( XacmlSchema.Policy, schemaVersion )
		{
			_id = id;
			_description = description;
			_target = target;
			_policies = policies;
			_policyCombiningAlgorithm = policyCombiningAlgorithm;
			_obligations = obligations;
			_xpathVersion = xpathVersion;
		}
Exemplo n.º 18
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 )
		{
		}
Exemplo n.º 19
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;
		}
Exemplo n.º 20
0
        /// <summary>
        /// Creates a new Policy using the XmlReader instance specified.
        /// </summary>
        /// <param name="reader">The XmlReader instance positioned at the Policy node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public PolicyElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader.LocalName == PolicySchema2.PolicyElement.Policy &&
                ValidateSchema(reader, schemaVersion))
            {
                // Read the policy id
                _id = reader.GetAttribute(PolicySchema2.PolicyElement.PolicyId);

                // Read the policy combining algorithm
                _ruleCombiningAlgorithm = reader.GetAttribute(PolicySchema2.PolicyElement.RuleCombiningAlgorithmId);
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                        case PolicySchema2.PolicyElement.Description:
                            _description = reader.ReadElementString();
                            break;
                        case PolicySchema2.PolicyElement.PolicyDefaults:
                            // Read all the policy defaults.
                            if (reader.Read() && reader.Read())
                            {
                                if (reader.LocalName == PolicyDefaultsElement.XPathVersion &&
                                    ValidateSchema(reader, schemaVersion))
                                {
                                    _xpathVersion = reader.ReadElementString();
                                    if (_xpathVersion != null && _xpathVersion.Length != 0 && _xpathVersion != Namespaces.XPath10)
                                    {
                                        throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_unsupported_xpath_version, _xpathVersion]);
                                    }
                                }
                                reader.Read();
                            }
                            break;
                        case PolicySchema2.TargetElement.Target:
                            _target = new TargetElementReadWrite(reader, schemaVersion);
                            break;
                        case PolicySchema2.RuleElement.Rule:
                            _rules.Add(new RuleElementReadWrite(reader, schemaVersion));
                            break;
                        case PolicySchema2.PolicyElement.Obligations:
                            // Read all the obligations
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case PolicySchema1.ObligationElement.Obligation:
                                        _obligations.Add(new ObligationElementReadWrite(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == ObligationsElement.Obligations &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case PolicySchema2.PolicyElement.CombinerParameters:
                            // Read all the combiner parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case PolicySchema2.CombinerParameterElement.CombinerParameter:
                                        _combinerParameters.Add(new CombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == PolicySchema2.PolicyElement.CombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case PolicySchema2.PolicyElement.RuleCombinerParameters:
                            // Read all the rule parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case PolicySchema2.RuleCombinerParameterElement.RuleCombinerParameter:
                                        _ruleCombinerParameters.Add(new RuleCombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == PolicySchema2.PolicyElement.RuleCombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case PolicySchema2.PolicyElement.VariableDefinition:
                            VariableDefinitionElement variable = new VariableDefinitionElement(reader, schemaVersion);
                            _variableDefinitions.Add(variable.Id, variable);
                            break;
                    }
                    if (reader.LocalName == PolicySchema1.PolicyElement.Policy &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a new Policy using the XmlReader instance specified.
        /// </summary>
        /// <param name="reader">The XmlReader instance positioned at the Policy node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public PolicyElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader.LocalName == PolicySchema2.PolicyElement.Policy &&
                ValidateSchema(reader, schemaVersion))
            {
                // Read the policy id
                _id = reader.GetAttribute(PolicySchema2.PolicyElement.PolicyId);

                // Read the policy combining algorithm
                _ruleCombiningAlgorithm = reader.GetAttribute(PolicySchema2.PolicyElement.RuleCombiningAlgorithmId);
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                    case PolicySchema2.PolicyElement.Description:
                        _description = reader.ReadElementString();
                        break;

                    case PolicySchema2.PolicyElement.PolicyDefaults:
                        // Read all the policy defaults.
                        if (reader.Read() && reader.Read())
                        {
                            if (reader.LocalName == PolicyDefaultsElement.XPathVersion &&
                                ValidateSchema(reader, schemaVersion))
                            {
                                _xpathVersion = reader.ReadElementString();
                                if (_xpathVersion != null && _xpathVersion.Length != 0 && _xpathVersion != Namespaces.XPath10)
                                {
                                    throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_unsupported_xpath_version, _xpathVersion]);
                                }
                            }
                            reader.Read();
                        }
                        break;

                    case PolicySchema2.TargetElement.Target:
                        _target = new TargetElementReadWrite(reader, schemaVersion);
                        break;

                    case PolicySchema2.RuleElement.Rule:
                        _rules.Add(new RuleElementReadWrite(reader, schemaVersion));
                        break;

                    case PolicySchema2.PolicyElement.Obligations:
                        // Read all the obligations
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema1.ObligationElement.Obligation:
                                _obligations.Add(new ObligationElementReadWrite(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == ObligationsElement.Obligations &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicyElement.CombinerParameters:
                        // Read all the combiner parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema2.CombinerParameterElement.CombinerParameter:
                                _combinerParameters.Add(new CombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == PolicySchema2.PolicyElement.CombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicyElement.RuleCombinerParameters:
                        // Read all the rule parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case PolicySchema2.RuleCombinerParameterElement.RuleCombinerParameter:
                                _ruleCombinerParameters.Add(new RuleCombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == PolicySchema2.PolicyElement.RuleCombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;

                    case PolicySchema2.PolicyElement.VariableDefinition:
                        VariableDefinitionElement variable = new VariableDefinitionElement(reader, schemaVersion);
                        _variableDefinitions.Add(variable.Id, variable);
                        break;
                    }
                    if (reader.LocalName == PolicySchema1.PolicyElement.Policy &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }