Exemplo n.º 1
0
        private MMessageProfile populateProfile(UIMessageProfile uiProfile, MAccountProfile accountProfile)
        {
            MMessageProfile mProfile = new MMessageProfile();

            if (accountProfile == null)
            {
                accountProfile = new MAccountProfile();
            }
            if (uiProfile.Id > 0)
            {
                mProfile             = MessageUtility.GetProfile(uiProfile.Id);
                mProfile.UpdatedBy   = accountProfile.Id;
                mProfile.UpdatedDate = DateTime.Now;
            }
            else
            {
                mProfile.AddedBy   = accountProfile.Id;
                mProfile.AddedDate = DateTime.Now;
            }
            mProfile.Body                = HttpContext.Current.Server.UrlDecode(uiProfile.Body);
            mProfile.Description         = uiProfile.Description;
            mProfile.FormatAsHtml        = uiProfile.FormatAsHtml;
            mProfile.Id                  = uiProfile.Id;
            mProfile.Name                = uiProfile.Name;
            mProfile.SecurityEntitySeqId = SecurityEntityUtility.CurrentProfile().Id;
            mProfile.Title               = uiProfile.Title;
            return(mProfile);
        }
Exemplo n.º 2
0
        public IHttpActionResult SaveMembers(UIAccounts groupAccounts)
        {
            string        mRetVal       = "false";
            Logger        mLog          = Logger.Instance();
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditGroups", true)), AccountUtility.CurrentProfile());

            if (!mSecurityInfo.MayEdit)
            {
                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            if (HttpContext.Current.Items["EditId"] == null || HttpContext.Current.Items["EditId"].ToString().ToLowerInvariant() != groupAccounts.SeqId.ToString().ToLowerInvariant())
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            MAccountProfile     accountProfile      = AccountUtility.CurrentProfile();
            MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(accountProfile.Account);
            MGroupRoles         mProfile            = new MGroupRoles();

            mProfile.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id;
            mProfile.GroupSeqId       = groupAccounts.SeqId;
            mProfile.Roles            = String.Join(",", groupAccounts.Accounts);
            mProfile.AddedUpdatedBy   = accountProfile.Id;
            GroupUtility.UpdateGroupRoles(mProfile);
            return(Ok(mRetVal));
        }
Exemplo n.º 3
0
 private void populateRoles()
 {
     ctlRoles.DataSource    = RoleUtility.GetRolesArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
     ctlRoles.SelectedItems = m_Profile.AssignedRoles.ToArray();
     ctlRoles.DataBind();
     foreach (String role in m_Profile.DerivedRoles)
     {
         lstBoxRoles.Items.Add(role);
     }
 }
Exemplo n.º 4
0
        MGroupProfile populateProfile(MUIGroupProfile profile)
        {
            MGroupProfile mRetVal = new MGroupProfile();

            mRetVal.Name             = profile.Name;
            mRetVal.Description      = profile.Description;
            mRetVal.Id               = profile.Id;
            mRetVal.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id;
            return(mRetVal);
        }
Exemplo n.º 5
0
        public static string Decrypt(string textValue)
        {
            string        mRetVal       = "Not Authorized";
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_Encryption_Helper", true)), AccountUtility.CurrentProfile());

            if (mSecurityInfo.MayView)
            {
                mRetVal = CryptoUtility.Decrypt(textValue.Trim(), SecurityEntityUtility.CurrentProfile().EncryptionType, ConfigSettings.EncryptionSaltExpression);
            }
            return(mRetVal);
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MAccountProfile mAccountProfile = AccountUtility.CurrentProfile();
            int             mSecurityId     = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId]);

            dropSecurityEntities.DataSource     = SecurityEntityUtility.GetValidSecurityEntities(mAccountProfile.Account, mSecurityId, mAccountProfile.IsSystemAdmin);
            dropSecurityEntities.DataValueField = "SE_SEQ_ID";
            dropSecurityEntities.DataTextField  = "NAME";
            dropSecurityEntities.DataBind();
            NameValuePairUtility.SetDropSelection(dropSecurityEntities, mSecurityId.ToString());
        }
Exemplo n.º 7
0
        MRoleProfile populateProfile(MUIRoleProfile profile)
        {
            MRoleProfile mRetVal = new MRoleProfile();

            mRetVal.Name             = profile.Name;
            mRetVal.Description      = profile.Description;
            mRetVal.Id               = profile.Id;
            mRetVal.IsSystem         = profile.IsSystem;
            mRetVal.IsSystemOnly     = profile.IsSystemOnly;
            mRetVal.SecurityEntityId = SecurityEntityUtility.CurrentProfile().Id;
            return(mRetVal);
        }
Exemplo n.º 8
0
        private void bindData(MSearchCriteria searchCriteria)
        {
            DataTable mDataTable = SecurityEntityUtility.Search(searchCriteria);

            if (mDataTable != null && mDataTable.Rows.Count > 0)
            {
                DataView mDataView = mDataTable.DefaultView;
                recordsReturned.Value    = mDataTable.Rows[0][0].ToString();
                searchResults.DataSource = mDataTable;
                searchResults.DataBind();
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int             mSecurityEntityID = SecurityEntityUtility.DefaultProfile().Id;
            MAccountProfile mAccountProfile   = AccountUtility.CurrentProfile();

            if (mAccountProfile != null)
            {
                mSecurityEntityID = int.Parse(ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account)[MClientChoices.SecurityEntityId].ToString());
            }
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(mSecurityEntityID);

            formStyles.Attributes["href"] = GWWebHelper.RootSite + "/Content/FormStyles/" + mSecurityEntityProfile.Style + ".css";
        }
Exemplo n.º 10
0
        public IHttpActionResult RequestChange(string account)
        {
            string                 mRetVal  = string.Empty;
            MAccountProfile        mProfile = AccountUtility.GetProfile(account);
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MMessageProfile        mMessageProfile        = MessageUtility.GetProfile("Request Password Reset UI");

            mRetVal = mMessageProfile.Body;
            string clearTextAccount = string.Empty;
            Logger mLog             = Logger.Instance();

            if (mProfile != null)
            {
                MAccountProfile mAccountProfile = mProfile;
                mAccountProfile.FailedAttempts = 0;
                mAccountProfile.Status         = 4;
                mAccountProfile.Password       = CryptoUtility.Encrypt(GWWebHelper.GetNewGuid, mSecurityEntityProfile.EncryptionType);
                mAccountProfile.UpdatedBy      = AccountUtility.GetProfile("anonymous").Id;
                mAccountProfile.UpdatedDate    = DateTime.Now;

                clearTextAccount = CryptoUtility.Decrypt(mProfile.Password, mSecurityEntityProfile.EncryptionType);
                try
                {
                    mMessageProfile = MessageUtility.GetProfile("RequestNewPassword");
                    MRequestNewPassword mRequestNewPassword = new MRequestNewPassword(mMessageProfile);
                    mRequestNewPassword.AccountName = HttpUtility.UrlEncode(CryptoUtility.Encrypt(mProfile.Account, mSecurityEntityProfile.EncryptionType));
                    mRequestNewPassword.FullName    = mProfile.FirstName + " " + mProfile.LastName;
                    mRequestNewPassword.Password    = HttpUtility.UrlEncode(mProfile.Password);
                    mRequestNewPassword.Server      = GWWebHelper.RootSite;
                    mProfile = AccountUtility.Save(mProfile, false, false);
                    NotifyUtility.SendMail(mRequestNewPassword, mProfile);
                    mLog.Debug("Reset password for account " + clearTextAccount);
                }
                catch (SmtpException ex)
                {
                    Exception myException = new Exception("Could not send e-mail." + ex.Message);
                    mLog.Error(myException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("PasswordSendMailError");
                    mRetVal         = mMessageProfile.Body;
                }
                catch (Exception ex)
                {
                    Exception mException = new Exception("Could not set account details." + ex.Message);
                    mLog.Error(mException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("ErrorAccountDetails");
                    mRetVal         = mMessageProfile.Body;
                }
            }
            return(Ok(mRetVal));
        }
Exemplo n.º 11
0
        protected new void Page_PreInit(object sender, EventArgs e)
        {
            base.Page_PreInit(sender, e);
            if (ConfigSettings.ForceHttps && HttpContext.Current.Request.Url.Scheme.ToLowerInvariant() != "https")
            {
                Response.Redirect(ConfigSettings.RootSite);
            }
            MSecurityEntityProfile mSecProfile = SecurityEntityUtility.CurrentProfile();
            String mMasterPage = "Content/Skins/" + mSecProfile.Skin + "/" + mSecProfile.Skin + ".master";
            string fileName    = null;

            fileName = HttpContext.Current.Server.MapPath("~\\") + mMasterPage;
            if (!File.Exists(fileName))
            {
                mMasterPage = "Content/Skins/Default/Default.Master";
            }
            this.MasterPageFile = mMasterPage;
        }
Exemplo n.º 12
0
        public IHttpActionResult SelectSecurityEntity([FromUri] int selectedSecurityEntityId)
        {
            MSecurityEntityProfile targetSEProfile     = SecurityEntityUtility.GetProfile(selectedSecurityEntityId);
            MSecurityEntityProfile currentSEProfile    = SecurityEntityUtility.CurrentProfile();
            MClientChoicesState    mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(AccountUtility.CurrentProfile().Account);
            MMessageProfile        mMessageProfile     = null;

            try
            {
                if (!ConfigSettings.CentralManagement)
                {
                    mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString();
                    mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                }
                else
                {
                    if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString)
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString();
                        mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                    }
                    else
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = ConfigSettings.DefaultSecurityEntityId.ToString();
                        mClientChoicesState[MClientChoices.SecurityEntityName] = "System";
                    }
                }
                MMessageProfile myMessageProfile = new MMessageProfile();
                // update all of your in memory information
                AccountUtility.RemoveInMemoryInformation(true);
                ClientChoicesUtility.Save(mClientChoicesState);
                mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity");
            }
            catch (Exception ex)
            {
                Logger mLog = Logger.Instance();
                mMessageProfile = MessageUtility.GetProfile("NoDataFound");
                Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex);
                mLog.Error(myEx);
            }
            // refresh the view
            return(Ok(mMessageProfile.Body));
        }
