Exemplo n.º 1
0
        protected void SetContextInfo(HeContext heContext, SecurityTokenAPI.RequestSecurityTokenPayload authorizationPayload)
        {
            try {
                if (authorizationPayload.TenantId != 0)
                {
                    heContext.Session.TenantId = authorizationPayload.TenantId;
                }
                if (authorizationPayload.UserId != 0)
                {
                    heContext.Session.UserId = authorizationPayload.UserId;
                }
            } catch (Exception e) {
                OSTrace.Warning("Invalid authentication information.", e);
            }

            if (Request.Content.Headers.TryGetValues("Content-Language", out var headerValues))
            {
                string locale = headerValues.First();
                if (!string.IsNullOrWhiteSpace(locale))
                {
                    GenericExtendedActions.SetCurrentLocale(heContext, locale);
                }
            }
            else
            {
                OSTrace.Warning("Locale information missing from the request.");
            }
        }
 private void SetContextInfo(HeContext heContext, int tenantId, int userId, string locale)
 {
     if (tenantId != 0)
     {
         heContext.Session.TenantId = tenantId;
     }
     if (userId != 0)
     {
         heContext.Session.UserId = userId;
     }
     GenericExtendedActions.SetCurrentLocale(heContext, locale);
 }
Exemplo n.º 3
0
        public static IEnumerable <int> GetAllowedActivities(HeContext heContext, Transaction tran, IEnumerable <int> activityIds, int userId)
        {
            foreach (var nextId in activityIds)
            {
                int            assignedUser;
                ActivityStatus statusId;
                bool           needsPermission = DBRuntimePlatform.Instance.NeedsActivityPermissions(tran, nextId, out assignedUser, out statusId);


                if (assignedUser != BuiltInFunction.NullIdentifier())
                {
                    if (assignedUser != userId)
                    {
                        continue;
                    }
                }
                else
                {
                    if (statusId != ActivityStatus.Ready)
                    {
                        continue;
                    }

                    if (needsPermission)
                    {
                        var roles = DBRuntimePlatform.Instance.GetActivityRoles(tran, nextId);
                        if (!roles.Any(role => GenericExtendedActions.Check(heContext, role.First, userId, role.Second)))
                        {
                            continue;
                        }
                    }
                }

                yield return(nextId);
            }
        }
 public static void AutoLogin(AppInfo info, SessionInfo session)
 {
     GenericExtendedActions.AutoLogin(info, session);
 }         /// <summary>
        protected void Application_AcquireRequestState(Object sender, EventArgs e)
        {
            Context.Items["osCurrentPTAName"]     = RequestPtaName;
            Context.Items["osCurrentPTAUserName"] = RequestPtaUserName;
            Context.Items["osIsLoadingScreen"]    = false;
            RunningInfo.InitializeRunningInfo();
            RunningInfo.ESpaceHash         = ConfigurationManager.AppSettings["OutSystems.HubEdition.EspaceCompilationHash"];
            RunningInfo.ESpaceVersionToken = ConfigurationManager.AppSettings["OutSystems.HubEdition.EspaceVersionToken"];
            RunningInfo.ESpaceVersionId    = int.Parse(ConfigurationManager.AppSettings["OutSystems.HubEdition.EspaceVersionID"]);
            RunningInfo.DebugMode          = false;
            // Skips internal pages
            if (Request.FilePath.ToLowerInvariant().EndsWith("/_ping.aspx") || Request.FilePath.ToLowerInvariant().EndsWith("/_queriescoverage.aspx") || Request.FilePath.ToLower().EndsWith("/_debugger.asmx") || Request.FilePath.ToLower().EndsWith("/_debuggerevents.ashx"))
            {
                return;
            }

            if (App == null)
            {
                // Try again
                Application_Start(sender, e);
                if (Application["ApplicationStartError"] != null)
                {
                    ApplicationStartErrorRedirect();
                }
            }

            if (App.Tenant.PhoneConfigException != null)
            {
                Application["ApplicationStartError"] = App.Tenant.PhoneConfigException;
                ApplicationStartErrorRedirect();
            }

            // Session Start
            HeContext heContext = Global.App.OsContext;

            heContext.InitSession();

            var sessionCookieKey = Response.Cookies.AllKeys.FirstIfSingleOrDefault(c => c == CookieActions.GetSessionCookieName());

            if (sessionCookieKey != null)
            {
                var sessionCookie = Response.Cookies.Get(sessionCookieKey);
                if (sessionCookie != null && Settings.GetBool(Settings.Configs.EnforceSessionCookiesSecure))
                {
                    sessionCookie.Secure = true;
                }
            }

            if (Context.Session == null || heContext.Session.NeedsSessionStart(App.eSpaceName))
            {
                if (Request.Path.ToLowerInvariant().EndsWith("_SmsHandler.aspx"))
                {
                    Global.App.OsContext.Session["TerminalType"] = "SMS";
                    Global.App.OsContext.Session["MSISDN"]       = Global.App.OsContext.MOMsg.MSISDN;
                }
                else if (Request.Path.ToLowerInvariant().EndsWith("smshandler.asmx"))
                {
                    Global.App.OsContext.Session["TerminalType"] = "SMS";
                    Global.App.OsContext.Session["MSISDN"]       = Request.Headers["MSISDN"];
                }
                else
                {
                    Global.App.OsContext.Session["TerminalType"] = "WEB";
                    Global.App.OsContext.Session["MSISDN"]       = "";
                }

                if (Application["ApplicationStartError"] != null)
                {
                    // Try again
                    Application_Start(sender, e);
                }

                if (Application["ApplicationStartError"] != null)
                {
                    ApplicationStartErrorRedirect();
                }
                if (Context.Session != null)
                {
                    ExtendedActions.AutoLogin(App, App.OsContext.Session);
                    RunOnSessionStart();
                }
            }            /*
                          * else {
                          *
                          * } */

            // Process visit cookies
            if (RuntimePlatformUtils.ShouldCreateCookieForRequest())
            {
                if (Request.CurrentExecutionFilePath.ToLowerInvariant().EndsWith(".aspx"))
                {
                    var osVisitorCookie = Request.Cookies["osVisitor"];
                    var osVisitCookie   = Request.Cookies["osVisit"];

                    if (osVisitorCookie == null || !GuidUtils.IsGuid(osVisitorCookie.Value))
                    {
                        osVisitorCookie         = new HttpCookie("osVisitor", Guid.NewGuid().ToString());
                        osVisitorCookie.Expires = DateTime.Now.AddYears(100);                         // forever
                        SecureCookieUtils.setSecureCookie(osVisitorCookie, heContext.Context.Response);
                    }

                    if (osVisitCookie == null || !GuidUtils.IsGuid(osVisitCookie.Value))
                    {
                        osVisitCookie = new HttpCookie("osVisit", Guid.NewGuid().ToString());
                        heContext.Session["osIsNewVisit"] = true;
                    }
                    osVisitCookie.Expires = DateTime.Now.AddMinutes(30);
                    SecureCookieUtils.setSecureCookie(osVisitCookie, heContext.Context.Response);

                    Context.Items["osVisitor"] = osVisitorCookie.Value;
                    Context.Items["osVisit"]   = osVisitCookie.Value;
                }
            }

            App.OsContext.Session[GenericExtendedActions.ReqAuditCountSessionName] = 0;

            // Default Multilingual state
            if (!App.MultilingualEnabled)
            {
                GenericExtendedActions.SetCurrentLocale(heContext, "");
            }
            else
            {
                string localeHeader = heContext.OsISAPIFilter.GetLocale(Request);
                if (localeHeader != null)
                {
                    try {
                        GenericExtendedActions.SetCurrentLocale(heContext, localeHeader);
                    } catch {}
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Action: Deprecated_NotifyGetMessage
        /// </summary>

        public static void Deprecated_NotifyGetMessage(HeContext heContext, out string outParamMessage)
        {
            outParamMessage = "";

            GenericExtendedActions.NotifyWidgetGetMessage(heContext, out outParamMessage);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Action: LogMessage
        /// </summary>

        public static void LogMessage(HeContext heContext, string inParamMessage, string inParamModuleName)
        {
            GenericExtendedActions.LogMessage(heContext, inParamMessage, inParamModuleName);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Action: Deprecated_Notify
        /// </summary>

        public static void Deprecated_Notify(HeContext heContext, object inParamWebblock, string inParamMessage)
        {
            GenericExtendedActions.Notify(heContext, inParamWebblock, inParamMessage);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Action: Deprecated_NotifyWidget
        /// </summary>

        public static void Deprecated_NotifyWidget(HeContext heContext, string inParamWidgetId, string inParamMessage)
        {
            GenericExtendedActions.NotifyWidget_Deprecated(heContext, inParamWidgetId, inParamMessage);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Action: SetCurrentLocale
        /// </summary>

        public static void SetCurrentLocale(HeContext heContext, string inParamLocale)
        {
            GenericExtendedActions.SetCurrentLocale(heContext, inParamLocale);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Log a message to the General Log
 /// </summary>
 /// <param name="message">What to log</param>
 internal static void LogMessage(object message)
 {
     GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, message.ToString(), "AdvXL");
 }