HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
X509Certificate testChainCert= (X509Certificate) CryptoDataLoader.certificatesFromFile(
new File(TestData.ROOT_CA_CERT)).get(0);
X509Certificate testCert= (X509Certificate) CryptoDataLoader.certificatesFromFile(
new File(TestData.TEST_CERT)).get(0);
ParsedLogEntryWithProof entry = client.getLogEntryAndProof(1, 2);
X509Certificate chainCert = null;
X509Certificate leafCert = null;
try {
byte[] leafCertBytes = entry.getParsedLogEntry().getLogEntry().getX509Entry()
.getLeafCertificate().toByteArray();
leafCert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(
new ByteArrayInputStream(leafCertBytes));
byte[] chainCertBytes = entry.getParsedLogEntry().getLogEntry().getX509Entry()
.getCertificateChain(0).toByteArray();
chainCert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate(
new ByteArrayInputStream(chainCertBytes));
} catch (CertificateException e) {
Assert.fail();
}
Assert.assertTrue(testCert.equals(leafCert));
Assert.assertTrue(testChainCert.equals(chainCert));
Assert.assertEquals(2, entry.getAuditProof().getPathNodeList().size());
Assert.assertEquals(1, entry.getAuditProof().getLeafIndex());
Assert.assertEquals(2, entry.getAuditProof().getTreeSize());
}