Search in sources :

Example 6 with UnsyncBufferedOutputStream

use of org.apache.xml.security.utils.UnsyncBufferedOutputStream in project santuario-java by apache.

the class AbstractSignatureReferenceVerifyInputProcessor method verifyExternalReference.

protected void verifyExternalReference(InputProcessorChain inputProcessorChain, InputStream inputStream, ReferenceType referenceType) throws XMLSecurityException, XMLStreamException {
    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
        DigestOutputStream digestOutputStream = createMessageDigestOutputStream(referenceType, inputProcessorChain.getSecurityContext());
        UnsyncBufferedOutputStream bufferedDigestOutputStream = new UnsyncBufferedOutputStream(digestOutputStream)) {
        if (referenceType.getTransforms() != null) {
            Transformer transformer = buildTransformerChain(referenceType, bufferedDigestOutputStream, inputProcessorChain, null);
            transformer.transform(bufferedInputStream);
            bufferedDigestOutputStream.close();
        } else {
            XMLSecurityUtils.copy(bufferedInputStream, bufferedDigestOutputStream);
            bufferedDigestOutputStream.close();
        }
        compareDigest(digestOutputStream.getDigestValue(), referenceType);
    } catch (IOException e) {
        throw new XMLSecurityException(e);
    }
}
Also used : Canonicalizer20010315_OmitCommentsTransformer(org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_OmitCommentsTransformer) DigestOutputStream(org.apache.xml.security.stax.impl.util.DigestOutputStream) UnsyncBufferedOutputStream(org.apache.xml.security.utils.UnsyncBufferedOutputStream) XMLSecurityException(org.apache.xml.security.exceptions.XMLSecurityException)

Aggregations

UnsyncBufferedOutputStream (org.apache.xml.security.utils.UnsyncBufferedOutputStream)6 IOException (java.io.IOException)4 OutputStream (java.io.OutputStream)4 XMLSecurityException (org.apache.xml.security.exceptions.XMLSecurityException)4 SignatureAlgorithm (org.apache.xml.security.algorithms.SignatureAlgorithm)2 SignerOutputStream (org.apache.xml.security.utils.SignerOutputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PublicKey (java.security.PublicKey)1 DigesterOutputStream (org.apache.jcp.xml.dsig.internal.DigesterOutputStream)1 MessageDigestAlgorithm (org.apache.xml.security.algorithms.MessageDigestAlgorithm)1 CanonicalizationException (org.apache.xml.security.c14n.CanonicalizationException)1 InvalidCanonicalizerException (org.apache.xml.security.c14n.InvalidCanonicalizerException)1 XMLSignatureInput (org.apache.xml.security.signature.XMLSignatureInput)1 Canonicalizer20010315_OmitCommentsTransformer (org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_OmitCommentsTransformer)1 DigestOutputStream (org.apache.xml.security.stax.impl.util.DigestOutputStream)1 Transforms (org.apache.xml.security.transforms.Transforms)1 DigesterOutputStream (org.apache.xml.security.utils.DigesterOutputStream)1 Element (org.w3c.dom.Element)1