Beispiel #1
0
        public IIbnControl LoadControl(string name)
        {
            IbnControlInfo controlInfo = this.Info.Controls[name];

            if (controlInfo == null)
            {
                throw new ArgumentException("Invalid agument.", "name");
            }

            IIbnControl retVal = (IIbnControl)AssemblyHelper.LoadObject(controlInfo.Type, typeof(IIbnControl));

            retVal.Init(this, controlInfo);

            return(retVal);
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
 public void Add(IbnControlInfo item)
 {
     this.InnerHashtable.Add(item.Name, item);
 }
        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);
        }