Example #1
0
        public override bool Visit(ObjectAccess node)
        {
            /*
             * if (node.obj is IdentifierStatic && node.Parent is Assignment)
             * {
             *      Assignment ass = node.Parent as Assignment;
             *      Identifier id = ass.lvalue as Identifier;
             *      IdentifierStatic stid = node.obj as IdentifierStatic;
             *      string objname = id.name;
             *      outputCode("new " + stid.name + "();", false, false);
             *      outputCode("", false, true);
             *      outputCode(objname + "->", true, false);
             * }
             * else
             */
            {
                if (node.obj is IdentifierStatic)
                {
                    IdentifierStatic stid = node.obj as IdentifierStatic;
                    outputCode(stid.name, false, false);
                }
                else
                {
                    traverse(node.obj);
                }
                outputCode(".", false, false);
            }

            outputCode(node.field, false, false);

            return(true);
        }
Example #2
0
        public override bool Visit(RoutineCall node)
        {
            //Visit((LvalueExpression) node);

            // string name = (node.func as Identifier).name;
            traverse(node.func);
            outputCode("(", false, false);
            int i = 0;

            foreach (Expression n in node.args)
            {
                if (i > 0)
                {
                    outputCode(", ", false, false);
                }
                traverse(n);
                i++;
            }
            outputCode(")", false, false);

            if (node.func.Type is MethodType)
            {
                MethodType met = (node.func.Type as MethodType);
                if (met.IsDestructor)
                {
                    outputCode(";", false, true);
                    ObjectAccess oa  = node.func as ObjectAccess;
                    Identifier   obj = oa.obj as Identifier;
                    outputCode("delete " + obj.name, true, false);
                }
            }

            return(true);
        }
Example #3
0
 public DryveMessage(UInt16 txnId, DryveObject dryveObject, ObjectAccess objectAccess, byte[] dataValue = null)
 {
     _txnId        = txnId;
     _dryveObject  = dryveObject;
     _objectAccess = objectAccess;
     _dataValue    = dataValue == null ? new byte[0] : dataValue;
     MessageBytes  = ConstructMessage();
 }
        /// <summary>
        /// Generate signed URL for the OSS object.
        /// </summary>
        private static async Task <string> GetSignedUrl(IObjectsApi api, string bucketKey, string objectName,
                                                        ObjectAccess access = ObjectAccess.Read, int minutesExpiration = 30)
        {
            var     signature = new PostBucketsSigned(minutesExpiration);
            dynamic result    = await api.CreateSignedResourceAsync(bucketKey, objectName, signature, AsString(access));

            return(result.signedUrl);
        }
Example #5
0
        public override Node VisitObjectAccess(TParser.ObjectAccessContext context)
        {
            var path = new NodesCollection <Node>(context.Start);

            VisitObjectAccess(context, path);
            var obj = new ObjectAccess(path[0], null, path[0].Position);

            foreach (var node in path.Skip(1))
            {
                obj = new ObjectAccess(node, obj, node.Position);
            }
            return(obj);
        }
Example #6
0
        private byte[] SendAndReceive(DryveObject messageType, int wait = 50, ObjectAccess accessType = ObjectAccess.Read, byte[] dataValue = null, ResultFormat format = ResultFormat.Binary)
        {
            DryveMessage msg = new DryveMessage(_txnId, messageType, accessType, dataValue);

            byte[] message = msg.MessageBytes;
            _txnId++;

            _client.SendMessage(message);
            System.Threading.Thread.Sleep(wait);

            var msgLength = accessType == ObjectAccess.Read ? message.Length + (int)message[18] : 19;
            var result    = _client.ReceiveMessage(msgLength);

            if (!result.Take(2).SequenceEqual(message.Take(2)))
            {
                throw new Exception("Communication error - Transaction ID mismatch.");
            }
            return(result);
        }
 public MemberAccessPermissionItem FindAccessItem(Type objectType, ObjectAccess access)
 {
     return(null);
     //            Type currentType = objectType;
     //            while (true)
     //            {
     //                bool needToCheckPersistentBaseObjectTypePermission = true;
     //                if (currentType != null && currentType.BaseType != null &&
     //                    PermissionTargetBusinessClassListConverter.PersistentBaseObjectType.IsAssignableFrom(currentType.BaseType))
     //                {
     //                    needToCheckPersistentBaseObjectTypePermission = false;
     //                }
     //                if (needToCheckPersistentBaseObjectTypePermission && PermissionTargetBusinessClassListConverter.PersistentBaseObjectType.IsAssignableFrom(currentType))
     //                {
     //                    ParticularAccessItem persistentBaseObjectItem = FindExactItem(PermissionTargetBusinessClassListConverter.PersistentBaseObjectType, access);
     //                    if (persistentBaseObjectItem != null)
     //                    {
     //                        return persistentBaseObjectItem;
     //                    }
     //                }
     //                ParticularAccessItem item = FindExactItem(currentType, access);
     //                if (item != null)
     //                {
     //                    return item;
     //                }
     //                if ((currentType != null) && currentType.IsInterface)
     //                {
     //                    currentType = typeof(object);
     //                }
     //                else
     //                {
     //                    if ((currentType == null) || (currentType == typeof(object)))
     //                    {
     //                        break;
     //                    }
     //                    currentType = currentType.BaseType;
     //                }
     //            }
     //            return null;
 }
 public ConditionalObjectAccessPermission(Type objectType, ObjectAccess objectAccess, ObjectAccessModifier modifier) : base(objectType, objectAccess, modifier)
 {
 }
 public ConditionalObjectAccessPermission(Type objectType, ObjectAccess access, SecurityContextList contexts) : base(objectType, access, contexts)
 {
 }
 public ConditionalObjectAccessPermission(Type objectType, ObjectAccess access) : base(objectType, access)
 {
 }
 public ConditionalParticularAccessItem(Type objectType, ObjectAccess particularAccess, ObjectAccessModifier modifier, string condition)
     : base(objectType, particularAccess, modifier)
 {
     Condition = condition ?? string.Empty;
 }
 public ConditionalParticularAccessItem(Type objectType, ObjectAccess particularAccess, ObjectAccessModifier modifier)
     : this(objectType, particularAccess, modifier, string.Empty)
 {
 }
 public virtual T Visit(ObjectAccess node)
 {
     Visit((LvalueExpression)node);
     return(traverse(node.obj));
 }
 private static string AsString(ObjectAccess access)
 {
     return(access.ToString().ToLowerInvariant());
 }
 /// <summary>
 /// Generate a signed URL to OSS object.
 /// NOTE: An empty object created if not exists.
 /// </summary>
 /// <param name="bucketKey">Bucket key.</param>
 /// <param name="objectName">Object name.</param>
 /// <param name="access">Requested access to the object.</param>
 /// <param name="minutesExpiration">Minutes while the URL is valid. Default is 30 minutes.</param>
 /// <returns>Signed URL</returns>
 public async Task <string> CreateSignedUrlAsync(string bucketKey, string objectName, ObjectAccess access = ObjectAccess.Read, int minutesExpiration = 30)
 {
     return(await WithObjectsApiAsync(async api => await GetSignedUrl(api, bucketKey, objectName, access, minutesExpiration)));
 }
 public ConditionalObjectAccessPermission(Type objectType, ObjectAccess access, params DevExpress.ExpressApp.Security.SecurityContext[] securityContexts) : base(objectType, access, securityContexts)
 {
 }
