Ejemplo n.º 1
0
        public void Handle(HttpApplication httpApplication)
        {
            object            data = null;
            string            str  = null;
            Hashtable         hashtable;
            bool              debug = false;
            CompressionLevels none  = CompressionLevels.None;

            if ((FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.Swx) || (FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.All))
            {
                none = FluorineConfiguration.Instance.HttpCompressSettings.CompressionLevel;
            }
            bool allowDomain = FluorineConfiguration.Instance.SwxSettings.AllowDomain;

            try
            {
                NameValueCollection queryString;
                string str5;
                if (httpApplication.Request.RequestType == "GET")
                {
                    queryString = httpApplication.Request.QueryString;
                }
                else
                {
                    queryString = httpApplication.Request.Form;
                }
                string typeName   = queryString["serviceClass"];
                string methodName = queryString["method"];
                string str4       = queryString["args"];
                str   = queryString["url"];
                debug = (queryString["debug"] != null) ? Convert.ToBoolean(queryString["debug"]) : false;
                if (str != null)
                {
                    str = HttpUtility.UrlDecode(str);
                    str = str.Replace("///", "//");
                    try
                    {
                        UriBuilder builder = new UriBuilder(str);
                    }
                    catch (UriFormatException)
                    {
                        if (log.get_IsWarnEnabled())
                        {
                            str5 = __Res.GetString("Swx_InvalidCrossDomainUrl", new object[] { str });
                            log.Warn(str5);
                        }
                        str = null;
                    }
                }
                else if (allowDomain && log.get_IsWarnEnabled())
                {
                    str5 = "No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting";
                    log.Warn(str5);
                }
                switch (str4)
                {
                case "undefined":
                case string.Empty:
                    str4 = "[]";
                    break;
                }
                object[]        arguments  = (JavaScriptConvert.DeserializeObject(str4.Replace(@"\t", "\t").Replace(@"\n", "\n").Replace(@"\'", "'")) as JavaScriptArray).ToArray();
                object          obj3       = ObjectFactory.CreateInstance(typeName);
                MethodInfo      methodInfo = MethodHandler.GetMethod(obj3.GetType(), methodName, arguments);
                ParameterInfo[] parameters = methodInfo.GetParameters();
                TypeHelper.NarrowValues(arguments, parameters);
                data = new InvocationHandler(methodInfo).Invoke(obj3, arguments);
            }
            catch (TargetInvocationException exception)
            {
                hashtable            = new Hashtable();
                hashtable["error"]   = true;
                hashtable["code"]    = "SERVER.PROCESSING";
                hashtable["message"] = exception.InnerException.Message;
                data = hashtable;
            }
            catch (Exception exception2)
            {
                hashtable            = new Hashtable();
                hashtable["error"]   = true;
                hashtable["code"]    = "SERVER.PROCESSING";
                hashtable["message"] = exception2.Message;
                data = hashtable;
            }
            byte[] buffer = new SwxAssembler().WriteSwf(data, debug, none, str, allowDomain);
            httpApplication.Response.Clear();
            httpApplication.Response.ClearHeaders();
            httpApplication.Response.Buffer      = true;
            httpApplication.Response.ContentType = "application/swf";
            int length = buffer.Length;

            httpApplication.Response.AppendHeader("Content-Length", length.ToString());
            httpApplication.Response.AppendHeader("Content-Disposition", "attachment; filename=data.swf");
            if (buffer.Length > 0)
            {
                httpApplication.Response.OutputStream.Write(buffer, 0, buffer.Length);
            }
            try
            {
                httpApplication.Response.Flush();
            }
            catch (SecurityException)
            {
            }
        }
