예제 #1
0
        public PolicySchema(Node node, string ID)
        {
            this._rootPolicyId = ID;
            var p = (IPolicyLanguageModel)PolicyElementFactory.GetInstance(node);

            AddPolicyLanguageModel(p.ElementId, p);
        }
예제 #2
0
파일: Apply.cs 프로젝트: develmax/Xacml
        public Apply(Node node)
        {
            Node _FunctionIdNode = node.Attributes.GetNamedItem("FunctionId");

            if (_FunctionIdNode != null)
            {
                this._functionId = _FunctionIdNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
            NodeList children = node.ChildNodes;

            this._description = null;
            this._evaluatable = new List <IEvaluatable>();
            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(Description.stringIdentifer))
                {
                    this._description = (Description)PolicyElementFactory.GetInstance(child);
                }
                else if (child.NodeType == Node.ELEMENT_NODE)
                {
                    IElement e = PolicyElementFactory.GetInstance(child);
                    if (e is IEvaluatable)
                    {
                        this._evaluatable.Add((IEvaluatable)e);
                    }
                }
            }
        }
예제 #3
0
        public VariableDefinition(Node node)
        {
            Node VariableIdNode = node.Attributes.GetNamedItem("VariableId");

            if (VariableIdNode != null)
            {
                this._variableId = VariableIdNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
            this._evaluatable = null;
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeType == Node.ELEMENT_NODE)
                {
                    IElement e = PolicyElementFactory.GetInstance(children.Item(i));
                    if (e is IEvaluatable)
                    {
                        this._evaluatable = (IEvaluatable)e;
                        break;
                    }
                }
            }
            if (this._evaluatable == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }
예제 #4
0
 public CombinerParameter(Node node)
 {
     Node attr = node.Attributes.GetNamedItem("ParameterName");
     if (attr != null)
     {
         this._parameterName = attr.NodeValue;
     }
     else
     {
         throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
     }
     this._attributeValue = null;
     NodeList children = node.ChildNodes;
     for (int i = 0; i < children.Length; i++)
     {
         Node child = children.Item(i);
         if (child.NodeName.Equals(AttributeValue.stringIdentifer))
         {
             this._attributeValue = (AttributeValue)PolicyElementFactory.GetInstance(child);
             break;
         }
     }
     if (this._attributeValue == null)
     {
         throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
     }
 }
예제 #5
0
 public static void Init()
 {
     if (factoryInstance == null)
     {
         InitializeSupportedElements();
         factoryInstance = new PolicyElementFactory();
     }
 }
예제 #6
0
 public static void AddPolicyLanguageModelFromURL(string url)
 {
     try
     {
         Node node = NodeFactory.GetInstanceFromURL(url);
         var  p    = (IPolicyLanguageModel)PolicyElementFactory.GetInstance(node);
         AddPolicyLanguageModel(p.ElementId, p);
     }
     catch (Indeterminate ex)
     {
         Logger.GetLogger(typeof(PolicySchema).Name).Log(null, ex);
     }
 }
예제 #7
0
        public PolicySetDefaults(Node node)
        {
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(XPathVersion.Identifer))
                {
                    this._xPathVersion = (XPathVersion)PolicyElementFactory.GetInstance(child);
                }
            }
        }
예제 #8
0
        public CombinerParameters(Node node)
        {
            this._combinerParameters = new List <CombinerParameter>();
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(CombinerParameter.stringIdentifer))
                {
                    this._combinerParameters.Add((CombinerParameter)PolicyElementFactory.GetInstance(child));
                }
            }
        }
예제 #9
0
파일: Target.cs 프로젝트: develmax/Xacml
        public Target(Node node)
        {
            NodeList Children = node.ChildNodes;

            this._anyofs = new ArrayList();
            for (int i = 0; i < Children.Length; i++)
            {
                Node child = Children.Item(i);
                if (child.NodeName.Equals(AnyOf.stringIdentifer))
                {
                    this._anyofs.Add(PolicyElementFactory.GetInstance(Children.Item(i)));
                }
            }
        }
예제 #10
0
        public AdviceExpressions(Node node)
        {
            this._adviceExpressions = new List <AdviceExpression>();
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(AdviceExpression.stringIdentifer))
                {
                    this._adviceExpressions.Add((AdviceExpression)PolicyElementFactory.GetInstance(child));
                }
            }
            if (this._adviceExpressions.Count == 0)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }
