los.writeln(); if (allowEmpty) { los.writeln(boundary); // put out boundary los.writeln(); // put out empty line } else { throw new MessagingException("Empty multipart: " + contentType); los.writeln(boundary); // put out boundary ((MimeBodyPart)parts.elementAt(i)).writeTo(os); los.writeln(); // put out empty line los.writeln(boundary + "--");
los.writeln(); if (allowEmpty) { los.writeln(boundary); // put out boundary los.writeln(); // put out empty line } else { throw new MessagingException("Empty multipart: " + contentType); los.writeln(boundary); // put out boundary ((MimeBodyPart)parts.elementAt(i)).writeTo(os); los.writeln(); // put out empty line los.writeln(boundary + "--");
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header @SuppressWarnings("unchecked") Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ @Override public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
public static MdnBuilder newInstance(MimeMessage mimeMessage) throws MessagingException, IOException { MdnBuilder mdnBuilder = new MdnBuilder(); mdnBuilder.addHeader(MdnHeader.REPORTING_UA, ISSUER); String recipient = String.format("rfc822; %s", mimeMessage.getHeader(As2Header.AS2_TO)[0]); mdnBuilder.addHeader(MdnHeader.ORIGINAL_RECIPIENT, recipient); mdnBuilder.addHeader(MdnHeader.FINAL_RECIPIENT, recipient); mdnBuilder.textLineOutputStream.writeln("= Received headers"); mdnBuilder.textLineOutputStream.writeln(); for (String header : Collections.list((Enumeration<String>) mimeMessage.getAllHeaderLines())) mdnBuilder.textLineOutputStream.writeln(header); mdnBuilder.textLineOutputStream.writeln(); return mdnBuilder; }
public static MdnBuilder newInstance(MimeMessage mimeMessage) throws MessagingException, IOException { MdnBuilder mdnBuilder = new MdnBuilder(); mdnBuilder.addHeader(MdnHeader.REPORTING_UA, ISSUER); String recipient = String.format("rfc822; %s", mimeMessage.getHeader(As2Header.AS2_TO)[0]); mdnBuilder.addHeader(MdnHeader.ORIGINAL_RECIPIENT, recipient); mdnBuilder.addHeader(MdnHeader.FINAL_RECIPIENT, recipient); mdnBuilder.textLineOutputStream.writeln("= Received headers"); mdnBuilder.textLineOutputStream.writeln(); for (String header : Collections.list((Enumeration<String>) mimeMessage.getAllHeaderLines())) mdnBuilder.textLineOutputStream.writeln(header); mdnBuilder.textLineOutputStream.writeln(); return mdnBuilder; }
/** * Extracts headers of body MIME part. Creates headers as done by Bouncycastle. * * @return Headers */ public byte[] getBodyHeader() throws IOException, OxalisAs2Exception { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); LineOutputStream los = new LineOutputStream(outputStream); Enumeration hdrLines = ((MimeBodyPart) mimeMultipart.getBodyPart(0)).getNonMatchingHeaderLines(new String[]{}); while (hdrLines.hasMoreElements()) los.writeln((String) hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); los.close(); return outputStream.toByteArray(); } catch (MessagingException e) { throw new OxalisAs2Exception("Unable to fetch body headers.", e); } }
/** * Extracts headers of body MIME part. Creates headers as done by Bouncycastle. * * @return Headers */ public byte[] getBodyHeader() throws IOException, OxalisAs2Exception { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); LineOutputStream los = new LineOutputStream(outputStream); Enumeration hdrLines = ((MimeBodyPart) mimeMultipart.getBodyPart(0)).getNonMatchingHeaderLines(new String[]{}); while (hdrLines.hasMoreElements()) los.writeln((String) hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); los.close(); return outputStream.toByteArray(); } catch (MessagingException e) { throw new OxalisAs2Exception("Unable to fetch body headers.", e); } }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ @Override public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ @Override public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
/** * Output the body part as an RFC 822 format stream. * * @exception IOException if an error occurs writing to the * stream or if an error is generated * by the javax.activation layer. * @exception MessagingException for other failures * @see javax.activation.DataHandler#writeTo */ @Override public void writeTo(OutputStream os) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration<String> hdrLines = getAllHeaderLines(); while (hdrLines.hasMoreElements()) los.writeln(hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content, already encoded. getDataHandler().writeTo(os); os.flush(); }
static void writeTo(MimePart part, OutputStream os, String[] ignoreList) throws IOException, MessagingException { // see if we already have a LOS LineOutputStream los = null; if (os instanceof LineOutputStream) { los = (LineOutputStream) os; } else { los = new LineOutputStream(os); } // First, write out the header Enumeration hdrLines = part.getNonMatchingHeaderLines(ignoreList); while (hdrLines.hasMoreElements()) los.writeln((String)hdrLines.nextElement()); // The CRLF separator between header and content los.writeln(); // Finally, the content. Encode if required. // XXX: May need to account for ESMTP ? os = MimeUtility.encode(os, part.getEncoding()); part.getDataHandler().writeTo(os); os.flush(); // Needed to complete encoding } }