@Test public void testReadRoles() throws SQLException { String user = "user1"; if (!userReader.userExist(user)) { SQLUtil.executeUpdateStatement(conn, "create user \"" + user + "\" identified by password"); } try { SQLUtil.executeUpdateStatement(conn, "drop role \"testrole\""); } catch (SQLException e) { } SQLUtil.executeUpdateStatement(conn, "create role \"testrole\""); SQLUtil.executeUpdateStatement(conn, "grant \"testrole\" to \"" + user + "\""); final List<String> roles = privReader.readRoles(user); assertTrue("User should be granteded testrole", roles.contains("testrole")); SQLUtil.executeUpdateStatement(conn, "drop user \"" + user + "\""); SQLUtil.executeUpdateStatement(conn, "drop role \"testrole\""); }
List<String> readRoles(String userName) { List<String> roles = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); final List<Object[]> selectRows = SQLUtil.selectRows(conn, "select GRANTED_ROLE from DBA_ROLE_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { roles.add((String) row[0]); } return roles; } catch (SQLException e) { throw ConnectorException.wrap(e); } }
OracleRolePrivReader { List<String> readRoles(String userName) { List<String> roles = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); final List<Object[]> selectRows = SQLUtil.selectRows(conn, "select GRANTED_ROLE from DBA_ROLE_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { roles.add((String) row[0]); } return roles; } catch (SQLException e) { throw ConnectorException.wrap(e); } } }
OracleRolePrivReader { List<String> readRoles(String userName) { List<String> roles = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); final List<Object[]> selectRows = SQLUtil.selectRows(conn, "select GRANTED_ROLE from DBA_ROLE_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { roles.add((String) row[0]); } return roles; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn); }
OracleRolePrivReader { List<String> readRoles(String userName) { List<String> roles = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); final List<Object[]> selectRows = SQLUtil.selectRows(conn, "select GRANTED_ROLE from DBA_ROLE_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { roles.add((String) row[0]); } return roles; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn);  }
OracleRolePrivReader { List<String> readRoles(String userName) { List<String> roles = new ArrayList<String>(); try { final SQLParam userNameParam = new SQLParam("Grantee", userName); final List<Object[]> selectRows = SQLUtil.selectRows(conn, "select GRANTED_ROLE from DBA_ROLE_PRIVS where Grantee = ?", userNameParam); for (Object[] row : selectRows) { roles.add((String) row[0]); } return roles; } catch (SQLException e) { throw ConnectorException.wrap(e); } } OracleRolePrivReader(Connection conn);   }