|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.SignedDataStream iaik.smime.SMimeSigned iaik.smime.JMailSMimeSigned
public class JMailSMimeSigned
This class extends class SMimeSigned for ensuring to write the body parts in right order.
When writing an explicit signed message, for calculating the hash it is important
that the data carrying body part is written before the signature part. Since JavaMail
calls any participated writeTo method twice and works with several threads, extra care
has been taken to ensure the correct writing order. This class only extends the
SMimeSigned
class to force the data body
part to be written before the signature. This is be done in a separate class because
- for use in other applications - the SMimeSigned class should be not responsible
on Java Mail parts.
Field Summary |
---|
Fields inherited from class iaik.cms.SignedDataStream |
---|
blockSize_, certSet_, contentType_, crls_, encapContentInfo_, EXPLICIT, IMPLICIT, inputStream_, mode_, securityProvider_, signerInfos_, thisObject_, version_ |
Constructor Summary | |
---|---|
JMailSMimeSigned(java.io.InputStream is)
Reads a JMailSMimeSigned message from an InputStream. |
|
JMailSMimeSigned(java.io.InputStream is,
AlgorithmID[] hashAlgorithm)
Creates a new JMailSMimeSigned from an InputStream holding the signed data and an algorithm specifying the hash algorithm to use for digesting. |
|
JMailSMimeSigned(java.io.InputStream is,
int mode)
Creates a JMailSMimeSigned object from an input stream which supplies the data to be signed. |
Method Summary | |
---|---|
byte[] |
toByteArray()
Returns this JMailSMimeSigned object as DER encoded byte array. |
void |
writeTo(java.io.OutputStream os)
Writes this JMailSMimeSigned object to the supplied output stream. |
void |
writeTo(java.io.OutputStream os,
int blockSize)
Writes this JMailSMimeSigned object to the supplied output stream. |
Methods inherited from class iaik.smime.SMimeSigned |
---|
addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, getMode, toASN1Object, toString, verify, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JMailSMimeSigned(java.io.InputStream is, int mode)
There are two possible modes:
is
- a stream supplying the data to signmode
- IMPLICIT if the message shall be included in the DER encoding,
EXPLICIT otherwisepublic JMailSMimeSigned(java.io.InputStream is, AlgorithmID[] hashAlgorithm) throws java.io.IOException
This constructor shall be used to process an already existing EXPLICIT
JMailSMimeSigned object. It will setup a DigestInputStream where the signed data
is piped through. The new InputStream can be retrieved using the method
getInputStream
for reading the data and thereby
piping it through a digest stream for hash calculation.
For subsequently processing the DER encoded JMailSMimeSigned object, use method
decode(InpuStream)
, e.g.:
AlgorithmID[] algID = { AlgorithmID.sha256 }; JMailSMimeSigned signed = new JMailSMimeSigned(data_is, algIDs); InputStream dataIs = signed.getInputStream(); byte[] buf = new byte[2048]; int r; while ((r = dataIs.read(buf)) > 0) { // do something useful } signed.decode(encoded_stream);
is
- the InputStream holding the raw data supplied by other means, i.e. the
first part of a multipart/signed messagehashAlgorithm
- the hash algorithm used for digesting the signed data;
supplied as array of hash algorithms as required by the parent
SignedDataStream class, but actually containing only one digest
algorithm identifier for the one and only signer
java.io.IOException
- if an I/O error occurs or there is no implementation for the specified
hash algorithmpublic JMailSMimeSigned(java.io.InputStream is) throws java.io.IOException
Do not use this constructor for supplying the content data
to be signed. This constructor may be used by the recipient for parsing an
already exisiting JMailSMimeSigned
object, supplied as DER encoding
from an input stream, that may have been created by means of the
writeTo
method.
Use the JMailSMimeSigned(InputStream data_is, int mode)
constructor for supplying the content data to be signed when creating a
JMailSMimeSigned
object.
This constructor only shall be used for decoding a JMailSMimeSigned object with
included raw data (implicit mode).
To initialize a JMailSMimeSigned object for parsing an explicit message where the
raw data is not included, use the
JMailSMimeSigned(InputStream is, AlgorithmID[] hashAlgorithms)
constructor, and perform the decoding explicitly by calling the
decode
method.
is
- the input stream where the DER encoded message shall be read from
java.io.IOException
- if an I/O error or parsing problem occursMethod Detail |
---|
public byte[] toByteArray() throws CMSException
CMSException
public void writeTo(java.io.OutputStream os) throws java.io.IOException
writeTo
in class SMimeSigned
os
- the output stream to which this JMailSMimeSigned shall be written
java.io.IOException
- if an error occurs while writing to the streampublic void writeTo(java.io.OutputStream os, int blockSize) throws java.io.IOException
blockSize
parameter indicates the block size to
be used for performimg block encoding.
writeTo
in class SMimeSigned
os
- the output stream to which this JMailSMimeSigned shall be writtenblockSize
- the block size for performing block encoding
java.io.IOException
- if an error occurs while writing to the stream
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |