public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            IbnContainerConfiguration cnfg = new IbnContainerConfiguration();

            foreach(XmlNode item in section.ChildNodes)
            {
                // Step 1. Extract Container
                if(item.Name=="container")
                {
                    IbnContainerInfo container = new IbnContainerInfo(item.Attributes["name"].Value);

                    // Step 2. Extract Conrol Infos.
                    foreach(XmlNode xmlControlNode in item.ChildNodes)
                    {
                        if(xmlControlNode.Name=="control")
                        {
                            IbnControlInfo control = new IbnControlInfo(xmlControlNode.Attributes["name"].Value,
                                xmlControlNode.Attributes["type"].Value);

                            // Step 3. Extract Parameters
                            foreach(XmlNode xmlParamNode in xmlControlNode.SelectNodes("params/param"))
                            {
                                control.Parameters.Add(xmlParamNode.Attributes["name"].Value,xmlParamNode.Attributes["value"].Value);
                            }

                            // Step 4. Extract ACL
                            foreach(XmlNode xmlACLNode in xmlControlNode.SelectNodes("acl"))
                            {
                                string Filter = "*";

                                if(xmlACLNode.Attributes["containerKey"]!=null)
                                    Filter = xmlACLNode.Attributes["containerKey"].Value;

                                foreach(XmlNode xmlACENode in xmlACLNode.SelectNodes("ace"))
                                {
                                    if(xmlACENode.Attributes["role"]!=null)
                                        // Role Ace
                                        control.DefaultAccessControlList.Add(Filter, new AccessControlEntry(xmlACENode.Attributes["role"].Value,
                                            xmlACENode.Attributes["action"].Value,bool.Parse(xmlACENode.Attributes["allow"].Value)));
                                    else
                                        // Principal Ace
                                        control.DefaultAccessControlList.Add(Filter, new AccessControlEntry(int.Parse(xmlACENode.Attributes["principalid"].Value),
                                            xmlACENode.Attributes["action"].Value,bool.Parse(xmlACENode.Attributes["allow"].Value)));
                                }
                            }

                            container.Controls.Add(control);
                        }
                    }

                    cnfg.Containers.Add(container);
                }
            }

            return cnfg;
        }
示例#2
0
 public void Add(IbnControlInfo item)
 {
     this.InnerHashtable.Add(item.Name,item);
 }
示例#3
0
        /// <summary>
        /// Inits the specified owner.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="controlInfo">The control info.</param>
        public void Init(IIbnContainer owner, IbnControlInfo controlInfo)
        {
            _ownerContainer = owner;

            _info =  controlInfo;

            using (IDataReader reader = DBDirectory.GetRoot(owner.Key))
            {
                if (reader.Read())
                    _root = new DirectoryInfo(this, reader);
            }

            if (_root==null)
            {
                using (IDataReader reader = DBDirectory.CreateRoot(owner.Key, "root", this.CurrentUserId, DateTime.Now))
                {
                    if (reader.Read())
                    {
                        _root = new DirectoryInfo(this, reader);
                    }
                }

                AccessControlList rootAcl = AccessControlList.GetACL(_root.Id);

                foreach(AccessControlEntry ace in _info.DefaultAccessControlList.GetACL(_ownerContainer.Key))
                    rootAcl.Add(ace);

                if(rootAcl.Count>0)
                    AccessControlList.SetACL(this, rootAcl);
            }
        }