@Test(expectedExceptions = CertificateNotFoundException.class, expectedExceptionsMessageRegExp = "Certificate with id null not found from pubFile=.*") public void testGetCertificateFromPublicationsFileUsingInvalidCertificateId_ThrowsCertificateNotFoundException() throws Exception { PublicationsFile publication = new InMemoryPublicationsFile(TestUtil.load(PUBLICATIONS_FILE)); publication.findCertificateById(null); }
public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); }
InMemoryPublicationsFile implements PublicationsFile { public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); } }
InMemoryPublicationsFile implements PublicationsFile { public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); } InMemoryPublicationsFile(InputStream input); }
InMemoryPublicationsFile implements PublicationsFile { public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); } InMemoryPublicationsFile(InputStream input); Date getCreationTime(); Long getVersion(); String getRepositoryUri(); List<PublicationRecord> getPublicationRecords(); Certificate findCertificateById(byte[] certificateId); String getName(); @Override String toString(); PublicationRecord getLatestPublication(); PublicationRecord getPublicationRecord(Date time); CMSSignature getSignature(); @Override boolean equals(Object o); @Override int hashCode(); }
InMemoryPublicationsFile implements PublicationsFile { public Certificate findCertificateById(byte[] certificateId) throws CertificateNotFoundException { if (certificateId == null) { throw new CertificateNotFoundException("Certificate with id null not found from pubFile='" + this.toString() + "'"); } for (InMemoryCertificateRecord record : certificateRecords) { if (Arrays.equals(certificateId, record.getCertificateId())) { return X509CertUtil.toCert(record.getCertificate()); } } throw new CertificateNotFoundException("Certificate with id " + Base64.encode(certificateId) + " not found from pubFile='" + this.toString() + "'"); } InMemoryPublicationsFile(InputStream input); Date getCreationTime(); Long getVersion(); String getRepositoryUri(); List<PublicationRecord> getPublicationRecords(); Certificate findCertificateById(byte[] certificateId); String getName(); @Override String toString(); PublicationRecord getLatestPublication(); PublicationRecord getPublicationRecord(Date time); CMSSignature getSignature(); @Override boolean equals(Object o); @Override int hashCode();  }