/** * Return the roles associated with the given user name * @param dbConnection The database connection to be used * @param username User name for which roles should be retrieved * @return an array list of the role names */ protected ArrayList<String> getRoles(Connection dbConnection, String username) { if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) { // Using an authentication only configuration and no role store has // been defined so don't spend cycles looking return null; } ArrayList<String> list = null; try (PreparedStatement stmt = roles(dbConnection, username); ResultSet rs = stmt.executeQuery()) { list = new ArrayList<>(); while (rs.next()) { String role = rs.getString(1); if (role != null) { list.add(role.trim()); } } return list; } catch(SQLException e) { containerLog.error( sm.getString("dataSourceRealm.getRoles.exception", username), e); } return null; }
/** * Return the roles associated with the given user name * @param dbConnection The database connection to be used * @param username User name for which roles should be retrieved * @return an array list of the role names */ protected ArrayList<String> getRoles(Connection dbConnection, String username) { if (allRolesMode != AllRolesMode.STRICT_MODE && !isRoleStoreDefined()) { // Using an authentication only configuration and no role store has // been defined so don't spend cycles looking return null; } ArrayList<String> list = null; try (PreparedStatement stmt = roles(dbConnection, username); ResultSet rs = stmt.executeQuery()) { list = new ArrayList<>(); while (rs.next()) { String role = rs.getString(1); if (role != null) { list.add(role.trim()); } } return list; } catch(SQLException e) { containerLog.error( sm.getString("dataSourceRealm.getRoles.exception", username), e); } return null; }
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<String>();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<>();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<String>();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<String>();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<String>();
stmt = roles(dbConnection, username); rs = stmt.executeQuery(); list = new ArrayList<String>();