Search in sources :

Example 1 with UnsyncByteArrayOutputStream

use of com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream in project jdk8u_jdk by JetBrains.

the class BufferOverflowTest method main.

public static void main(String[] args) throws Exception {
    try {
        UnsyncByteArrayOutputStream out = new UnsyncByteArrayOutputStream();
        out.write(new byte[(8192) << 2 + 1]);
        System.out.println("PASSED");
    } catch (ArrayIndexOutOfBoundsException e) {
        System.err.println("FAILED, got ArrayIndexOutOfBoundsException");
        throw new Exception(e);
    }
}
Also used : UnsyncByteArrayOutputStream(com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream)

Example 2 with UnsyncByteArrayOutputStream

use of com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream in project jdk8u_jdk by JetBrains.

the class CanonicalizerBase method engineCanonicalizeXPathNodeSetInternal.

private byte[] engineCanonicalizeXPathNodeSetInternal(Node doc) throws CanonicalizationException {
    try {
        this.canonicalizeXPathNodeSet(doc, doc);
        this.writer.flush();
        if (this.writer instanceof ByteArrayOutputStream) {
            byte[] sol = ((ByteArrayOutputStream) this.writer).toByteArray();
            if (reset) {
                ((ByteArrayOutputStream) this.writer).reset();
            } else {
                this.writer.close();
            }
            return sol;
        } else if (this.writer instanceof UnsyncByteArrayOutputStream) {
            byte[] result = ((UnsyncByteArrayOutputStream) this.writer).toByteArray();
            if (reset) {
                ((UnsyncByteArrayOutputStream) this.writer).reset();
            } else {
                this.writer.close();
            }
            return result;
        } else {
            this.writer.close();
        }
        return null;
    } catch (UnsupportedEncodingException ex) {
        throw new CanonicalizationException("empty", ex);
    } catch (IOException ex) {
        throw new CanonicalizationException("empty", ex);
    }
}
Also used : UnsyncByteArrayOutputStream(com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream) CanonicalizationException(com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnsyncByteArrayOutputStream(com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream) IOException(java.io.IOException)

Example 3 with UnsyncByteArrayOutputStream

use of com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream in project jdk8u_jdk by JetBrains.

the class CanonicalizerBase method engineCanonicalizeSubTree.

/**
     * Canonicalizes a Subtree node.
     *
     * @param rootNode
     *            the root of the subtree to canonicalize
     * @param excludeNode
     *            a node to be excluded from the canonicalize operation
     * @return The canonicalize stream.
     * @throws CanonicalizationException
     */
protected byte[] engineCanonicalizeSubTree(Node rootNode, Node excludeNode) throws CanonicalizationException {
    this.excludeNode = excludeNode;
    try {
        NameSpaceSymbTable ns = new NameSpaceSymbTable();
        int nodeLevel = NODE_BEFORE_DOCUMENT_ELEMENT;
        if (rootNode != null && Node.ELEMENT_NODE == rootNode.getNodeType()) {
            //Fills the nssymbtable with the definitions of the parent of the root subnode
            getParentNameSpaces((Element) rootNode, ns);
            nodeLevel = NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
        }
        this.canonicalizeSubTree(rootNode, ns, rootNode, nodeLevel);
        this.writer.flush();
        if (this.writer instanceof ByteArrayOutputStream) {
            byte[] result = ((ByteArrayOutputStream) this.writer).toByteArray();
            if (reset) {
                ((ByteArrayOutputStream) this.writer).reset();
            } else {
                this.writer.close();
            }
            return result;
        } else if (this.writer instanceof UnsyncByteArrayOutputStream) {
            byte[] result = ((UnsyncByteArrayOutputStream) this.writer).toByteArray();
            if (reset) {
                ((UnsyncByteArrayOutputStream) this.writer).reset();
            } else {
                this.writer.close();
            }
            return result;
        } else {
            this.writer.close();
        }
        return null;
    } catch (UnsupportedEncodingException ex) {
        throw new CanonicalizationException("empty", ex);
    } catch (IOException ex) {
        throw new CanonicalizationException("empty", ex);
    }
}
Also used : UnsyncByteArrayOutputStream(com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream) CanonicalizationException(com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UnsyncByteArrayOutputStream(com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

UnsyncByteArrayOutputStream (com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream)3 CanonicalizationException (com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2