From aab5d860e3894a006557dc8bc18fd878c6031cda Mon Sep 17 00:00:00 2001 From: Alexandru Ionut Balan <113347266+alexandru-ionut-balan@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:14:23 +0300 Subject: [PATCH] Fixing the duplicate Accept header value (#59) * fix: duplicate Accept header value and jws fingerprint calculation --- .../Java/libraries/jersey2/ApiClient.mustache | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/open-banking-driver-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache b/open-banking-driver-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache index 417d771..683ba25 100644 --- a/open-banking-driver-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache +++ b/open-banking-driver-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache @@ -1175,7 +1175,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { } } - Invocation.Builder invocationBuilder = target.request().accept(accept); + Invocation.Builder invocationBuilder = target.request(); for (Entry entry : cookieParams.entrySet()) { String value = entry.getValue(); @@ -1196,7 +1196,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { String applicationAccessToken = token.access_token; final Map mandatoryHeaders = new HashMap(); - mandatoryHeaders.put("Accept", "application/json"); + if (!accept.isEmpty()) { + mandatoryHeaders.put("Accept", accept); + } else { + mandatoryHeaders.put("Accept", "application/json"); + } mandatoryHeaders.put("User-Agent", "openbanking-sdk/0.0.3-SNAPSHOT java"); mandatoryHeaders.put("Digest", digest(body == null ? "" : body.toString())); mandatoryHeaders.put("Date", ZonedDateTime.now(ZoneId.of("GMT")).format(FORMATTER)); @@ -1220,7 +1224,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { try { String fingerprint = DigestUtils.sha256Hex(this.certificate.getEncoded()); byte[] decodedHex = Hex.decodeHex(fingerprint.toCharArray()); - String encodedHexB64URL = Base64.getEncoder().encodeToString(decodedHex).replace("=", "").replace("\n", "").replace("+", "-").replace("\\/", "_"); + String encodedHexB64URL = Base64.getUrlEncoder().withoutPadding().encodeToString(decodedHex); Date date = Calendar.getInstance().getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");