Top Inners Fields Constructors Methods
org.bouncycastle.mail.smime

public Class SMIMEUtil

extends Object
Class Inheritance
Imports
java.io.ByteArrayInputStream, .File, .FilterOutputStream, .IOException, .InputStream, .OutputStream, java.security.cert.CertificateParsingException, .X509Certificate, java.util.Enumeration, javax.mail.BodyPart, .MessagingException, .Multipart, .Part, javax.mail.internet.ContentType, .MimeBodyPart, .MimeMultipart, org.bouncycastle.asn1.cms.IssuerAndSerialNumber, org.bouncycastle.cert.jcajce.JcaX509CertificateHolder, org.bouncycastle.cms.CMSTypedStream, org.bouncycastle.mail.smime.util.CRLFOutputStream, .FileBackedMimeBodyPart, org.bouncycastle.util.Strings

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IssuerAndSerialNumber

Returns:

an IssuerAndSerialNumber structure representing the certificate.
createIssuerAndSerialNumberFor
(X509Certificate
the X.509 certificate to get the issuer and serial number for.
cert
)

Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.

pack-priv static boolean
isCanonicalisationRequired(MimeBodyPart bodyPart, String defaultContentTransferEncoding)

public static boolean
pack-priv static void
outputBodyPart(OutputStream out, boolean topLevel, BodyPart bodyPart, String defaultContentTransferEncoding)

pack-priv static void
outputPostamble(SMIMEUtil.LineOutputStream lOut, MimeBodyPart part, int count, String boundary)

internal postamble is generally included in signatures, while this is technically wrong, if we find internal postamble we include it by default.

pack-priv static void
outputPostamble(SMIMEUtil.LineOutputStream lOut, BodyPart parent, String parentBoundary, BodyPart part)

pack-priv static void
outputPreamble(SMIMEUtil.LineOutputStream lOut, MimeBodyPart part, String boundary)

internal preamble is generally included in signatures, while this is technically wrong, if we find internal preamble we include it by default.

private static String
public static MimeBodyPart
toMimeBodyPart(byte[] content)

return the MimeBodyPart described in the raw bytes provided in content

public static MimeBodyPart
toMimeBodyPart(InputStream content)

return the MimeBodyPart described in the input stream content

public static FileBackedMimeBodyPart
toMimeBodyPart(CMSTypedStream content)

return a file backed MimeBodyPart described in CMSTypedStream content.

public static FileBackedMimeBodyPart

Returns:

the decoded body part.
toMimeBodyPart
(CMSTypedStream
content stream containing body part.
content
,
File
file to store the decoded body part in.
file
)

Return a file based MimeBodyPart represented by content and backed by the file represented by file.

pack-priv static FileBackedMimeBodyPart
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUF_SIZEback to summary
private static final int BUF_SIZE
MULTIPARTback to summary
private static final String MULTIPART

Constructor Detail

SMIMEUtilback to summary
public SMIMEUtil()

Method Detail

createIssuerAndSerialNumberForback to summary
public static IssuerAndSerialNumber createIssuerAndSerialNumberFor(X509Certificate cert) throws CertificateParsingException

Return a CMS IssuerAndSerialNumber structure for the passed in X.509 certificate.

Parameters
cert:X509Certificate

the X.509 certificate to get the issuer and serial number for.

Returns:IssuerAndSerialNumber

an IssuerAndSerialNumber structure representing the certificate.

isCanonicalisationRequiredback to summary
pack-priv static boolean isCanonicalisationRequired(MimeBodyPart bodyPart, String defaultContentTransferEncoding) throws MessagingException
isMultipartContentback to summary
public static boolean isMultipartContent(Part part) throws MessagingException
outputBodyPartback to summary
pack-priv static void outputBodyPart(OutputStream out, boolean topLevel, BodyPart bodyPart, String defaultContentTransferEncoding) throws MessagingException, IOException
outputPostambleback to summary
pack-priv static void outputPostamble(SMIMEUtil.LineOutputStream lOut, MimeBodyPart part, int count, String boundary) throws MessagingException, IOException

internal postamble is generally included in signatures, while this is technically wrong, if we find internal postamble we include it by default.

