@Test public void testReadObjectPrivileges() throws SQLException { String user = "user1"; if (userReader.userExist(user)) { SQLUtil.executeUpdateStatement(conn, "drop user \"" + user + "\" cascade"); } SQLUtil.executeUpdateStatement(conn, "create user \"" + user + "\" identified by password"); try { SQLUtil.executeUpdateStatement(conn, "drop table MYTABLE"); } catch (SQLException e) { } SQLUtil.executeUpdateStatement(conn, "create table mytable(id number)"); SQLUtil.executeUpdateStatement(conn, "grant select on mytable to \"" + user + "\""); SQLUtil.executeUpdateStatement(conn, "grant delete on mytable to \"" + user + "\""); SQLUtil.executeUpdateStatement(conn, "grant update on mytable to \"" + user + "\""); final List<String> privileges = privReader.readObjectPrivileges(user); SQLUtil.executeUpdateStatement(conn, "drop user \"" + user + "\""); SQLUtil.executeUpdateStatement(conn, "drop table MYTABLE"); AssertJUnit.assertEquals("Must have just 3 object privileges", 3, privileges.size()); assertThat(privileges).contains("SELECT ON " + cfg.getUserOwner() + ".MYTABLE"); assertThat(privileges).contains("DELETE ON " + cfg.getUserOwner() + ".MYTABLE"); assertThat(privileges).contains("UPDATE ON " + cfg.getUserOwner() + ".MYTABLE"); }
List<String> readObjectPrivileges(String userName) { List<String> privileges = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); List<Object[]> selectRows = SQLUtil.selectRows( conn, "select PRIVILEGE,OWNER,TABLE_NAME from DBA_TAB_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { String privilege = row[0] + " ON " + row[1] + "." + row[2]; privileges.add(privilege); } return privileges; } catch (SQLException e) { throw ConnectorException.wrap(e); } }
OracleRolePrivReader { List<String> readObjectPrivileges(String userName) { List<String> privileges = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); List<Object[]> selectRows = SQLUtil.selectRows( conn, "select PRIVILEGE,OWNER,TABLE_NAME from DBA_TAB_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { String privilege = row[0] + " ON " + row[1] + "." + row[2]; privileges.add(privilege); } return privileges; } catch (SQLException e) { throw ConnectorException.wrap(e); } } }
OracleRolePrivReader { List<String> readObjectPrivileges(String userName) { List<String> privileges = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); List<Object[]> selectRows = SQLUtil.selectRows( conn, "select PRIVILEGE,OWNER,TABLE_NAME from DBA_TAB_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { String privilege = row[0] + " ON " + row[1] + "." + row[2]; privileges.add(privilege); } return privileges; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn); }
OracleRolePrivReader { List<String> readObjectPrivileges(String userName) { List<String> privileges = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); List<Object[]> selectRows = SQLUtil.selectRows( conn, "select PRIVILEGE,OWNER,TABLE_NAME from DBA_TAB_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { String privilege = row[0] + " ON " + row[1] + "." + row[2]; privileges.add(privilege); } return privileges; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn);  }
OracleRolePrivReader { List<String> readObjectPrivileges(String userName) { List<String> privileges = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); List<Object[]> selectRows = SQLUtil.selectRows( conn, "select PRIVILEGE,OWNER,TABLE_NAME from DBA_TAB_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { String privilege = row[0] + " ON " + row[1] + "." + row[2]; privileges.add(privilege); } return privileges; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn);   }