|
3 | 3 |
|
4 | 4 | import com.fasterxml.jackson.databind.JsonNode; |
5 | 5 | import com.google.gson.FieldNamingPolicy; |
6 | | -import com.google.gson.FieldNamingStrategy; |
7 | 6 | import com.google.gson.Gson; |
8 | 7 | import com.google.gson.GsonBuilder; |
9 | 8 | import com.google.gson.JsonSyntaxException; |
|
21 | 20 | import eu.europa.ec.dgc.gateway.connector.dto.ValidationRuleDto; |
22 | 21 | import eu.europa.ec.dgc.gateway.connector.model.ValidationRule; |
23 | 22 | import eu.europa.ec.dgc.signing.SignedStringMessageParser; |
| 23 | +import eu.europa.ec.dgc.utils.CertificateUtils; |
24 | 24 | import java.io.IOException; |
25 | | -import java.math.BigInteger; |
26 | | -import java.security.MessageDigest; |
27 | 25 | import java.security.NoSuchAlgorithmException; |
28 | 26 | import java.time.ZonedDateTime; |
29 | 27 | import java.util.ArrayList; |
30 | 28 | import java.util.Arrays; |
31 | 29 | import java.util.Base64; |
32 | | -import java.util.Collection; |
33 | 30 | import java.util.HashMap; |
34 | 31 | import java.util.List; |
35 | 32 | import java.util.Map; |
@@ -65,6 +62,7 @@ public class GatewayDataDownloadBtpServiceImpl implements GatewayDataDownloadSer |
65 | 62 | private final BusinessRuleService businessRuleService; |
66 | 63 | private final ValueSetService valueSetService; |
67 | 64 | private final CountryListService countryListService; |
| 65 | + private final CertificateUtils certificateUtils; |
68 | 66 |
|
69 | 67 | @Override |
70 | 68 | @Scheduled(fixedDelayString = "${dgc.businessRulesDownload.timeInterval}") |
@@ -267,12 +265,7 @@ private boolean checkThumbprintIntegrity(TrustListItemDto trustListItem) { |
267 | 265 | private String getCertThumbprint(X509CertificateHolder x509CertificateHolder) { |
268 | 266 | try { |
269 | 267 | byte[] data = x509CertificateHolder.getEncoded(); |
270 | | - byte[] certHashBytes = MessageDigest.getInstance("SHA-256").digest(data); |
271 | | - String hexString = (new BigInteger(1, certHashBytes)).toString(16); |
272 | | - if (hexString.length() == 63) { |
273 | | - hexString = "0" + hexString; |
274 | | - } |
275 | | - return hexString; |
| 268 | + return certificateUtils.calculateHash(data); |
276 | 269 | } catch (NoSuchAlgorithmException | IOException e) { |
277 | 270 | log.error("Could not calculate thumbprint of certificate '{}': {}.", |
278 | 271 | x509CertificateHolder.getSubject(), e.getMessage()); |
|
0 commit comments