Пример #1
0
        public DataTypeValue Evaluate(EvaluationContext ctx, string SchemeID)
        {
            var helper = new SelectorXPathHelper();
            var bag    = new BagDataType();

            try
            {
                NodeList ret = helper.EvaluateXPath(
                    this._path.Trim(), ctx.ContentRoot, ctx.Request.Content.XPathNamespaceContext);
                for (int i = 0; i < ret.Length; i++)
                {
                    Node node = ret.Item(i);
                    if (node.TextContent != null)
                    {
                        bag.AddDataType(DataTypeFactory.Instance.CreateValue(this._dataType, node.TextContent));
                    }
                }
            }
            catch (XPathExpressionException)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }

            if (bag.Empty && this._mustBePresent.EqualsIgnoreCase("true"))
            {
                throw new Indeterminate(Indeterminate.IndeterminateProcessingError);
            }

            return(bag);
        }
Пример #2
0
        private TypeInfo CreateBagType(BagDataType bagType)
        {
            var result = new BagTypeInfo();

            SetTypeInfoDelayed(bagType.ElementType, result.SetElementType);

            return(result);
        }
Пример #3
0
        private void ExcuteBag(string functionid, BagDataType input, BagDataType output, EvaluationContext ctx)
        {
            IList children = input.Children;

            for (int i = 0; i < children.Count; i++)
            {
                this.ExcuteOne(functionid, (DataTypeValue)children[i], output, ctx);
            }
        }
Пример #4
0
 public AttributeValue(BagDataType bag)
 {
     this._value = new BagDataType();
     foreach (object o in bag.Children)
     {
         this._value.AddDataType((DataTypeValue)o);
         this._datatype = ((DataTypeValue)o).Identifier.ToString();
     }
 }
Пример #5
0
        public DataTypeValue Evaluate(EvaluationContext ctx, string SchemeID)
        {
            BagDataType ret = ctx.Evaluate(
                this._category, this._attributeId, this._dataType, this._mustBePresent, this._issuer);

            if (ret.Empty && this._mustBePresent.EqualsIgnoreCase("true"))
            {
                throw new Indeterminate(Indeterminate.IndeterminateProcessingError);
            }
            return(ret);
        }
Пример #6
0
 private void ExcuteOne(string functionid, DataTypeValue input, BagDataType output, EvaluationContext ctx)
 {
     DataTypeValue[] newparams = { input };
     try
     {
         output.AddDataType(FunctionFactory.Evaluate(functionid, newparams, ctx));
     }
     catch (Indeterminate ex)
     {
         throw new IllegalExpressionEvaluationException(ex.Message);
     }
 }
Пример #7
0
        public virtual BagDataType Evaluate(string attributeId, string dataType)
        {
            var bag = new BagDataType();

            foreach (AttributeValue attr in this._attributeValues)
            {
                if ((this._attributeId.Value.Equals(attributeId)) && attr.DataType.Equals(dataType))
                {
                    bag.AddDataType(attr.DataTypeValue);
                }
            }
            return(bag);
        }
Пример #8
0
        private bool isContainedInBag(BagDataType bag, DataTypeValue value)
        {
            IList children = bag.Children;

            for (int j = 0; j < children.Count; j++)
            {
                var child2 = (DataTypeValue)children[j];
                if (value.Equals(child2))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #9
0
        private void addDataType(BagDataType bag, DataTypeValue value)
        {
            IList children = bag.Children;

            for (int j = 0; j < children.Count; j++)
            {
                var child = (DataTypeValue)children[j];
                if (child.Equals(value))
                {
                    return;
                }
            }
            bag.AddDataType(value);
        }
Пример #10
0
 public virtual BagDataType Evaluate(string Category, string AttributeId, string DataType)
 {
     if (this._category.Value.Equals(Category))
     {
         foreach (Attribute attr in this._attributes)
         {
             BagDataType ret = attr.Evaluate(AttributeId, DataType);
             if (!ret.Empty)
             {
                 return(ret);
             }
         }
     }
     return(new BagDataType());
 }
Пример #11
0
 public override DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx)
 {
     if (@params.Length >= 2)
     {
         var bag = new BagDataType();
         for (int i = 0; @params[i] is BagDataType && i < @params.Length; i++)
         {
             IList children = @params[i].Children;
             for (int j = 0; j < children.Count; j++)
             {
                 var value = (DataTypeValue)children[j];
                 this.addDataType(bag, value);
             }
         }
         return(bag);
     }
     throw new IllegalExpressionEvaluationException("TypeUnion");
 }
Пример #12
0
        protected internal virtual DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx, Type cls)
        {
            var bag = new BagDataType();

            for (int i = 0; i < @params.Length; i++)
            {
                DataTypeValue param = @params[i];
                if (cls.IsInstance(param))
                {
                    bag.AddDataType(param);
                }
                else
                {
                    throw new IllegalExpressionEvaluationException(this.StringIdentifer);
                }
            }
            return(bag);
        }
