@Test public void testReadTableAuthorities() throws SQLException { testee.readTableAuthorities(testUser); }
Collection<DB2Authority> readTableAuthorities(String user) throws SQLException { String accountIDUC = user.toUpperCase(); String sql = "SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = '" + accountIDUC + "' AND GRANTEETYPE = 'U'"; Collection<DB2Authority> grants = new ArrayList<DB2Authority>(); ResultSet rs = executeQuery(sql); while (rs.next()) { if (rs.getString("CONTROLAUTH").equals("Y")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "CONTROL", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("ALTERAUTH").equals("Y") || rs.getString("ALTERAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "ALTER", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("DELETEAUTH").equals("Y") || rs.getString("DELETEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "DELETE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INDEXAUTH").equals("Y") || rs.getString("INDEXAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INDEX", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INSERTAUTH").equals("Y") || rs.getString("INSERTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INSERT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("SELECTAUTH").equals("Y") || rs.getString("SELECTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "SELECT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("UPDATEAUTH").equals("Y") || rs.getString("UPDATEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "UPDATE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("REFAUTH").equals("Y") || rs.getString("REFAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "REFERENCES", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } } return grants; }
DB2AuthorityReader { Collection<DB2Authority> readTableAuthorities(String user) throws SQLException { String accountIDUC = user.toUpperCase(); String sql = "SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = '" + accountIDUC + "' AND GRANTEETYPE = 'U'"; Collection<DB2Authority> grants = new ArrayList<DB2Authority>(); ResultSet rs = executeQuery(sql); while (rs.next()) { if (rs.getString("CONTROLAUTH").equals("Y")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "CONTROL", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("ALTERAUTH").equals("Y") || rs.getString("ALTERAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "ALTER", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("DELETEAUTH").equals("Y") || rs.getString("DELETEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "DELETE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INDEXAUTH").equals("Y") || rs.getString("INDEXAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INDEX", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INSERTAUTH").equals("Y") || rs.getString("INSERTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INSERT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("SELECTAUTH").equals("Y") || rs.getString("SELECTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "SELECT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("UPDATEAUTH").equals("Y") || rs.getString("UPDATEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "UPDATE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("REFAUTH").equals("Y") || rs.getString("REFAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "REFERENCES", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } } return grants; } }
DB2AuthorityReader { Collection<DB2Authority> readTableAuthorities(String user) throws SQLException { String accountIDUC = user.toUpperCase(); String sql = "SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = '" + accountIDUC + "' AND GRANTEETYPE = 'U'"; Collection<DB2Authority> grants = new ArrayList<DB2Authority>(); ResultSet rs = executeQuery(sql); while (rs.next()) { if (rs.getString("CONTROLAUTH").equals("Y")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "CONTROL", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("ALTERAUTH").equals("Y") || rs.getString("ALTERAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "ALTER", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("DELETEAUTH").equals("Y") || rs.getString("DELETEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "DELETE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INDEXAUTH").equals("Y") || rs.getString("INDEXAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INDEX", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INSERTAUTH").equals("Y") || rs.getString("INSERTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INSERT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("SELECTAUTH").equals("Y") || rs.getString("SELECTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "SELECT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("UPDATEAUTH").equals("Y") || rs.getString("UPDATEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "UPDATE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("REFAUTH").equals("Y") || rs.getString("REFAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "REFERENCES", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } } return grants; } DB2AuthorityReader(Connection adminConn); }
DB2AuthorityReader { Collection<DB2Authority> readTableAuthorities(String user) throws SQLException { String accountIDUC = user.toUpperCase(); String sql = "SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = '" + accountIDUC + "' AND GRANTEETYPE = 'U'"; Collection<DB2Authority> grants = new ArrayList<DB2Authority>(); ResultSet rs = executeQuery(sql); while (rs.next()) { if (rs.getString("CONTROLAUTH").equals("Y")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "CONTROL", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("ALTERAUTH").equals("Y") || rs.getString("ALTERAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "ALTER", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("DELETEAUTH").equals("Y") || rs.getString("DELETEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "DELETE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INDEXAUTH").equals("Y") || rs.getString("INDEXAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INDEX", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INSERTAUTH").equals("Y") || rs.getString("INSERTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INSERT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("SELECTAUTH").equals("Y") || rs.getString("SELECTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "SELECT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("UPDATEAUTH").equals("Y") || rs.getString("UPDATEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "UPDATE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("REFAUTH").equals("Y") || rs.getString("REFAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "REFERENCES", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } } return grants; } DB2AuthorityReader(Connection adminConn);  }
DB2AuthorityReader { Collection<DB2Authority> readTableAuthorities(String user) throws SQLException { String accountIDUC = user.toUpperCase(); String sql = "SELECT * FROM SYSIBM.SYSTABAUTH WHERE GRANTEE = '" + accountIDUC + "' AND GRANTEETYPE = 'U'"; Collection<DB2Authority> grants = new ArrayList<DB2Authority>(); ResultSet rs = executeQuery(sql); while (rs.next()) { if (rs.getString("CONTROLAUTH").equals("Y")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "CONTROL", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("ALTERAUTH").equals("Y") || rs.getString("ALTERAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "ALTER", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("DELETEAUTH").equals("Y") || rs.getString("DELETEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "DELETE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INDEXAUTH").equals("Y") || rs.getString("INDEXAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INDEX", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("INSERTAUTH").equals("Y") || rs.getString("INSERTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "INSERT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("SELECTAUTH").equals("Y") || rs.getString("SELECTAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "SELECT", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("UPDATEAUTH").equals("Y") || rs.getString("UPDATEAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "UPDATE", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } if (rs.getString("REFAUTH").equals("Y") || rs.getString("REFAUTH").equals("G")) { grants.add(new DB2Authority(AUTH_TYPE_TABLE, "REFERENCES", rs.getString("TCREATOR") .trim() + "." + rs.getString("TTNAME").trim(), accountIDUC)); } } return grants; } DB2AuthorityReader(Connection adminConn);   }