Example usage for org.bouncycastle.cms CMSTypedData write

List of usage examples for org.bouncycastle.cms CMSTypedData write

Introduction

In this page you can find the example usage for org.bouncycastle.cms CMSTypedData write.

Prototype

public void write(OutputStream out) throws IOException, CMSException;

Source Link

Document

generic routine to copy out the data we want processed - the OutputStream passed in will do the handling on it's own.

Usage

From source file:eu.europa.ec.markt.dss.validation102853.cades.CAdESSignature.java

License:Open Source License

private byte[] getOriginalDocumentBytes() throws DSSException {

    final CMSTypedData signedContent = cmsSignedData.getSignedContent();
    if (signedContent != null) {

        try {//from ww w  . j  av  a2 s.  c  om

            final ByteArrayOutputStream originalSignedFileByteArrayOutputStream = new ByteArrayOutputStream();
            signedContent.write(originalSignedFileByteArrayOutputStream);
            return originalSignedFileByteArrayOutputStream.toByteArray();
        } catch (IOException e) {
            throw new DSSException(e);
        } catch (CMSException e) {
            throw new DSSException(e);
        }
    } else {
        if (detachedContents != null && detachedContents.size() > 0) {

            return detachedContents.get(0).getBytes();
        }
        return DSSUtils.EMPTY_BYTE_ARRAY;
    }
}