Exemplo n.º 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(Request.QueryString["SecurityEntitySeqId"]))
     {
         int mAccountSeqID = int.Parse(Request.QueryString["SecurityEntitySeqId"]);
         if (mAccountSeqID != -1)
         {
             m_Profile = SecurityEntityUtility.GetProfile(mAccountSeqID);
         }
         else
         {
             m_Profile = new MSecurityEntityProfile();
             m_Profile.DataAccessLayerAssemblyName = "GrowthWareFramework";
             m_Profile.DataAccessLayerNamespace    = "GrowthWare.Framework.DataAccessLayer.SQLServer.V2008";
         }
     }
     HttpContext.Current.Session.Add("EditId", m_Profile.Id);
     populatePage();
 }
Exemplo n.º 14
0
        public string SetSelectedSecurityEntity(int selectedSecurityEntityId)
        {
            MSecurityEntityProfile targetSEProfile     = SecurityEntityUtility.GetProfile(selectedSecurityEntityId);
            MSecurityEntityProfile currentSEProfile    = SecurityEntityUtility.CurrentProfile();
            MClientChoicesState    mClientChoicesState = (MClientChoicesState)HttpContext.Current.Cache[MClientChoices.SessionName];
            MMessageProfile        mMessageProfile     = null;

            try
            {
                if (!ConfigSettings.CentralManagement)
                {
                    //SecurityEntityUtility.SetSessionSecurityEntity(targetSEProfile)
                    mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture);
                    mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                }
                else
                {
                    if (currentSEProfile.ConnectionString == targetSEProfile.ConnectionString)
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = targetSEProfile.Id.ToString(CultureInfo.InvariantCulture);
                        mClientChoicesState[MClientChoices.SecurityEntityName] = targetSEProfile.Name;
                    }
                    else
                    {
                        mClientChoicesState[MClientChoices.SecurityEntityId]   = ConfigSettings.DefaultSecurityEntityId.ToString(CultureInfo.InvariantCulture);
                        mClientChoicesState[MClientChoices.SecurityEntityName] = "System";
                    }
                }
                ClientChoicesUtility.Save(mClientChoicesState);
                AccountUtility.RemoveInMemoryInformation(true);
                mMessageProfile = MessageUtility.GetProfile("ChangedSelectedSecurityEntity");
            }
            catch (Exception ex)
            {
                MMessageProfile myMessageProfile = new MMessageProfile();
                Logger          mLog             = Logger.Instance();
                mMessageProfile = MessageUtility.GetProfile("NoDataFound");
                Exception myEx = new Exception("SelectSecurityEntity:: reported an error.", ex);
                mLog.Error(myEx);
            }
            // update all of your in memory information
            return(mMessageProfile.Body);
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            noResults.Visible = false;
            searchResults.HeaderStyle.ForeColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeaderForeColor]);
            searchResults.HeaderStyle.BackColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeadColor]);
            searchResults.AlternatingRowStyle.BackColor = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.AlternatingRowBackColor]);
            searchResults.RowStyle.BackColor            = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.RowBackColor]);
            if (!String.IsNullOrEmpty(GWWebHelper.GetQueryValue(Request, "Columns")))
            {
                MSearchCriteria mSearchCriteria = new MSearchCriteria();
                mSearchCriteria.Columns          = GWWebHelper.GetQueryValue(Request, "Columns");
                mSearchCriteria.OrderByColumn    = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "OrderByColumn"));
                mSearchCriteria.OrderByDirection = GWWebHelper.GetQueryValue(Request, "OrderByDirection");
                int mTryParse = 0;
                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "PageSize"), out mTryParse))
                {
                    mSearchCriteria.PageSize = int.Parse(GWWebHelper.GetQueryValue(Request, "PageSize"));
                }
                else
                {
                    mSearchCriteria.PageSize = 10;
                }

                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "SelectedPage"), out mTryParse))
                {
                    mSearchCriteria.SelectedPage = int.Parse(GWWebHelper.GetQueryValue(Request, "SelectedPage"));
                }
                else
                {
                    mSearchCriteria.SelectedPage = 1;
                }
                mSearchCriteria.WhereClause  = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "WhereClause"));
                mSearchCriteria.WhereClause += " AND Security_Entity_SeqID = " + SecurityEntityUtility.CurrentProfile().Id.ToString();
                mSearchCriteria.WhereClause  = mSearchCriteria.WhereClause.Replace("\"", String.Empty);
                bindData(mSearchCriteria);
            }
        }
