private byte[] calculateSignerId(List<? extends X509Certificate> certs) throws SignatureException { try { CertificateFactory certFactory = CertificateFactory.getInstance(X509); CertPath path = certFactory.generateCertPath(certs); byte[] encodedCertPath = path.getEncoded(PKI_PATH_ENCODING); MessageDigest digest = MessageDigest.getInstance( AlgorithmUtil.getJceName(getHashAlgorithm())); return digest.digest(encodedCertPath); } catch (CertificateException e) { throw new SignatureException("could not parse certificate chain", e); } catch (NoSuchAlgorithmException e) { throw new SignatureException("could not calculate hash of cert chain", e); } } }
public void testGetHashAlgorithm() throws Exception { signerInfo = new SignerInfo(HashAlgorithm.SHA256, certChain, DOMAIN); assertEquals(HashAlgorithm.SHA256, signerInfo.getHashAlgorithm()); }
public void testGetHashAlgorithm() throws Exception { signerInfo = new SignerInfo(HashAlgorithm.SHA256, certChain, DOMAIN); assertEquals(HashAlgorithm.SHA256, signerInfo.getHashAlgorithm()); }