Top Description Inners Fields Constructors Methods
org.bouncycastle.mime.smime

public Class SMIMEEnvelopedWriter

extends MimeWriter
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.util.LinkedHashMap, .Map, org.bouncycastle.cms.CMSAttributeTableGenerator, .CMSEnvelopedDataStreamGenerator, .CMSException, .OriginatorInformation, .RecipientInfoGenerator, org.bouncycastle.mime.Headers, .MimeIOException, .MimeWriter, org.bouncycastle.mime.encoding.Base64OutputStream, org.bouncycastle.operator.OutputEncryptor, org.bouncycastle.util.Strings

Writer for SMIME Enveloped objects.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class

Field Summary

Modifier and TypeField and Description
private final String
private final CMSEnvelopedDataStreamGenerator
private final OutputStream
private final OutputEncryptor
Inherited from org.bouncycastle.mime.MimeWriter:
headers

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public OutputStream
Inherited from org.bouncycastle.mime.MimeWriter:
getHeadersmapToLines

Field Detail

contentTransferEncodingback to summary
private final String contentTransferEncoding
envGenback to summary
private final CMSEnvelopedDataStreamGenerator envGen
mimeOutback to summary
private final OutputStream mimeOut
outEncback to summary
private final OutputEncryptor outEnc

Constructor Detail

SMIMEEnvelopedWriterback to summary
private SMIMEEnvelopedWriter(SMIMEEnvelopedWriter.Builder builder, OutputEncryptor outEnc, OutputStream mimeOut)

Method Detail

getContentStreamback to summary
public OutputStream getContentStream() throws IOException

Implements abstract org.bouncycastle.mime.MimeWriter.getContentStream.

org.bouncycastle.mime.smime back to summary

public Class SMIMEEnvelopedWriter.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv String
private final CMSEnvelopedDataStreamGenerator
private final Map<String, String>
private static final String[]
private static final String[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public SMIMEEnvelopedWriter.Builder

Returns:

the current Builder instance.
addRecipientInfoGenerator
(RecipientInfoGenerator
a generator of a recipient info object.
recipientGenerator
)

Add a generator to produce the recipient info required.

public SMIMEEnvelopedWriter
public SMIMEEnvelopedWriter.Builder
setBufferSize(int
length of octet strings to buffer the data.
bufferSize
)

Set the underlying string size for encapsulated data

public SMIMEEnvelopedWriter.Builder
public SMIMEEnvelopedWriter.Builder
public SMIMEEnvelopedWriter.Builder

Returns:

the current Builder instance.
withHeader
(String
name of the MIME header.
headerName
,
String
value of the MIME header.
headerValue
)

Specify a MIME header (name, value) pair for this builder.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentTransferEncodingback to summary
pack-priv String contentTransferEncoding
envGenback to summary
private final CMSEnvelopedDataStreamGenerator envGen
headersback to summary
private final Map<String, String> headers
stdHeadersback to summary
private static final String[] stdHeaders
stdValuesback to summary
private static final String[] stdValues

Constructor Detail

Builderback to summary
public Builder()

Method Detail

addRecipientInfoGeneratorback to summary
public SMIMEEnvelopedWriter.Builder addRecipientInfoGenerator(RecipientInfoGenerator recipientGenerator)

Add a generator to produce the recipient info required.

Parameters
recipientGenerator:RecipientInfoGenerator

a generator of a recipient info object.

Returns:SMIMEEnvelopedWriter.Builder

the current Builder instance.

buildback to summary
public SMIMEEnvelopedWriter build(OutputStream mimeOut, OutputEncryptor outEnc)
setBufferSizeback to summary
public SMIMEEnvelopedWriter.Builder setBufferSize(int bufferSize)

Set the underlying string size for encapsulated data

Parameters
bufferSize:int

length of octet strings to buffer the data.

setOriginatorInfoback to summary
public SMIMEEnvelopedWriter.Builder setOriginatorInfo(OriginatorInformation originatorInfo)
setUnprotectedAttributeGeneratorback to summary
public SMIMEEnvelopedWriter.Builder setUnprotectedAttributeGenerator(CMSAttributeTableGenerator unprotectedAttributeGenerator)
withHeaderback to summary
public SMIMEEnvelopedWriter.Builder withHeader(String headerName, String headerValue)

Specify a MIME header (name, value) pair for this builder. If the headerName already exists it will be overridden.

Parameters
headerName:String

name of the MIME header.

headerValue:String

value of the MIME header.

Returns:SMIMEEnvelopedWriter.Builder

the current Builder instance.

org.bouncycastle.mime.smime back to summary

private Class SMIMEEnvelopedWriter.ContentOutputStream

extends OutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final OutputStream
private final OutputStream

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public void
write(byte[]
the data.
buf
)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array 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.OutputStream.write.

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

public void
write(int
the byte.
i
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

Inherited from java.io.OutputStream:
flushnullOutputStream

Field Detail

backingback to summary
private final OutputStream backing
mainback to summary
private final OutputStream main

Constructor Detail

ContentOutputStreamback to summary
pack-priv ContentOutputStream(OutputStream main, OutputStream backing)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

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

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Parameters
buf:byte[]

the data.

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.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

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. In particular, an IOException is thrown if the output stream is closed.
writeback to summary
public void write(int i) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
i:int

the byte.

Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.