los.close(); } catch (IOException cex) { }
los.close(); } catch (IOException cex) { }
public MimeBodyPart build() throws MessagingException, IOException { // Initiate multipart MimeMultipart mimeMultipart = new MimeMultipart(); mimeMultipart.setSubType("report; Report-Type=disposition-notification"); // Insert text part MimeBodyPart textPart = new MimeBodyPart(); textLineOutputStream.close(); textPart.setContent(textOutputStream.toString("UTF-8"), "text/plain"); // textPart.setHeader("Content-Type", "text/plain"); mimeMultipart.addBodyPart(textPart); // Extract headers ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); LineOutputStream lineOutputStream = new LineOutputStream(outputStream); for (String header : Collections.list((Enumeration<String>) headers.getAllHeaderLines())) lineOutputStream.writeln(header); lineOutputStream.close(); // Insert header part MimeBodyPart headerPart = new MimeBodyPart(); headerPart.setContent(outputStream.toString(), "message/disposition-notification"); mimeMultipart.addBodyPart(headerPart); MimeBodyPart mimeBodyPart = new MimeBodyPart(); mimeBodyPart.setContent(mimeMultipart, mimeMultipart.getContentType()); return mimeBodyPart; } }
public MimeBodyPart build() throws MessagingException, IOException { // Initiate multipart MimeMultipart mimeMultipart = new MimeMultipart(); mimeMultipart.setSubType("report; Report-Type=disposition-notification"); // Insert text part MimeBodyPart textPart = new MimeBodyPart(); textLineOutputStream.close(); textPart.setContent(textOutputStream.toString("UTF-8"), "text/plain"); // textPart.setHeader("Content-Type", "text/plain"); mimeMultipart.addBodyPart(textPart); // Extract headers ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); LineOutputStream lineOutputStream = new LineOutputStream(outputStream); for (String header : Collections.list((Enumeration<String>) headers.getAllHeaderLines())) lineOutputStream.writeln(header); lineOutputStream.close(); // Insert header part MimeBodyPart headerPart = new MimeBodyPart(); headerPart.setContent(outputStream.toString(), "message/disposition-notification"); mimeMultipart.addBodyPart(headerPart); MimeBodyPart mimeBodyPart = new MimeBodyPart(); mimeBodyPart.setContent(mimeMultipart, mimeMultipart.getContentType()); return mimeBodyPart; } }
/** * 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); } }
los.close(); } catch (IOException cex) { }
los.close(); } catch (IOException cex) { }
los.close(); } catch (IOException cex) { }
los.close(); } catch (IOException cex) { }
los.close(); } catch (IOException cex) { }