Ejemplo n.º 1
0
        public PolicySet(Node node)
        {
            this._policySetId          = this.GetNodeAttribute(node, "PolicySetId", true);
            this._version              = this.GetNodeAttribute(node, "Version", true);
            this._policyCombiningAlgId = this.GetNodeAttribute(node, "PolicyCombiningAlgId", true);
            string MaxDelegationDepthStr = this.GetNodeAttribute(node, "MaxDelegationDepth", false);

            if (MaxDelegationDepthStr != null)
            {
                this._maxDelegationDepth = Convert.ToInt32(MaxDelegationDepthStr);
            }

            this._policies = new List <IPolicyLanguageModel>();
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node   child = children.Item(i);
                string name  = child.NodeName;
                if (name.Equals(Description.stringIdentifer))
                {
                    this._description = (Description)PolicyElementFactory.GetInstance(child);
                }
                else if (name.Equals(PolicyIssuer.stringIdentifer))
                {
                    this._policyIssuer = (PolicyIssuer)PolicyElementFactory.GetInstance(child);
                }
                else if (name.Equals(Target.stringIdentifer))
                {
                    this._target = (Target)PolicyElementFactory.GetInstance(child);
                }
                else if (name.Equals(PolicySetDefaults.stringIdentifer))
                {
                    this._policySetDefaults = (PolicySetDefaults)PolicyElementFactory.GetInstance(child);
                }
                else if (name.Equals(stringIdentifer))
                {
                    var ps = (PolicySet)PolicyElementFactory.GetInstance(child);
                    PolicySchema.AddPolicyLanguageModel(ps.ElementId, ps);
                    this._policies.Add(ps);
                }
                else if (name.Equals(Policy.stringIdentifer))
                {
                    var p = (Policy)PolicyElementFactory.GetInstance(child);
                    PolicySchema.AddPolicyLanguageModel(p.ElementId, p);
                    this._policies.Add(p);
                }
                else if (name.Equals(PolicyIdReference.Identifer))
                {
                    var pref = (PolicyIdReference)PolicyElementFactory.GetInstance(child);
                    this._policies.Add(pref);
                }
                else if (name.Equals(ObligationExpressions.stringIdentifer))
                {
                    this._obligationExpressions = ((ObligationExpressions)PolicyElementFactory.GetInstance(child));
                }
                else if (name.Equals(PolicySetIdReference.Identifer))
                {
                    var psref = (PolicySetIdReference)PolicyElementFactory.GetInstance(child);
                    this._policies.Add(psref);
                }
                else if (name.Equals(PolicyCombinerParameters.stringIdentifer))
                {
                    var pcp = (PolicyCombinerParameters)PolicyElementFactory.GetInstance(child);
                    this._policies.Add(pcp);
                }
                else if (name.Equals(PolicySetCombinerParameters.stringIdentifer))
                {
                    var pscp = (PolicySetCombinerParameters)PolicyElementFactory.GetInstance(child);
                    this._policies.Add(pscp);
                }
                else if (name.Equals(CombinerParameters.stringIdentifer))
                {
                    var cp = (CombinerParameters)PolicyElementFactory.GetInstance(child);
                    this._policies.Add(cp);
                }
                else if (name.Equals(AdviceExpressions.stringIdentifer))
                {
                    this._adviceExpressions = ((AdviceExpressions)PolicyElementFactory.GetInstance(child));
                }
            }

            if (this._target == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }
Ejemplo n.º 2
0
        public Policy(Node node)
        {
            this._policyId           = this.GetNodeAttribute(node, "PolicyId", true);
            this._version            = this.GetNodeAttribute(node, "Version", true);
            this._ruleCombiningAlgId = this.GetNodeAttribute(node, "RuleCombiningAlgId", true);
            this._maxDelegationDepth = this.GetNodeAttribute(node, "MaxDelegationDepth", false);

            this._policyLanguageModels = new List <IPolicyLanguageModel>();
            this._variableDefinitions  = new Dictionary <string, VariableDefinition>();
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(Target.stringIdentifer))
                {
                    this._target = (Target)PolicyElementFactory.GetInstance(child);
                }
                else if (child.NodeName.Equals(Rule.stringIdentifer))
                {
                    var r = (Rule)PolicyElementFactory.GetInstance(child);
                    r.PolicyParentID = this._policyId;
                    PolicySchema.AddPolicyLanguageModel(r.ElementId, r);
                    this._policyLanguageModels.Add(r);
                }
                else if (child.NodeName.Equals(Description.stringIdentifer))
                {
                    this._description = (Description)PolicyElementFactory.GetInstance(child);
                }
                else if (child.NodeName.Equals(PolicyIssuer.stringIdentifer))
                {
                    this._policyIssuer = (PolicyIssuer)PolicyElementFactory.GetInstance(child);
                }
                else if (child.NodeName.Equals(PolicyDefaults.stringIdentifer))
                {
                    this._policyDefaults = (PolicyDefaults)PolicyElementFactory.GetInstance(child);
                }
                else if (child.NodeName.Equals(VariableDefinition.stringIdentifer))
                {
                    var vd = (VariableDefinition)PolicyElementFactory.GetInstance(child);
                    this._variableDefinitions.Add(vd.VariableId, vd);
                }
                else if (child.NodeName.Equals(RuleCombinerParameters.stringIdentifer))
                {
                    var rcp = ((RuleCombinerParameters)PolicyElementFactory.GetInstance(child));
                    this._policyLanguageModels.Add(rcp);
                }
                else if (child.NodeName.Equals(CombinerParameters.stringIdentifer))
                {
                    var cp = ((CombinerParameters)PolicyElementFactory.GetInstance(child));
                    this._policyLanguageModels.Add(cp);
                }
                else if (child.NodeName.Equals(ObligationExpressions.stringIdentifer))
                {
                    this._obligationExpressions = (((ObligationExpressions)PolicyElementFactory.GetInstance(child)));
                }
                else if (child.NodeName.Equals(AdviceExpressions.stringIdentifer))
                {
                    this._adviceExpressions = ((AdviceExpressions)PolicyElementFactory.GetInstance(child));
                }
            }
            if (this._target == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }