Example #1
0
        public void AppModel_ActionManager_SelfDispatcher()
        {
            // create browse action
            var portalContext = CreatePortalContext("/home/SelfDispatcherContent1", "");

            var action = HttpActionManager.CreateAction(portalContext);

            Assert.IsInstanceOfType(action, typeof(RewriteHttpAction));
            Assert.IsNotNull(action.AppNode, "action.AppNode is null");
            Assert.IsNotNull(action.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(action.AppNode.Path == "/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit", "action.AppNode.Path is not \"/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit\"");
            Assert.IsTrue(action.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1\"");


            var targetNode = Node.LoadNode(action.TargetNode.Id) as GenericContent;

            targetNode.BrowseApplication = null;
            targetNode.Save();

            action = HttpActionManager.CreateAction(portalContext);

            Assert.IsInstanceOfType(action, typeof(RewriteHttpAction));
            Assert.IsNotNull(action.AppNode, "action.AppNode is null");
            Assert.IsNotNull(action.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(action.AppNode.Path == "/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse", "action.AppNode.Path is not \"/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse\"");
            Assert.IsTrue(action.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home/SelfDispatcherContent1\"");
        }
Example #2
0
        private static void CheckExecutableType(NodeHead nodeHead, string actioName)
        {
            if (nodeHead == null)
            {
                return;
            }

            // check if the extension interests us
            if (!RepositoryTools.IsExecutableExtension(Path.GetExtension(nodeHead.Name)))
            {
                return;
            }

            // If this is not an action request: if the extension indicates an executable file,
            // but the type is wrong OR the user does not have Run application
            // permission: rewrite the action to simply return the text of the file.
            if (string.IsNullOrEmpty(actioName) && (!RepositoryTools.IsExecutableType(nodeHead.GetNodeType()) || !SecurityHandler.HasPermission(nodeHead, PermissionType.RunApplication)))
            {
                PortalContext.Current.ActionName = "BinarySpecial";

                // Workaround: at this point we cannot change the action in any other way: we need
                // to rewrite the context to point to the binary highlighter page instead of the
                // executable content itself. This is how we prevent executing the file and allow
                // only showing the text content of the file (if Open permission is present).
                var action = HttpActionManager.CreateAction(PortalContext.Current);
                action.Execute();
            }
        }
Example #3
0
        public void AppModel_ActionManager_PageProperty()
        {
            var portalContext = CreatePortalContext("/home", "NodeProperty=PersonalizationSettings");

            var action         = HttpActionManager.CreateAction(portalContext);
            var downloadAction = action as DownloadHttpAction;

            Assert.IsNotNull(downloadAction, "action is not DownloadAction");
            Assert.IsTrue(downloadAction.BinaryPropertyName == "PersonalizationSettings", "downloadAction.BinaryPropertyName is not \"PersonalizationSettings\"");
            Assert.IsNotNull(downloadAction.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(downloadAction.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home\"");
        }
Example #4
0
        public void AppModel_ActionManager_FileBrowse()
        {
            var portalContext = CreatePortalContext("/home/file1", "");

            var action         = HttpActionManager.CreateAction(portalContext);
            var downloadAction = action as DownloadHttpAction;

            Assert.IsNotNull(downloadAction, "action is not DownloadAction");
            Assert.IsTrue(downloadAction.BinaryPropertyName == "Binary", "downloadAction.BinaryPropertyName is not \"Binary\"");
            Assert.IsNotNull(downloadAction.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(downloadAction.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home/File1", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home/File1\"");
        }
Example #5
0
        public void AppModel_ActionManager_GenericContentEdit()
        {
            var portalContext = CreatePortalContext("/home/webcontent1", "action=edit");

            var action = HttpActionManager.CreateAction(portalContext);

            Assert.IsInstanceOfType(action, typeof(RewriteHttpAction));
            Assert.IsNotNull(action.AppNode, "action.AppNode is null");
            Assert.IsNotNull(action.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(action.AppNode.Path == "/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit", "action.AppNode.Path is not \"/Root/TestSiteForAppModelTest/(apps)/GenericContent/Edit\"");
            Assert.IsTrue(action.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home/WebContent1", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home/WebContent1\"");
        }
Example #6
0
        public void AppModel_ActionManager_PageBrowse()
        {
            var portalContext = CreatePortalContext("/home", "");

            var action = HttpActionManager.CreateAction(portalContext);

            Assert.IsInstanceOfType(action, typeof(RewriteHttpAction));
            Assert.IsNotNull(action.AppNode, "action.AppNode is null");
            Assert.IsNotNull(action.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(action.AppNode.Path == "/Root/TestSiteForAppModelTest/Home", "action.AppNode.Path is not \"/Root/TestSiteForAppModelTest/Home\"");
            Assert.IsTrue(action.TargetNode.Path == "/Root/TestSiteForAppModelTest/Home", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest/Home\"");
        }
Example #7
0
        private void OnEnter(object sender, EventArgs e)
        {
            HttpContext httpContext = (sender as HttpApplication).Context;

            var request = httpContext.Request;

            SnTrace.Web.Write("PCM.OnEnter {0} {1}", request.RequestType, request.Url);

            // check if messages to process from msmq exceeds configured limit: delay current thread until it goes back to normal levels
            DelayCurrentRequestIfNecessary();

            var initInfo = PortalContext.CreateInitInfo(httpContext);

            // Check for forbidden paths (custom request filtering), mainly for phisycal folders in the web folder.
            // The built-in Request filtering module is not capable of filtering folders only in the root, but let
            // us have folders with the same name somewhere else in the Content Repository.
            if (IsForbiddenFolder(initInfo))
            {
                AuthenticationHelper.ThrowNotFound();
            }

            // check if request came to a restricted site via another site
            if (Configuration.WebApplication.DenyCrossSiteAccessEnabled)
            {
                if (initInfo.RequestedNodeSite != null && initInfo.RequestedSite != null)
                {
                    if (initInfo.RequestedNodeSite.DenyCrossSiteAccess && initInfo.RequestedSite.Id != initInfo.RequestedNodeSite.Id)
                    {
                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.End();
                        return;
                    }
                }
            }

            // add cache-control headers and handle ismodifiedsince requests
            HandleResponseForClientCache(initInfo);

            PortalContext portalContext = PortalContext.Create(httpContext, initInfo);

            var action = HttpActionManager.CreateAction(portalContext);

            SnTrace.Web.Write("HTTP Action." + GetLoggedProperties(portalContext));

            action.Execute();
        }
Example #8
0
        public void AppModel_ActionManager_SiteBrowse_WithoutStartPage()
        {
            RemoveSiteStartPage(Node.Load <Site>("/Root/TestSiteForAppModelTest"));

            var portalContext = CreatePortalContext("/", "");

            var action = HttpActionManager.CreateAction(portalContext);

            //Trace.WriteLine("Action: " + typeof(RewriteHttpAction).FullName);
            //Trace.WriteLine("AppNode: " + (action.AppNode == null ? "[null]" : action.AppNode.Path));
            //Trace.WriteLine("TargetNode: " + (action.TargetNode == null ? "[null]" : action.TargetNode.Path));
            //Trace.WriteLine("StartPage: " + (portalContext.Site.StartPage == null ? "[null]" : portalContext.Site.StartPage.Path));

            Assert.IsInstanceOfType(action, typeof(RewriteHttpAction));
            Assert.IsNotNull(action.AppNode, "action.AppNode is null");
            Assert.IsNotNull(action.TargetNode, "action.TargetNode is null");
            Assert.IsTrue(action.AppNode.Path == "/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse", "action.AppNode.Path is not \"/Root/TestSiteForAppModelTest/(apps)/GenericContent/Browse\"");
            Assert.IsTrue(action.TargetNode.Path == "/Root/TestSiteForAppModelTest", "action.TargetNode.Path is not \"/Root/TestSiteForAppModelTest\"");
        }
        void OnEnter(object sender, EventArgs e)
        {
            // check if messages to process from msmq exceeds configured limit: delay current thread until it goes back to normal levels
            DelayCurrentRequestIfNecessary();

            HttpContext httpContext = (sender as HttpApplication).Context;
            var         request     = httpContext.Request;


            //trace
            bool traceReportEnabled;
            var  traceQueryString = request.QueryString["trace"];

            if (!String.IsNullOrEmpty(traceQueryString))
            {
                traceReportEnabled = (traceQueryString == "true") ? true : false;
            }
            else
            {
                traceReportEnabled = RepositoryConfiguration.TraceReportEnabled;
            }

            if (traceReportEnabled)
            {
                var slot = Thread.GetNamedDataSlot(Tracing.OperationTraceDataSlotName);
                var data = Thread.GetData(slot);

                if (data == null)
                {
                    Thread.SetData(slot, new OperationTraceCollector());
                }
            }
            //trace


            var initInfo = PortalContext.CreateInitInfo(httpContext);

            // check if request came to a restricted site via another site
            if (DenyCrossSiteAccessEnabled)
            {
                if (initInfo.RequestedNodeSite != null && initInfo.RequestedSite != null)
                {
                    if (initInfo.RequestedNodeSite.DenyCrossSiteAccess && initInfo.RequestedSite.Id != initInfo.RequestedNodeSite.Id)
                    {
                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.End();
                        return;
                    }
                }
            }

            // add cache-control headers and handle ismodifiedsince requests
            HandleResponseForClientCache(initInfo);


            PortalContext portalContext = PortalContext.Create(httpContext, initInfo);

            SetThreadCulture(portalContext);

            var action = HttpActionManager.CreateAction(portalContext);

            Logger.WriteVerbose("HTTP Action.", CollectLoggedProperties, portalContext);

            action.Execute();
        }
Example #10
0
        void OnEnter(object sender, EventArgs e)
        {
            // check if messages to process from msmq exceeds configured limit: delay current thread until it goes back to normal levels
            DelayCurrentRequestIfNecessary();

            HttpContext httpContext = (sender as HttpApplication).Context;
            var         request     = httpContext.Request;

#if WEB
            DetailedLogger.Log("PCM.OnEnter {0} {1}", request.RequestType, request.Url); // category: WEB
#endif

            //trace
            bool traceReportEnabled;
            var  traceQueryString = request.QueryString["trace"];

            if (!String.IsNullOrEmpty(traceQueryString))
            {
                traceReportEnabled = (traceQueryString == "true") ? true : false;
            }
            else
            {
                traceReportEnabled = RepositoryConfiguration.TraceReportEnabled;
            }

            if (traceReportEnabled)
            {
                var slot = Thread.GetNamedDataSlot(Tracing.OperationTraceDataSlotName);
                var data = Thread.GetData(slot);

                if (data == null)
                {
                    Thread.SetData(slot, new OperationTraceCollector());
                }
            }
            //trace


            var initInfo = PortalContext.CreateInitInfo(httpContext);

            // Check for forbidden paths (custom request filtering), mainly for phisycal folders in the web folder.
            // The built-in Request filtering module is not capable of filtering folders only in the root, but let
            // us have folders with the same name somewhere else in the Content Repository.
            if (IsForbiddenFolder(initInfo))
            {
                AuthenticationHelper.ThrowNotFound();
            }

            // check if request came to a restricted site via another site
            if (DenyCrossSiteAccessEnabled)
            {
                if (initInfo.RequestedNodeSite != null && initInfo.RequestedSite != null)
                {
                    if (initInfo.RequestedNodeSite.DenyCrossSiteAccess && initInfo.RequestedSite.Id != initInfo.RequestedNodeSite.Id)
                    {
                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.End();
                        return;
                    }
                }
            }

            // add cache-control headers and handle ismodifiedsince requests
            HandleResponseForClientCache(initInfo);

            PortalContext portalContext = PortalContext.Create(httpContext, initInfo);

            var action = HttpActionManager.CreateAction(portalContext);
            Logger.WriteVerbose("HTTP Action.", CollectLoggedProperties, portalContext);

            action.Execute();
        }