예제 #1
0
        private void privManager_PrivilegesGranted(RoleManager.Role sender,
                                                   ReadOnlyCollection <ESysPrivilege> privileges)
        {
            // create a queue
            var queue = CreateDistributionQueue(
                new {
                Source      = default(RoleManager.Role),
                Destination = default(UserRole),
                Privileges  = default(ReadOnlyCollection <ESysPrivilege>)
            });

            // fill a queue
            foreach (UserRole userRole in sender.RoleManager.Dependants)
            {
                queue.Enqueue(new { Source = sender, Destination = userRole, Privileges = privileges });
            }

            // start BFS
            while (queue.Count > 0)
            {
                // get a distribution vector
                var vector = queue.Dequeue();
                // get a user or role, which is going to download the privilege info
                UserRole destination = vector.Destination;

                if (destination.PrivManager.DownloadPrivilegeChange(privilege, vector.Source))
                {
                    // enqueue dependants
                    foreach (UserRole dependant in destination.RoleManager.Dependants)
                    {
                        queue.Enqueue(new { Source = destination as RoleManager.Role, Destination = dependant, Privilege = privilege });
                    }
                }
            }
        }
예제 #2
0
        public bool RefreshRoleData(RoleManager.Role role)
        {
            if (refreshUserRoleData(role))
            {
                return(true);
            }
            else
            {
                OracleCommand cmd = new OracleCommand(ROLE_SYS_PRIVS_ROLE_SELECT, conn);
                // set up parameters
                OracleParameter roleParam = cmd.CreateParameter();
                roleParam.ParameterName = "role";
                roleParam.OracleDbType  = OracleDbType.Char;
                roleParam.Direction     = System.Data.ParameterDirection.Input;
                roleParam.Value         = role.Name;
                // execute
                OracleDataReader odr = cmd.ExecuteReader();

                if (!odr.HasRows)
                {
                    return(false);
                }

                // purge old data
                purgeOldUserRoleSysPrivs(role.Name);

                while (odr.Read())
                {
                    GrantedSysPrivilege grant = LoadPrivilege(odr);
                    grants.Add(grant);
                }

                return(true);
            }
        }
예제 #3
0
            public ReadOnlyCollection <GrantedSysPrivilege> DownloadPrivilegesChange(
                ReadOnlyCollection <ESysPrivilege> privs, RoleManager.Role from)
            {
                RolePrivManagerLocal rolePrivManager = from.PrivManager as RolePrivManagerLocal;
                ReadOnlyCollection <GrantedSysPrivilege> grants;

                if (rolePrivManager.GetPrivilegesGrantsInfo(privs, out grants))
                {
                }
            }
예제 #4
0
 public RoleGrant(string grantee, string grantedRole, bool adminOption, bool defaultRole,
                  bool directGrant)
 {
     this.grantee       = grantee;
     this.grantedRole   = grantedRole;
     this.adminOption   = adminOption;
     this.weakReference = true;
     this.roleReference = null;
     this.directGrant   = directGrant;
     this.defaultRole   = defaultRole;
 }
예제 #5
0
 public RoleGrant(string grantee, string grantedRole, bool adminOption, bool defaultRole,
                  bool directGrant)
 {
     this.grantee = grantee;
     this.grantedRole = grantedRole;
     this.adminOption = adminOption;
     this.weakReference = true;
     this.roleReference = null;
     this.directGrant = directGrant;
     this.defaultRole = defaultRole;
 }
예제 #6
0
        public RoleGrant(RoleGrant grant, string grantee, bool adminOption)
        {
            if(grant == null)
                throw new ArgumentNullException("Grant");

            this.grantee = grantee;
            this.grantedRole = grant.GrantedRole;
            this.adminOption = adminOption;
            this.weakReference = false;
            this.roleReference = grant.Role;
            this.directGrant = false;
            this.defaultRole = false;
        }
예제 #7
0
        public RoleGrant(RoleGrant grant, string grantee, bool adminOption)
        {
            if (grant == null)
            {
                throw new ArgumentNullException("Grant");
            }

            this.grantee       = grantee;
            this.grantedRole   = grant.GrantedRole;
            this.adminOption   = adminOption;
            this.weakReference = false;
            this.roleReference = grant.Role;
            this.directGrant   = false;
            this.defaultRole   = false;
        }
예제 #8
0
            public bool DownloadPrivilegeChange(ESysPrivilege privilege, RoleManager.Role from)
            {
                GrantedSysPrivilege  downloaded;
                RolePrivManagerLocal rolePrivManager = from.PrivManager as RolePrivManagerLocal;

                if (rolePrivManager.GetPrivilegeGrantInfo(privilege, out downloaded))
                {
                    if (mergePrivilege(createInheritedGrant(downloaded)))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(false);
            }
예제 #9
0
            // Downloads privileges from directly granted roles
            public void RefreshPrivileges()
            {
                // get direct role grants from associated local role manager
                ReadOnlyCollection <RoleGrant> directRoleGrants =
                    localRoleManager.DirectRoleGrants;

                // walk them and download role grants
                foreach (RoleGrant grant in directRoleGrants)
                {
                    // get role reference
                    RoleManager.Role grantedRole = grant.Role;
                    // get all of its privilege grants
                    ReadOnlyCollection <GrantedSysPrivilege> privs =
                        grantedRole.PrivManager.PrivilegeGrants;
                    // find those which are applicable for you and add them
                    // to your privilege list
                    addInheritedGrants(privs);
                }
            }
예제 #10
0
 public RolePrivManagerLocal(SessionManager.Session session, RoleManager.Role role) :
     base(session, role)
 {
 }
예제 #11
0
 public RolePrivManagerLocal CreateRolePrivLocalManager(RoleManager.Role role)
 {
     return(new RolePrivManagerLocal(session, role));
 }