示例#1
0
        private void permissionCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chkBox = sender as CheckBox;

            if (chkBox != null)
            {
                // Find out which permission has changed
                Permission permission = Permission.None;
                foreach (Permission p in Enum.GetValues(typeof(Permission)))
                {
                    if (chkBox.Name.Contains(SecurityDemoHelper.GetPermissionString(p)))
                    {
                        permission = p;
                        break;
                    }
                }
                // Check if the permission is set
                char           domainName        = (char)cboDomain.SelectedItem;
                SecurityAccess access            = chkBox.Name.Contains("View") ? SecurityAccess.View : SecurityAccess.Modify;
                bool           permissionGranted = owner.SecurityManager.IsGranted(permission, access, domainName);

                // Update only if the granted state changed
                if (permissionGranted != chkBox.Checked)
                {
                    StandardRole role = (StandardRole)cboUser.SelectedItem;
                    // Set General or Domain permissions
                    if (permission == Permission.Designs || permission == Permission.Security || permission == Permission.Templates)
                    {
                        if (chkBox.Checked)
                        {
                            owner.SecurityManager.AddPermissions(role, permission, access);
                        }
                        else
                        {
                            owner.SecurityManager.RemovePermissions(role, permission, access);
                        }
                    }
                    else
                    {
                        if (chkBox.Checked)
                        {
                            owner.SecurityManager.AddPermissions(domainName, role, permission, access);
                        }
                        else
                        {
                            owner.SecurityManager.RemovePermissions(domainName, role, permission, access);
                        }
                    }


                    UpdateSecurityControls();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Returns the name of the given role.
        /// </summary>
        public string GetRoleName(StandardRole role)
        {
            switch (role)
            {
            case StandardRole.Administrator: return(roleNameAdministrator);

            case StandardRole.Designer: return(roleNameDesigner);

            case StandardRole.Guest: return(roleNameGuest);

            case StandardRole.Operator: return(roleNameOperator);

            case StandardRole.SuperUser: return(roleNameSuperUser);

            default:
                throw new InvalidOperationException(string.Format("{0} is not a valid role for this operation.", role));
            }
        }
示例#3
0
        /// <summary>
        /// Returns the name of the given role.
        /// </summary>
        public string GetRoleName(StandardRole role)
        {
            switch (role)
            {
            case StandardRole.Administrator: return(roleNameAdministrator);

            case StandardRole.Designer: return(roleNameDesigner);

            case StandardRole.Guest: return(roleNameGuest);

            case StandardRole.Operator: return(roleNameOperator);

            case StandardRole.SuperUser: return(roleNameSuperUser);

            default:
                throw new InvalidOperationException(string.Format(Dataweb.NShape.Properties.Resources.MessageFmt_0IsNotAValidRoleForThisOperation, role));
            }
        }
示例#4
0
        /// <summary>
        /// Removes permissions from the given domain and role.
        /// </summary>
        /// <remarks>Security domain dependent permissions are checked against the role's domain permissions.</remarks>
        public void RemovePermissions(char domain, StandardRole role, Permission permissions, SecurityAccess access)
        {
            string roleName = GetRoleName(role);

            RemovePermissions(domain, roleName, permissions, access);
        }
示例#5
0
 /// <summary>
 /// Removes permissions from the given domain and role.
 /// </summary>
 /// <remarks>Security domain dependent permissions are checked against the role's domain permissions.</remarks>
 public void RemovePermissions(char domain, StandardRole role, Permission permissions)
 {
     RemovePermissions(domain, role, permissions, SecurityAccess.View);
 }
示例#6
0
 /// <summary>
 /// Removes permissions from the given role.
 /// </summary>
 /// <remarks>Security domain independent permissions are checked against the role permissions.</remarks>
 public void RemovePermissions(StandardRole role, Permission permissions)
 {
     RemovePermissions(role, permissions, SecurityAccess.View);
 }
示例#7
0
 /// <summary>
 /// Redefines the permissions of the given domain and role.
 /// </summary>
 /// <remarks>Security domain dependent permissions are checked against the role's domain permissions.</remarks>
 public void SetPermissions(char domain, StandardRole role, Permission permissions)
 {
     SetPermissions(domain, role, permissions, SecurityAccess.Modify);
 }
示例#8
0
        /// <summary>
        /// Redefines the permissions of the given role.
        /// </summary>
        /// <remarks>Security domain independent permissions are checked against the role permissions.</remarks>
        public void SetPermissions(StandardRole role, Permission permissions, SecurityAccess access)
        {
            string roleName = GetRoleName(role);

            SetPermissions(roleName, permissions, access);
        }
示例#9
0
 /// <summary>
 /// Redefines the permissions of the given role.
 /// </summary>
 /// <remarks>Security domain independent permissions are checked against the role permissions.</remarks>
 public void SetPermissions(StandardRole role, Permission permissions)
 {
     SetPermissions(role, permissions, SecurityAccess.Modify);
 }
示例#10
0
		/// <summary>
		/// Returns the name of the given role.
		/// </summary>
		public string GetRoleName(StandardRole role) {
			switch (role) {
				case StandardRole.Administrator: return roleNameAdministrator;
				case StandardRole.Designer: return roleNameDesigner;
				case StandardRole.Guest: return roleNameGuest;
				case StandardRole.Operator: return roleNameOperator;
				case StandardRole.SuperUser: return roleNameSuperUser;
				default: 
					throw new InvalidOperationException(string.Format("{0} is not a valid role for this operation.", role));
			}
		}
示例#11
0
		/// <summary>
		/// Removes permissions from the given domain and role.
		/// </summary>
		public void RemovePermissions(char domain, StandardRole role, Permission permissions) {
			string roleName = GetRoleName(role);
			RemovePermissions(domain, roleName, permissions);
		}
示例#12
0
        /// <summary>
        /// Redefines the permissions of the given domain and role.
        /// </summary>
        public void SetPermissions(char domain, StandardRole role, Permission permissions)
        {
            string roleName = GetRoleName(role);

            SetPermissions(domain, roleName, permissions);
        }