Exemplo n.º 1
0
        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            StringBuilder permission  = new StringBuilder();
            AclGroup      parentGroup = Group;

            while (parentGroup != null)
            {
                if (permission.Length > 0)
                {
                    permission.Insert(0, ":");
                }
                permission.Insert(0, parentGroup.ID);
                parentGroup = parentGroup.ParentGroup;
            }

            permission.Append(":");
            permission.Append(this.ID);

            return(permission.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the acl collection.
        /// </summary>
        /// <param name="aclNode">The acl node.</param>
        /// <returns></returns>
        public static AclGroupCollection CreateAclCollection(ModuleConfig module, XmlNode aclNode)
        {
            if (aclNode == null)
            {
                return(null);
            }

            // Create list
            AclGroupCollection aclGroupCol = new AclGroupCollection();
            AclGroup           rootGroup   = new AclGroup(module.Name, module.DisplayName);

            aclGroupCol.Add(rootGroup);
            XmlNodeList groups = aclNode.SelectNodes("Group");

            foreach (XmlNode group in groups)
            {
                AclGroup aclGroup = PopulateGroupRecursive(group);
                aclGroup.ParentGroup = rootGroup;
                rootGroup.Groups.Add(aclGroup);
            }

            return(aclGroupCol);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Populates the group recursive.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        private static AclGroup PopulateGroupRecursive(XmlNode node)
        {
            AclGroup group = new AclGroup(node.Attributes["id"].Value, node.Attributes["text"].Value);

            // Populate children
            XmlNodeList permissions = node.SelectNodes("Permission");

            foreach (XmlNode nodeChild in permissions)
            {
                group.Permissions.Add(PopulatePermission(group, nodeChild));
            }

            // Populate children
            XmlNodeList groups = node.SelectNodes("Group");

            foreach (XmlNode nodeChild in groups)
            {
                AclGroup subGroup = PopulateGroupRecursive(nodeChild);
                subGroup.ParentGroup = group;
                group.Groups.Add(subGroup);
            }

            return(group);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Populates the permission.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <param name="node">The node.</param>
 /// <returns></returns>
 private static AclPermission PopulatePermission(AclGroup group, XmlNode node)
 {
     return(new AclPermission(group, node.Attributes["id"].Value, node.Attributes["text"].Value));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AclPermission"/> class.
 /// </summary>
 /// <param name="group">The group.</param>
 /// <param name="id">The id.</param>
 /// <param name="name">The name.</param>
 public AclPermission(AclGroup group, string id, string name)
 {
     _ID    = id;
     _Name  = name;
     _Group = group;
 }