Esempio n. 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);
        }
Esempio n. 2
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);
     }
 }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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");
 }