Methods Summary |
---|
public java.lang.Object | getContent(javax.activation.DataSource ds)
try
{
return new MimeMultipart(ds);
}
catch (MessagingException ex)
{
return null;
}
|
public java.lang.Object | getTransferData(java.awt.datatransfer.DataFlavor df, javax.activation.DataSource ds)
if (ADF.equals(df))
{
return getContent(ds);
}
else
{
return null;
}
|
public java.awt.datatransfer.DataFlavor[] | getTransferDataFlavors()
return DFS;
|
private void | outputBodyPart(java.io.OutputStream out, java.lang.Object bodyPart)
if (bodyPart instanceof Multipart)
{
Multipart mp = (Multipart)bodyPart;
ContentType contentType = new ContentType(mp.getContentType());
String boundary = "--" + contentType.getParameter("boundary");
LineOutputStream lOut = new LineOutputStream(out);
for (int i = 0; i < mp.getCount(); i++)
{
lOut.writeln(boundary);
outputBodyPart(out, mp.getBodyPart(i));
lOut.writeln(); // CRLF terminator
}
lOut.writeln(boundary + "--");
return;
}
MimeBodyPart mimePart = (MimeBodyPart)bodyPart;
if (mimePart.getContent() instanceof Multipart)
{
Multipart mp = (Multipart)mimePart.getContent();
ContentType contentType = new ContentType(mp.getContentType());
String boundary = "--" + contentType.getParameter("boundary");
LineOutputStream lOut = new LineOutputStream(out);
Enumeration headers = mimePart.getAllHeaderLines();
while (headers.hasMoreElements())
{
lOut.writeln((String)headers.nextElement());
}
lOut.writeln(); // CRLF separator
outputPreamble(lOut, mimePart, boundary);
outputBodyPart(out, mp);
return;
}
mimePart.writeTo(out);
|
static void | outputPreamble(org.bouncycastle.mail.smime.handlers.multipart_signed$LineOutputStream lOut, javax.mail.internet.MimeBodyPart part, java.lang.String boundary)internal preamble is generally included in signatures, while this is technically wrong,
if we find internal preamble we include it by default.
InputStream in;
try
{
in = part.getRawInputStream();
}
catch (MessagingException e)
{
return; // no underlying content, rely on default generation
}
String line;
while ((line = readLine(in)) != null)
{
if (line.equals(boundary))
{
break;
}
lOut.writeln(line);
}
in.close();
if (line == null)
{
throw new MessagingException("no boundary found");
}
|
private static java.lang.String | readLine(java.io.InputStream in)
StringBuffer b = new StringBuffer();
int ch;
while ((ch = in.read()) >= 0 && ch != '\n")
{
if (ch != '\r")
{
b.append((char)ch);
}
}
if (ch < 0)
{
return null;
}
return b.toString();
|
public void | writeTo(java.lang.Object obj, java.lang.String _mimeType, java.io.OutputStream os)
if (obj instanceof MimeMultipart)
{
try
{
outputBodyPart(os, obj);
}
catch (MessagingException ex)
{
throw new IOException(ex.getMessage());
}
}
else if(obj instanceof byte[])
{
os.write((byte[])obj);
}
else if (obj instanceof InputStream)
{
int b;
InputStream in = (InputStream)obj;
if (!(in instanceof BufferedInputStream))
{
in = new BufferedInputStream(in);
}
while ((b = in.read()) >= 0)
{
os.write(b);
}
}
else if (obj instanceof SMIMEStreamingProcessor)
{
SMIMEStreamingProcessor processor = (SMIMEStreamingProcessor)obj;
processor.write(os);
}
else
{
throw new IOException("unknown object in writeTo " + obj);
}
|