Exemplo n.º 16
0
 private void populateGroups()
 {
     ctlGroups.DataSource    = GroupUtility.GetGroupsArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
     ctlGroups.SelectedItems = m_Profile.Groups.ToArray();
     ctlGroups.DataBind();
 }
Exemplo n.º 17
0
        private void populatePage()
        {
            litSecurityEntity.Text = m_Profile.Name;
            txtSecurityEntity.Text = m_Profile.Name;
            if (m_Profile.Id == -1)
            {
                litSecurityEntity.Visible = false;
                txtSecurityEntity.Style.Add("display", "");
            }
            else
            {
                litSecurityEntity.Visible = true;
                txtSecurityEntity.Style.Add("display", "none");
            }
            txtSeqID.Text       = m_Profile.Id.ToString();
            txtDescription.Text = m_Profile.Description;
            txtURL.Text         = m_Profile.Url;
            try
            {
                txtConnectionstring.Text = CryptoUtility.Decrypt(m_Profile.ConnectionString, SecurityEntityUtility.CurrentProfile().EncryptionType);
            }
            catch (Exception)
            {
                txtConnectionstring.Text = m_Profile.ConnectionString;
            }
            litSecurityEntityTranslation.Text = ConfigSettings.SecurityEntityTranslation;
            txtAssembly_Name.Text             = m_Profile.DataAccessLayerAssemblyName;
            txtName_Space.Text = m_Profile.DataAccessLayerNamespace;
            MDirectoryProfile myDirectoryInfo = new MDirectoryProfile();
            DataView          dvSkin          = new DataView();

            dvSkin                  = FileUtility.GetDirectoryTableData(GWWebHelper.SkinPath, myDirectoryInfo, false).DefaultView;
            dvSkin.RowFilter        = "Type = 'folder'";
            dropSkin.DataSource     = dvSkin;
            dropSkin.DataTextField  = "Name";
            dropSkin.DataValueField = "Name";
            dropSkin.DataBind();

            DataView dvStyles = new DataView();

            dvStyles                  = FileUtility.GetDirectoryTableData(Server.MapPath(@"~\Content\FormStyles"), myDirectoryInfo, true).DefaultView;
            dvStyles.RowFilter        = "[Name] like '%.css'";
            dropStyles.DataSource     = dvStyles;
            dropStyles.DataTextField  = "ShortFileName";
            dropStyles.DataValueField = "ShortFileName";
            dropStyles.DataBind();
            Collection <MSecurityEntityProfile> mProfiles = SecurityEntityUtility.Profiles();

            dropParent.DataSource = mProfiles;
            MSecurityEntityProfile mm = new MSecurityEntityProfile();

            dropParent.DataTextField  = "Name";
            dropParent.DataValueField = "Id";
            dropParent.DataBind();
            ListItem lstItem = new ListItem();

            lstItem.Text  = "None";
            lstItem.Value = "-1";
            dropParent.Items.Add(lstItem);
            NameValuePairUtility.SetDropSelection(dropParent, m_Profile.ParentSeqId.ToString());
            NameValuePairUtility.SetDropSelection(dropSkin, m_Profile.Skin);
            NameValuePairUtility.SetDropSelection(dropStyles, m_Profile.Style);
            NameValuePairUtility.SetDropSelection(dropStatus, m_Profile.StatusSeqId.ToString());
            NameValuePairUtility.SetDropSelection(dropDAL, m_Profile.DataAccessLayer);
            NameValuePairUtility.SetDropSelection(dropEncryptionType, m_Profile.EncryptionType.ToString());
        }
Exemplo n.º 18
0
        public IHttpActionResult SaveNameValuePair(UINVPProfile uiProfile)
        {
            string         mRetVal  = false.ToString();
            MNameValuePair mProfile = new MNameValuePair();
            String         mAction  = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");
            int            mEditId  = int.Parse(HttpContext.Current.Items["EditId"].ToString());
            Logger         mLog     = Logger.Instance();

            if (mEditId != uiProfile.NVP_SEQ_ID)
            {
                Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }

            MAccountProfile        mUpdatingAccount       = AccountUtility.CurrentProfile();
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MSecurityInfo          mSecurityInfo          = new MSecurityInfo(FunctionUtility.GetProfile(mAction), mUpdatingAccount);
            String mGroups        = String.Join(",", uiProfile.Groups);
            String mRoles         = String.Join(",", uiProfile.Roles);
            String mCommaSepRoles = mUpdatingAccount.GetCommaSeparatedAssignedRoles;

            if (uiProfile.NVP_SEQ_ID != -1)
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to add");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            else
            {
                if (!mSecurityInfo.MayAdd)
                {
                    Exception mError = new Exception("The account (" + mUpdatingAccount.Account + ") being used does not have the correct permissions to edit");
                    mLog.Error(mError);
                    return(this.InternalServerError(mError));
                }
            }
            if (uiProfile.NVP_SEQ_ID != -1)
            {
                mProfile = NameValuePairUtility.GetNameValuePair(uiProfile.NVP_SEQ_ID);
            }
            else
            {
                mProfile.AddedBy   = mUpdatingAccount.Id;
                mProfile.AddedDate = DateTime.Today;
            }

            mProfile.UpdatedBy   = mUpdatingAccount.Id;
            mProfile.UpdatedDate = DateTime.Today;
            mProfile.StaticName  = uiProfile.STATIC_NAME;
            mProfile.SchemaName  = uiProfile.SchemaName;
            mProfile.Display     = uiProfile.Display;
            mProfile.Description = uiProfile.Description;
            mProfile.Status      = uiProfile.Status;
            int mID         = NameValuePairUtility.Save(mProfile);
            int mSecurityId = mSecurityEntityProfile.Id;

            NameValuePairUtility.UpdateRoles(mID, mSecurityId, mRoles, mProfile);
            NameValuePairUtility.UpdateGroups(mID, mSecurityId, mGroups, mProfile);
            return(this.Ok(mRetVal));
        }
