コード例 #1
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)
 {
 }
コード例 #2
0
ファイル: PolicyElement.cs プロジェクト: mingkongbin/anycmd
		/// <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 )
		{
		}
コード例 #3
0
ファイル: RuleElementReadWrite.cs プロジェクト: zszqwe/anycmd
 /// <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;
 }
コード例 #4
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;
 }
コード例 #5
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);
        }
コード例 #6
0
ファイル: Target.cs プロジェクト: mingkongbin/anycmd
        /// <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);
        }
コード例 #7
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;
 }
コード例 #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 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;
 }
コード例 #9
0
ファイル: RuleElementReadWrite.cs プロジェクト: zszqwe/anycmd
        /// <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));
            }
        }
コード例 #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 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;
 }
コード例 #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 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;
 }
コード例 #12
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 == Consts.Schema1.PolicyElement.Policy)
            {
                if (!ValidateSchema(reader, schemaVersion))
                {
                    throw new Exception("ģʽÑé֤ʧ°Ü");
                }
                // Read the policy id
                _id = reader.GetAttribute(Consts.Schema1.PolicyElement.PolicyId);

                // Read the policy combining algorithm
                _ruleCombiningAlgorithm = reader.GetAttribute(Consts.Schema1.PolicyElement.RuleCombiningAlgorithmId);
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                        case Consts.Schema1.PolicyElement.Description:
                            _description = reader.ReadElementString();
                            break;
                        case Consts.Schema1.PolicyElement.PolicyDefaults:
                            // Read all the policy defaults.
                            if (reader.Read() && reader.Read())
                            {
                                if (reader.LocalName == Consts.Schema1.PolicyDefaultsElement.XPathVersion &&
                                    ValidateSchema(reader, schemaVersion))
                                {
                                    _xpathVersion = reader.ReadElementString();
                                    if (!string.IsNullOrEmpty(_xpathVersion) && _xpathVersion != Consts.Schema1.Namespaces.XPath10)
                                    {
                                        throw new Exception(string.Format(Properties.Resource.exc_unsupported_xpath_version, _xpathVersion));
                                    }
                                }
                                reader.Read();
                            }
                            break;
                        case Consts.Schema1.TargetElement.Target:
                            _target = new TargetElementReadWrite(reader, schemaVersion);
                            break;
                        case Consts.Schema1.RuleElement.Rule:
                            _rules.Add(new RuleElementReadWrite(reader, schemaVersion));
                            break;
                        case Consts.Schema1.PolicyElement.Obligations:
                            // Read all the obligations
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema1.ObligationElement.Obligation:
                                        _obligations.Add(new ObligationElementReadWrite(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema1.ObligationsElement.Obligations &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicyElement.CombinerParameters:
                            // Read all the combiner parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema2.CombinerParameterElement.CombinerParameter:
                                        _combinerParameters.Add(new CombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema2.PolicyElement.CombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicyElement.RuleCombinerParameters:
                            // Read all the rule parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema2.RuleCombinerParameterElement.RuleCombinerParameter:
                                        _ruleCombinerParameters.Add(new RuleCombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema2.PolicyElement.RuleCombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicyElement.VariableDefinition:
                            var variable = new VariableDefinitionElement(reader, schemaVersion);
                            _variableDefinitions.Add(variable.Id, variable);
                            break;
                    }
                    if (reader.LocalName == Consts.Schema1.PolicyElement.Policy &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
コード例 #13
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));
            }
        }
コード例 #14
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 == Consts.Schema1.PolicySetElement.PolicySet &&
                ValidateSchema(reader, schemaVersion))
            {
                // Get the attributes
                _id = reader.GetAttribute(Consts.Schema1.PolicySetElement.PolicySetId);
                _policyCombiningAlgorithm = reader.GetAttribute(Consts.Schema1.PolicySetElement.PolicyCombiningAlgorithmId);

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

                    case Consts.Schema1.PolicySetElement.PolicySetDefaults:
                        if (reader.Read() && reader.Read())
                        {
                            if (reader.LocalName == Consts.Schema1.PolicySetDefaultsElement.XPathVersion &&
                                ValidateSchema(reader, schemaVersion))
                            {
                                _xpathVersion = reader.ReadElementString();
                                if (!string.IsNullOrEmpty(_xpathVersion) && _xpathVersion != Consts.Schema1.Namespaces.XPath10)
                                {
                                    throw new Exception(string.Format(Properties.Resource.exc_unsupported_xpath_version, _xpathVersion));
                                }
                            }
                            reader.Read();
                        }
                        break;

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

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

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

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

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

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

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

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

                    case Consts.Schema2.PolicySetElement.PolicySetCombinerParameters:
                        // Read all the policy set combiner parameters
                        while (reader.Read())
                        {
                            switch (reader.LocalName)
                            {
                            case Consts.Schema2.PolicySetCombinerParameterElement.PolicySetCombinerParameter:
                                _policySetCombinerParameters.Add(new PolicySetCombinerParameterElement(reader, schemaVersion));
                                break;
                            }
                            if (reader.LocalName == Consts.Schema2.PolicySetElement.PolicySetCombinerParameters &&
                                reader.NodeType == XmlNodeType.EndElement)
                            {
                                reader.Read();
                                break;
                            }
                        }
                        break;
                    }
                    if (reader.LocalName == Consts.Schema1.PolicySetElement.PolicySet &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        reader.Read();
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
コード例 #15
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 == Consts.Schema1.PolicyElement.Policy)
            {
                if (!ValidateSchema(reader, schemaVersion))
                {
                    throw new Exception("ģʽÑé֤ʧ°Ü");
                }
                // Read the policy id
                _id = reader.GetAttribute(Consts.Schema1.PolicyElement.PolicyId);

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

                    case Consts.Schema1.PolicyElement.PolicyDefaults:
                        // Read all the policy defaults.
                        if (reader.Read() && reader.Read())
                        {
                            if (reader.LocalName == Consts.Schema1.PolicyDefaultsElement.XPathVersion &&
                                ValidateSchema(reader, schemaVersion))
                            {
                                _xpathVersion = reader.ReadElementString();
                                if (!string.IsNullOrEmpty(_xpathVersion) && _xpathVersion != Consts.Schema1.Namespaces.XPath10)
                                {
                                    throw new Exception(string.Format(Properties.Resource.exc_unsupported_xpath_version, _xpathVersion));
                                }
                            }
                            reader.Read();
                        }
                        break;

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

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

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

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

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

                    case Consts.Schema2.PolicyElement.VariableDefinition:
                        var variable = new VariableDefinitionElement(reader, schemaVersion);
                        _variableDefinitions.Add(variable.Id, variable);
                        break;
                    }
                    if (reader.LocalName == Consts.Schema1.PolicyElement.Policy &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }
コード例 #16
0
ファイル: RuleElement.cs プロジェクト: zszqwe/anycmd
 /// <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)
 {
 }
コード例 #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 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)
 {
 }
コード例 #18
0
ファイル: RuleElement.cs プロジェクト: mingkongbin/anycmd
 /// <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)
 {
 }
コード例 #19
0
ファイル: PolicySetElement.cs プロジェクト: zszqwe/anycmd
 /// <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)
 {
 }
コード例 #20
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 == Consts.Schema1.PolicySetElement.PolicySet &&
                ValidateSchema(reader, schemaVersion))
            {
                // Get the attributes
                _id = reader.GetAttribute(Consts.Schema1.PolicySetElement.PolicySetId);
                _policyCombiningAlgorithm = reader.GetAttribute(Consts.Schema1.PolicySetElement.PolicyCombiningAlgorithmId);

                // Read the inner nodes
                while (reader.Read())
                {
                    switch (reader.LocalName)
                    {
                        case Consts.Schema1.PolicySetElement.Description:
                            _description = reader.ReadElementString();
                            break;
                        case Consts.Schema1.PolicySetElement.PolicySetDefaults:
                            if (reader.Read() && reader.Read())
                            {
                                if (reader.LocalName == Consts.Schema1.PolicySetDefaultsElement.XPathVersion &&
                                    ValidateSchema(reader, schemaVersion))
                                {
                                    _xpathVersion = reader.ReadElementString();
                                    if (!string.IsNullOrEmpty(_xpathVersion) && _xpathVersion != Consts.Schema1.Namespaces.XPath10)
                                    {
                                        throw new Exception(string.Format(Properties.Resource.exc_unsupported_xpath_version, _xpathVersion));
                                    }
                                }
                                reader.Read();
                            }
                            break;
                        case Consts.Schema1.TargetElement.Target:
                            _target = new TargetElementReadWrite(reader, schemaVersion);
                            break;
                        case Consts.Schema1.PolicySetElement.PolicySet:
                            if (!reader.IsEmptyElement && reader.NodeType != XmlNodeType.EndElement)
                            {
                                _policies.Add(new PolicySetElementReadWrite(reader, schemaVersion));
                            }
                            break;
                        case Consts.Schema1.PolicyElement.Policy:
                            _policies.Add(new PolicyElementReadWrite(reader, schemaVersion));
                            break;
                        case Consts.Schema1.PolicySetIdReferenceElement.PolicySetIdReference:
                            _policies.Add(new PolicySetIdReferenceElementReadWrite(reader, schemaVersion));
                            break;
                        case Consts.Schema1.PolicyIdReferenceElement.PolicyIdReference:
                            _policies.Add(new PolicyIdReferenceElement(reader, schemaVersion));
                            break;
                        case Consts.Schema1.PolicySetElement.Obligations:
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema1.ObligationElement.Obligation:
                                        _obligations.Add(new ObligationElementReadWrite(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema1.ObligationsElement.Obligations &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicySetElement.CombinerParameters:
                            // Read all the combiner parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema2.CombinerParameterElement.CombinerParameter:
                                        _combinerParameters.Add(new CombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema2.PolicySetElement.CombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicySetElement.PolicyCombinerParameters:
                            // Read all the policy combiner parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema2.PolicyCombinerParameterElement.PolicyCombinerParameter:
                                        _policyCombinerParameters.Add(new PolicyCombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema2.PolicySetElement.PolicyCombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                        case Consts.Schema2.PolicySetElement.PolicySetCombinerParameters:
                            // Read all the policy set combiner parameters
                            while (reader.Read())
                            {
                                switch (reader.LocalName)
                                {
                                    case Consts.Schema2.PolicySetCombinerParameterElement.PolicySetCombinerParameter:
                                        _policySetCombinerParameters.Add(new PolicySetCombinerParameterElement(reader, schemaVersion));
                                        break;
                                }
                                if (reader.LocalName == Consts.Schema2.PolicySetElement.PolicySetCombinerParameters &&
                                    reader.NodeType == XmlNodeType.EndElement)
                                {
                                    reader.Read();
                                    break;
                                }
                            }
                            break;
                    }
                    if (reader.LocalName == Consts.Schema1.PolicySetElement.PolicySet &&
                        reader.NodeType == XmlNodeType.EndElement)
                    {
                        reader.Read();
                        break;
                    }
                }
            }
            else
            {
                throw new Exception(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }