Search in sources :

Example 1 with Right

use of org.hsqldb_voltpatches.rights.Right in project voltdb by VoltDB.

the class DatabaseInformationFull method ROUTINE_PRIVILEGES.

Table ROUTINE_PRIVILEGES() {
    Table t = sysTables[ROUTINE_PRIVILEGES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[ROUTINE_PRIVILEGES]);
        // not null
        addColumn(t, "GRANTOR", SQL_IDENTIFIER);
        // not null
        addColumn(t, "GRANTEE", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "SPECIFIC_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "SPECIFIC_NAME", SQL_IDENTIFIER);
        addColumn(t, "ROUTINE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "ROUTINE_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "ROUTINE_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
        // not null
        addColumn(t, "IS_GRANTABLE", YES_OR_NO);
        //
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[ROUTINE_PRIVILEGES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, false);
        return t;
    }
    // column number mappings
    final int grantor = 0;
    final int grantee = 1;
    final int specific_catalog = 2;
    final int specific_schema = 3;
    final int specific_name = 4;
    final int routine_catalog = 5;
    final int routine_schema = 6;
    final int routine_name = 7;
    final int privilege_type = 8;
    final int is_grantable = 9;
    //
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // calculated column values
    Grantee granteeObject;
    String privilege;
    // intermediate holders
    Iterator routines;
    RoutineSchema routine;
    Object[] row;
    OrderedHashSet grantees = session.getGrantee().getGranteeAndAllRolesWithPublic();
    routines = database.schemaManager.databaseObjectIterator(SchemaObject.ROUTINE);
    while (routines.hasNext()) {
        routine = (RoutineSchema) routines.next();
        for (int i = 0; i < grantees.size(); i++) {
            granteeObject = (Grantee) grantees.get(i);
            OrderedHashSet rights = granteeObject.getAllDirectPrivileges(routine);
            OrderedHashSet grants = granteeObject.getAllGrantedPrivileges(routine);
            if (!grants.isEmpty()) {
                grants.addAll(rights);
                rights = grants;
            }
            for (int j = 0; j < rights.size(); j++) {
                Right right = (Right) rights.get(j);
                Right grantableRight = right.getGrantableRights();
                for (int k = 0; k < Right.privilegeTypes.length; k++) {
                    if (!right.canAccess(Right.privilegeTypes[k])) {
                        continue;
                    }
                    Routine[] specifics = routine.getSpecificRoutines();
                    for (int m = 0; m < specifics.length; m++) {
                        privilege = Right.privilegeNames[k];
                        row = t.getEmptyRowData();
                        //
                        row[grantor] = right.getGrantor().getName().name;
                        row[grantee] = right.getGrantee().getName().name;
                        row[specific_catalog] = database.getCatalogName().name;
                        row[specific_schema] = specifics[m].getSchemaName().name;
                        row[specific_name] = specifics[m].getName().name;
                        row[routine_catalog] = database.getCatalogName().name;
                        row[routine_schema] = routine.getSchemaName().name;
                        row[routine_name] = routine.getName().name;
                        row[privilege_type] = privilege;
                        row[is_grantable] = right.getGrantee() == routine.getOwner() || grantableRight.canAccess(Right.privilegeTypes[k]) ? "YES" : "NO";
                        try {
                            t.insertSys(store, row);
                        } catch (HsqlException e) {
                        }
                    }
                }
            }
        }
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) Right(org.hsqldb_voltpatches.rights.Right) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) Routine(org.hsqldb_voltpatches.Routine) Constraint(org.hsqldb_voltpatches.Constraint) Grantee(org.hsqldb_voltpatches.rights.Grantee) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) HsqlException(org.hsqldb_voltpatches.HsqlException) RoutineSchema(org.hsqldb_voltpatches.RoutineSchema)

Example 2 with Right

use of org.hsqldb_voltpatches.rights.Right in project voltdb by VoltDB.

the class ParserDDL method compileRightGrantOrRevoke.

