RevocationFreshnessValidator { public void validate() { DiagnosticData diagnosticData = reports.getDiagnosticData(); for (CertificateWrapper certificateWrapper : diagnosticData.getUsedCertificates()) { for (SignatureWrapper signatureWrapper : diagnosticData.getSignatures()) { if (signatureWrapper.getSigningCertificate() == null) { return; } validate(certificateWrapper, signatureWrapper); } } } RevocationFreshnessValidator(Reports reports, List<AdvancedSignature> signatures); void validate();  }
@Test public void emptySignatureList() { Reports reports = getDefaultReport(3, 12, 15); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, Collections.emptyList()); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getErrors(SIGNATURE_ID).isEmpty()); Assert.assertTrue(reports.getSimpleReport().getWarnings(SIGNATURE_ID).isEmpty()); }
@Test public void validTimestampAndOcspDelta() throws Exception { Reports reports = getDefaultReport(15, 12, 47); List<AdvancedSignature> signatures = getDefaultSignatures(null, new MockSignature.MockOfflineOCSPSource()); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, signatures); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getErrors(SIGNATURE_ID).isEmpty()); Assert.assertTrue(reports.getSimpleReport().getWarnings(SIGNATURE_ID).isEmpty()); }
@Test public void freshnessWarning_timestampBeforeOcsp() throws Exception { Reports reports = getDefaultReport(15, 12, 30); List<AdvancedSignature> signatures = getDefaultSignatures(null, new MockSignature.MockOfflineOCSPSource()); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, signatures); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getErrors(SIGNATURE_ID).isEmpty()); Assert.assertEquals(1, reports.getSimpleReport().getWarnings(SIGNATURE_ID).size()); Assert.assertEquals("The revocation information is not considered as 'fresh'.", reports.getSimpleReport().getWarnings(SIGNATURE_ID).get(0)); }
@Test public void freshnessWarning_timestampAfterOcsp() throws Exception { Reports reports = getDefaultReport(15, 13, 10); List<AdvancedSignature> signatures = getDefaultSignatures(null, new MockSignature.MockOfflineOCSPSource()); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, signatures); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getErrors(SIGNATURE_ID).isEmpty()); Assert.assertEquals(1, reports.getSimpleReport().getWarnings(SIGNATURE_ID).size()); Assert.assertEquals("The revocation information is not considered as 'fresh'.", reports.getSimpleReport().getWarnings(SIGNATURE_ID).get(0)); }
@Test public void freshnessError_timestampAfterOcsp() throws Exception { Reports reports = getDefaultReport(16, 12, 48); List<AdvancedSignature> signatures = getDefaultSignatures(null, new MockSignature.MockOfflineOCSPSource()); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, signatures); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getWarnings(SIGNATURE_ID).isEmpty()); Assert.assertEquals(1, reports.getSimpleReport().getErrors(SIGNATURE_ID).size()); Assert.assertEquals("The revocation information is not considered as 'fresh'.", reports.getSimpleReport().getErrors(SIGNATURE_ID).get(0)); }
@Test public void freshnessError_timestampBeforeOcsp() throws Exception { Reports reports = getDefaultReport(14, 12, 46); List<AdvancedSignature> signatures = getDefaultSignatures(null, new MockSignature.MockOfflineOCSPSource()); RevocationFreshnessValidator validator = new RevocationFreshnessValidator(reports, signatures); validator.validate(); Assert.assertTrue(reports.getSimpleReport().getWarnings(SIGNATURE_ID).isEmpty()); Assert.assertEquals(1, reports.getSimpleReport().getErrors(SIGNATURE_ID).size()); Assert.assertEquals("The revocation information is not considered as 'fresh'.", reports.getSimpleReport().getErrors(SIGNATURE_ID).get(0)); }