Beispiel #1
0
        private void VerifyVanityUrl(Guid organizationId, Guid instanceId)
        {
            if (organizationId != Guid.Empty)
            {
                string vanityUrl = CustomUrlProvider.GetVanityUrl(organizationId, instanceId);

                if (!string.IsNullOrEmpty(vanityUrl) && (string.Compare(Request.Url.Host, vanityUrl, StringComparison.OrdinalIgnoreCase) != 0))
                {
                    string redirectUrl = this.ReturnUrl;

                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        redirectUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery);
                    }
                    else
                    {
                        redirectUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery)
                                      + ((Request.QueryString["returnurl"] == null)
                                ? ((Request.Url.PathAndQuery.IndexOf("&", StringComparison.OrdinalIgnoreCase) > -1) ? "&" : "?") + "returnurl=" + HttpUtility.UrlEncode(redirectUrl)
                                : string.Empty);
                    }

                    Response.Redirect(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", Request.Url.Scheme, Uri.SchemeDelimiter, vanityUrl, redirectUrl));
                }
            }
        }
Beispiel #2
0
        private static Image CreateItemIcon(Micajah.Common.Bll.Action item, IconSize iconSize)
        {
            Image img = null;

            try
            {
                img            = new Image();
                img.ImageAlign = ImageAlign.AbsMiddle;
                img.ImageUrl   = CustomUrlProvider.CreateApplicationAbsoluteUrl(item.IconUrl);
                if (iconSize != IconSize.NotSet)
                {
                    img.Height = img.Width = Unit.Pixel((int)iconSize);
                }
                string descr = item.CustomDescription;
                if (!string.IsNullOrEmpty(descr))
                {
                    img.ToolTip = descr;
                }

                return(img);
            }
            finally
            {
                if (img != null)
                {
                    img.Dispose();
                }
            }
        }
Beispiel #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            m_UserContext = UserContext.Current;

            if (!Page.IsPostBack)
            {
                MasterDataSet.CustomUrlRow row = null;

                if (m_UserContext.InstanceId != Guid.Empty)
                {
                    row = CustomUrlProvider.GetCustomUrl(m_UserContext.OrganizationId, m_UserContext.InstanceId);
                }

                if (row == null)
                {
                    row = CustomUrlProvider.GetCustomUrlByOrganizationId(m_UserContext.OrganizationId);
                }

                if (row != null)
                {
                    VanityUrlTextBox.Text     = row.PartialCustomUrl.ToLowerInvariant();
                    FullVanityUrlTextBox.Text = row.FullCustomUrl.ToLowerInvariant();
                }
                if (ShowFullVanityUrl)
                {
                    TrFullCustomURL.Visible       = true;
                    PartialVanityUrlTitle.Visible = true;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Selectes the specified instance and redirects to specified URL.
        /// </summary>
        /// <param name="instanceId">The instance identifier to select.</param>
        /// <param name="redirectUrl">The URL to redirect to.</param>
        internal static void SelectInstance(Guid instanceId, string redirectUrl, bool validateRedirectUrl, HtmlGenericControl errorPanel)
        {
            try
            {
                UserContext user = UserContext.Current;

                if (FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled)
                {
                    if (validateRedirectUrl)
                    {
                        ValidateRedirectUrl(ref redirectUrl, true);
                    }

                    errorPanel.Page.Session.Clear();

                    errorPanel.Page.Response.Redirect(CustomUrlProvider.GetVanityUri(user.OrganizationId, instanceId, redirectUrl));
                }
                else
                {
                    user.SelectInstance(instanceId);

                    //if (validateRedirectUrl)
                    ValidateRedirectUrl(ref redirectUrl, true);

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        errorPanel.Page.Response.Redirect(redirectUrl);
                    }
                }
            }
            catch (AuthenticationException ex)
            {
                ShowError(ex.Message, errorPanel);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Renders the application logo and the logo of the copyright holder company.
        /// </summary>
        /// <param name="writer">The System.Web.UI.HtmlTextWriter to render content to.</param>
        public static void RenderHeader(HtmlTextWriter writer)
        {
            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                return;
            }

            if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl))
            {
                using (Image img = new Image())
                {
                    img.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                    img.ToolTip  = FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName;

                    RenderHeader(writer, img);
                }
            }
            else
            {
                using (LiteralControl literal = new LiteralControl(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName))
                {
                    RenderHeader(writer, literal);
                }
            }
        }
        /// <summary>
        /// Stores the specified organization identifier and redirects to originally requested URL.
        /// </summary>
        /// <param name="organizationId">The organization identifier.</param>
        internal static void SelectOrganization(Guid organizationId, string redirectUrl, bool validateRedirectUrl, HtmlGenericControl errorDiv)
        {
            try
            {
                if (FrameworkConfiguration.Current.WebApplication.CustomUrl.Enabled)
                {
                    if (validateRedirectUrl)
                    {
                        ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);
                    }

                    errorDiv.Page.Session.Clear();

                    errorDiv.Page.Response.Redirect(CustomUrlProvider.GetVanityUri(organizationId, Guid.Empty, redirectUrl));
                }
                else
                {
                    UserContext.Current.SelectOrganization(organizationId);

                    //if (validateRedirectUrl)
                    ActiveInstanceControl.ValidateRedirectUrl(ref redirectUrl, true);

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        errorDiv.Page.Response.Redirect(redirectUrl);
                    }
                }
            }
            catch (AuthenticationException ex)
            {
                ActiveInstanceControl.ShowError(ex.Message, errorDiv);
            }
        }
Beispiel #7
0
        protected void OrganizationUrlValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args == null)
            {
                return;
            }

            OrganizationUrlTick.Visible           = OrganizationUrl.IsValid = args.IsValid = false;
            OrganizationUrlValidator.ErrorMessage = Resources.SignupOrganizationControl_OrganizationUrlValidator_ErrorMessage;

            try
            {
                OrganizationUrlValidator.ErrorMessage = Resources.CustomUrlProvider_CustomUrlAlreadyExists;
                if (!string.IsNullOrEmpty(OrganizationUrl.Text))
                {
                    CustomUrlProvider.ValidatePartialCustomUrl(OrganizationUrl.Text);
                    OrganizationUrlTick.Visible = OrganizationUrl.IsValid = args.IsValid = CustomUrlProvider.ValidateCustomUrl(OrganizationUrl.Text);
                }
                else
                {
                    args.IsValid = true;
                }
            }
            catch (DataException ex)
            {
                OrganizationUrlValidator.ErrorMessage = ex.Message;

                OrganizationUrl.Attributes["validatorId"] = OrganizationUrlValidator.ClientID;
                OrganizationUrl.Focus();
            }
        }
Beispiel #8
0
            public void CorrectlyValidatesForUrls(string url, bool expectedValue)
            {
                var provider = new CustomUrlProvider();
                var valid    = provider.Initialize(url);

                Assert.AreEqual(expectedValue, valid);
            }
Beispiel #9
0
            public void ReturnsNullCompany()
            {
                var provider = new CustomUrlProvider();

                provider.Initialize(CorrectUrl);

                Assert.IsNull(provider.CompanyName);
            }
Beispiel #10
0
            public void ReturnsNullProjectUrl()
            {
                var provider = new CustomUrlProvider();

                provider.Initialize(CorrectUrl);

                Assert.IsNull(provider.ProjectUrl);
            }
Beispiel #11
0
        private void Tree_DataBind()
        {
            Type   typeOfThis     = typeof(EntitiesControl);
            string entityImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Entity.gif"));
            string fieldImageUrl  = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Field.gif"));
            string eventImageUrl  = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Event.gif"));

            foreach (Entity entity in EntityFieldProvider.Entities)
            {
                RadTreeNode entityNode = new RadTreeNode(entity.Name);
                entityNode.ImageUrl = entityImageUrl;
                Tree.Nodes.Add(entityNode);

                if (entity.EnableHierarchy)
                {
                    RadTreeNode parentNode = entityNode;
                    foreach (EntityNodeType nodeType in entity.NodeTypes)
                    {
                        RadTreeNode nodeTypeNode = new RadTreeNode(nodeType.Name);
                        nodeTypeNode.ImageUrl = entityImageUrl;
                        parentNode.Nodes.Add(nodeTypeNode);

                        foreach (EntityEvent entityEvent in nodeType.Events)
                        {
                            RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                            eventNode.ImageUrl = eventImageUrl;
                            nodeTypeNode.Nodes.Add(eventNode);
                        }

                        parentNode = nodeTypeNode;
                    }

                    foreach (EntityEvent entityEvent in entity.CustomEvents)
                    {
                        RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                        eventNode.ImageUrl = eventImageUrl;
                        entityNode.Nodes.Add(eventNode);
                    }
                }
                else
                {
                    foreach (EntityField field in entity.Fields)
                    {
                        RadTreeNode fieldNode = new RadTreeNode(field.Name);
                        fieldNode.ImageUrl = fieldImageUrl;
                        entityNode.Nodes.Add(fieldNode);
                    }

                    foreach (EntityEvent entityEvent in entity.Events)
                    {
                        RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                        eventNode.ImageUrl = eventImageUrl;
                        entityNode.Nodes.Add(eventNode);
                    }
                }
            }
        }
Beispiel #12
0
        protected void InviteUsersLink_Init(object sender, EventArgs e)
        {
            HyperLink lnk = sender as HyperLink;

            if (lnk != null)
            {
                lnk.Text        = Resources.UsersControl_InviteUsersLink_Text;
                lnk.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.InviteUsersPageVirtualPath);
            }
        }
Beispiel #13
0
        protected override void LoadResources()
        {
            base.LoadResources();
            HyperLinkField field = (List.Columns[1] as HyperLinkField);

            if (field != null)
            {
                field.Text = Resources.GroupsControl_List_RolesLinkColumns_Text;
                field.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(string.Concat(ResourceProvider.GroupsInstancesRolesPageVirtualPath, "?GroupId={0:N}"));
            }
        }
Beispiel #14
0
        protected override void LoadResources()
        {
            base.LoadResources();
            HyperLinkField field = (List.Columns[0] as HyperLinkField);

            if (field != null)
            {
                field.Text = Resources.RulesControl_List_Caption;
                field.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.VirtualRootShortPath + "admin/rules.aspx?RuleEngineId={0:N}");
            }
        }
Beispiel #15
0
            public void ReturnsValidRawGitUrl()
            {
                var provider = new CustomUrlProvider();

                provider.Initialize(CorrectUrl);

                string correctReturnedUrl = CorrectUrl.Replace("{filename}", "%var2%");

                correctReturnedUrl = correctReturnedUrl.Replace("{revision}", "{0}");

                Assert.AreEqual(correctReturnedUrl, provider.RawGitUrl);
            }
Beispiel #16
0
        protected override void LoadResources()
        {
            base.LoadResources();

            TemplateField tempField = (List.Columns[0] as TemplateField);

            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_OrderNumberColumn_HeaderText;
            }

            HyperLinkField linkField = (List.Columns[1] as HyperLinkField);

            if (linkField != null)
            {
                linkField.HeaderText = Resources.RulesControl_List_InputParametersLinkColumns_HeaderText;
                linkField.Text       = Resources.RulesControl_List_InputParametersLinkColumns_Text;
                linkField.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.VirtualRootShortPath + "admin/ruleparameters.aspx?RuleId={0:N}");
                linkField.HeaderGroup = Resources.RulesControl_List_ParametersLinkColumns_HeaderGroup;
            }

            linkField = (List.Columns[2] as HyperLinkField);
            if (linkField != null)
            {
                linkField.HeaderText = Resources.RulesControl_List_OutputParametersLinkColumns_HeaderText;
                linkField.Text       = Resources.RulesControl_List_OutputParametersLinkColumns_Text;
                linkField.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl((string)FormRuleEngine.DataKey["OutputEditPage"]);
                linkField.HeaderGroup = Resources.RulesControl_List_ParametersLinkColumns_HeaderGroup;
            }

            tempField = (List.Columns[6] as TemplateField);
            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_LastUsedUserColumn_HeaderText;
            }

            List.Columns[7].HeaderText = Resources.RulesControl_List_LastUsedDateColumn_HeaderText;

            tempField = (List.Columns[8] as TemplateField);
            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_CreatedByColumn_HeaderText;
            }

            List.Columns[9].HeaderText = Resources.RulesControl_List_CreatedDateColumn_HeaderText;

            Initialize(FormRuleEngine);
            FormRuleEngine.Visible = true;
            FormRuleEngine.AutoGenerateEditButton = FormRuleEngine.AutoGenerateInsertButton = false;

            LoadResources(FormRuleEngine, this.GetType().BaseType.Name);
        }
Beispiel #17
0
        protected override void OnLoad(EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.InitializeSetupPage(this.Page);

            if (DatabaseServerProvider.GetDatabaseServers().Count == 0)
            {
                List.EmptyDataText = string.Format(CultureInfo.CurrentCulture
                                                   , Resources.DatabasesControl_ErrorMessage_NoDatabaseServer
                                                   , CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.DatabaseServersPageVirtualPath));
                List.ShowAddLink = EditForm.Visible = false;
            }

            base.OnLoad(e);
        }
Beispiel #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MagicForm.ApplyStyle(FormTable, ColorScheme.White, false, true);
            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

            if (!this.IsPostBack)
            {
                this.LoadResources();
                CancelLink.NavigateUrl      = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.UsersPageVirtualPath);
                EmailValidator.ErrorMessage = Resources.TextBox_RegularExpressionValidator_ErrorMessage;

                EmailValidator.Attributes["controltovalidate2"] = EmailTextBox.ClientID;
            }
        }
        internal static void OrganizationListItemDataBound(DataListItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
                Organization org = e.Item.DataItem as Organization;
                if (org != null)
                {
                    if (org.Expired)
                    {
                        int days = org.GraceDaysRemaining;
                        if (days > 0)
                        {
                            HyperLink expirationLink = e.Item.FindControl("ExpirationLink") as HyperLink;
                            if (expirationLink != null)
                            {
                                expirationLink.Text        = string.Format(CultureInfo.InvariantCulture, Resources.ActiveOrganizationControl_OrganizationList_ExpirationLink_Text, days);
                                expirationLink.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.SupportPageVirtualPath) + "?o=" + org.OrganizationId.ToString("N");
                                expirationLink.Visible     = true;
                            }
                        }
                        else
                        {
                            Label expiredLabel = e.Item.FindControl("ExpiredLabel") as Label;
                            if (expiredLabel != null)
                            {
                                expiredLabel.Text    = Resources.ActiveOrganizationControl_OrganizationList_ExpiredLabel_Text;
                                expiredLabel.Visible = true;
                            }

                            LinkButton orgButton = e.Item.FindControl("OrgButton") as LinkButton;
                            if (orgButton != null)
                            {
                                orgButton.Visible = false;
                            }

                            HyperLink orgLink = e.Item.FindControl("OrgLink") as HyperLink;
                            if (orgLink != null)
                            {
                                orgLink.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.SupportPageVirtualPath) + "?o=" + org.OrganizationId.ToString("N");
                                orgLink.Visible     = true;
                            }
                        }
                    }
                }
                break;
            }
        }
Beispiel #20
0
        protected static string GetUrl(object roleId, object actionId)
        {
            string str = null;

            if (RoleProvider.IsBuiltIn((Guid)roleId))
            {
                str = Resources.RolesControl_BuiltInRoleUrl;
            }
            else
            {
                Micajah.Common.Bll.Action action = ActionProvider.PagesAndControls.FindByActionId((Guid)actionId);
                str = ((action == null) ? string.Empty : CustomUrlProvider.CreateApplicationRelativeUrl(action.AbsoluteNavigateUrl));
            }
            return(str);
        }
Beispiel #21
0
        private int ValidateLoginName(string loginName)
        {
            int returnValue = 0;

            ConfirmPasswordRow.Visible = true;
            if (LoginProvider.Current.LoginNameExists(loginName))
            {
                if (LoginProvider.Current.LoginInOrganization(loginName, this.OrganizationId))
                {
                    this.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.SignupUserControl_ErrorMessage_LoginInOrganizationExists, m_Organization.Name));
                    return(1);
                }

                ClientDataSet.UserRow userRow = UserProvider.GetUserRow(loginName);
                if (userRow != null)
                {
                    FirstNameTextBox.Text = userRow.FirstName;
                    LastNameTextBox.Text  = userRow.LastName;
                }

                ConfirmPasswordRow.Visible = false;

                this.ShowDescription(string.Format(CultureInfo.CurrentCulture
                                                   , Resources.SignupUserControl_DescriptionLabel_Text_UserExists
                                                   , string.Concat(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.PasswordRecoveryPageVirtualPath), "?l=", HttpUtility.UrlEncode(loginName))));

                returnValue = 2;
            }

            LoginTextLabel.Text = loginName;
            FirstNameTextBox.Focus();
            Step1Table.Visible = false;
            Step2Table.Visible = true;

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                MainContainer.Style[HtmlTextWriterStyle.Height]    = "500px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-250px";
            }
            else
            {
                MainContainer.Style[HtmlTextWriterStyle.Height]    = "360px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-180px";
            }

            return(returnValue);
        }
Beispiel #22
0
        protected void SimpleViewSaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    Guid orgId  = m_UserContext.OrganizationId;
                    Guid?instId = null;
                    if (m_UserContext.InstanceId != Guid.Empty)
                    {
                        instId = m_UserContext.InstanceId;
                    }

                    MasterDataSet.CustomUrlRow row = null;

                    if (instId.HasValue)
                    {
                        row = CustomUrlProvider.GetCustomUrl(orgId, instId.Value);
                    }

                    if (row == null)
                    {
                        row = CustomUrlProvider.GetCustomUrlByOrganizationId(orgId);
                    }

                    if (row != null)
                    {
                        CustomUrlProvider.UpdateCustomUrl(row.CustomUrlId, ((ShowFullVanityUrl && !string.IsNullOrEmpty(FullVanityUrlTextBox.Text.Trim())) ? FullVanityUrlTextBox.Text.ToLowerInvariant() : null), VanityUrlTextBox.Text.ToLowerInvariant());
                    }
                    else
                    {
                        CustomUrlProvider.InsertCustomUrl(orgId, instId, ((ShowFullVanityUrl && !string.IsNullOrEmpty(FullVanityUrlTextBox.Text.Trim())) ? FullVanityUrlTextBox.Text.ToLowerInvariant() : null), VanityUrlTextBox.Text.ToLowerInvariant());
                    }

                    SimpleViewTitleLabel.Text = Resources.CustomUrlsControl_SimpleViewMessageLabel_Text;

                    if (SaveButtonClick != null)
                    {
                        SaveButtonClick(sender, e);
                    }
                }
                catch (ConstraintException ex)
                {
                    BaseControl.ShowError(ex, SimpleErrorPanel);
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Adds the Home page action.
        /// </summary>
        private void AddHomePageAction()
        {
            if (this.Count == 0)
            {
                return;
            }

            Action      homeItem  = null;
            Action      firstItem = this[0];
            UserContext user      = UserContext.Current;

            if (user != null)
            {
                homeItem = ActionProvider.FindAction(user.StartPageUrl);
            }
            else
            {
                homeItem = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl("~/default.aspx"));
                if (homeItem != null)
                {
                    if (homeItem.AuthenticationRequired)
                    {
                        homeItem = null;
                    }
                }
            }

            if (Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                if (homeItem != null)
                {
                    if ((homeItem != null) && (firstItem.ActionId == homeItem.ActionId))
                    {
                        base.Remove(firstItem);
                    }
                }
            }
            else
            {
                if ((homeItem != null) && (firstItem.ActionId != homeItem.ActionId))
                {
                    base.Insert(0, homeItem.Clone());
                }
            }
        }
Beispiel #24
0
        private static void Tree_SetNodeAttributes(RadTreeNode node)
        {
            if (node == null)
            {
                return;
            }

            ActionType type       = (ActionType)Enum.Parse(typeof(ActionType), node.Category);
            string     imageUrl   = null;
            Type       typeOfThis = typeof(ActionsControl);

            if (node.ParentNode == null)
            {
                imageUrl      = ResourceProvider.GetImageUrl(typeOfThis, "Folder.gif");
                node.Expanded = true;
            }

            switch (type)
            {
            case ActionType.GlobalNavigationLink:
                if (node.ParentNode != null)
                {
                    if (imageUrl == null)
                    {
                        imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "HyperLink.gif");
                    }
                }
                break;

            case ActionType.Page:
                if (imageUrl == null)
                {
                    imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "Page.gif");
                }
                break;

            case ActionType.Control:
                imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "Control.gif");
                break;
            }

            node.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(imageUrl);
        }