private StatementSchema compileRightGrantOrRevoke(boolean grant) {
    OrderedHashSet granteeList = new OrderedHashSet();
    Grantee grantor = null;
    Right right = null;
    //        SchemaObject   schemaObject;
    HsqlName objectName = null;
    boolean isTable = false;
    boolean isUsage = false;
    boolean isExec = false;
    boolean isAll = false;
    boolean isGrantOption = false;
    boolean cascade = false;
    if (!grant) {
        if (token.tokenType == Tokens.GRANT) {
            read();
            readThis(Tokens.OPTION);
            readThis(Tokens.FOR);
            isGrantOption = true;
        // throw not suppoerted
        } else if (token.tokenType == Tokens.HIERARCHY) {
            throw unsupportedFeature();
        /*
                read();
                readThis(Token.OPTION);
                readThis(Token.FOR);
*/
        }
    }
    // ALL means all the rights the grantor can grant
    if (token.tokenType == Tokens.ALL) {
        read();
        if (token.tokenType == Tokens.PRIVILEGES) {
            read();
        }
        right = Right.fullRights;
        isAll = true;
    } else {
        right = new Right();
        boolean loop = true;
        while (loop) {
            checkIsNotQuoted();
            int rightType = GranteeManager.getCheckSingleRight(token.tokenString);
            int grantType = token.tokenType;
            OrderedHashSet columnSet = null;
            read();
            switch(grantType) {
                case Tokens.REFERENCES:
                case Tokens.SELECT:
                case Tokens.INSERT:
                case Tokens.UPDATE:
                    if (token.tokenType == Tokens.OPENBRACKET) {
                        columnSet = readColumnNames(false);
                    }
                // $FALL-THROUGH$
                case Tokens.DELETE:
                case Tokens.TRIGGER:
                    if (right == null) {
                        right = new Right();
                    }
                    right.set(rightType, columnSet);
                    isTable = true;
                    break;
                case Tokens.USAGE:
                    if (isTable) {
                        throw unexpectedToken();
                    }
                    right = Right.fullRights;
                    isUsage = true;
                    loop = false;
                    continue;
                case Tokens.EXECUTE:
                    if (isTable) {
                        throw unexpectedToken();
                    }
                    right = Right.fullRights;
                    isExec = true;
                    loop = false;
                    continue;
            }
            if (token.tokenType == Tokens.COMMA) {
                read();
                continue;
            }
            break;
        }
    }
    readThis(Tokens.ON);
    if (token.tokenString.equals(Tokens.T_CLASS)) {
        if (!isExec && !isAll) {
            throw unexpectedToken();
        }
        read();
        if (!isSimpleName() || !isDelimitedIdentifier()) {
            throw Error.error(ErrorCode.X_42569);
        }
        objectName = readNewSchemaObjectNameNoCheck(SchemaObject.FUNCTION);
    } else if (token.tokenType == Tokens.TYPE || token.tokenType == Tokens.DOMAIN || token.tokenType == Tokens.SEQUENCE || token.tokenType == Tokens.CHARACTER) {
        if (!isUsage && !isAll) {
            throw unexpectedToken();
        }
        int type = 0;
        switch(token.tokenType) {
            case Tokens.TYPE:
                read();
                type = SchemaObject.TYPE;
                break;
            case Tokens.DOMAIN:
                read();
                type = SchemaObject.DOMAIN;
                break;
            case Tokens.SEQUENCE:
                read();
                type = SchemaObject.SEQUENCE;
                break;
            case Tokens.CHARACTER:
                read();
                readThis(Tokens.SET);
                type = SchemaObject.CHARSET;
                break;
        }
        objectName = readNewSchemaObjectNameNoCheck(type);
    } else {
        if (!isTable && !isAll) {
            throw unexpectedToken();
        }
        readIfThis(Tokens.TABLE);
        objectName = readNewSchemaObjectNameNoCheck(SchemaObject.TABLE);
    }
    if (grant) {
        readThis(Tokens.TO);
    } else {
        readThis(Tokens.FROM);
    }
    while (true) {
        checkIsSimpleName();
        granteeList.add(token.tokenString);
        read();
        if (token.tokenType == Tokens.COMMA) {
            read();
        } else {
            break;
        }
    }
    if (grant) {
        if (token.tokenType == Tokens.WITH) {
            read();
            readThis(Tokens.GRANT);
            readThis(Tokens.OPTION);
            isGrantOption = true;
        }
        /** @todo - implement */
        if (token.tokenType == Tokens.GRANTED) {
            read();
            readThis(Tokens.BY);
            if (token.tokenType == Tokens.CURRENT_USER) {
                read();
            //
            } else {
                readThis(Tokens.CURRENT_ROLE);
            }
        }
    } else {
        if (token.tokenType == Tokens.CASCADE) {
            cascade = true;
            read();
        } else {
            readThis(Tokens.RESTRICT);
        }
    }
    int type = grant ? StatementTypes.GRANT : StatementTypes.REVOKE;
    Object[] args = new Object[] { granteeList, objectName, right, grantor, Boolean.valueOf(cascade), Boolean.valueOf(isGrantOption) };
    String sql = getLastPart();
    StatementSchema cs = new StatementSchema(sql, type, args, null, null);
    return cs;
}
Also used : Grantee(org.hsqldb_voltpatches.rights.Grantee) Right(org.hsqldb_voltpatches.rights.Right) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName)

