Ejemplo n.º 1
0
        private void AddToFullRights(MultiValueHashMap <QNameManager.QName, Right> map)
        {
            Iterator <QNameManager.QName> iterator = map.GetKeySet().GetIterator();

            while (iterator.HasNext())
            {
                QNameManager.QName key       = iterator.Next();
                Iterator <Right>   iterator2 = map.Get(key);
                Right right = this._fullRightsMap.Get(key);
                while (iterator2.HasNext())
                {
                    Right right2 = iterator2.Next();
                    if (right == null)
                    {
                        right = right2.Duplicate();
                        this._fullRightsMap.Put(key, right);
                    }
                    else
                    {
                        right.Add(right2);
                    }
                    if (right2.GrantableRights != null)
                    {
                        if (right.GrantableRights == null)
                        {
                            right.GrantableRights = right2.GrantableRights.Duplicate();
                        }
                        else
                        {
                            right.GrantableRights.Add(right2.GrantableRights);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public List <string> GetRightsSQL()
        {
            List <string> list = new List <string>();
            string        directRolesAsString = this.GetDirectRolesAsString();

            if (directRolesAsString.Length != 0)
            {
                StringBuilder builder = new StringBuilder(0x80);
                builder.Append("GRANT").Append(' ').Append(directRolesAsString);
                builder.Append(' ').Append("TO").Append(' ');
                builder.Append(this.GetStatementName());
                list.Add(builder.ToString());
            }
            MultiValueHashMap <QNameManager.QName, Right> rights = this.GetRights();
            Iterator <QNameManager.QName> iterator = rights.GetKeySet().GetIterator();

            while (iterator.HasNext())
            {
                QNameManager.QName key       = iterator.Next();
                Iterator <Right>   iterator2 = rights.Get(key);
                while (iterator2.HasNext())
                {
                    Right              right    = iterator2.Next();
                    StringBuilder      builder2 = new StringBuilder(0x80);
                    QNameManager.QName name2    = key;
                    switch (name2.type)
                    {
                    case 3:
                    case 4:
                    {
                        Table table = this.granteeManager.database.schemaManager.FindUserTable(null, name2.Name, name2.schema.Name);
                        if (table != null)
                        {
                            builder2.Append("GRANT").Append(' ');
                            builder2.Append(right.GetTableRightsSQL(table));
                            builder2.Append(' ').Append("ON").Append(' ');
                            builder2.Append("TABLE").Append(' ');
                            builder2.Append(name2.GetSchemaQualifiedStatementName());
                        }
                        break;
                    }

                    case 7:
                        if (((NumberSequence)this.granteeManager.database.schemaManager.FindSchemaObject(name2.Name, name2.schema.Name, 7)) != null)
                        {
                            builder2.Append("GRANT").Append(' ');
                            builder2.Append("USAGE");
                            builder2.Append(' ').Append("ON").Append(' ');
                            builder2.Append("SEQUENCE").Append(' ');
                            builder2.Append(name2.GetSchemaQualifiedStatementName());
                        }
                        break;

                    case 12:
                        if (((SqlType)this.granteeManager.database.schemaManager.FindSchemaObject(name2.Name, name2.schema.Name, 13)) != null)
                        {
                            builder2.Append("GRANT").Append(' ');
                            builder2.Append("USAGE");
                            builder2.Append(' ').Append("ON").Append(' ');
                            builder2.Append("TYPE").Append(' ');
                            builder2.Append(name2.GetSchemaQualifiedStatementName());
                        }
                        break;

                    case 13:
                        if (((SqlType)this.granteeManager.database.schemaManager.FindSchemaObject(name2.Name, name2.schema.Name, 13)) != null)
                        {
                            builder2.Append("GRANT").Append(' ');
                            builder2.Append("USAGE");
                            builder2.Append(' ').Append("ON").Append(' ');
                            builder2.Append("DOMAIN").Append(' ');
                            builder2.Append(name2.GetSchemaQualifiedStatementName());
                        }
                        break;

                    case 0x10:
                    case 0x11:
                    case 0x18:
                    case 0x1b:
                    {
                        ISchemaObject obj2 = this.granteeManager.database.schemaManager.FindSchemaObject(name2.Name, name2.schema.Name, name2.type);
                        if (obj2 != null)
                        {
                            builder2.Append("GRANT").Append(' ');
                            builder2.Append("EXECUTE").Append(' ');
                            builder2.Append("ON").Append(' ');
                            builder2.Append("SPECIFIC").Append(' ');
                            if (obj2.GetSchemaObjectType() == 0x11)
                            {
                                builder2.Append("PROCEDURE");
                            }
                            else if (obj2.GetSchemaObjectType() == 0x1b)
                            {
                                builder2.Append("AGGREGATE");
                            }
                            else
                            {
                                builder2.Append("FUNCTION");
                            }
                            builder2.Append(' ');
                            builder2.Append(name2.GetSchemaQualifiedStatementName());
                        }
                        break;
                    }
                    }
                    if (builder2.Length != 0)
                    {
                        builder2.Append(' ').Append("TO").Append(' ');
                        builder2.Append(this.GetStatementName());
                        list.Add(builder2.ToString());
                    }
                }
            }
            return(list);
        }