Ejemplo n.º 2
0
        public void Handle(HttpApplication httpApplication)
        {
            object            result           = null;
            string            url              = null;
            bool              debug            = false;
            CompressionLevels compressionLevel = CompressionLevels.None;

            if (FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.Swx ||
                FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.All)
            {
                compressionLevel = FluorineConfiguration.Instance.HttpCompressSettings.CompressionLevel;
            }
            bool allowDomain = FluorineConfiguration.Instance.SwxSettings.AllowDomain;

            try
            {
                NameValueCollection parameters;
                if (httpApplication.Request.RequestType == "GET")
                {
                    parameters = httpApplication.Request.QueryString;
                }
                else
                {
                    parameters = httpApplication.Request.Form;
                }

                string serviceClass = parameters["serviceClass"];
                string operation    = parameters["method"];
                string args         = parameters["args"];
                url   = parameters["url"];
                debug = parameters["debug"] != null?FluorineFx.Util.Convert.ToBoolean(parameters["debug"]) : false;

                if (url != null)
                {
                    url = HttpUtility.UrlDecode(url);
                    // Firefox/Flash (at least, and tested only on a Mac), sends
                    // file:/// (three slashses) in the URI and that fails the validation
                    // so replacing that with two slashes instead.
                    url = url.Replace("///", "//");

                    try
                    {
                        UriBuilder uriBuilder = new UriBuilder(url);
                    }
                    catch (UriFormatException)
                    {
                        if (log.IsWarnEnabled)
                        {
                            string msg = __Res.GetString(__Res.Swx_InvalidCrossDomainUrl, url);
                            log.Warn(msg);
                        }
                        url = null;
                    }
                }
                else
                {
                    if (allowDomain && log.IsWarnEnabled)
                    {
                        string msg = "No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting";
                        log.Warn(msg);
                    }
                }
                // If the user did not pass an args array, treat it as
                // an empty args array. (Although this may be an error
                // on the client side, it may also be the user calling
                // a method that doesn't take arguments and we shouldn't
                // force the user to create an args parameter with an empty
                // array.)
                if (args == "undefined" || args == string.Empty)
                {
                    args = "[]";
                }
                // Massage special characters back
                args = args.Replace("\\t", "\t");
                args = args.Replace("\\n", "\n");
                args = args.Replace("\\'", "'");

                FluorineFx.Json.JavaScriptArray argsArray = FluorineFx.Json.JavaScriptConvert.DeserializeObject(args) as FluorineFx.Json.JavaScriptArray;
                object[] arguments = argsArray.ToArray();

                object          instance       = ObjectFactory.CreateInstance(serviceClass);
                MethodInfo      mi             = MethodHandler.GetMethod(instance.GetType(), operation, arguments);
                ParameterInfo[] parameterInfos = mi.GetParameters();
                TypeHelper.NarrowValues(arguments, parameterInfos);
                InvocationHandler invocationHandler = new InvocationHandler(mi);
                result = invocationHandler.Invoke(instance, arguments);
            }
            catch (TargetInvocationException exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"]   = true;
                resultObj["code"]    = "SERVER.PROCESSING";
                resultObj["message"] = exception.InnerException.Message;
                result = resultObj;
            }
            catch (Exception exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"]   = true;
                resultObj["code"]    = "SERVER.PROCESSING";
                resultObj["message"] = exception.Message;
                result = resultObj;
            }

            SwxAssembler assembler = new SwxAssembler();

            byte[] buffer = assembler.WriteSwf(result, debug, compressionLevel, url, allowDomain);
            httpApplication.Response.Clear();
            httpApplication.Response.ClearHeaders();
            httpApplication.Response.Buffer      = true;
            httpApplication.Response.ContentType = "application/swf";
            httpApplication.Response.AppendHeader("Content-Length", buffer.Length.ToString());
            httpApplication.Response.AppendHeader("Content-Disposition", "attachment; filename=data.swf");
            if (buffer.Length > 0)
            {
                httpApplication.Response.OutputStream.Write(buffer, 0, buffer.Length);
            }
            try
            {
                httpApplication.Response.Flush();
            }
            catch (SecurityException)
            {
            }
        }