예제 #11
0
        public AttributeAssignmentExpression(Node node)
        {
            this._attributeId = this.GetNodeAttribute(node, "AttributeId", true);
            this._category    = this.GetNodeAttribute(node, "Category", false);
            this._issuer      = this.GetNodeAttribute(node, "Issuer", false);
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeType == Node.ELEMENT_NODE)
                {
                    this._evaluatable = (IEvaluatable)PolicyElementFactory.GetInstance(child);
                }
            }
            if (this._evaluatable == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }
예제 #12
0
        public Rule(Node node)
        {
            Node ruleidnode = node.Attributes.GetNamedItem("RuleId");

            this._ruleId =
                (StringDataType)DataTypeFactory.Instance.CreateValue(StringDataType.URIID, ruleidnode.NodeValue);
            Node effectnode = node.Attributes.GetNamedItem("Effect");

            this._effect = new Effect(effectnode.NodeValue);
            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);
                }
                if (child.NodeName.Equals(Description.stringIdentifer))
                {
                    this._description = (Description)PolicyElementFactory.GetInstance(child);
                }
                if (child.NodeName.Equals(Condition.stringIdentifer))
                {
                    this._condition = (Condition)PolicyElementFactory.GetInstance(child);
                }
                if (child.NodeName.Equals(ObligationExpressions.stringIdentifer))
                {
                    this._obligationExpressions = ((ObligationExpressions)PolicyElementFactory.GetInstance(child));
                }
                if (child.NodeName.Equals(AdviceExpressions.stringIdentifer))
                {
                    this._adviceExpressions = ((AdviceExpressions)PolicyElementFactory.GetInstance(child));
                }
            }
            if (this._target == null && this._condition == null)
            {
                this._isRuleReference = true;
            }
        }
예제 #13
0
        public static void AddPolicyLanguageModelFromDir(string policydir)
        {
            var file = new Directory(policydir);

            string[] fns = file.GetList();
            foreach (string name in fns)
            {
                if (name.EndsWith(".xml"))
                {
                    try
                    {
                        Node node = NodeFactory.GetInstanceFromFile(file.AbsolutePath + "/" + name);
                        var  p    = (IPolicyLanguageModel)PolicyElementFactory.GetInstance(node);
                        AddPolicyLanguageModel(p.ElementId, p);
                    }
                    catch (Indeterminate ex)
                    {
                        Logger.GetLogger(typeof(PolicySchema).Name).Log(null, ex);
                    }
                }
            }
        }
예제 #14
0
        private AdviceExpression(Node node)
        {
            Node AdviceIdNode = node.Attributes.GetNamedItem("AdviceId");

            if (AdviceIdNode != null)
            {
                this._adviceId = AdviceIdNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }

            Node AppliesToNode = node.Attributes.GetNamedItem("AppliesTo");

            if (AdviceIdNode != null)
            {
                this._appliesTo = AppliesToNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }

            this._attributeAssignmentExpressions = new List <AttributeAssignmentExpression>();

            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(AttributeAssignmentExpression.stringIdentifer))
                {
                    this._attributeAssignmentExpressions.Add(
                        (AttributeAssignmentExpression)PolicyElementFactory.GetInstance(child));
                }
            }
        }
예제 #15
0
        public Condition(Node node)
        {
            this._evaluatable = null;
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeType == Node.ELEMENT_NODE)
                {
                    IElement e = PolicyElementFactory.GetInstance(children.Item(i));
                    if (e != null && e is IEvaluatable)
                    {
                        this._evaluatable = (IEvaluatable)e;
                        break;
                    }
                }
            }
            if (this._evaluatable == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
        }
예제 #16
0
        private ObligationExpression(Node node)
        {
            Node ObligationIdNode = node.Attributes.GetNamedItem("ObligationId");

            if (ObligationIdNode != null)
            {
                this._obligationId = ObligationIdNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }

            Node FulfillOnNode = node.Attributes.GetNamedItem("FulfillOn");

            if (FulfillOnNode != null)
            {
                this._fulfillOn = FulfillOnNode.NodeValue;
            }
            else
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }

            this._attributeAssignmentExpressions = new List <AttributeAssignmentExpression>();
            NodeList children = node.ChildNodes;

            for (int i = 0; i < children.Length; i++)
            {
                Node child = children.Item(i);
                if (child.NodeName.Equals(AttributeAssignmentExpression.stringIdentifer))
                {
                    this._attributeAssignmentExpressions.Add(
                        (AttributeAssignmentExpression)PolicyElementFactory.GetInstance(child));
                }
            }
        }
예제 #17
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);
            }
        }
예제 #18
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);
            }
        }