You’ll want to look at these:
Essentially, you need to set the "Authorization" header in the request to “Basic base64” where base64 is the user and password, separated by a colon, encoded in base 64.
URL url = new URL("http://ficcjira.xyz.com/rest/api/2/search?jql=project=ABC&fields=Timetracking")
URLConnection conn = url.openConnection();
String auth = user + ":" + password;
byte[] authBytes = auth.getBytes(StandardCharsets.UTF_8);
String encodedAuth = Base64.getEncoder().encodeToString(authBytes);
conn.setRequestProperty("Authorization", "Basic " + encodedAuth);
try (InputStream responseStream = conn.getInputStream()) {
// To read response as a string:
//MimeType contentType = new MimeType(conn.getContentType());
//String charset = contentType.getParameter("charset");
//String response =
// new Scanner(responseStream, charset).useDelimiter("\\Z").next();
// To save response to a file:
//Path response = Files.createTempFile(null, null);
//Files.copy(responseStream, response,
// StandardCopyOption.REPLACE_EXISTING);
// To read as JSON object using javax.json library:
//JsonObject response =
// Json.createReader(responseStream).readObject();
}