Example 3 with Right

use of org.hsqldb_voltpatches.rights.Right in project voltdb by VoltDB.

the class DatabaseInformationFull method USAGE_PRIVILEGES.

/**
     * The USAGE_PRIVILEGES view has one row for each usage privilege
     * descriptor. <p>
     *
     * It effectively contains a representation of the usage privilege
     * descriptors. <p>
     *
     * <b>Definition:</b> <p>
     *
     * <pre class="SqlCodeExample">
     * CREATE TABLE SYSTEM_USAGE_PRIVILEGES (
     *      GRANTOR         VARCHAR NOT NULL,
     *      GRANTEE         VARCHAR NOT NULL,
     *      OBJECT_CATALOG  VARCHAR NULL,
     *      OBJECT_SCHEMA   VARCHAR NULL,
     *      OBJECT_NAME     VARCHAR NOT NULL,
     *      OBJECT_TYPE     VARCHAR NOT NULL
     *
     *          CHECK ( OBJECT_TYPE IN (
     *                      'DOMAIN',
     *                      'CHARACTER SET',
     *                      'COLLATION',
     *                      'TRANSLATION',
     *                      'SEQUENCE' ) ),
     *
     *      IS_GRANTABLE    VARCHAR NOT NULL
     *
     *          CHECK ( IS_GRANTABLE IN ( 'YES', 'NO' ) ),
     *
     *      UNIQUE( GRANTOR, GRANTEE, OBJECT_CATALOG,
     *              OBJECT_SCHEMA, OBJECT_NAME, OBJECT_TYPE )
     * )
     * </pre>
     *
     * <b>Description:</b><p>
     *
     * <ol>
     * <li> The value of GRANTOR is the &lt;authorization identifier&gt; of the
     *      user or role who granted usage privileges on the object of the type
     *      identified by OBJECT_TYPE that is identified by OBJECT_CATALOG,
     *      OBJECT_SCHEMA, and OBJECT_NAME, to the user or role identified by the
     *      value of GRANTEE forthe usage privilege being described. <p>
     *
     * <li> The value of GRANTEE is the &lt;authorization identifier&gt; of some
     *      user or role, or PUBLIC to indicate all users, to whom the usage
     *      privilege being described is granted. <p>
     *
     * <li> The values of OBJECT_CATALOG, OBJECT_SCHEMA, and OBJECT_NAME are the
     *      catalog name, unqualified schema name, and qualified identifier,
     *      respectively, of the object to which the privilege applies. <p>
     *
     * <li> The values of OBJECT_TYPE have the following meanings: <p>
     *
     *      <table border cellpadding="3">
     *          <tr>
     *              <td nowrap>DOMAIN</td>
     *              <td nowrap>The object to which the privilege applies is
     *                         a domain.</td>
     *          <tr>
     *          <tr>
     *              <td nowrap>CHARACTER SET</td>
     *              <td nowrap>The object to which the privilege applies is a
     *                         character set.</td>
     *          <tr>
     *          <tr>
     *              <td nowrap>COLLATION</td>
     *              <td nowrap>The object to which the privilege applies is a
     *                         collation.</td>
     *          <tr>
     *          <tr>
     *              <td nowrap>TRANSLATION</td>
     *              <td nowrap>The object to which the privilege applies is a
     *                         transliteration.</td>
     *          <tr>
     *          <tr>
     *              <td nowrap>SEQUENCE</td>
     *              <td nowrap>The object to which the privilege applies is a
     *                         sequence generator.</td>
     *          <tr>
     *      </table> <p>
     *
     * <li> The values of IS_GRANTABLE have the following meanings: <p>
     *
     *      <table border cellpadding="3">
     *          <tr>
     *              <td nowrap>YES</td>
     *              <td nowrap>The privilege being described was granted
     *                         WITH GRANT OPTION and is thus grantable.</td>
     *          <tr>
     *          <tr>
     *              <td nowrap>NO</td>
     *              <td nowrap>The privilege being described was not granted
     *                  WITH GRANT OPTION and is thus not grantable.</td>
     *          <tr>
     *      </table> <p>
     * <ol>
     *
     * @return Table
     */
Table USAGE_PRIVILEGES() {
    Table t = sysTables[USAGE_PRIVILEGES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[USAGE_PRIVILEGES]);
        // not null
        addColumn(t, "GRANTOR", SQL_IDENTIFIER);
        // not null
        addColumn(t, "GRANTEE", SQL_IDENTIFIER);
        addColumn(t, "OBJECT_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "OBJECT_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "OBJECT_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "OBJECT_TYPE", CHARACTER_DATA);
        addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
        // not null
        addColumn(t, "IS_GRANTABLE", YES_OR_NO);
        // order: COLUMN_NAME, PRIVILEGE
        // for unique: GRANTEE, GRANTOR, TABLE_NAME, TABLE_SCHEM, TABLE_CAT
        // false PK, as TABLE_SCHEM and/or TABLE_CAT may be null
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[USAGE_PRIVILEGES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, false);
        return t;
    }
    //
    Object[] row;
    //
    final int grantor = 0;
    final int grantee = 1;
    final int object_catalog = 2;
    final int object_schema = 3;
    final int object_name = 4;
    final int object_type = 5;
    final int privilege_type = 6;
    final int is_grantable = 7;
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Iterator objects = new WrapperIterator(database.schemaManager.databaseObjectIterator(SchemaObject.SEQUENCE), database.schemaManager.databaseObjectIterator(SchemaObject.COLLATION));
    objects = new WrapperIterator(objects, database.schemaManager.databaseObjectIterator(SchemaObject.CHARSET));
    objects = new WrapperIterator(objects, database.schemaManager.databaseObjectIterator(SchemaObject.DOMAIN));
    /*
        objects = new WrapperIterator(
            objects,
            database.schemaManager.databaseObjectIterator(SchemaObject.TYPE));
*/
    OrderedHashSet grantees = session.getGrantee().getGranteeAndAllRolesWithPublic();
    while (objects.hasNext()) {
        SchemaObject object = (SchemaObject) objects.next();
        for (int i = 0; i < grantees.size(); i++) {
            Grantee granteeObject = (Grantee) grantees.get(i);
            OrderedHashSet rights = granteeObject.getAllDirectPrivileges(object);
            OrderedHashSet grants = granteeObject.getAllGrantedPrivileges(object);
            if (!grants.isEmpty()) {
                grants.addAll(rights);
                rights = grants;
            }
            for (int j = 0; j < rights.size(); j++) {
                Right right = (Right) rights.get(j);
                Right grantableRight = right.getGrantableRights();
                row = t.getEmptyRowData();
                row[grantor] = right.getGrantor().getName().name;
                row[grantee] = right.getGrantee().getName().name;
                row[object_catalog] = database.getCatalogName().name;
                row[object_schema] = object.getSchemaName().name;
                row[object_name] = object.getName().name;
                row[object_type] = SchemaObjectSet.getName(object.getName().type);
                row[privilege_type] = Tokens.T_USAGE;
                row[is_grantable] = right.getGrantee() == object.getOwner() || grantableRight.isFull() ? Tokens.T_YES : Tokens.T_NO;
                ;
                try {
                    t.insertSys(store, row);
                } catch (HsqlException e) {
                }
            }
        }
    }
    return t;
}
Also used : SchemaObject(org.hsqldb_voltpatches.SchemaObject) Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) Right(org.hsqldb_voltpatches.rights.Right) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) Constraint(org.hsqldb_voltpatches.Constraint) Grantee(org.hsqldb_voltpatches.rights.Grantee) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 4 with Right

use of org.hsqldb_voltpatches.rights.Right in project voltdb by VoltDB.

the class DatabaseInformationMain method init.

/**
     * One time initialisation of instance attributes
     * at construction time. <p>
     *
     */
protected final void init() {
    ns = new DINameSpace(database);
    pi = new DIProcedureInfo(ns);
    // flag the Session-dependent cached tables
    Table t;
    for (int i = 0; i < sysTables.length; i++) {
        t = sysTables[i] = generateTable(i);
        if (t != null) {
            t.setDataReadOnly(true);
        }
    }
    GranteeManager gm = database.getGranteeManager();
    Right right = new Right();
    right.set(GrantConstants.SELECT, null);
    for (int i = 0; i < sysTableHsqlNames.length; i++) {
        if (sysTables[i] != null) {
            gm.grantSystemToPublic(sysTables[i], right);
        }
    }
    right = Right.fullRights;
    gm.grantSystemToPublic(SqlInvariants.YES_OR_NO, right);
    gm.grantSystemToPublic(SqlInvariants.TIME_STAMP, right);
    gm.grantSystemToPublic(SqlInvariants.CARDINAL_NUMBER, right);
    gm.grantSystemToPublic(SqlInvariants.CHARACTER_DATA, right);
    gm.grantSystemToPublic(SqlInvariants.SQL_CHARACTER, right);
    gm.grantSystemToPublic(SqlInvariants.SQL_IDENTIFIER_CHARSET, right);
    gm.grantSystemToPublic(SqlInvariants.SQL_IDENTIFIER, right);
    gm.grantSystemToPublic(SqlInvariants.SQL_TEXT, right);
}
Also used : Table(org.hsqldb_voltpatches.Table) Right(org.hsqldb_voltpatches.rights.Right) Constraint(org.hsqldb_voltpatches.Constraint) GranteeManager(org.hsqldb_voltpatches.rights.GranteeManager)

Example 5 with Right

use of org.hsqldb_voltpatches.rights.Right in project voltdb by VoltDB.

the class DatabaseInformationMain method COLUMN_PRIVILEGES.

// -----------------------------------------------------------------------------
// SQL SCHEMATA VIEWS
// limited to views used in JDBC DatabaseMetaData
/**
     * Retrieves a <code>Table</code> object describing the visible
     * access rights for all visible columns of all accessible
     * tables defined within this database.<p>
     *
     * Each row is a column privilege description with the following
     * columns: <p>
     *
     * <pre class="SqlCodeExample">
     * TABLE_CAT    VARCHAR   table catalog
     * TABLE_SCHEM  VARCHAR   table schema
     * TABLE_NAME   VARCHAR   table name
     * COLUMN_NAME  VARCHAR   column name
     * GRANTOR      VARCHAR   grantor of access
     * GRANTEE      VARCHAR   grantee of access
     * PRIVILEGE    VARCHAR   name of access
     * IS_GRANTABLE VARCHAR   grantable?: "YES" - grant to others, else "NO"
     * </pre>
     *
     * <b>Note:</b> From 1.9.0, HSQLDB supports column level
     * privileges. <p>
     *
     * @return a <code>Table</code> object describing the visible
     *        access rights for all visible columns of
     *        all accessible tables defined within this
     *        database
     */
