Beispiel #1
0
 private static void LoadFunctions(XmlNode node, RBACContext rbac)
 {
     foreach (System.Xml.XmlNode groupNode in node.ChildNodes)
     {
         if (groupNode.NodeType != XmlNodeType.Element || groupNode.Name.ToLower() != "group")
         {
             continue;
         }
         FunctionGroup group = new FunctionGroup()
         {
             Name = groupNode.GetAttribute("name", null)
         };
         foreach (System.Xml.XmlNode funcNode in groupNode.ChildNodes)
         {
             if (funcNode.NodeType != XmlNodeType.Element || funcNode.Name.ToLower() != "function")
             {
                 continue;
             }
             Function func = new Function()
             {
                 Id   = funcNode.GetAttribute("ID", null),
                 Name = funcNode.GetAttribute("name", null)
             };
             group.Functions.Add(func);
         }
         rbac.Functions.Add(group);
     }
 }
Beispiel #2
0
 private static void LoadXMLRole(XmlNode node, RBACContext rbac)
 {
     rbac.RoleProvider = node.GetAttribute("provider", null);
     foreach (System.Xml.XmlNode nodeR in node.ChildNodes)
     {
         if (node.NodeType != XmlNodeType.Element)
         {
             continue;
         }
         IRole role = new XMLRole()
         {
             Id   = nodeR.GetAttribute("ID", 0),
             Name = nodeR.GetAttribute("name", null)
         };
         foreach (System.Xml.XmlNode nodeF in nodeR.ChildNodes)
         {
             if (nodeF.NodeType != XmlNodeType.Element || nodeF.Name.ToLower() != "function")
             {
                 continue;
             }
             role.FunctionIds.Add(nodeF.GetAttribute("ID", null));
         }
         rbac.Roles.Add(role);
     }
 }
Beispiel #3
0
        public static RBACContext Load()
        {
            string      xmlPath = (Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase) + "\\rbac.cfg.xml").Replace("file:\\", "");
            XmlDocument doc     = new XmlDocument();

            doc.Load(xmlPath);
            if (RBAC == null)
            {
                RBAC = new Lemon.RBAC.RBACContext();
                LoadRBAC(RBAC.Menu, doc.DocumentElement);
            }
            return(RBAC);
        }