XMLDocumentValidator extends SignedDocumentValidator { @Override public boolean isSupported(DSSDocument dssDocument) { return DSSUtils.compareFirstBytes(dssDocument, xmlPreamble) || DSSUtils.compareFirstBytes(dssDocument, xmlWithBomPreample); } XMLDocumentValidator();  XMLDocumentValidator(final DSSDocument dssDocument); @Override boolean isSupported(DSSDocument dssDocument); void setDisableXSWProtection(boolean disableXSWProtection); @Override List<AdvancedSignature> getSignatures(); AdvancedSignature getSignatureById(final String signatureId); @Override List<DSSDocument> getOriginalDocuments(final String signatureId); @Override List<DSSDocument> getOriginalDocuments(AdvancedSignature advancedSignature); List<XAdESPaths> getXAdESPathsHolder(); void addXAdESPathsHolder(final XAdESPaths xadesPathsHolder); void clearQueryHolders(); Document getRootElement();  }
@Test public void isSupported() { XMLDocumentValidator validator = new XMLDocumentValidator(); byte[] wrongBytes = new byte[] { 1, 2 }; assertFalse(validator.isSupported(new InMemoryDocument(wrongBytes))); assertFalse(validator.isSupported(new InMemoryDocument(wrongBytes, "test", MimeType.PDF))); assertFalse(validator.isSupported(new InMemoryDocument(wrongBytes, "test"))); assertFalse(validator.isSupported(new InMemoryDocument(wrongBytes, "test", MimeType.XML))); assertFalse(validator.isSupported(new InMemoryDocument(wrongBytes, "test.xml"))); assertTrue(validator.isSupported(new InMemoryDocument(new byte[] { '<', '?', 'x', 'm', 'l' }))); assertTrue(validator.isSupported(new InMemoryDocument(new byte[] { -17, -69, -65, '<' }))); assertTrue(validator.isSupported(new InMemoryDocument(new byte[] { '<', 'd', 's', ':' }))); }