RemoteCertificateValidationService { public CertificateReportsDTO validateCertificate(CertificateToValidateDTO certificateToValidate) { LOG.info("ValidateCertificate in process..."); CertificateValidator validator = initValidator(certificateToValidate); CertificateReports reports = validator.validate(); CertificateReportsDTO certificateReportsDTO = new CertificateReportsDTO(reports.getDiagnosticDataJaxb(), reports.getSimpleReportJaxb(), reports.getDetailedReportJaxb()); LOG.info("ValidateCertificate is finished"); return certificateReportsDTO; }  void setVerifier(CertificateVerifier verifier); CertificateReportsDTO validateCertificate(CertificateToValidateDTO certificateToValidate);  }
@Test public void testWithCertificateChainAndValidationTime() { CertificateToValidateDTO certificateDTO = getCompleteCertificateToValidateDTO(); CertificateReportsDTO reportsDTO = validationService.validateCertificate(certificateDTO); validateReports(reportsDTO); XmlDiagnosticData diagnosticData = reportsDTO.getDiagnosticData(); assertEquals(0, certificateDTO.getValidationTime().compareTo(diagnosticData.getValidationDate())); }
@Test public void noCertificateChainAndValidationTimeProvidedTest() { CertificateToValidateDTO certificateDTO = getCompleteCertificateToValidateDTO(); certificateDTO.setCertificateChain(null); CertificateReportsDTO reportsDTO = validationService.validateCertificate(certificateDTO); validateReports(reportsDTO); }
@Test public void noCertificateChainNoStrategyAndValidationTimeProvidedTest() { CertificateToValidateDTO certificateDTO = getCompleteCertificateToValidateDTO(); certificateDTO.setCertificateChain(null); certificateDTO.setTokenExtractionStategy(null); CertificateReportsDTO reportsDTO = validationService.validateCertificate(certificateDTO); validateReports(reportsDTO); }
@Test public void testWithNoCertificateProvided() { assertThrows(NullPointerException.class, () -> validationService.validateCertificate(null)); CertificateToValidateDTO emptyDTO= new CertificateToValidateDTO(); assertThrows(NullPointerException.class, () -> validationService.validateCertificate(emptyDTO)); }