Пример #13
0
        private bool IsOneOfBag(string functionid, DataTypeValue one, BagDataType bag, EvaluationContext ctx)
        {
            IList children = bag.Children;

            for (int j = 0; j < children.Count; j++)
            {
                DataTypeValue[] newparams = { one, (DataTypeValue)children[j] };
                try
                {
                    if (BooleanDataType.False.Equals(FunctionFactory.Evaluate(functionid, newparams, ctx)))
                    {
                        return(false);
                    }
                }
                catch (Indeterminate ex)
                {
                    throw new IllegalExpressionEvaluationException(ex.Message);
                }
            }
            return(true);
        }
Пример #14
0
        public virtual BagDataType Evaluate(
            EvaluationContext ctx,
            string Category,
            string AttributeId,
            string DataType,
            string MustBePresent,
            string Issuer)
        {
            var bag = new BagDataType();

            foreach (Attributes attrs in this._attributes)
            {
                BagDataType ret = attrs.Evaluate(Category, AttributeId, DataType);
                if (!ret.Empty)
                {
                    foreach (object o in ret.Children)
                    {
                        bag.AddDataType((DataTypeValue)o);
                    }
                }
            }
            if (bag.Empty)
            {
                if ("urn:oasis:names:tc:xacml:1.0:environment:current-date".Equals(AttributeId))
                {
                    bag.AddDataType(ctx.CurrentDate);
                }
                else if ("urn:oasis:names:tc:xacml:1.0:environment:current-datetime".Equals(AttributeId))
                {
                    bag.AddDataType(ctx.CurrentDateTime);
                }
                else if ("urn:oasis:names:tc:xacml:1.0:environment:current-time".Equals(AttributeId))
                {
                    bag.AddDataType(ctx.CurrentTime);
                }
            }
            return(bag);
        }
Пример #15
0
        public override DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx)
        {
            int size = @params.Length;

            if (size >= paramsnum)
            {
                var    bag        = new BagDataType();
                string functionid = @params[0].Value;
                for (int i = 1; i < size; i++)
                {
                    if (@params[i] is BagDataType)
                    {
                        this.ExcuteBag(functionid, (BagDataType)@params[i], bag, ctx);
                    }
                    else
                    {
                        this.ExcuteOne(functionid, @params[i], bag, ctx);
                    }
                }
                return(bag);
            }
            throw new IllegalExpressionEvaluationException(stringIdentifer);
        }
Пример #16
0
        public AttributeValue(Node node)
        {
            NamedNodeMap allattrs = node.Attributes;

            for (int i = 0; i < allattrs.Length; i++)
            {
                Node child = allattrs.Item(i);
                if (child.NodeName.Equals("DataType"))
                {
                    this._datatype = child.NodeValue;
                }
                else
                {
                    this._anyAttributeName  = child.NodeName;
                    this._anyAttributeValue = child.NodeValue;
                }
            }
            if (this._datatype == null)
            {
                throw new Indeterminate(Indeterminate.IndeterminateSyntaxError);
            }
            this._value = new BagDataType();
            this._value.AddDataType(DataTypeFactory.Instance.CreateValue(this._datatype, node.TextContent));
        }
Пример #17
0
 public override DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx)
 {
     if (@params.Length == 2 && @params[0] is BagDataType && @params[1] is BagDataType)
     {
         var   bag       = new BagDataType();
         IList children0 = @params[0].Children;
         IList children1 = @params[1].Children;
         for (int i = 0; i < children0.Count; i++)
         {
             var child1 = (DataTypeValue)children0[i];
             for (int j = 0; j < children0.Count; j++)
             {
                 var child2 = (DataTypeValue)children1[j];
                 if (child1.Equals(child2))
                 {
                     bag.AddDataType(child1);
                     break;
                 }
             }
         }
         return(bag);
     }
     throw new IllegalExpressionEvaluationException("Intersection");
 }
Пример #18
0
 public DataTypeValue GetInstance(string value)
 {
     return BagDataType.GetInstance(value);
 }
Пример #19
0
 public virtual void VisitBagDataType(BagDataType bagDataType)
 {
     DefaultVisit(bagDataType);
 }
Пример #20
0
 public DataTypeValue GetInstance(Node node)
 {
     return BagDataType.GetInstance(node);
 }