Ejemplo n.º 1
0
        private void Bind()
        {
            cbInstances.DataSource    = Rbac.GetRbacs();
            cbInstances.DisplayMember = "Name";

            cbUsers.DataSource    = Rbac.GetUsers();
            cbUsers.DisplayMember = "UserName";

            cbRoles.DataSource    = Rbac.GetRoles();
            cbRoles.DisplayMember = "Name";

            _Request = new RbacEngineWebRequest();
            engineInput.SelectedObject = _Request;
        }
Ejemplo n.º 2
0
        private void Bind()
        {
            cbInstances.DataSource    = Rbac.GetRbacs();
            cbInstances.DisplayMember = "Name";

            List <RbacUser> users = Rbac.GetUsers();

            for (int i = 0; i < users.Count; i++)
            {
                if (users[i].Role == null)
                {
                    users[i] = users[i].PopulateRole();
                }
            }
            cbUsers.DataSource    = users;
            cbUsers.DisplayMember = "UserName";

            cbRoles.DataSource    = Rbac.GetRoles();
            cbRoles.DisplayMember = "Name";

            _Request = new RbacEngineWebRequest();
            engineInput.SelectedObject = _Request;
        }
Ejemplo n.º 3
0
        public void Setup(Options options)
        {
            if (string.IsNullOrEmpty(options.ConnectionString))
            {
                WriteErrorLine("Connection string is required. Please use -x <connection string>");
                return;
            }

            Rbac rbac = new Rbac();

            rbac = rbac.CreateNew("books", "books description",
                                  options.ConnectionString,
                                  File.ReadAllText(Path.Combine(_rootDir, "Books", "entitlement.xml")));

            Console.Write(".");
            InsertRoles(rbac);
            GenericParserAdapter parser = new GenericParserAdapter(Path.Combine(_rootDir, "Books", "BooksUsers.csv"));

            parser.FirstRowHasHeader = true;
            DataTable table = parser.GetDataTable();


            if (table.Rows.Count > 0)
            {
                foreach (DataRow dataRow in table.Rows)
                {
                    RbacRole role = roles.Where(r => r.Name == dataRow["Role"].ToString()).SingleOrDefault();
                    if (role == null)
                    {
                        throw new Exception(dataRow["Role"].ToString() + " is not defined!");
                    }

                    RbacUser user = Rbac.CreateUser(dataRow[0].ToString(), dataRow[1].ToString(), dataRow[2].ToString(), "password", role);
                    if (role.Name == "role_city_mgr")
                    {
                        user.AddParameter("{CityNames}", "('New York','Charlotte')");
                    }
                    else if (role.Name == "role_state_mgr")
                    {
                        user.AddParameter("{ShortNames}", "('NY','NC')");
                    }
                    else if (role.Name == "role_country_mgr")
                    {
                        user.AddParameter("{CountryCodes}", "('IN','US')");
                    }
                    if (role.Name == "role_guest_user")
                    {
                        user.AddParameter("{CityNames}", "('New York')");
                    }
                    Console.Write(".");
                }
            }
            Console.WriteLine();

            var rbacs = Rbac.GetRbacs();

            if (rbacs != null)
            {
                WriteColor(ConsoleColor.Green, rbacs.Count + " rbac instance(s) created." + Environment.NewLine);
            }
            else
            {
                WriteErrorLine("rbac creation failed!");
            }

            var vroles = Rbac.GetRoles();

            if (vroles != null)
            {
                WriteColor(ConsoleColor.Green, vroles.Count + " role(s) created." + Environment.NewLine);
            }
            else
            {
                WriteErrorLine("role(s) creation failed!");
            }

            var users = Rbac.GetUsers();

            if (users != null)
            {
                WriteColor(ConsoleColor.Green, users.Count + " user(s) created." + Environment.NewLine);
            }
            else
            {
                WriteErrorLine("user(s) creation failed!");
            }
        }
Ejemplo n.º 4
0
 public List <Rbac> Get()
 {
     return(Rbac.GetRbacs());
 }