use of org.postgresql.ds.PGPoolingDataSource in project Gatekeeper by FINRAOS.
the class PostgresDBConnection method revokeAccess.
public boolean revokeAccess(String user, RoleType roles, String address) throws SQLException {
PGPoolingDataSource dataSource = null;
try {
dataSource = connect(address);
JdbcTemplate conn = new JdbcTemplate(dataSource);
logger.info("Removing " + user + " from " + address + " if they exist.");
revokeUser(conn, user + "_" + roles.getShortSuffix());
return true;
} catch (Exception ex) {
logger.error("An exception was thrown while trying to revoke user " + user + "_" + roles.getShortSuffix() + " from address " + address, ex);
return false;
} finally {
if (dataSource != null) {
dataSource.close();
}
}
}
use of org.postgresql.ds.PGPoolingDataSource in project Gatekeeper by FINRAOS.
the class PostgresDBConnection method getAvailableTables.
public Map<RoleType, List<String>> getAvailableTables(String address) throws SQLException {
Map<RoleType, List<String>> results = new HashMap<>();
PGPoolingDataSource dataSource = connect(address);
JdbcTemplate conn = new JdbcTemplate(dataSource);
logger.info("Getting available schema information for " + address);
for (RoleType roleType : RoleType.values()) {
try {
List<String> schemas = conn.queryForList(getSchemas, new Object[] { roleType.getDbRole() }, String.class);
results.put(roleType, !schemas.isEmpty() ? schemas : Collections.singletonList("No Schemas are available for role " + roleType.getDbRole() + " at this time."));
logger.info("Retrieved available schema information for database " + address + " for role " + roleType.getDbRole());
} catch (Exception ex) {
logger.error("Could not retrieve available role information for database " + address + " for role " + roleType.getDbRole(), ex);
results.put(roleType, Collections.singletonList("Unable to get available schemas for role " + roleType.getDbRole()));
}
}
dataSource.close();
return results;
}
Aggregations