Beispiel #1
0
        /// <summary>
        /// Traverses the token and checks whether all required expression values
        /// and functions are provided.
        /// </summary>
        public static bool CheckHasRequiredContext(
            this TemplateToken token,
            IReadOnlyObject expressionValues,
            IList<IFunctionInfo> expressionFunctions)
        {
            var expressionTokens = token.Traverse()
                .OfType<BasicExpressionToken>()
                .ToArray();
            var parser = new ExpressionParser();
            foreach (var expressionToken in expressionTokens)
            {
                var tree = parser.ValidateSyntax(expressionToken.Expression, null);
                foreach (var node in tree.Traverse())
                {
                    if (node is NamedValue namedValue)
                    {
                        if (expressionValues?.Keys.Any(x => string.Equals(x, namedValue.Name, StringComparison.OrdinalIgnoreCase)) != true)
                        {
                            return false;
                        }
                    }
                    else if (node is Function function &&
                        !ExpressionConstants.WellKnownFunctions.ContainsKey(function.Name) &&
                        expressionFunctions?.Any(x => string.Equals(x.Name, function.Name, StringComparison.OrdinalIgnoreCase)) != true)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
Beispiel #2
0
 public ObjectEnumerator(
     EvaluationContext context,
     EvaluationResult result,
     IReadOnlyObject obj)
 {
     m_context    = context;
     m_result     = result;
     m_enumerator = obj.GetEnumerator();
 }
Beispiel #3
0
        private void ApplyAuthorizationRules(Control control)
        {
            foreach (Binding binding in control.DataBindings)
            {
                // get the BindingSource if appropriate
                if (binding.DataSource is BindingSource)
                {
                    BindingSource bs =
                        (BindingSource)binding.DataSource;
                    // get the object property name
                    string propertyName =
                        binding.BindingMemberInfo.BindingField;
                    // get the BusinessObject if appropriate
                    if (bs.DataSource is BusinessBase)
                    {
                        BusinessBase ds =
                            (BusinessBase)bs.DataSource;

                        ApplyReadRules(
                            control, binding,
                            ds.CanReadProperty(propertyName));
                        ApplyWriteRules(
                            control, binding,
                            ds.CanWriteProperty(propertyName));
                    }
                    else if (bs.DataSource is IReadOnlyObject)
                    {
                        IReadOnlyObject ds =
                            (IReadOnlyObject)bs.DataSource;

                        ApplyReadRules(
                            control, binding,
                            ds.CanReadProperty(propertyName));
                    }
                }
            }
        }
Beispiel #4
0
        private void CreateSecurityDemoObjects()
        {
            IFullAccessObject fullAccessObject = ObjectSpace.FindObject <IFullAccessObject>(new BinaryOperator("Name", "Fully Accessible Object"));

            if (fullAccessObject == null)
            {
                fullAccessObject      = ObjectSpace.CreateObject <IFullAccessObject>();
                fullAccessObject.Name = "Fully Accessible Object";
            }
            IProtectedContentObject protectedContentObject = ObjectSpace.FindObject <IProtectedContentObject>(new BinaryOperator("Name", "Protected Object"));

            if (protectedContentObject == null)
            {
                protectedContentObject      = ObjectSpace.CreateObject <IProtectedContentObject>();
                protectedContentObject.Name = "Protected Object";
            }
            IReadOnlyObject readOnlyObject = ObjectSpace.FindObject <IReadOnlyObject>(new BinaryOperator("Name", "Read-Only Object"));

            if (readOnlyObject == null)
            {
                readOnlyObject      = ObjectSpace.CreateObject <IReadOnlyObject>();
                readOnlyObject.Name = "Read-Only Object";
            }

            IIrremovableObject irremovableObject = ObjectSpace.FindObject <IIrremovableObject>(new BinaryOperator("Name", "Protected Deletion Object"));

            if (irremovableObject == null)
            {
                irremovableObject      = ObjectSpace.CreateObject <IIrremovableObject>();
                irremovableObject.Name = "Protected Deletion Object";
            }
            IUncreatableObject uncreatableObject = ObjectSpace.FindObject <IUncreatableObject>(new BinaryOperator("Name", "Protected Creation Object"));

            if (uncreatableObject == null)
            {
                uncreatableObject      = ObjectSpace.CreateObject <IUncreatableObject>();
                uncreatableObject.Name = "Protected Creation Object";
            }
            IMemberLevelSecurityObject memberLevelSecurityObject = ObjectSpace.FindObject <IMemberLevelSecurityObject>(new BinaryOperator("Name", "Member-Level Protected Object"));

            if (memberLevelSecurityObject == null)
            {
                memberLevelSecurityObject      = ObjectSpace.CreateObject <IMemberLevelSecurityObject>();
                memberLevelSecurityObject.Name = "Member-Level Protected Object";
                memberLevelSecurityObject.ProtectedContentProperty = "Secure Property Value";
                memberLevelSecurityObject.ReadWriteProperty        = "Read Write Property Value";
                memberLevelSecurityObject.ReadOnlyProperty         = "Read Only Property Value";
                IMemberLevelReferencedObject1 obj1 = ObjectSpace.CreateObject <IMemberLevelReferencedObject1>();
                obj1.Name = "Referenced Object Type 1";
                memberLevelSecurityObject.ProtectedContentCollection.Add(obj1);
                IMemberLevelReferencedObject2 obj2 = ObjectSpace.CreateObject <IMemberLevelReferencedObject2>();
                obj2.Name = "Referenced Object Type 2";
                memberLevelSecurityObject.ReadOnlyCollection.Add(obj2);
            }
            IObjectLevelSecurityObject fullAccessObjectObject = ObjectSpace.FindObject <IObjectLevelSecurityObject>(new BinaryOperator("Name", "Fully Accessible Object"));

            if (fullAccessObjectObject == null)
            {
                fullAccessObjectObject      = ObjectSpace.CreateObject <IObjectLevelSecurityObject>();
                fullAccessObjectObject.Name = "Fully Accessible Object";
            }
            IObjectLevelSecurityObject protectedContentObjectObject = ObjectSpace.FindObject <IObjectLevelSecurityObject>(new BinaryOperator("Name", "Protected Object"));

            if (protectedContentObjectObject == null)
            {
                protectedContentObjectObject      = ObjectSpace.CreateObject <IObjectLevelSecurityObject>();
                protectedContentObjectObject.Name = "Protected Object";
            }
            IObjectLevelSecurityObject readOnlyObjectObject = ObjectSpace.FindObject <IObjectLevelSecurityObject>(new BinaryOperator("Name", "Read-Only Object"));

            if (readOnlyObjectObject == null)
            {
                readOnlyObjectObject      = ObjectSpace.CreateObject <IObjectLevelSecurityObject>();
                readOnlyObjectObject.Name = "Read-Only Object";
            }
            IObjectLevelSecurityObject irremovableObjectObject = ObjectSpace.FindObject <IObjectLevelSecurityObject>(new BinaryOperator("Name", "Protected Deletion Object"));

            if (irremovableObjectObject == null)
            {
                irremovableObjectObject      = ObjectSpace.CreateObject <IObjectLevelSecurityObject>();
                irremovableObjectObject.Name = "Protected Deletion Object";
            }
        }