public class JMailSMimeSigned extends SMimeSigned
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.blockSize_, certSet_, contentType_, crls_, encapContentInfo_, EXPLICIT, IMPLICIT, inputStream_, mode_, securityProvider_, signerInfos_, thisObject_, version_
Constructor and Description |
---|
JMailSMimeSigned(java.io.InputStream is)
Reads a JMailSMimeSigned message from an InputStream.
|
JMailSMimeSigned(java.io.InputStream is,
iaik.asn1.structures.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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, addSigner, getMode, toASN1Object, toString, verify, verify
addCertificates, addCRLs, addDigestAlgorithm, addSDSEncodeListener, addSignerInfo, clearSignatures, decode, encodeCalled, getAttributeCertificates, getBlockSize, getCertificate, getCertificates, getCertificates, getCertificateSet, getContentType, getCRLs, getDigestAlgorithms, getEncapsulatedContentType, getInputStream, getMessageDigest, getRevocationInfoChoices, getSecurityProvider, getSignedDigest, getSignerInfo, getSignerInfo, getSignerInfoIndex, getSignerInfos, getVersion, getX509Certificates, notifyEOF, removeMessageDigest, removeSignerInfo, setBlockSize, setCertificates, setCertificateSet, setCRLs, setInputStream, setMessageDigest, setRevocationInfoChoices, setSDSEncodeListener, setSecurityProvider, setSignerInfos, toASN1Object, toString, verify, verify, verify
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, iaik.asn1.structures.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 signerjava.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 fromjava.io.IOException
- if an I/O error or parsing problem occurspublic byte[] toByteArray() throws CMSException
CMSException
- if an error occurspublic void writeTo(java.io.OutputStream os) throws java.io.IOException
writeTo
in class SMimeSigned
os
- the output stream to which this JMailSMimeSigned shall be writtenjava.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 encodingjava.io.IOException
- if an error occurs while writing to the stream