Package org.apache.xml.security.test.dom.resource

Examples of org.apache.xml.security.test.dom.resource.TestVectorResolver


        String fileRef = prefix + "in/37_c14n.xml";
        //String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
        //boolean validating = true;

        DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
        org.xml.sax.EntityResolver resolver = new TestVectorResolver();

        db.setEntityResolver(resolver);

        Document doc = db.parse(resolver.resolveEntity(null, fileIn));

        String xpath = "(//. | //@* | //namespace::*)"
            + "[ "
            + "self::ietf:e1 or "
            + "(parent::ietf:e1 and not(self::text() or self::e2)) or "
            + "count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node()) "
            + "]";

        Map<String, String> namespace = new HashMap<String, String>();
        namespace.put("ietf", "http://www.ietf.org");
 
        XPathFactory xpf = XPathFactory.newInstance();
        XPath xPath = xpf.newXPath();
        DSNamespaceContext namespaceContext =
            new DSNamespaceContext(namespace);
        xPath.setNamespaceContext(namespaceContext);

        NodeList nodes = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
        Canonicalizer c14n =
            Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
        byte c14nBytes[] = c14n.canonicalizeXPathNodeSet(nodes);
        InputStream refStream = resolver.resolveEntity(null,
                                                       fileRef).getByteStream();
        byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
        assertEquals(new String(refBytes),new String(c14nBytes));
    }
View Full Code Here


            "<UTF16>The german &amp;auml (which is Unicode &amp;#xE4;):  &quot;&#xE4;&quot;</UTF16>";
        byte utf16[] = convertToUTF16(val.getBytes());
        Canonicalizer c14n =
            Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
        byte c14nBytes[] = c14n.canonicalize(utf16);
        org.xml.sax.EntityResolver resolver = new TestVectorResolver();
        InputStream refStream =
            resolver.resolveEntity(
                null, prefix + "/in/testTranslationFromUTF16toUTF8.xml").getByteStream();
        byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
        boolean equal = java.security.MessageDigest.isEqual(refBytes, c14nBytes);

        assertTrue("Parser does not translate to UCS character domain", equal);
View Full Code Here

        String fileRef = prefix + "in/37_c14n.xml";
        //String c14nURI = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
        //boolean validating = true;

        DocumentBuilder db = XMLUtils.createDocumentBuilder(false, false);
        org.xml.sax.EntityResolver resolver = new TestVectorResolver();

        db.setEntityResolver(resolver);

        Document doc = db.parse(resolver.resolveEntity(null, fileIn));

        String xpath = "(//. | //@* | //namespace::*)"
            + "[ "
            + "self::ietf:e1 or "
            + "(parent::ietf:e1 and not(self::text() or self::e2)) or "
            + "count(id(\"E3\")|ancestor-or-self::node()) = count(ancestor-or-self::node()) "
            + "]";

        Map<String, String> namespace = new HashMap<String, String>();
        namespace.put("ietf", "http://www.ietf.org");
 
        XPathFactory xpf = XPathFactory.newInstance();
        XPath xPath = xpf.newXPath();
        DSNamespaceContext namespaceContext =
            new DSNamespaceContext(namespace);
        xPath.setNamespaceContext(namespaceContext);

        NodeList nodes = (NodeList)xPath.evaluate(xpath, doc, XPathConstants.NODESET);
        Canonicalizer c14n =
            Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
        byte c14nBytes[] = c14n.canonicalizeXPathNodeSet(nodes);
        InputStream refStream = resolver.resolveEntity(null,
                                                       fileRef).getByteStream();
        byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
        assertEquals(new String(refBytes),new String(c14nBytes));
    }
View Full Code Here

            "<UTF16>The german &amp;auml (which is Unicode &amp;#xE4;):  &quot;&#xE4;&quot;</UTF16>";
        byte utf16[] = convertToUTF16(val.getBytes());
        Canonicalizer c14n =
            Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
        byte c14nBytes[] = c14n.canonicalize(utf16);
        org.xml.sax.EntityResolver resolver = new TestVectorResolver();
        InputStream refStream =
            resolver.resolveEntity(
                null, prefix + "/in/testTranslationFromUTF16toUTF8.xml").getByteStream();
        byte refBytes[] = JavaUtils.getBytesFromStream(refStream);
        boolean equal = java.security.MessageDigest.isEqual(refBytes, c14nBytes);

        assertTrue("Parser does not translate to UCS character domain", equal);
View Full Code Here

TOP

Related Classes of org.apache.xml.security.test.dom.resource.TestVectorResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.