Example #1
0
        /// <summary>
        /// Instantiate the object.
        /// </summary>
        /// <param name="dbFile">Database file.</param>
        public RbacServer(string dbFile = "gatekeeper.db")
        {
            if (String.IsNullOrEmpty(dbFile))
            {
                throw new ArgumentNullException(nameof(dbFile));
            }
            _ORM = new WatsonORM(new DatabaseSettings(dbFile));
            _ORM.InitializeDatabase();
            _ORM.InitializeTables(_TypesToInitialize);

            _Permissions = new PermissionManager(_ORM);
            _Resources   = new ResourceManager(_ORM);
            _Roles       = new RoleManager(_ORM);
            _Users       = new UserManager(_ORM);
            _UserRoles   = new UserRoleManager(_ORM, _Users, _Roles);

            _Permissions.Resources = _Resources;
            _Permissions.Roles     = _Roles;
            _Permissions.Users     = _Users;
            _Permissions.UserRoles = _UserRoles;

            _Resources.Permissions = _Permissions;
            _Resources.Roles       = _Roles;
            _Resources.Users       = _Users;
            _Resources.UserRoles   = _UserRoles;

            _Roles.Permissions = _Permissions;
            _Roles.Resources   = _Resources;
            _Roles.Users       = _Users;
            _Roles.UserRoles   = _UserRoles;

            _Users.Permissions = _Permissions;
            _Users.Resources   = _Resources;
            _Users.Roles       = _Roles;
            _Users.UserRoles   = _UserRoles;

            _UserRoles.Permissions = _Permissions;
            _UserRoles.Resources   = _Resources;
        }