static void Main(string[] args) { ms_rbac1 = new RBAC1(); string[] users = new string[] { "u1", "u2", "u3", "u4" }; // roles Role r1 = new Role("r1"); Role r2 = new Role("r2"); Role r3 = new Role("r3"); Role r4 = new Role("r4"); // permissions Permission p1 = new Permission("p1", "GET", "URI1"); Permission p2 = new Permission("p2", "GET", "URI2"); Permission p4 = new Permission("p4", "GET", "URI4"); // Add Permissions ms_rbac1.AddPermission(p1); ms_rbac1.AddPermission(p2); ms_rbac1.AddPermission(p4); // populate users foreach (string user in users) ms_rbac1.AddUser(user); // Populate Roles ms_rbac1.AddRole(r1); ms_rbac1.AddRole(r2); ms_rbac1.AddRole(r3); ms_rbac1.AddRole(r4); // associate permissions with roles ms_rbac1.AddRolePermission(r1, p1); ms_rbac1.AddRolePermission(r2, p2); ms_rbac1.AddRolePermission(r4, p4); // build hierarchy r4.AddChildrenRole(r3); r3.AddChildrenRole(r1); r3.AddChildrenRole(r2); ListUsers(ms_rbac1.UserList); ListRoles(ms_rbac1.RoleList); ListPermissions(ms_rbac1.PermissionList); RBACSession session = new RBACSession("u1", "r4"); // Test role permission TestRolePermission(session, p1); TestRolePermission(session, p2); TestRolePermission(session, p4); session = new RBACSession("u1", new string[]{"r1","r2"}); // Test role permission TestRolePermission(session, p1); TestRolePermission(session, p2); TestRolePermission(session, p4); // Now let's load it from a file Console.WriteLine("\n\nLoading rbac1 from xml file!"); session = new RBACSession("u1", "r3"); ms_rbac1 = new RBAC1(); ms_rbac1.Load("rbac1.xml"); // Test role permission TestRolePermission(session, p1); TestRolePermission(session, p2); TestRolePermission(session, p4); }