Пример #1
0
        public void CheckRoleList(string granteeName, OrderedHashSet <string> roleList, Grantee grantor, bool grant)
        {
            Grantee grantee = this.Get(granteeName);

            for (int i = 0; i < roleList.Size(); i++)
            {
                string  name = roleList.Get(i);
                Grantee role = this.GetRole(name);
                if (role == null)
                {
                    throw Error.GetError(0x898, name);
                }
                if (name.Equals("SYS") || name.Equals("PUBLIC"))
                {
                    throw Error.GetError(0xfa2, name);
                }
                if (grant)
                {
                    if (grantee.GetDirectRoles().Contains(role))
                    {
                        throw Error.GetError(0x898, granteeName);
                    }
                }
                else if (!grantee.GetDirectRoles().Contains(role))
                {
                    throw Error.GetError(0x898, name);
                }
                if (!grantor.IsAdmin())
                {
                    throw Error.GetError(0x7d0, grantor.GetNameString());
                }
            }
        }
Пример #2
0
 public void Revoke(Grantee role)
 {
     if (!this.HasRoleDirect(role))
     {
         throw Error.GetError(0x8cd, role.GetNameString());
     }
     this.Roles.Remove(role);
 }
Пример #3
0
        public string[] GetRightstSQL()
        {
            List <string>      list     = new List <string>();
            Iterator <Grantee> iterator = this.GetGrantees().GetIterator();

            while (iterator.HasNext())
            {
                Grantee grantee = iterator.Next();
                if (!IsImmutable(grantee.GetNameString()))
                {
                    List <string> rightsSQL = grantee.GetRightsSQL();
                    list.AddRange(rightsSQL);
                }
            }
            return(list.ToArray());
        }
Пример #4
0
        public void Grant(OrderedHashSet <string> granteeList, ISchemaObject[] routines, Right right, Grantee grantor, bool withGrantOption)
        {
            bool flag = false;

            for (int i = 0; i < routines.Length; i++)
            {
                if (grantor.IsGrantable(routines[i], right))
                {
                    this.Grant(granteeList, routines[i], right, grantor, withGrantOption);
                    flag = true;
                }
            }
            if (!flag)
            {
                throw Error.GetError(0x7d0, grantor.GetNameString());
            }
        }
Пример #5
0
        public void Grant(OrderedHashSet <string> granteeList, ISchemaObject dbObject, Right right, Grantee grantor, bool withGrantOption)
        {
            RoutineSchema schema = dbObject as RoutineSchema;

            if (schema != null)
            {
                ISchemaObject[] specificRoutines = schema.GetSpecificRoutines();
                this.Grant(granteeList, specificRoutines, right, grantor, withGrantOption);
            }
            else
            {
                QNameManager.QName specificName = dbObject.GetName();
                Routine            routine      = dbObject as Routine;
                if (routine != null)
                {
                    specificName = routine.GetSpecificName();
                }
                if (!grantor.IsGrantable(dbObject, right))
                {
                    throw Error.GetError(0x7d0, grantor.GetNameString());
                }
                if (grantor.IsAdmin())
                {
                    grantor = dbObject.GetOwner();
                }
                this.CheckGranteeList(granteeList);
                for (int i = 0; i < granteeList.Size(); i++)
                {
                    Grantee role = this.Get(granteeList.Get(i));
                    role.Grant(specificName, right, grantor, withGrantOption);
                    if (role.IsRole)
                    {
                        this.UpdateAllRights(role);
                    }
                }
            }
        }
Пример #6
0
        public void Grant(string granteeName, string roleName, Grantee grantor)
        {
            Grantee role = this.Get(granteeName);

            if (role == null)
            {
                throw Error.GetError(0xfa1, granteeName);
            }
            if (IsImmutable(granteeName))
            {
                throw Error.GetError(0xfa2, granteeName);
            }
            Grantee grantee2 = this.GetRole(roleName);

            if (grantee2 == null)
            {
                throw Error.GetError(0x898, roleName);
            }
            if (grantee2 == role)
            {
                throw Error.GetError(0x8cb, granteeName);
            }
            if (grantee2.HasRole(role))
            {
                throw Error.GetError(0x8cb, roleName);
            }
            if (!grantor.IsGrantable(grantee2))
            {
                throw Error.GetError(0x7d0, grantor.GetNameString());
            }
            role.Grant(grantee2);
            role.UpdateAllRights();
            if (role.IsRole)
            {
                this.UpdateAllRights(role);
            }
        }
Пример #7
0
        public string[] GetSQL()
        {
            List <string>      list     = new List <string>();
            Iterator <Grantee> iterator = this.GetRoles().GetIterator();

            while (iterator.HasNext())
            {
                Grantee grantee = iterator.Next();
                if (!IsReserved(grantee.GetNameString()))
                {
                    list.Add(grantee.GetSql());
                }
            }
            iterator = this.GetGrantees().GetIterator();
            while (iterator.HasNext())
            {
                Grantee grantee2 = iterator.Next();
                if (grantee2 is User)
                {
                    list.Add(grantee2.GetSql());
                }
            }
            return(list.ToArray());
        }