Exemplo n.º 1
0
        /// <summary>
        /// Deletes a role from the application
        /// </summary>
        /// <param name="role"></param>
        public void DeleteRole(string name)
        {
            RoleDefinition r = Roles[name];

            if (r == null)
            {
                return;
            }

            r.Delete();
        }
Exemplo n.º 2
0
        //public void UpdateGroup(ApplicationGroup group)
        //{
        //    if (group == null)
        //        throw new ArgumentNullException("group");
        //    if (!CheckObjectIsValid(group))
        //        throw new AzException("The group is not part of this application. Only application groups can be updated here.");

        //    Groups.CheckName(group);
        //    Locator.Factory.UpdateGroup(group);
        //    Groups.UpdateValue(group);
        //}

        /// <summary>
        /// Create a new role in the application
        /// </summary>
        /// <param name="name">Required name of the role</param>
        /// <param name="description">Description of the role</param>
        /// <returns>new role</returns>
        public RoleDefinition CreateRole(string name, string description)
        {
            Roles.CheckName(name);

            RoleDefinition r = Locator.Factory.CreateRole(Key, name, description);

            r.Parent = this;
            Roles.AddValue(r);

            return(r);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Removes a role from the Roles collection
        /// </summary>
        /// <param name="role">Role to remove</param>
        public void RemoveRole(RoleDefinition role)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            CheckObjectIsValid(role);
            if (!Roles.ContainsKey(role.Key))
            {
                return;
            }

            ((Interfaces.IRoleDefinition)Instance).RemoveRole(role);
            Roles.RemoveValue(role.Key);
        }
Exemplo n.º 4
0
 public RoleAssignments CreateRoleAssignments(string name, string description, RoleDefinition role)
 {
     return(CreateRoleAssignments(name, description, role, false));
 }
Exemplo n.º 5
0
        public RoleAssignments CreateRoleAssignments(string name, string description, RoleDefinition role, bool renameOnMatch)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            if (renameOnMatch)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentNullException("name");
                }
                name = RoleAssignments.MakeNameUnique(name);
            }
            else
            {
                RoleAssignments.CheckName(name);
            }

            if (!CheckObjectIsValid(role))
            {
                throw new AzException("The role is not defined in this application");
            }

            AzAlternative.RoleAssignments r = Locator.Factory.CreateRoleAssignments(Key, name, description, role);
            r.Parent = this;
            RoleAssignments.AddValue(r);

            return(r);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds a role to the Roles collection
        /// </summary>
        /// <param name="name">name of the role to add</param>
        public void AddRole(string name)
        {
            RoleDefinition r = Parent.Roles[name];

            AddRole(r);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Removes a role from the Roles collection
        /// </summary>
        /// <param name="name">name of the role to remove</param>
        public void RemoveRole(string name)
        {
            RoleDefinition r = Roles[name];

            RemoveRole(r);
        }