public override DeleteRoleRes Execute(DeleteRoleReq pServiceRequest) { Rol wRol; DeleteRoleRes wRes = new DeleteRoleRes(); //Elimina el rol: Este componente si el rol tiene o no asociado usuarios //FwkMembership.DeleteRole(pServiceRequest.BusinessData.RolName, pServiceRequest.SecurityProviderName); if (FwkMembership.GetUsersInRole(pServiceRequest.BusinessData.RolName, pServiceRequest.SecurityProviderName).Count != 0) { throw new FunctionalException(string.Format("El rol {0} contiene usuarios asociados.-", pServiceRequest.BusinessData.RolName)); } //Elimino todas las asociciones de las reglas al rol.- Se modificara el valor Expression de la regla List <FwkAuthorizationRule> ruleListAux = FwkMembership.GetRulesByRole(pServiceRequest.BusinessData.RolName, pServiceRequest.SecurityProviderName); //TODO: Revisar este codigo e actualizacion de reglas si esta bien foreach (FwkAuthorizationRule rule in ruleListAux) { wRol = new Rol(pServiceRequest.BusinessData.RolName); FwkMembership.RemoveRol_From_Rule(wRol, rule); FwkMembership.UpdateRule(rule, pServiceRequest.SecurityProviderName); } FwkMembership.DeleteRole(pServiceRequest.BusinessData.RolName, pServiceRequest.SecurityProviderName); return(wRes); }
public override UpdateRulesRes Execute(UpdateRulesReq pServiceRequest) { UpdateRulesRes wRes = new UpdateRulesRes(); pServiceRequest.BusinessData.FwkAuthorizationRuleList.ForEach(r => FwkMembership.UpdateRule(r, pServiceRequest.SecurityProviderName)); return(wRes); }
/// <summary> /// Cambia la password.- /// Si pOldPassword es = null se resetea y luego se asigna pNewPassword /// </summary> /// <param name="pUserName">Nombre de usuario</param> /// <param name="pOldPassword">Password anterior.- Si es en String.Empty se resetea</param> /// <param name="pNewPassword">Nueva password</param> public void ChangePassword(string pUserName, string pOldPassword, string pNewPassword) { if (string.IsNullOrEmpty(pOldPassword)) { try { pOldPassword = FwkMembership.ResetUserPassword(pUserName, _ProviderName); } catch (System.Web.Security.MembershipPasswordException) { FwkMembership.UnlockUser(pUserName, _ProviderName); pOldPassword = FwkMembership.ResetUserPassword(pUserName, _ProviderName); } catch (Exception er) { throw er; } } if (!FwkMembership.ChangeUserPassword(pUserName, pOldPassword, pNewPassword, _ProviderName)) { TechnicalException te = new TechnicalException(string.Format(Fwk.Security.Properties.Resource.User_InvalidCredentialsMessage, pUserName)); ExceptionHelper.SetTechnicalException <FwkMembership>(te); te.ErrorId = "4007"; throw te; } }
private void btnLogOn_Click(object sender, EventArgs e) { // Prompt the user for name and password this.credentialsForm.Text = Properties.Resources.AuthenticateTitleMessage; DialogResult result = this.credentialsForm.ShowDialog(); if (result == DialogResult.OK) { using (new WaitCursorHelper(this)) { _Authenticated = FwkMembership.ValidateUser(this.credentialsForm.Username, this.credentialsForm.Password, Membership.Provider.Name); if (_Authenticated) { _Identity = new GenericIdentity(this.credentialsForm.Username, Membership.Provider.Name); txtUserName.Text = _Identity.Name; FwkMessageView.Show(string.Format(Properties.Resources.ValidCredentialsMessage, this.credentialsForm.Username), "ValidateUser", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error); } else { FwkMessageView.Show(string.Format(Properties.Resources.InvalidCredentialsMessage, this.credentialsForm.Username), "ValidateUser", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error); } } } }
void CreeateUser_No_Service(User pUserBe) { String strErrorResut = String.Empty; CreateUserReq req = new CreateUserReq(); CreateUserRes res = new CreateUserRes(); CreateUserService svc = new CreateUserService(); req.SecurityProviderName = SecurityProviderName; try { RolList roles = FwkMembership.GetAllRoles(SecurityProviderName); if (roles.Count >= 2) { pUserBe.Roles = new String[2]; pUserBe.Roles[0] = roles[0].RolName; pUserBe.Roles[1] = roles[1].RolName; } req.BusinessData.User = pUserBe; res = svc.Execute(req); } catch (Exception ex) { strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex); } Assert.AreEqual <String>(strErrorResut, string.Empty, strErrorResut); pUserBe.UserId = res.BusinessData.UserId; }
public override CreateRuleRes Execute(CreateRuleReq pServiceRequest) { CreateRuleRes wRes = new CreateRuleRes(); FwkMembership.CreateRule(pServiceRequest.BusinessData, pServiceRequest.SecurityProviderName); return(wRes); }
/// <summary> /// Crea un nuevo usuario. /// </summary> /// <param name="pUser">UsuarioBE a crear</param> /// <returns>UserId del nuevo usuario.</returns> public void Create(User pUser) { //TODO: Ver tema de nuevo GUID para el usuario //Guid wUserGUID = Guid.NewGuid(); MembershipCreateStatus pStatus = MembershipCreateStatus.UserRejected; // se inserta en las membership el nuevo usuario User wNewUser = FwkMembership.CreateUser(pUser.UserName, pUser.Password, pUser.Email, pUser.QuestionPassword, pUser.AnswerPassword, pUser.IsApproved, out pStatus, _ProviderName); // se inserta el usuario custom if (pStatus == MembershipCreateStatus.Success) { //UsersDAC.Create(pUser, CustomParameters, _ProviderName, pCustomUserTable); // Se insertan los roles if (pUser.Roles != null) { RolList roleList = pUser.GetRolList(); FwkMembership.CreateRolesToUser(roleList, pUser.UserName, _ProviderName); } pUser.ProviderId = wNewUser.ProviderId; wNewUser = null; } else { TechnicalException te = new TechnicalException(string.Format(Fwk.Security.Properties.Resource.User_Created_Error_Message, pUser.UserName, pStatus)); ExceptionHelper.SetTechnicalException <FwkMembership>(te); te.ErrorId = "4008"; throw te; } }
/// <summary> /// Fin de el metodo populate que fue llamado de forma asincrona /// </summary> /// <param name="res"></param> void EndPopulate(IAsyncResult res) { Exception ex; if (this.InvokeRequired) { AsyncCallback d = new AsyncCallback(EndPopulate); this.Invoke(d, new object[] { res }); } else { AsyncResult result = (AsyncResult)res; DelegateWithOutAndRefParameters del = (DelegateWithOutAndRefParameters)result.AsyncDelegate; del.EndInvoke(out ex, res); if (ex != null) { throw ex; } treeList1.BeginUnboundLoad(); this.categoryTreeBindingSource.DataSource = _CategoryTreeList; treeList1.RefreshDataSource(); treeList1.EndUnboundLoad(); treeList1.ExpandAll(); _AllRuleList = FwkMembership.GetRulesAuxList(frmAdmin.Provider.Name); fwkAuthorizationRuleBindingSource.DataSource = _AllRuleList; grdAllRules.RefreshDataSource(); } }
/// <summary> /// /// </summary> /// <param name="pUserName"></param> /// <returns></returns> public User GetUser(String pUserName) { User wUser = FwkMembership.GetUser(pUserName, _ProviderName); return(wUser); }
private void mDeleteRule_Click(object sender, EventArgs e) { if (_CurrentRule == null) { return; } DialogResult res = DialogResult.No; res = MessageBox.Show(string.Concat("Are you shure to remove ", _CurrentRule.Name, " ?"), "Security ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { foreach (CategoryTree category in _CategoryTreeList.Where(p => p.IsCategory)) { if (category.AnyRule(_CurrentRule.Name)) { res = MessageBox.Show(string.Concat(_CurrentRule.Name, " is in ", category.Name, "\r\n Are you shure remove it ?"), "Security ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { category.RemoveRule(_CurrentRule.Name); FwkMembership.CreateRuleInCategory(category.FwkCategory, frmAdmin.Provider.Name); } } } } if (res == DialogResult.Yes) { FwkMembership.DeleteRule(_CurrentRule.Name, frmAdmin.Provider.Name); } PopulateAsync(); }
private void mRemove_Click(object sender, EventArgs e) { if (_CurrentCategory.IsCategory == false) { //Obtengo el padre _ParentFwkCategory = _CategoryTreeList.Where(p => p.Id.Equals(_CurrentCategory.ParentId)).FirstOrDefault <CategoryTree>(); _ParentFwkCategory.RemoveRule(_CurrentCategory.Name); _CategoryTreeList.RemoveItem(_CurrentCategory.Id);//No es necesario ya que se ejecurara luego --> PopulateAsync try { FwkMembership.CreateRuleInCategory(_ParentFwkCategory.FwkCategory, frmAdmin.Provider.Name); MessageViewInfo.Show("Rule was successfully removed from category"); PopulateAsync(); } catch (Exception ex) { throw ex; } } else { DialogResult r = MessageBox.Show("Will have to delete the category and recursively all its subcategories", "Rules mannager", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { try { FwkMembership.RemoveCategory(_CurrentCategory.FwkCategory.CategoryId, frmAdmin.Provider.Name); MessageViewInfo.Show("Category was successfully removed "); PopulateAsync(); } catch (Exception ex) { throw ex; } } } }
public override void Initialize() { txtRuleName.Focus(); using (new WaitCursorHelper(this)) { try { userBindingSource.DataSource = FwkMembership.GetAllUsers(frmAdmin.Provider.Name); rolBindingSource.DataSource = FwkMembership.GetAllRoles(frmAdmin.Provider.Name); if (userBindingSource.Count == 0) { throw new Exception(string.Concat("La aplicaión ", frmAdmin.Provider.ApplicationName, " no contiene usuarios.-")); } if (rolBindingSource.Count == 0) { throw new Exception(string.Concat("La aplicaión ", frmAdmin.Provider.ApplicationName, " no contiene roles.-")); } } catch (Exception es) { throw es; } } if (this.State == Bases.EntityUpdateEnum.UPDATED) { label3.Text = "Update bussiness rule"; //txtRuleName.Enabled = false; } }
void Connect() { try { this.Cursor = Cursors.WaitCursor; frmAdmin.Provider = System.Web.Security.Membership.Providers[cmbProviders.Text]; RoleProvider wRoleProvider = FwkMembership.GetRoleProvider(cmbProviders.Text); string cnnString = FwkMembership.GetProvider_ConnectionString(frmAdmin.Provider.Name); Fwk.DataBase.CnnString cnn = new DataBase.CnnString("", cnnString); lblServer.Text = cnn.DataSource; lblDatabase.Text = cnn.InitialCatalog; lblCnnString.Text = cnn.ToString(); if (!onInit) { DataBase.Metadata m = new DataBase.Metadata(cnn); if (m.TestConnection()) { CurrentProviderConnectedOk = true; lblConnectionStatus.Text = "Connected"; this.btnRefreshConnection.Image = global::Fwk.Security.Admin.Properties.Resources.Connection_Check; this.btnRefreshConnection.Text = "Refresh"; } else { CurrentProviderConnectedOk = false; lblConnectionStatus.Text = "Disconected"; this.btnRefreshConnection.Image = global::Fwk.Security.Admin.Properties.Resources.Connection_Warning; this.btnRefreshConnection.Text = "Try reconnect"; } } } catch (Exception ex) { CurrentProviderConnectedOk = false; lblConnectionStatus.Text = "Disconected"; this.btnRefreshConnection.Image = global::Fwk.Security.Admin.Properties.Resources.Connection_Warning; this.btnRefreshConnection.Text = "Try reconnect"; base.MessageViewInfo.Show(Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex)); } if (currontSecurityControlBase == null) { this.Cursor = Cursors.Arrow; return; } try { currontSecurityControlBase.Initialize(); } catch (Exception ex) { CurrentProviderConnectedOk = false; lblConnectionStatus.Text = "Disconected"; base.MessageViewInfo.Show(Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex)); } this.Cursor = Cursors.Arrow; }
public override DeleteRulesCategoryRes Execute(DeleteRulesCategoryReq pServiceRequest) { DeleteRulesCategoryRes wRes = new DeleteRulesCategoryRes(); FwkMembership.RemoveCategory(pServiceRequest.BusinessData.CategoryId, pServiceRequest.SecurityProviderName); return(wRes); }
/// <summary> /// /// </summary> /// <param name="pServiceRequest"></param> /// <returns></returns> public override CreateRulesCategoryRes Execute(CreateRulesCategoryReq pServiceRequest) { CreateRulesCategoryRes wRes = new CreateRulesCategoryRes(); FwkMembership.CreateCategory(pServiceRequest.BusinessData, pServiceRequest.SecurityProviderName); wRes.BusinessData.Id = pServiceRequest.BusinessData.CategoryId; return(wRes); }
public override void Initialize() { using (new WaitCursorHelper(this)) { rolListBindingSource.DataSource = FwkMembership.GetAllRoles(frmAdmin.Provider.Name); grdRoles.Refresh(); } }
private void frmAdmin_Load(object sender, EventArgs e) { cmbProviders.Properties.DataSource = FwkMembership.GetAllMembershiproviderNameArray(); cmbProviders.ItemIndex = 0; navBarControl1.SelectedLink = navBarItem2.Links[0]; onInit = false; }
public override void Initialize() { // inicializo Fwk Authorization provider y cathcing security provider this.ruleProvider = ControlsFactory.CreateAuthorizationProvider(frmAdmin.Provider.Name); rulesComboBox.DataSource = FwkMembership.GetRules(frmAdmin.Provider.Name); }
public override void Initialize() { using (new WaitCursorHelper(this)) { usersGrid1.Initialize(); bindingSourceRoles1.DataSource = FwkMembership.GetAllRoles(frmAdmin.Provider.Name); } }
/// <summary> /// /// </summary> /// <returns></returns> public UserList GetAllUser() { // Se obtienen los usuarios de las memberships UserList pUserList = new UserList(); pUserList.AddRange(FwkMembership.GetAllUsers(_ProviderName)); return(pUserList); }
public override SearchRolesForUserRes Execute(SearchRolesForUserReq pServiceRequest) { SearchRolesForUserRes wRes = new SearchRolesForUserRes(); wRes.BusinessData.RolList = FwkMembership.GetRolesForUser(pServiceRequest.BusinessData.Username, pServiceRequest.SecurityProviderName); //Implement your code here return(wRes); }
public bool AceptChanges() { if (string.IsNullOrEmpty(txtRuleName.Text)) { errorProvider1.SetError(txtRuleName, "Rule name must not be empty"); return(false); } try { if (_CurrentRule == null) { _CurrentRule = new FwkAuthorizationRule(); } _CurrentRule.Expression = txtRuleExpression.Text; if (base.State == Bases.EntityUpdateEnum.NEW) { _CurrentRule.Name = txtRuleName.Text; if (FwkMembership.ExistRule(txtRuleName.Text.Trim(), frmAdmin.Provider.Name)) { MessageViewInfo.Show(String.Format("The rule {0} exist", txtRuleName.Text)); txtRuleName.Focus(); return(false); } FwkMembership.CreateRule(_CurrentRule, frmAdmin.Provider.Name); MessageViewInfo.Show(String.Format(Properties.Resources.RuleCreatedMessage, txtRuleName.Text)); this.btnCreateRule.Enabled = false; } if (base.State == Bases.EntityUpdateEnum.UPDATED) { //Si Cambio el nombre if (_CurrentRule.Name.Trim().CompareTo(txtRuleName.Text.Trim()) != 0) { FwkMembership.UpdateRuleAndRuleName(_CurrentRule, txtRuleName.Text.Trim(), frmAdmin.Provider.Name); } else { FwkMembership.UpdateRule(_CurrentRule, frmAdmin.Provider.Name); } MessageViewInfo.Show(String.Format(Properties.Resources.RuleUpdatedMessage, txtRuleName.Text)); } NewSecurityInfoCreatedHandler(); } catch (Exception ex) { MessageViewInfo.Show(ex); return(false); } return(true); }
private void authorizeUsingIdentityRoleRulesButton_Click(object sender, EventArgs e) { if (this.identityTextBox.Text.CompareTo(String.Empty) != 0 && this.rulesComboBox.SelectedIndex != -1) { string identity = this.identityTextBox.Text; string rule = ((FwkAuthorizationRule) this.rulesComboBox.SelectedItem).Name; string[] roles = FwkMembership.GetRolesForUser_StringArray(identity, frmAdmin.Provider.Name); IPrincipal principal = new GenericPrincipal(new GenericIdentity(identity), roles); Cursor = System.Windows.Forms.Cursors.WaitCursor; //if (ControlsFactory.ruleProvider != null) //{ this.DisplayAuthorizationResults(string.Format(Properties.Resources.IdentityRoleMessage, identity, String.Join(",", roles))); bool wAuthorized = false; // Try to authorize using selected rule try { wAuthorized = ControlsFactory.Authorize(principal, rule); } catch (Exception ex) { if (string.IsNullOrEmpty(FwkMembership.GetRule(rule, frmAdmin.Provider.Name).Expression.Trim())) { wAuthorized = false; fwkMessageViewInfo.Show("Regla no contiene exoprecion o roles asociados"); } else { fwkMessageViewInfo.Show(ex); } } if (wAuthorized) { this.DisplayAuthorizationResults(string.Format(Properties.Resources.RuleResultTrueMessage, rule) + Environment.NewLine); } else { this.DisplayAuthorizationResults(string.Format(Properties.Resources.RuleResultFalseMessage, rule) + Environment.NewLine); } //} Cursor = System.Windows.Forms.Cursors.Arrow; } }
private void button1_Click(object sender, EventArgs e) { if (FwkMembership.ValidateUser(txtUserName.Text, txtPassword.Text, frmAdmin.Provider.Name)) { MessageViewInfo.Show("Log sussefully"); } else { MessageViewInfo.Show("Log not sussefully"); } }
public void CreateUser(string userName, string password, string email) { if (String.IsNullOrEmpty(email)) { FwkMembership.CreateUser(userName, password, email, ProviderName); } else { FwkMembership.CreateUser(userName, password, ProviderName); } }
private void removeSelectedsToolStripMenuItem_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in grdAssignedRoles.SelectedRows) { _AssignedRolList.Remove(((Rol)row.DataBoundItem)); } grdAssignedRoles.DataSource = null; grdAssignedRoles.DataSource = _AssignedRolList; grdAssignedRoles.Refresh(); txtRuleExpression.Text = FwkMembership.BuildRuleExpression(_AssignedRolList, _ExcludeUserList); }
public override SearchAllRulesRes Execute(SearchAllRulesReq pServiceRequest) { SearchAllRulesRes wRes = new SearchAllRulesRes(); FwkAuthorizationRuleList rules = FwkMembership.GetRulesAuxList(pServiceRequest.SecurityProviderName); wRes.BusinessData = rules; return(wRes); }
public override RemoveUserFromRoleRes Execute(RemoveUserFromRoleReq pServiceRequest) { RemoveUserFromRoleRes wRes = new RemoveUserFromRoleRes(); //if (string.IsNullOrEmpty(pServiceRequest.BusinessData.ApplicationName)) // pServiceRequest.BusinessData.ApplicationName = Membership.ApplicationName; FwkMembership.RemoveUserFromRole(pServiceRequest.BusinessData.UserName, pServiceRequest.BusinessData.RolName, pServiceRequest.SecurityProviderName); return(wRes); }
private void mCreateRuele_Click(object sender, EventArgs e) { using (frmRulesAdmin frm = new frmRulesAdmin()) { if (frm.ShowDialog() == DialogResult.OK) { _AllRuleList = FwkMembership.GetRulesAuxList(frmAdmin.Provider.Name); fwkAuthorizationRuleBindingSource.DataSource = _AllRuleList; grdAllRules.RefreshDataSource(); } } }
public override CreateRoleRes Execute(CreateRoleReq pServiceRequest) { CreateRoleRes wRes = new CreateRoleRes(); //if (string.IsNullOrEmpty(pServiceRequest.BusinessData.ApplicationName)) // pServiceRequest.BusinessData.ApplicationName = Membership.ApplicationName; FwkMembership.CreateRole(pServiceRequest.BusinessData.Rol.RolName, pServiceRequest.BusinessData.Rol.Description, pServiceRequest.SecurityProviderName); return(wRes); }