Example #17
0
 public override bool Visit(ObjectAccess node)
 {
     Visit((LvalueExpression)node);
     TraversePrint(node.obj);
     return(true);
 }
Example #18
0
        private object EvaluateNode(ObjectPathNode expression, Context context)
        {
            var    originalContext = context;
            object result          = context.Unwrap();
            var    tmp             = context;

            foreach (var path in expression.path)
            {
                if (path is StaticObjectPathPartNode)
                {
                    var key = ((StaticObjectPathPartNode)path).name;
                    result = ObjectAccess.GetProperty(result, key);
                    // tmp = (Context)EvaluateNode((StaticObjectPathPartNode)path, context);
                }
                if (path is MethodCallNode)
                {
                    var methodCall = (MethodCallNode)path;
                    var callee     = result;
                    if (callee == null)
                    {
                        // TODO this might happen if a function is registered directly in the context
                        continue;
                    }
                    if (!this.CanCallMethod(callee, methodCall.name))
                    {
                        throw new EvaluationException($"Method {methodCall.name} cannot be called on the given object");
                    }
                    var methodInfo = callee.GetType().GetMethod(methodCall.name);
                    if (methodInfo == null)
                    {
                        throw new EvaluationException($"Method ${methodCall.name} does not exist on the given object");
                    }
                    var parameters = new List <object>();
                    for (var i = 0; i < methodCall.arguments.Length; i++)
                    {
                        var argNode  = methodCall.arguments[i];
                        var argValue = EvaluateNode(argNode, context);
                        if (argValue is float)
                        {
                            var parameterInfo = methodInfo.GetParameters()[i];
                            if (parameterInfo.ParameterType == typeof(int))
                            {
                                argValue = Convert.ToInt32(argValue);
                            }
                        }
                        parameters.Add(argValue);
                    }
                    for (var i = methodCall.arguments.Length; i < methodInfo.GetParameters().Length; i++)
                    {
                        var parameterInfo = methodInfo.GetParameters()[i];
                        if (parameterInfo.IsOptional)
                        {
                            parameters.Add(parameterInfo.DefaultValue);
                        }
                    }
                    // var parameters = methodCall.arguments.Select(argNode => EvaluateNode(argNode, context)).ToArray();
                    var callResult = methodInfo.Invoke(tmp, parameters.ToArray());
                    result = callResult;
                }
                if (path is OffsetAccessNode)
                {
                    var offset = Convert.ToString(EvaluateNode(((OffsetAccessNode)path).exp, context));
                    var value  = ObjectAccess.GetProperty(result, offset);
                    result = value;
                }
            }
            return(result);
        }
Example #19
0
 public ObjectBase()
 {
     Flag   = ObjectFlag.Literal;
     Access = ObjectAccess.Unlimited;
 }
 /// <summary>
 /// Generate a signed URL to OSS object.
 /// NOTE: An empty object created if not exists.
 /// </summary>
 /// <param name="objectName">Object name.</param>
 /// <param name="access">Requested access to the object.</param>
 /// <param name="minutesExpiration">Minutes while the URL is valid. Default is 30 minutes.</param>
 /// <returns>Signed URL</returns>
 public async Task <string> CreateSignedUrlAsync(string objectName, ObjectAccess access = ObjectAccess.Read, int minutesExpiration = 30)
 {
     return(await _forgeOSS.CreateSignedUrlAsync(BucketKey, objectName, access, minutesExpiration));
 }