public class SigningCertificateDemo extends java.lang.Object
SigningCertificate
attribute to the SignerInfo of a SignedDataStream
or
SignedData
object. The SigningCertificate attributes maybe used
to include certificate identification information into the signed attributes of a
CMS SignerInfo
object.SigningCertificate
,
SignerInfo
,
SignedDataStream
,
SignedData
Constructor and Description |
---|
SigningCertificateDemo()
Setups the demo certificate chains.
|
Modifier and Type | Method and Description |
---|---|
iaik.x509.attr.AttributeCertificate |
createAttributeCertificate()
Creates an attribute certificate just for testing.
|
byte[] |
createSignedData(byte[] message,
int mode)
Creates a CMS
SignedData object. |
byte[] |
createSignedDataStream(byte[] message,
int mode)
Creates a CMS
SignedData object. |
protected iaik.smime.ess.SigningCertificate |
createSigningCertificate(java.security.cert.Certificate[] certs)
Creates a SigningCertificate attribute for the given certificates.
|
byte[] |
getSignedData(byte[] encoding,
byte[] message)
Parses a CMS
SignedData object and verifies the signatures
for all participated signers. |
byte[] |
getSignedDataStream(byte[] signedData,
byte[] message)
Parses a CMS
SignedData object and verifies the signatures
for all participated signers. |
protected iaik.smime.ess.SigningCertificate |
getSigningCertificate(iaik.cms.SignerInfo signerInfo)
Gets the SigningCertificate attribute from the given SignerInfo.
|
static void |
main(java.lang.String[] argv)
The main method.
|
protected void |
printHeader()
Prints some header lines to System.out.
|
void |
start()
Starts the demo.
|
public SigningCertificateDemo() throws java.io.IOException
java.io.IOException
- if an file read error occurspublic byte[] createSignedDataStream(byte[] message, int mode) throws iaik.cms.CMSException, java.io.IOException
SignedData
object.
message
- the message to be signed, as byte representationmode
- the transmission mode, either IMPLICIT or EXPLICITSignedData
object just creatediaik.cms.CMSException
- if the SignedData
object cannot
be createdjava.io.IOException
- if some stream I/O error occurspublic byte[] getSignedDataStream(byte[] signedData, byte[] message) throws iaik.cms.CMSException, java.io.IOException
SignedData
object and verifies the signatures
for all participated signers.signedData
- SignedData
object as BER encoded byte arraymessage
- the the message which was transmitted out-of-band (explicit signed)iaik.cms.CMSException
- if any signature does not verifyjava.io.IOException
- if some stream I/O error occurspublic byte[] createSignedData(byte[] message, int mode) throws iaik.cms.CMSException
SignedData
object.
message
- the message to be signed, as byte representationmode
- the mode, either SignedData.IMPLICIT or SignedData.EXPLICITSignedData
objectiaik.cms.CMSException
- if the SignedData
object cannot
be createdpublic byte[] getSignedData(byte[] encoding, byte[] message) throws iaik.cms.CMSException, java.io.IOException
SignedData
object and verifies the signatures
for all participated signers.encoding
- the DER encoded SignedData
objectmessage
- the the message which was transmitted out-of-band (explicit signed)iaik.cms.CMSException
- if any signature does not verifyjava.io.IOException
- if some stream I/O error occurspublic iaik.x509.attr.AttributeCertificate createAttributeCertificate() throws iaik.cms.CMSException
iaik.cms.CMSException
- if an error occurs when creating the attribute certificatepublic void start()
protected iaik.smime.ess.SigningCertificate createSigningCertificate(java.security.cert.Certificate[] certs) throws iaik.cms.CMSException
certs
- the certificates for which to create the SigningCertificate
attributeiaik.cms.CMSException
- if an error occurs when creating the
SigningCertificate attributeprotected iaik.smime.ess.SigningCertificate getSigningCertificate(iaik.cms.SignerInfo signerInfo) throws iaik.cms.CMSException
signerInfo
- the SignerInfo from which to get the
SigningCertificate attributenull
if no SigningCertificate attribute is includediaik.cms.CMSException
- if an error occurs when getting the
SigningCertificate attributeprotected void printHeader()
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.io.IOException
- if an I/O error occurs when reading required keys
and certificates from filesjava.lang.Exception