Beispiel #25
0
        /// <summary>
        /// Raises when a security module has established the identity of the user.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected virtual void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            string pageUrl = Request.AppRelativeCurrentExecutionFilePath;

            if (ResourceProvider.IsResourceUrl(pageUrl))
            {
                Context.SkipAuthorization = true;
            }
            else if (ActionProvider.IsPublicPage(pageUrl))
            {
                if ((!FrameworkConfiguration.Current.WebApplication.Password.EnablePasswordRetrieval) &&
                    (string.Compare(pageUrl, ResourceProvider.PasswordRecoveryPageVirtualPath, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    throw new HttpException(404, Resources.Error_404);
                }
                else
                {
                    Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                    if (action != null)
                    {
                        Context.SkipAuthorization = (!action.AuthenticationRequired);
                    }
                    else
                    {
                        Context.SkipAuthorization = true;
                    }

                    switch (FrameworkConfiguration.Current.WebApplication.AuthenticationMode)
                    {
                    case AuthenticationMode.Forms:
                        HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
                        if (authCookie == null)
                        {
                            FormsIdentity    id        = new FormsIdentity(new FormsAuthenticationTicket(string.Empty, false, FrameworkConfiguration.Current.WebApplication.Login.Timeout));
                            GenericPrincipal principal = new GenericPrincipal(id, null);
                            Context.User = principal;
                        }
                        break;
                    }
                }
            }
        }
Beispiel #26
0
        // Just validates the access rights of current user to specified URL.
        internal static void ValidateRedirectUrl(ref string redirectUrl)
        {
            if (!string.IsNullOrEmpty(redirectUrl))
            {
                if (string.Compare(CustomUrlProvider.CreateApplicationRelativeUrl(redirectUrl), "/", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    redirectUrl = null;
                }
                else
                {
                    Guid   actionId = Guid.Empty;
                    object obj      = Support.ConvertStringToType(Support.ExtractQueryStringParameterValue(redirectUrl, "pageid"), typeof(Guid));
                    if (obj != null)
                    {
                        actionId = (Guid)obj;
                    }

                    Micajah.Common.Bll.Action action = ActionProvider.FindAction(actionId, CustomUrlProvider.CreateApplicationAbsoluteUrl(redirectUrl));
                    if (action != null)
                    {
                        if (action.AuthenticationRequired)
                        {
                            UserContext user = UserContext.Current;
                            if (user != null && user.OrganizationId != Guid.Empty)
                            {
                                if (!user.ActionIdList.Contains(action.ActionId))
                                {
                                    redirectUrl = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        redirectUrl = null;
                    }
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// Returns the URL of the action to navigate.
        /// </summary>
        /// <param name="action">The action to get URL of.</param>
        /// <returns>The System.String that represents the URL of the action to navigate.</returns>
        public virtual string GetNavigateUrl(Action action)
        {
            if (action == null)
            {
                return(null);
            }

            if ((action.ActionId == ActionProvider.ConfigurationPageActionId) || (action.ActionId == ActionProvider.ConfigurationGlobalNavigationLinkActionId))
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(CustomUrlProvider.CreateApplicationRelativeUrl(ResourceProvider.AccountSettingsVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.LoginGlobalNavigationLinkActionId)
            {
                UserContext user = UserContext.Current;
                if ((user != null) && (user.OrganizationId == Guid.Empty))
                {
                    return(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.ActiveOrganizationPageVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(string.Empty);
                }
            }
            else if (action.ActionId == ActionProvider.StartGlobalNavigationLinkActionId)
            {
                Action page = ActionProvider.FindAction(ActionProvider.StartPageActionId);

                return(page.AbsoluteNavigateUrl);
            }

            return(action.NavigateUrl);
        }
Beispiel #28
0
        /// <summary>
        /// Renders the control and the logo of the copyright holder company.
        /// </summary>
        /// <param name="writer">The System.Web.UI.HtmlTextWriter to render content to.</param>
        /// <param name="control">The System.Web.UI.Control to render.</param>
        private static void RenderHeader(HtmlTextWriter writer, Control control)
        {
            if (writer == null)
            {
                return;
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Mp_Hdr");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "A");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            if (control != null)
            {
                control.RenderControl(writer);
            }
            writer.RenderEndTag();

            writer.AddStyleAttribute("line-height", "normal !important");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "G");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            using (HyperLink link = new HyperLink())
            {
                if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.LogoImageUrl))
                {
                    link.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.LogoImageUrl);
                    link.ToolTip  = FrameworkConfiguration.Current.WebApplication.Name;
                }
                else
                {
                    link.Text = FrameworkConfiguration.Current.WebApplication.Name;
                }
                link.RenderControl(writer);
            }
            writer.RenderEndTag();

            writer.RenderEndTag();
        }
        /// <summary>
        /// Occurs when the page is being loaded.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.CreatePageHeader(this.Page, false, false);

            if (!IsPostBack)
            {
                Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, action);

                if (string.Compare(Request.QueryString["ao"], "1", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.ActiveOrganizationControl_YouAreLoggedIntoAnotherOrganization, ErrorPanel);
                }

                LogOffLink.Text = Resources.ActiveOrganizationControl_LogoffLink_Text;

                UserContext user = UserContext.Current;

                if (user.IsFrameworkAdministrator)
                {
                    OrLabel1.Text = Resources.ActiveOrganizationControl_OrText;
                    SetupLinkContainer.Visible = true;
                    SetupLink.Text             = Resources.ActiveOrganizationControl_SetupLink_Text;
                    action = ActionProvider.PagesAndControls.FindByActionId(ActionProvider.SetupPageActionId);
                    if (action != null)
                    {
                        SetupLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                if (user.CanLogOnAsUser)
                {
                    OrLabel2.Text = Resources.ActiveOrganizationControl_OrText;
                    LogOnAsAnotherUserLinkContainer.Visible = true;
                    LogOnAsAnotherUserLink.Text             = Resources.ActiveOrganizationControl_LogOnAsAnotherUserLink_Text;
                    action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LoginAsUserGlobalNavigationLinkActionId);
                    if (action != null)
                    {
                        LogOnAsAnotherUserLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                OrganizationCollection coll = LoginProvider.Current.GetOrganizationsByLoginId(user.UserId);
                int count = 0;
                if (coll != null)
                {
                    count = coll.Count;
                    if (count > 1)
                    {
                        coll  = coll.FindAllVisible();
                        count = coll.Count;
                        if (count == 1)
                        {
                            if (user.OrganizationId != Guid.Empty)
                            {
                                if (coll[0].OrganizationId != user.OrganizationId)
                                {
                                    count = 2;
                                }
                            }
                        }
                    }
                }

                if (count == 0)
                {
                    if (user.IsFrameworkAdministrator)
                    {
                        OrLabel1.Visible = false;
                    }
                    else if (user.CanLogOnAsUser)
                    {
                        OrLabel2.Visible = false;
                    }
                }

                if (count == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithOrganizations, ErrorPanel);
                }
                else if ((count == 1) && (!user.CanLogOnAsUser))
                {
                    OrganizationArea.Visible = false;
                    OrLabel3.Visible         = false;
                    ErrorPanel.Style.Add(HtmlTextWriterStyle.PaddingBottom, "7px");
                    SelectOrganization(coll[0].OrganizationId, Request.QueryString["returnurl"], true, ErrorPanel);
                }
                else
                {
                    DescriptionLabel.Text = Resources.ActiveOrganizationControl_DescriptionLabel_Text;
                    OrLabel3.Text         = Resources.ActiveOrganizationControl_OrText;

                    coll.SortByExpiration();

                    OrganizationList.DataSource = coll;
                    OrganizationList.DataBind();
                }
            }

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnModernStyleSheet, true)));
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
        protected override bool IsSignatureValid(ITamperResistantOAuthMessage message)
        {
            message.Recipient = new Uri(new Uri(CustomUrlProvider.CreateApplicationUri(null)), message.Recipient.PathAndQuery);

            return(base.IsSignatureValid(message));
        }