SignedDocumentValidator implements DocumentValidator { public static SignedDocumentValidator fromDocument(final DSSDocument dssDocument) { Objects.requireNonNull(dssDocument, "DSSDocument is null"); ServiceLoader<DocumentValidatorFactory> serviceLoaders = ServiceLoader.load(DocumentValidatorFactory.class); for (DocumentValidatorFactory factory : serviceLoaders) { if (factory.isSupported(dssDocument)) { return factory.create(dssDocument); } } throw new DSSException("Document format not recognized/handled"); } protected  SignedDocumentValidator(); protected  SignedDocumentValidator(SignatureScopeFinder signatureScopeFinder); static SignedDocumentValidator fromDocument(final DSSDocument dssDocument); abstract boolean isSupported(DSSDocument dssDocument); @Override void defineSigningCertificate(final CertificateToken token); @Override void setCertificateVerifier(final CertificateVerifier certificateVerifier); @Override void setTokenExtractionStategy(TokenExtractionStategy tokenExtractionStategy); @Override void setIncludeSemantics(boolean include); @Override void setDetachedContents(final List<DSSDocument> detachedContents); @Override void setContainerContents(List<DSSDocument> containerContents); @Override void setManifestFiles(List<ManifestFile> manifestFiles); @Override void setValidationTime(Date validationTime); @Override void setValidationLevel(ValidationLevel validationLevel); @Override void setEnableEtsiValidationReport(boolean enableEtsiValidationReport); @Override Reports validateDocument(); @Override Reports validateDocument(final URL validationPolicyURL); @Override Reports validateDocument(final String policyResourcePath); @Override Reports validateDocument(final File policyFile); @Override Reports validateDocument(final InputStream policyDataStream); @Override Reports validateDocument(final ConstraintsParameters validationPolicyJaxb); @Override Reports validateDocument(final ValidationPolicy validationPolicy); @Override void prepareSignatureValidationContext(final ValidationContext validationContext, final List<AdvancedSignature> allSignatureList); @Override void prepareDetachedTimestampValidationContext(final ValidationContext validationContext, List<TimestampToken> timestamps); @Override void setSignaturePolicyProvider(SignaturePolicyProvider signaturePolicyProvider); @Override void setProcessExecutor(final DocumentProcessExecutor processExecutor); @Override DocumentProcessExecutor getDefaultProcessExecutor(); @Override List<AdvancedSignature> getSignatures(); @Override List<TimestampToken> getDetachedTimestamps(); @Override void processSignaturesValidation(List<AdvancedSignature> allSignatureList); @Override void findSignatureScopes(List<AdvancedSignature> allSignatures); void setSkipValidationContextExecution(boolean skipValidationContextExecution); void setLocale(Locale locale);  }
@Test public void testNoDepencency() { FileDocument fileDocument = new FileDocument("src/test/resources/sample.xml"); Exception exception = assertThrows(DSSException.class, () -> SignedDocumentValidator.fromDocument(fileDocument)); assertEquals("Document format not recognized/handled", exception.getMessage()); }
@Test public void testNull() { assertThrows(NullPointerException.class, () -> SignedDocumentValidator.fromDocument(null)); }
@Test public void testEmtpyDoc() { InMemoryDocument emptyDoc = new InMemoryDocument(); assertThrows(NullPointerException.class, () -> SignedDocumentValidator.fromDocument(emptyDoc)); }