diff --git a/src/main/java/it/pagopa/swclient/mil/idpay/service/TransactionsService.java b/src/main/java/it/pagopa/swclient/mil/idpay/service/TransactionsService.java index 3b4dcb7..e7d4d56 100644 --- a/src/main/java/it/pagopa/swclient/mil/idpay/service/TransactionsService.java +++ b/src/main/java/it/pagopa/swclient/mil/idpay/service/TransactionsService.java @@ -46,6 +46,7 @@ import java.time.*; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; +import java.util.Base64; import java.util.Date; import java.util.List; import java.util.UUID; @@ -535,8 +536,10 @@ public Uni authorizeTransaction(CommonHeader headers, AuthorizeTransac // Start trying to encrypt session key with public key retrieved String encryptedSessionKey = encryptUtil.encryptSessionKeyForIdpay(publicKeyIDPay, unwrappedKey.getValue()); + String hexPinBlock = base64ToHex(authorizeTransaction.getAuthCodeBlockData().getAuthCodeBlock()); + PinBlockDTO pinBlock = PinBlockDTO.builder() - .pinBlock(authorizeTransaction.getAuthCodeBlockData().getAuthCodeBlock()) + .pinBlock(hexPinBlock) .encryptedKey(encryptedSessionKey) .build(); @@ -889,4 +892,15 @@ private InternalServerErrorException certificateException(Throwable exception, S .entity(new Errors(List.of(ErrorCode.ERROR_CERTIFICATE_EXPIRED), List.of(ErrorCode.ERROR_CERTIFICATE_EXPIRED_MSG))) .build()); } + + private static String base64ToHex(String base64String) { + byte[] decodedBytes = Base64.getDecoder().decode(base64String); + + StringBuilder hexStringBuilder = new StringBuilder(); + for (byte b : decodedBytes) { + hexStringBuilder.append(String.format("%02X", b & 0xFF)); + } + + return hexStringBuilder.toString(); + } }