com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DOMSignedInfo.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void canonicalize(XMLCryptoContext context, ByteArrayOutputStream bos)
    throws XMLSignatureException {
    if (context == null) {
        throw new NullPointerException("context cannot be null");
    }

    OutputStream os = new UnsyncBufferedOutputStream(bos);
    try {
        os.close();
    } catch (IOException e) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, e.getMessage(), e);
        }
        // Impossible
    }

    DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);

    try {
        ((DOMCanonicalizationMethod)
            canonicalizationMethod).canonicalize(subTree, context, bos);
    } catch (TransformException te) {
        throw new XMLSignatureException(te);
    }

    byte[] signedInfoBytes = bos.toByteArray();

    // this whole block should only be done if logging is enabled
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Canonicalized SignedInfo:");
        StringBuilder sb = new StringBuilder(signedInfoBytes.length);
        for (int i = 0; i < signedInfoBytes.length; i++) {
            sb.append((char)signedInfoBytes[i]);
        }
        log.log(java.util.logging.Level.FINE, sb.toString());
        log.log(java.util.logging.Level.FINE, "Data to be signed/verified:" + Base64.encode(signedInfoBytes));
    }

    this.canonData = new ByteArrayInputStream(signedInfoBytes);
}
 
Example #2
Source File: DOMSignedInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void canonicalize(XMLCryptoContext context, ByteArrayOutputStream bos)
    throws XMLSignatureException {
    if (context == null) {
        throw new NullPointerException("context cannot be null");
    }

    OutputStream os = new UnsyncBufferedOutputStream(bos);
    try {
        os.close();
    } catch (IOException e) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, e.getMessage(), e);
        }
        // Impossible
    }

    DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);

    try {
        ((DOMCanonicalizationMethod)
            canonicalizationMethod).canonicalize(subTree, context, bos);
    } catch (TransformException te) {
        throw new XMLSignatureException(te);
    }

    byte[] signedInfoBytes = bos.toByteArray();

    // this whole block should only be done if logging is enabled
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Canonicalized SignedInfo:");
        StringBuilder sb = new StringBuilder(signedInfoBytes.length);
        for (int i = 0; i < signedInfoBytes.length; i++) {
            sb.append((char)signedInfoBytes[i]);
        }
        log.log(java.util.logging.Level.FINE, sb.toString());
        log.log(java.util.logging.Level.FINE, "Data to be signed/verified:" + Base64.encode(signedInfoBytes));
    }

    this.canonData = new ByteArrayInputStream(signedInfoBytes);
}