Exemplo n.º 19
0
        public IHttpActionResult Save(UIAccountProfile uiProfile)
        {
            if (uiProfile == null)
            {
                throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            string          mRetVal                = "false";
            bool            mSaveGroups            = false;
            bool            mSaveRoles             = false;
            MAccountProfile mCurrentAccountProfile = AccountUtility.CurrentProfile();
            MAccountProfile mAccountProfileToSave  = new MAccountProfile();
            Logger          mLog = Logger.Instance();

            if (HttpContext.Current.Request.QueryString["Action"].ToString().ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1)
            {
                MAccountProfile mExistingAccount = AccountUtility.GetProfile(uiProfile.Account);
                if (mExistingAccount == null)
                {
                    mAccountProfileToSave    = populateAccountProfile(uiProfile, mAccountProfileToSave);
                    mAccountProfileToSave.Id = uiProfile.Id;
                    string mGroups = ConfigSettings.RegistrationGroups;
                    string mRoles  = ConfigSettings.RegistrationRoles;
                    if (!string.IsNullOrEmpty(mGroups))
                    {
                        mSaveGroups = true;
                    }
                    if (!string.IsNullOrEmpty(mRoles))
                    {
                        mSaveRoles = true;
                    }
                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                    mAccountProfileToSave.AddedDate = DateTime.Now;
                    mAccountProfileToSave.SetGroups(mGroups);
                    mAccountProfileToSave.SetRoles(mRoles);
                    mAccountProfileToSave.PasswordLastSet = DateTime.Now;
                    mAccountProfileToSave.LastLogOn       = DateTime.Now;
                    mAccountProfileToSave.Password        = CryptoUtility.Encrypt(ConfigSettings.RegistrationPassword, ConfigSettings.EncryptionType);
                    mAccountProfileToSave.Status          = int.Parse(ConfigSettings.RegistrationStatusId);
                    if (HttpContext.Current.Request.QueryString["Action"].ToString().ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1)
                    {
                        mAccountProfileToSave.Status = (int)SystemStatus.Active;
                    }
                    MClientChoicesState    mClientChoiceState     = ClientChoicesUtility.GetClientChoicesState(ConfigSettings.RegistrationAccountChoicesAccount, true);
                    MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(ConfigSettings.RegistrationSecurityEntityId);
                    string mCurrentSecurityEntityId = mClientChoiceState[MClientChoices.SecurityEntityId];

                    mClientChoiceState.IsDirty = false;
                    mClientChoiceState[MClientChoices.AccountName]        = mAccountProfileToSave.Account;
                    mClientChoiceState[MClientChoices.SecurityEntityId]   = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture);
                    mClientChoiceState[MClientChoices.SecurityEntityName] = mSecurityEntityProfile.Name;
                    try
                    {
                        AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups, mSecurityEntityProfile);
                        ClientChoicesUtility.Save(mClientChoiceState, false);
                        AccountUtility.SetPrincipal(mAccountProfileToSave);
                        mRetVal = "Your account has been created";
                    }
                    catch (Exception ex)
                    {
                        mLog.Error(ex);
                    }
                }
                else
                {
                    mRetVal = "The account '" + uiProfile.Account + "' already exists please choose a different account/email";
                }
            }
            else
            {
                if ((HttpContext.Current.Items["EditId"] != null) | mCurrentAccountProfile.Status == (int)SystemStatus.SetAccountDetails)
                {
                    int mEditId = 0;
                    if ((HttpContext.Current.Items["EditId"] != null))
                    {
                        mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                    }
                    else
                    {
                        mEditId = mCurrentAccountProfile.Id;
                    }
                    if (mEditId == uiProfile.Id)
                    {
                        MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
                        if ((mSecurityInfo != null))
                        {
                            if (mEditId != -1)
                            {
                                if (mCurrentAccountProfile.Id != uiProfile.Id)
                                {
                                    mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true)), mCurrentAccountProfile);
                                }
                                if (mSecurityInfo.MayEdit | mCurrentAccountProfile.Status == (int)SystemStatus.SetAccountDetails)
                                {
                                    MSecurityInfo mGroupTabSecurity = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_View_Account_Group_Tab", true)), mCurrentAccountProfile);
                                    MSecurityInfo mRoleTabSecurity  = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_View_Account_Role_Tab", true)), mCurrentAccountProfile);
                                    mAccountProfileToSave    = AccountUtility.GetProfile(mEditId);
                                    mAccountProfileToSave    = populateAccountProfile(uiProfile, mAccountProfileToSave);
                                    mAccountProfileToSave.Id = uiProfile.Id;
                                    string mGroups = string.Join(",", uiProfile.AccountGroups.Groups);
                                    string mRoles  = string.Join(",", uiProfile.AccountRoles.Roles);
                                    if (mGroupTabSecurity.MayView & FunctionUtility.CurrentProfile().Action.ToLowerInvariant() == ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true).ToLower(CultureInfo.InvariantCulture))
                                    {
                                        if (mAccountProfileToSave.GetCommaSeparatedAssignedGroups != mGroups)
                                        {
                                            mSaveGroups = true;
                                            mAccountProfileToSave.SetGroups(mGroups);
                                        }
                                    }
                                    if (mRoleTabSecurity.MayView & FunctionUtility.CurrentProfile().Action.ToLowerInvariant() == ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true).ToLower(CultureInfo.InvariantCulture))
                                    {
                                        if (mAccountProfileToSave.GetCommaSeparatedAssignedRoles != mRoles)
                                        {
                                            mSaveRoles = true;
                                            mAccountProfileToSave.SetRoles(mRoles);
                                        }
                                    }
                                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate = DateTime.Now;
                                    AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups);
                                    mLog.Debug("Saved account " + mAccountProfileToSave.Account + " by " + mCurrentAccountProfile.Account);
                                    mRetVal = "true";
                                }
                                else
                                {
                                    Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit");
                                    mLog.Error(mError);
                                    return(this.InternalServerError(mError));
                                }
                            }
                            else
                            {
                                if (mSecurityInfo.MayAdd)
                                {
                                    mSaveGroups                     = true;
                                    mSaveRoles                      = true;
                                    mAccountProfileToSave           = populateAccountProfile(uiProfile, mAccountProfileToSave);
                                    mAccountProfileToSave.Id        = -1;
                                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate = DateTime.Now;

                                    mAccountProfileToSave.AddedBy         = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate       = DateTime.Now;
                                    mAccountProfileToSave.PasswordLastSet = DateTime.Now;
                                    mAccountProfileToSave.LastLogOn       = DateTime.Now;
                                    mAccountProfileToSave.Password        = CryptoUtility.Encrypt(ConfigSettings.RegistrationPassword, ConfigSettings.EncryptionType);
                                    mAccountProfileToSave.Status          = ConfigSettings.AutoCreateAccountStatusId;
                                    string mGroups = string.Join(",", uiProfile.AccountGroups.Groups);
                                    string mRoles  = string.Join(",", uiProfile.AccountRoles.Roles);
                                    mAccountProfileToSave.SetGroups(mGroups);
                                    mAccountProfileToSave.SetRoles(mRoles);
                                    try
                                    {
                                        AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups);
                                    }
                                    catch (Exception ex)
                                    {
                                        mLog.Error(ex);
                                    }
                                    mLog.Debug("Added account " + mAccountProfileToSave.Account + " by " + mCurrentAccountProfile.Account);
                                    mRetVal = "true";
                                }
                                else
                                {
                                    Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                                    mLog.Error(mError);
                                    return(this.InternalServerError(mError));
                                }
                            }
                        }
                        else
                        {
                            Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!");
                            mLog.Error(mError);
                            return(this.InternalServerError(mError));
                        }
                    }
                    else
                    {
                        Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
            }

            return(Ok(mRetVal));
        }
