CMSDocumentValidator extends SignedDocumentValidator { @Override public List<AdvancedSignature> getSignatures() { List<AdvancedSignature> signatures = new ArrayList<>(); if (cmsSignedData != null) { for (final SignerInformation signerInformation : cmsSignedData.getSignerInfos().getSigners()) { final CAdESSignature cadesSignature = new CAdESSignature(cmsSignedData, signerInformation); if (document != null) { cadesSignature.setSignatureFilename(document.getName()); } cadesSignature.setDetachedContents(detachedContents); cadesSignature.setContainerContents(containerContents); cadesSignature.setManifestFiles(manifestFiles); cadesSignature.setProvidedSigningCertificateToken(providedSigningCertificateToken); cadesSignature.prepareOfflineCertificateVerifier(certificateVerifier); signatures.add(cadesSignature); } } return signatures; } CMSDocumentValidator();   CMSDocumentValidator(SignatureScopeFinder<CAdESSignature> signatureScopeFinder);  CMSDocumentValidator(final CMSSignedData cmsSignedData);  CMSDocumentValidator(final DSSDocument document); protected  CMSDocumentValidator(final DSSDocument document, SignatureScopeFinder<CAdESSignature> signatureScopeFinder); @Override boolean isSupported(DSSDocument dssDocument); @Override List<AdvancedSignature> getSignatures(); @Override List<DSSDocument> getOriginalDocuments(final String signatureId); @Override List<DSSDocument> getOriginalDocuments(final AdvancedSignature advancedSignature);  }
@Test public void testCMSOnly() throws IOException, CMSException { CMSSignedData cmsSignedData = new CMSSignedData(new FileInputStream(PATH)); CMSDocumentValidator validator = new CMSDocumentValidator(cmsSignedData); List<AdvancedSignature> signatures = validator.getSignatures(); assertTrue(Utils.isCollectionNotEmpty(signatures)); }
@Test public void testFileDocument() { CMSDocumentValidator validator = new CMSDocumentValidator(new FileDocument(PATH)); List<AdvancedSignature> signatures = validator.getSignatures(); assertTrue(Utils.isCollectionNotEmpty(signatures)); }
@Test public void testInMemoryDocument() throws FileNotFoundException { CMSDocumentValidator validator = new CMSDocumentValidator(new InMemoryDocument(new FileInputStream(PATH))); List<AdvancedSignature> signatures = validator.getSignatures(); assertTrue(Utils.isCollectionNotEmpty(signatures)); }