Ejemplo n.º 3
0
        public void Handle(HttpApplication httpApplication)
        {
            object result = null;
            string url = null;
            bool debug = false;
            CompressionLevels compressionLevel = CompressionLevels.None;
			if( FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.Swx || 
				FluorineConfiguration.Instance.HttpCompressSettings.HandleRequest == HandleRequest.All )
				compressionLevel = FluorineConfiguration.Instance.HttpCompressSettings.CompressionLevel;
            bool allowDomain = FluorineConfiguration.Instance.SwxSettings.AllowDomain;
            try
            {
                NameValueCollection parameters;
                if (httpApplication.Request.RequestType == "GET")
                    parameters = httpApplication.Request.QueryString;
                else
                    parameters = httpApplication.Request.Form;

                string serviceClass = parameters["serviceClass"];
                string operation = parameters["method"];
                string args = parameters["args"];
                url = parameters["url"];
                debug = parameters["debug"] != null ? FluorineFx.Util.Convert.ToBoolean(parameters["debug"]) : false;

				if (url != null)
				{
					url = HttpUtility.UrlDecode(url);
					// Firefox/Flash (at least, and tested only on a Mac), sends 
					// file:/// (three slashses) in the URI and that fails the validation
					// so replacing that with two slashes instead.
					url = url.Replace("///", "//");

					try
					{
						UriBuilder uriBuilder = new UriBuilder(url);
					}
					catch (UriFormatException)
					{
						if (log.IsWarnEnabled)
						{
							string msg = __Res.GetString(__Res.Swx_InvalidCrossDomainUrl, url);
							log.Warn(msg);
						}
						url = null;
					}
				}
				else
				{
					if (allowDomain && log.IsWarnEnabled)
					{
						string msg = "No referring URL received from Flash. Cross-domain will not be supported on this call regardless of allowDomain setting";
						log.Warn(msg);
					}
				}
                // If the user did not pass an args array, treat it as
                // an empty args array. (Although this may be an error
                // on the client side, it may also be the user calling
                // a method that doesn't take arguments and we shouldn't
                // force the user to create an args parameter with an empty
                // array.)
                if (args == "undefined" || args == string.Empty)
                    args = "[]";
                // Massage special characters back
                args = args.Replace("\\t", "\t");
                args = args.Replace("\\n", "\n");
                args = args.Replace("\\'", "'");

                FluorineFx.Json.JavaScriptArray argsArray = FluorineFx.Json.JavaScriptConvert.DeserializeObject(args) as FluorineFx.Json.JavaScriptArray;
                object[] arguments = argsArray.ToArray();

                object instance = ObjectFactory.CreateInstance(serviceClass);
                MethodInfo mi = MethodHandler.GetMethod(instance.GetType(), operation, arguments);
                ParameterInfo[] parameterInfos = mi.GetParameters();
                TypeHelper.NarrowValues(arguments, parameterInfos);
                InvocationHandler invocationHandler = new InvocationHandler(mi);
                result = invocationHandler.Invoke(instance, arguments);
            }
            catch (TargetInvocationException exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"] = true;
                resultObj["code"] = "SERVER.PROCESSING";
                resultObj["message"] = exception.InnerException.Message;
                result = resultObj;
            }
            catch (Exception exception)
            {
                Hashtable resultObj = new Hashtable();
                resultObj["error"] = true;
                resultObj["code"] = "SERVER.PROCESSING";
                resultObj["message"] = exception.Message;
                result = resultObj;
            }

            SwxAssembler assembler = new SwxAssembler();
            byte[] buffer = assembler.WriteSwf(result, debug, compressionLevel, url, allowDomain);
            httpApplication.Response.Clear();
            httpApplication.Response.ClearHeaders();
            httpApplication.Response.Buffer = true;
            httpApplication.Response.ContentType = "application/swf";
            httpApplication.Response.AppendHeader("Content-Length", buffer.Length.ToString());
            httpApplication.Response.AppendHeader("Content-Disposition", "attachment; filename=data.swf");
            if (buffer.Length > 0)
                httpApplication.Response.OutputStream.Write(buffer, 0, buffer.Length);
            try
            {
                httpApplication.Response.Flush();
            }
            catch (SecurityException)
            {
            }
        }