Exemplo n.º 20
0
        public IHttpActionResult Save(MUISecurityEntityProfile uiProfile)
        {
            if (uiProfile == null)
            {
                new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            bool          mRetVal       = false;
            Logger        mLog          = Logger.Instance();
            var           session       = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
            MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditSecurityEntity", true)), AccountUtility.CurrentProfile());

            if (mSecurityInfo != null)
            {
                if (HttpContext.Current.Session["EditId"] != null)
                {
                    int mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                    if (mEditId == int.Parse(uiProfile.Id))
                    {
                        if (mEditId != -1)
                        {
                            if (mSecurityInfo.MayEdit)
                            {
                                MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(mEditId);
                                mSecurityEntityProfile    = populateSecurityEntity(uiProfile);
                                mSecurityEntityProfile.Id = int.Parse(uiProfile.Id);
                                SecurityEntityUtility.Save(mSecurityEntityProfile);
                                mRetVal = true;
                            }
                            else
                            {
                                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                                mLog.Error(mError);
                                return(this.InternalServerError(mError));
                            }
                        }
                        else
                        {
                            if (mSecurityInfo.MayAdd)
                            {
                                MSecurityEntityProfile mSecurityEntityProfile = populateSecurityEntity(uiProfile);
                                mSecurityEntityProfile.Id          = -1;
                                mSecurityEntityProfile.AddedBy     = AccountUtility.CurrentProfile().Id;
                                mSecurityEntityProfile.AddedDate   = DateTime.Now;
                                mSecurityEntityProfile.UpdatedBy   = mSecurityEntityProfile.AddedBy;
                                mSecurityEntityProfile.UpdatedDate = mSecurityEntityProfile.AddedDate;
                                SecurityEntityUtility.Save(mSecurityEntityProfile);
                                mRetVal = true;
                            }
                            else
                            {
                                Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                                mLog.Error(mError);
                                return(this.InternalServerError(mError));
                            }
                        }
                    }
                    else
                    {
                        Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
            }
            else
            {
                Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!");
                mLog.Error(mError);
                return(this.InternalServerError(mError));
            }
            return(this.Ok(mRetVal));
        }
Exemplo n.º 21
0
        private void populateGeneral()
        {
            //litFunctionSeqId.Text = m_Profile.Id.ToString();
            divFunctionSeqId.InnerHtml = m_Profile.Id.ToString();
            txtName.Value        = m_Profile.Name;
            txtDescription.Value = m_Profile.Description;
            txtNotes.Text        = m_Profile.Notes;
            txtKeyWords.Text     = m_Profile.MetaKeywords;

            divAction.InnerHtml = m_Profile.Action;
            divAction.Visible   = true;
            txtAction.Text      = m_Profile.Action;
            //txtAction.Visible = false;

            txtSource.Text = m_Profile.Source;

            chkEnableViewState.Checked     = m_Profile.EnableViewState;
            chkEnableNotifications.Checked = m_Profile.EnableNotifications;
            chkRedirectOnTimeout.Checked   = m_Profile.RedirectOnTimeout;
            chkNoUI.Checked  = m_Profile.NoUI;
            chkIsNav.Checked = m_Profile.IsNavigable;

            RolesControl.AllRoles            = RoleUtility.GetRolesArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
            RolesControl.SelectedAddRoles    = m_Profile.AssignedAddRoles.ToArray();
            RolesControl.SelectedDeleteRoles = m_Profile.AssignedDeleteRoles.ToArray();
            RolesControl.SelectedEditRoles   = m_Profile.AssignedEditRoles.ToArray();
            RolesControl.SelectedViewRoles   = m_Profile.AssignedViewRoles.ToArray();

            GroupsControl.AllGroups            = GroupUtility.GetGroupsArrayListBySecurityEntity(SecurityEntityUtility.CurrentProfile().Id);
            GroupsControl.SelectedAddGroups    = m_Profile.AddGroups.ToArray();
            GroupsControl.SelectedDeleteGroups = m_Profile.DeleteGroups.ToArray();
            GroupsControl.SelectedEditGroups   = m_Profile.EditGroups.ToArray();
            GroupsControl.SelectedViewGroups   = m_Profile.ViewGroups.ToArray();
        }
Exemplo n.º 22
0
        public IHttpActionResult ChangePassword(MChangePassword mChangePassword)
        {
            if (mChangePassword == null)
            {
                throw new ArgumentNullException("mChangePassword", "mChangePassword cannot be a null reference (Nothing in Visual Basic)!");
            }
            MMessageProfile        mMessageProfile        = new MMessageProfile();
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MAccountProfile        mAccountProfile        = AccountUtility.CurrentProfile();
            string mCurrentPassword = "";

            mMessageProfile = MessageUtility.GetProfile("SuccessChangePassword");
            try
            {
                mCurrentPassword = CryptoUtility.Decrypt(mAccountProfile.Password, mSecurityEntityProfile.EncryptionType);
            }
            catch (Exception)
            {
                mCurrentPassword = mAccountProfile.Password;
            }
            if (mAccountProfile.Status != (int)SystemStatus.ChangePassword)
            {
                if (mChangePassword.OldPassword != mCurrentPassword)
                {
                    mMessageProfile = MessageUtility.GetProfile("PasswordNotMatched");
                }
                else
                {
                    mAccountProfile.PasswordLastSet = System.DateTime.Now;
                    mAccountProfile.Status          = (int)SystemStatus.Active;
                    mAccountProfile.FailedAttempts  = 0;
                    mAccountProfile.Password        = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType);
                    try
                    {
                        AccountUtility.Save(mAccountProfile, false, false);
                    }
                    catch (Exception)
                    {
                        mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword");
                    }
                }
            }
            else
            {
                try
                {
                    var _with2 = mAccountProfile;
                    _with2.PasswordLastSet = System.DateTime.Now;
                    _with2.Status          = (int)SystemStatus.Active;
                    _with2.FailedAttempts  = 0;
                    _with2.Password        = CryptoUtility.Encrypt(mChangePassword.NewPassword.Trim(), mSecurityEntityProfile.EncryptionType);
                    AccountUtility.Save(mAccountProfile, false, false);
                }
                catch (Exception)
                {
                    mMessageProfile = MessageUtility.GetProfile("UnSuccessChangePassword");
                }
            }
            AccountUtility.RemoveInMemoryInformation(true);
            return(Ok(mMessageProfile.Body));
        }