final Table COLUMN_PRIVILEGES() {
    Table t = sysTables[COLUMN_PRIVILEGES];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[COLUMN_PRIVILEGES]);
        // not null
        addColumn(t, "GRANTOR", SQL_IDENTIFIER);
        // not null
        addColumn(t, "GRANTEE", SQL_IDENTIFIER);
        addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "PRIVILEGE_TYPE", CHARACTER_DATA);
        // not null
        addColumn(t, "IS_GRANTABLE", YES_OR_NO);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[COLUMN_PRIVILEGES].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 2, 3, 4, 5, 6, 1, 0 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    // calculated column values
    String tableCatalog;
    String tableSchema;
    String tableName;
    Grantee granteeObject;
    // intermediate holders
    User user;
    Iterator tables;
    Table table;
    Object[] row;
    // column number mappings
    final int grantor = 0;
    final int grantee = 1;
    final int table_catalog = 2;
    final int table_schema = 3;
    final int table_name = 4;
    final int column_name = 5;
    final int privilege_type = 6;
    final int is_grantable = 7;
    // enumerations
    OrderedHashSet grantees = session.getGrantee().getGranteeAndAllRolesWithPublic();
    // Initialization
    tables = allTables();
    while (tables.hasNext()) {
        table = (Table) tables.next();
        tableName = table.getName().name;
        tableCatalog = database.getCatalogName().name;
        tableSchema = table.getSchemaName().name;
        for (int i = 0; i < grantees.size(); i++) {
            granteeObject = (Grantee) grantees.get(i);
            OrderedHashSet rights = granteeObject.getAllDirectPrivileges(table);
            OrderedHashSet grants = granteeObject.getAllGrantedPrivileges(table);
            if (!grants.isEmpty()) {
                grants.addAll(rights);
                rights = grants;
            }
            for (int j = 0; j < rights.size(); j++) {
                Right right = (Right) rights.get(j);
                Right grantableRight = right.getGrantableRights();
                for (int k = 0; k < Right.privilegeTypes.length; k++) {
                    OrderedHashSet columnList = right.getColumnsForPrivilege(table, Right.privilegeTypes[k]);
                    OrderedHashSet grantableList = grantableRight.getColumnsForPrivilege(table, Right.privilegeTypes[k]);
                    for (int l = 0; l < columnList.size(); l++) {
                        HsqlName fullName = ((HsqlName) columnList.get(l));
                        row = t.getEmptyRowData();
                        row[grantor] = right.getGrantor().getName().name;
                        row[grantee] = right.getGrantee().getName().name;
                        row[table_catalog] = tableCatalog;
                        row[table_schema] = tableSchema;
                        row[table_name] = tableName;
                        row[column_name] = fullName.name;
                        row[privilege_type] = Right.privilegeNames[k];
                        row[is_grantable] = right.getGrantee() == table.getOwner() || grantableList.contains(fullName) ? "YES" : "NO";
                        try {
                            t.insertSys(store, row);
                        } catch (HsqlException e) {
                        }
                    }
                }
            }
        }
    }
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) User(org.hsqldb_voltpatches.rights.User) Right(org.hsqldb_voltpatches.rights.Right) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) Constraint(org.hsqldb_voltpatches.Constraint) Grantee(org.hsqldb_voltpatches.rights.Grantee) Iterator(org.hsqldb_voltpatches.lib.Iterator) WrapperIterator(org.hsqldb_voltpatches.lib.WrapperIterator) OrderedHashSet(org.hsqldb_voltpatches.lib.OrderedHashSet) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) SchemaObject(org.hsqldb_voltpatches.SchemaObject) HsqlException(org.hsqldb_voltpatches.HsqlException)

Aggregations

Right (org.hsqldb_voltpatches.rights.Right)6 Constraint (org.hsqldb_voltpatches.Constraint)5 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)5 Table (org.hsqldb_voltpatches.Table)5 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)5 Grantee (org.hsqldb_voltpatches.rights.Grantee)5 HsqlException (org.hsqldb_voltpatches.HsqlException)4 SchemaObject (org.hsqldb_voltpatches.SchemaObject)4 Iterator (org.hsqldb_voltpatches.lib.Iterator)4 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)4 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)4 TextTable (org.hsqldb_voltpatches.TextTable)2 Routine (org.hsqldb_voltpatches.Routine)1 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)1 GranteeManager (org.hsqldb_voltpatches.rights.GranteeManager)1 User (org.hsqldb_voltpatches.rights.User)1