Ejemplo n.º 1
0
 void OnCreateRole(object sender, EventArgs e)
 {
     using (RoleManagerProxy roleManager = new RoleManagerProxy(m_Url))
     {
         string[]           roles  = roleManager.GetAllRoles(m_Application);
         Predicate <string> exists = delegate(string role)
         {
             return(role == m_RoleTextBox.Text);
         };
         if (Array.Exists(roles, exists))
         {
             m_RoleValidator.SetError(m_RoleTextBox, "Role already exists");
             return;
         }
         m_RoleValidator.Clear();
         if (m_RoleTextBox.Text == String.Empty)
         {
             m_RoleValidator.SetError(m_RoleTextBox, "Role cannot be empty");
             return;
         }
         m_RoleValidator.Clear();
         roleManager.CreateRole(m_Application, m_RoleTextBox.Text);
         m_Roles.Add(m_RoleTextBox.Text);
         m_CreatedRolesListView.AddItem(m_RoleTextBox.Text, true);
         m_RoleTextBox.Focus();
         m_RoleTextBox.Text = String.Empty;
     }
 }
Ejemplo n.º 2
0
      public AuthorizationDialog(string url,string application,string user) : this()
      {
         m_Url = url;
         m_ApplicationTextBox.Text = application;
         m_UserComboBox.Text = user;

         using(RoleManagerProxy roleManager = new RoleManagerProxy(url))
         {
            string[] roles = roleManager.GetAllRoles(application);

            m_RoleComboBox.Items.AddRange(roles);
            if(roles.Length > 0)
            {
               m_RoleComboBox.Text = roles[roles.Length-1];
            }

            using(MembershipManagerProxy membershipManager = new MembershipManagerProxy(url))
            {

               string[] users = membershipManager.GetAllUsers(application);

               m_UserComboBox.Items.AddRange(users);
               if(users.Length > 0)
               {
                  m_UserComboBox.Text = users[users.Length-1];
               }
            }
         }
      }
Ejemplo n.º 3
0
        public AuthorizationDialog(string url, string application, string user) : this()
        {
            m_Url = url;
            m_ApplicationTextBox.Text = application;
            m_UserComboBox.Text       = user;

            using (RoleManagerProxy roleManager = new RoleManagerProxy(url))
            {
                string[] roles = roleManager.GetAllRoles(application);

                m_RoleComboBox.Items.AddRange(roles);
                if (roles.Length > 0)
                {
                    m_RoleComboBox.Text = roles[roles.Length - 1];
                }

                using (MembershipManagerProxy membershipManager = new MembershipManagerProxy(url))
                {
                    string[] users = membershipManager.GetAllUsers(application);

                    m_UserComboBox.Items.AddRange(users);
                    if (users.Length > 0)
                    {
                        m_UserComboBox.Text = users[users.Length - 1];
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void OnRemoveUserFromRole(object sender, EventArgs e)
        {
            string role = m_RolesListView.CurrentListViewItem;

            Debug.Assert(!String.IsNullOrEmpty(role));
            using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
            {
                using (UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
                {
                    Debug.Assert(userManager != null);

                    if (userManager.IsInRole(ApplicationName, UserToAssign, role))
                    {
                        DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from the role " + m_RolesListView.CurrentListViewItem + " ?", "Credentials Manager", MessageBoxButtons.OKCancel);
                        if (result == DialogResult.OK)
                        {
                            roleManager.RemoveUserFromRole(ApplicationName, UserToAssign, role);
                            RefreshRolesForUserComboBox();
                            RefreshUsersForRoleComboBox();
                            RefreshRolePageButtons();
                        }
                    }
                    else
                    {
                        MessageBox.Show("The user " + UserToAssign + " is not a member of the role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 5
0
      void OnCreateRole(object sender,EventArgs e)
      {
         using(RoleManagerProxy roleManager = new RoleManagerProxy(m_Url))
         {
            string[] roles = roleManager.GetAllRoles(m_Application);

            if(roles.Any(role => role == m_RoleTextBox.Text))
            {
               m_RoleValidator.SetError(m_RoleTextBox,"Role already exists");
               return;
            }
            m_RoleValidator.Clear();
            if(m_RoleTextBox.Text == String.Empty)
            {
               m_RoleValidator.SetError(m_RoleTextBox,"Role cannot be empty");
               return;
            }
            m_RoleValidator.Clear();
            roleManager.CreateRole(m_Application,m_RoleTextBox.Text);
            m_Roles.Add(m_RoleTextBox.Text);
            m_CreatedRolesListView.AddItem(m_RoleTextBox.Text,true);
            m_RoleTextBox.Focus();
            m_RoleTextBox.Text = String.Empty;
         }
      }
Ejemplo n.º 6
0
        void OnAssignUserToRole(object sender, EventArgs e)
        {
            using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
            {
                using (UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
                {
                    Debug.Assert(userManager != null);

                    string role = m_RolesListView.CurrentListViewItem;
                    Debug.Assert(role != String.Empty);

                    if (userManager.IsInRole(ApplicationName, UserToAssign, role))
                    {
                        MessageBox.Show("The user " + UserToAssign + " is already a member of the role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else
                    {
                        roleManager.AddUserToRole(ApplicationName, UserToAssign, m_RolesListView.CurrentListViewItem);
                        RefreshRolesForUserComboBox();
                        RefreshUsersForRoleComboBox();
                        RefreshRolePageButtons();
                    }
                }
            }
        }
 void RefreshRolesForUserComboBox()
 {
     string[] roles = null;
     if (String.IsNullOrEmpty(UserToAssign) == false)
     {
         using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
             roles = roleManager.GetRolesForUser(ApplicationName, UserToAssign);
     }
     m_RolesForUserComboBox.RefreshComboBox(UserToAssign, roles);
 }
        void RefreshUsersForRoleComboBox()
        {
            string[] users = null;

            if (String.IsNullOrEmpty(RoleName) == false)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                    users = roleManager.GetUsersInRole(ApplicationName, RoleName);
            }
            m_UsersInRoleComboBox.RefreshComboBox(RoleName, users);
        }
 void RefreshRolesListView()
 {
     m_RolesListView.ClearItems();
     if (ApplicationName == String.Empty)
     {
         return;
     }
     using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
     {
         string[] roles = roleManager.GetAllRoles(ApplicationName);
         m_RolesListView.AddItems(roles, true);
     }
 }
Ejemplo n.º 10
0
        void OnDeleteAllRoles(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete all roles from the application?", "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    roleManager.DeleteAllRoles(ApplicationName, m_ThrowIfPopulatedCheckBox.Checked);
                }
                m_RolesListView.ClearItems();
                RefreshUsersForRoleComboBox();
                RefreshRolesForUserComboBox();
                RefreshRolePageButtons();
            }
        }
Ejemplo n.º 11
0
        void OnRemoveUsersFromAllRoles(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from all its roles?", "Credentials Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    string[] roles = roleManager.GetRolesForUser(ApplicationName, UserToAssign);
                    if (roles.Length > 0)
                    {
                        roleManager.RemoveUserFromRoles(ApplicationName, UserToAssign, roles);
                        RefreshRolesForUserComboBox();
                        RefreshUsersForRoleComboBox();
                        RefreshRolePageButtons();
                    }
                }
            }
        }
Ejemplo n.º 12
0
        void OnDeleteRole(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete the role " + RoleName + " ?", "Credentials Manager", MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                using (RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
                {
                    try
                    {
                        bool deleted = roleManager.DeleteRole(ApplicationName, RoleName, m_ThrowIfPopulatedCheckBox.Checked);
                        if (deleted == false)
                        {
                            MessageBox.Show("Encountered an error trying to delete role " + m_RolesListView.CurrentListViewItem, "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            m_RolesListView.RemoveItem(RoleName);
                            RefreshUsersForRoleComboBox();
                            RefreshRolesForUserComboBox();
                            RefreshRolePageButtons();
                        }
                    }
                    catch (SoapException exception)
                    {
                        if (exception.Message.Contains("This role cannot be deleted because there are users present in it"))
                        {
                            MessageBox.Show("Failed to delete role " + m_RolesListView.CurrentListViewItem + " because it was populated.", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
      void OnAssignUserToRole(object sender,EventArgs e)
      {
         using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
         {
            using(UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
            {
               Debug.Assert(userManager != null);

               string role = m_RolesListView.CurrentListViewItem;
               Debug.Assert(role != String.Empty);

               if(userManager.IsInRole(ApplicationName,UserToAssign,role))
               {
                  MessageBox.Show("The user " + UserToAssign + " is already a member of the role " +  m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                  return;
               }
               else
               {
                  roleManager.AddUserToRole(ApplicationName,UserToAssign,m_RolesListView.CurrentListViewItem);
                  RefreshRolesForUserComboBox();
                  RefreshUsersForRoleComboBox();
                  RefreshRolePageButtons();
               }
            }
         }
      }
Ejemplo n.º 14
0
 void OnDeleteAllRoles(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to delete all roles from the application?","Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          roleManager.DeleteAllRoles(ApplicationName,m_ThrowIfPopulatedCheckBox.Checked);
       }
       m_RolesListView.ClearItems();
       RefreshUsersForRoleComboBox();
       RefreshRolesForUserComboBox();
       RefreshRolePageButtons();
    }
 }
Ejemplo n.º 15
0
 void OnRemoveUsersFromAllRoles(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from all its roles?","Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          string[] roles = roleManager.GetRolesForUser(ApplicationName,UserToAssign);
          if(roles.Length > 0)
          {
             roleManager.RemoveUserFromRoles(ApplicationName,UserToAssign,roles);
             RefreshRolesForUserComboBox();
             RefreshUsersForRoleComboBox();
             RefreshRolePageButtons();
          }
       }
    }
 }
Ejemplo n.º 16
0
 void RefreshRolesListView()
 {
    m_RolesListView.ClearItems();
    if(ApplicationName == String.Empty)
    {
       return;
    }
    using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
    {
       string[] roles = roleManager.GetAllRoles(ApplicationName);
       m_RolesListView.AddItems(roles,true);
    }
 }
Ejemplo n.º 17
0
 void RefreshRolesForUserComboBox()
 {
    string[] roles = null;
    if(String.IsNullOrEmpty(UserToAssign) == false)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       roles = roleManager.GetRolesForUser(ApplicationName,UserToAssign);
    }
    m_RolesForUserComboBox.RefreshComboBox(UserToAssign,roles);        
 }
Ejemplo n.º 18
0
 void RefreshUsersForRoleComboBox()
 {
    string[] users = null;
    
    if(String.IsNullOrEmpty(RoleName) == false)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       users = roleManager.GetUsersInRole(ApplicationName,RoleName);
    }
    m_UsersInRoleComboBox.RefreshComboBox(RoleName,users);
 }
Ejemplo n.º 19
0
 void OnDeleteRole(object sender,EventArgs e)
 {
    DialogResult result = MessageBox.Show("Are you sure you want to delete the role " + RoleName + " ?","Credentials Manager",MessageBoxButtons.OKCancel);
    if(result == DialogResult.OK)
    {
       using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
       {
          try
          {
             bool deleted = roleManager.DeleteRole(ApplicationName,RoleName,m_ThrowIfPopulatedCheckBox.Checked);
             if(deleted == false)
             {
                MessageBox.Show("Encountered an error trying to delete role " + m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Error);
             }
             else
             {
                m_RolesListView.RemoveItem(RoleName);
                RefreshUsersForRoleComboBox();
                RefreshRolesForUserComboBox();
                RefreshRolePageButtons();
             }
          }
          catch(SoapException exception)
          {
             if(exception.Message.Contains("This role cannot be deleted because there are users present in it"))
             {
                MessageBox.Show("Failed to delete role " + m_RolesListView.CurrentListViewItem + " because it was populated.","Credentials Manager",MessageBoxButtons.OK,MessageBoxIcon.Error);
             }
             else
             {
                throw;
             }
          }
       }
    }
 }
Ejemplo n.º 20
0
      void OnRemoveUserFromRole(object sender,EventArgs e)
      {
         string role = m_RolesListView.CurrentListViewItem;
         Debug.Assert(! String.IsNullOrEmpty(role));
         using(RoleManagerProxy roleManager = new RoleManagerProxy(ServiceAddress))
         {
            using(UserManagerProxy userManager = new UserManagerProxy(ServiceAddress))
            {
               Debug.Assert(userManager != null);

               if(userManager.IsInRole(ApplicationName,UserToAssign,role))
               {
                  DialogResult result = MessageBox.Show("Are you sure you want to remove the user " + UserToAssign + " from the role " +  m_RolesListView.CurrentListViewItem + " ?","Credentials Manager",MessageBoxButtons.OKCancel);
                  if(result == DialogResult.OK)
                  {
                     roleManager.RemoveUserFromRole(ApplicationName,UserToAssign,role);
                     RefreshRolesForUserComboBox();
                     RefreshUsersForRoleComboBox();
                     RefreshRolePageButtons();
                  }
               }
               else
               {
                  MessageBox.Show("The user " + UserToAssign + " is not a member of the role " +  m_RolesListView.CurrentListViewItem,"Credentials Manager",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
               }
            }
         }
      }