DSSXMLUtils { public static String validateAgainstXSD(XSDAbstractUtils xsdUtils, final Source source) { return xsdUtils.validateAgainstXSD(source); } private  DSSXMLUtils(); static boolean registerTransform(final String transformURI); static boolean registerCanonicalizer(final String c14nAlgorithmURI); static Node indentAndReplace(final Document document, Node node); static Node indentAndExtend(final Document document, Node newNode, Node oldNode); static Document getDocWithIndentedSignatures(final Document documentDom, String signatureId, List<String> noIndentObjectIds); static Node getIndentedNode(final Node documentDom, final Node xmlNode); static Node alignChildrenIndents(Node parentNode); static byte[] serializeNode(final Node xmlNode); static boolean canCanonicalize(final String canonicalizationMethod); static byte[] canonicalize(final String canonicalizationMethod, final byte[] toCanonicalizeBytes); static byte[] canonicalizeSubtree(String canonicalizationMethod, final Node node); static String getCanonicalizationMethod(String canonicalizationMethod); static void recursiveIdBrowse(final Element element); static String getIDIdentifier(final Node node); static String getAttribute(final Node node, final String attributeName); static void setIDIdentifier(final Element childElement); static String validateAgainstXSD(XSDAbstractUtils xsdUtils, final Source source); static boolean isOid(String policyId); static String getOidCode(String oid); static boolean isDuplicateIdsDetected(DSSDocument doc); static byte[] getNodeBytes(Node node); static byte[] getReferenceOriginalContentBytes(Reference reference); static Digest getDigestAndValue(Element element); static boolean isSignedProperties(final Reference reference, final XAdESPaths xadesPaths); static boolean isCounterSignature(final Reference reference, final XAdESPaths xadesPaths); static boolean isKeyInfoReference(final Reference reference, final Element signature); static boolean isObjectReferenceType(String referenceType); static boolean isManifestReferenceType(String referenceType); static boolean isCounterSignatureReferenceType(String referenceType); static PublicKey getKeyInfoSigningCertificatePublicKey(final Element signatureElement); static final String DEFAULT_CANONICALIZATION_METHOD; }
@Test public void validateAgainstXSDWithExternalSourceMissing() throws SAXException, IOException { DSSDocument document = new FileDocument("src/test/resources/ASiCManifest.xml"); String exceptionMessage = xadesUtils.validateAgainstXSD(getSource(document), new StreamSource[0]); assertFalse(Utils.isStringEmpty(exceptionMessage)); }
@Test public void validateAgainstXSDWithExternalSourceOK() throws SAXException, IOException { StreamSource streamSource = new StreamSource(DSSXMLUtilsTest.class.getResourceAsStream("/ExternalXSDForAsic.xsd")); DSSDocument document = new FileDocument("src/test/resources/ASiCManifest.xml"); String exceptionMessage = xadesUtils.validateAgainstXSD(getSource(document), streamSource); assertTrue(Utils.isStringEmpty(exceptionMessage)); }
@Test public void validateAgainstXSDvalidMessage() { FileDocument document = new FileDocument("src/test/resources/valid-xades-structure.xml"); assertFalse(Utils.isStringNotEmpty(DSSXMLUtils.validateAgainstXSD(XAdES319132Utils.getInstance(), getSource(document)))); }
@Test public void validateAgainstXSDInvalidMessage() { FileDocument document = new FileDocument("src/test/resources/invalid-xades-structure.xml"); assertTrue(Utils.isStringNotEmpty(DSSXMLUtils.validateAgainstXSD(XAdES319132Utils.getInstance(), getSource(document)))); }