outputPostambleback to summary
pack-priv static void outputPostamble(SMIMEUtil.LineOutputStream lOut, BodyPart parent, String parentBoundary, BodyPart part) throws MessagingException, IOException
outputPreambleback to summary
pack-priv static void outputPreamble(SMIMEUtil.LineOutputStream lOut, MimeBodyPart part, String boundary) throws MessagingException, IOException

internal preamble is generally included in signatures, while this is technically wrong, if we find internal preamble we include it by default.

readLineback to summary
private static String readLine(InputStream in) throws IOException
toMimeBodyPartback to summary
public static MimeBodyPart toMimeBodyPart(byte[] content) throws SMIMEException

return the MimeBodyPart described in the raw bytes provided in content

toMimeBodyPartback to summary
public static MimeBodyPart toMimeBodyPart(InputStream content) throws SMIMEException

return the MimeBodyPart described in the input stream content

toMimeBodyPartback to summary
public static FileBackedMimeBodyPart toMimeBodyPart(CMSTypedStream content) throws SMIMEException

return a file backed MimeBodyPart described in CMSTypedStream content.

toMimeBodyPartback to summary
public static FileBackedMimeBodyPart toMimeBodyPart(CMSTypedStream content, File file) throws SMIMEException

Return a file based MimeBodyPart represented by content and backed by the file represented by file.

Parameters
content:CMSTypedStream

content stream containing body part.

file:File

file to store the decoded body part in.

Returns:FileBackedMimeBodyPart

the decoded body part.

toWriteOnceBodyPartback to summary
pack-priv static FileBackedMimeBodyPart toWriteOnceBodyPart(CMSTypedStream content) throws SMIMEException
org.bouncycastle.mail.smime back to summary

pack-priv Class SMIMEUtil.Base64CRLFOutputStream

extends FilterOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
protected int
protected static byte[]
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
write(int
the byte.
i
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.
public void
write(byte[]
the data to be written.
buf
)

Overrides java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.
public void
write(byte[]
the data.
buf
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
public void
Inherited from java.io.FilterOutputStream:
closeflush

Field Detail

isCrlfStreamback to summary
private boolean isCrlfStream
lastbback to summary
protected int lastb
newlineback to summary
protected static byte[] newline

Constructor Detail

Base64CRLFOutputStreamback to summary
public Base64CRLFOutputStream(OutputStream outputstream)

Method Detail

writeback to summary
public void write(int i) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
i:int

the byte.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] buf) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes b.length bytes to this output stream.

Parameters
buf:byte[]

the data to be written.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
buf:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Exceptions
IOException:
if an I/O error occurs.
writelnback to summary
public void writeln() throws IOException
org.bouncycastle.mail.smime back to summary

pack-priv Class SMIMEUtil.LineOutputStream

extends FilterOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static byte[]
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]
public void
public void
Inherited from java.io.FilterOutputStream:
closeflushwritewritewrite

Field Detail

newlineback to summary
private static byte[] newline

Constructor Detail

LineOutputStreamback to summary
public LineOutputStream(OutputStream outputstream)

Method Detail

getBytesback to summary
private static byte[] getBytes(String s)
writelnback to summary
public void writeln(String s) throws MessagingException
writelnback to summary
public void writeln() throws MessagingException
org.bouncycastle.mail.smime back to summary

private Class SMIMEUtil.WriteOnceFileBackedMimeBodyPart

extends FileBackedMimeBodyPart
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
writeTo(OutputStream
the stream to write to
out
)

Overrides org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart.writeTo.

Implements javax.mail.Part.writeTo.

Output the body part as an RFC 822 format stream.
Inherited from org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart:
dispose

Constructor Detail

WriteOnceFileBackedMimeBodyPartback to summary
public WriteOnceFileBackedMimeBodyPart(InputStream content, File file) throws MessagingException, IOException

Method Detail

writeToback to summary
public void writeTo(OutputStream out) throws MessagingException, IOException

Overrides org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart.writeTo.

Implements javax.mail.Part.writeTo.

Doc from javax.mail.internet.MimeBodyPart.writeTo.

Output the body part as an RFC 822 format stream.

Parameters
out:OutputStream

Doc from javax.mail.Part.writeTo.

the stream to write to

Exceptions
MessagingException:
for other failures
IOException:
if an error occurs writing to the stream or if an error is generated by the javax.activation layer.