public byte [] getContentAsBytes () { return m_aOS.m_aBAOS.toByteArray (); }
/** * Returns the data for this output stream as an array of bytes, assuming that * the data has been retained in memory. If the data was written to disk, this * method returns <code>null</code>. * * @return The data for this output stream, or <code>null</code> if no such * data is available. * @see #isInMemory() */ @Nullable @ReturnsMutableCopy public byte [] getData () { if (m_aMemoryOS != null) return m_aMemoryOS.toByteArray (); return null; }
@Nonnull @ReturnsMutableCopy public byte [] getContentAsByteArray () { flushBuffer (); return m_aContent.toByteArray (); }
public byte [] getAsBytes (@Nonnull final SignatureHelper aSH) { try { final Marshaller aMarshaller = s_aJaxbContext.createMarshaller (); aMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ()) { // TODO aMarshaller.marshal (OF_CADES.createXAdESSignatures (getCreateXAdESSignatures (aSH)), aBAOS); return aBAOS.toByteArray (); } } catch (final JAXBException ex) { throw new IllegalStateException ("Unable to marshall the XAdESSignature into string output", ex); } }
return aBAOS.toByteArray ();
return aBAOS.toByteArray ();
final byte [] aContent = aBAOS.toByteArray (); final String sContent = new String (aContent, StandardCharsets.ISO_8859_1); final String sigReference = CadesAsicManifest.extractAndVerify (sContent, m_aManifestVerifier); _handleCadesSigning (m_aCurrentZipEntry.getName (), aBAOS.toByteArray (), true);
private void writeObject (@Nonnull final ObjectOutputStream aOOS) throws IOException { // write the mime body // Write to BAOS first to avoid serializing an incomplete object try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ()) { try { if (m_aData != null) { aBAOS.write (1); m_aData.writeTo (aBAOS); } else { aBAOS.write (0); } } catch (final MessagingException ex) { throw new IOException ("Messaging exception: " + ex.getMessage ()); } aOOS.write (aBAOS.toByteArray ()); } // write the message's MDN aOOS.writeObject (m_aMDN); }
return aBAOS.toByteArray ();
return aBAOS.toByteArray ();
@Nonnull public IAsicWriter addEncrypted (final InputStream aIS, final String sFilename, final IMimeType aMimeType) throws IOException { try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ()) { AsicUtils.copyStream (aIS, aBAOS); final CMSEnvelopedDataGenerator aCMSEnvelopedDataGenerator = new CMSEnvelopedDataGenerator (); aCMSEnvelopedDataGenerator.addRecipientInfoGenerator (new JceKeyTransRecipientInfoGenerator (m_aCertificate).setProvider (PBCProvider.getProvider ())); final CMSEnvelopedData aData = aCMSEnvelopedDataGenerator.generate (new CMSProcessableByteArray (aBAOS.toByteArray ()), new JceCMSContentEncryptorBuilder (m_aCmsAlgorithm).setProvider (PBCProvider.getProvider ()) .build ()); m_aEntryNames.add (sFilename); return m_aAsicWriter.add (new NonBlockingByteArrayInputStream (aData.getEncoded ()), sFilename + ".p7m", aMimeType); } catch (final CMSException | CertificateEncodingException e) { throw new IOException (e.getMessage (), e); } }
if (aIncomingDumper != null) aIncomingDumper.dumpIncomingRequest (aMDN.headers ().getAllHeaderLines (), aMDNStream != null ? aMDNStream.toByteArray () : ArrayHelper.EMPTY_BYTE_ARRAY, aMDN); try aPart = new MimeBodyPart (AS2HttpHelper.getAsInternetHeaders (aMDN.headers ()), aMDNStream.toByteArray ());
aIncomingDumper.dumpIncomingRequest (aMDN.headers ().getAllHeaderLines (), aMDNStream.toByteArray (), aMDN); aMDNStream.toByteArray ()); aMsg.getMDN ().setData (aPart);