Skip to content

Commit

Permalink
Converted pinBlock from base64 to hex
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoGiuliani committed Feb 9, 2024
1 parent b3a6170 commit 31aeffe
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -535,8 +536,10 @@ public Uni<Response> 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();

Expand Down Expand Up @@ -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();
}
}

0 comments on commit 31aeffe

Please sign in to comment.