### Question:
TokenAlgorithmSupport { public static DigestAlgorithm determineSignatureDigestAlgorithm(X509Certificate certificate) { if (DigiDocGenFactory.isPre2011IdCard(certificate)) { logger.debug("The certificate belongs to a pre 2011 Estonian ID card supporting SHA-224"); return DigestAlgorithm.SHA224; } return DigestAlgorithm.SHA256; }  static DigestAlgorithm determineSignatureDigestAlgorithm(X509Certificate certificate);  }### Answer:
@Test public void getDefaultDigestAlgorithm_shouldReturnSha256() throws Exception { PKCS12SignatureToken testSignatureToken = new PKCS12SignatureToken("src/test/resources/testFiles/p12/signout.p12", "test".toCharArray()); DigestAlgorithm digestAlgorithm = TokenAlgorithmSupport.determineSignatureDigestAlgorithm(testSignatureToken.getCertificate()); Assert.assertEquals(DigestAlgorithm.SHA256, digestAlgorithm); }
@Test public void oldEstonianIdCardCert_shouldReturnSha224() throws Exception { String certString = FileUtils.readFileToString(new File("src/test/resources/testFiles/certs/esteid-pre2011-test-signing-certificate-37101010021.cer"), StandardCharsets.UTF_8); DigestAlgorithm digestAlgorithm = TokenAlgorithmSupport.determineSignatureDigestAlgorithm(TestSigningUtil.toX509Certificate(certString)); Assert.assertEquals(DigestAlgorithm.SHA224, digestAlgorithm); }