Oracle Security Developer Tools S/MIME Java API Reference
10g Release 2 (10.1.2.0.2)

B15567-01


oracle.security.crypto.smime
Class SmimeSigned

java.lang.Object
  extended byoracle.security.crypto.smime.SmimeSigned

All Implemented Interfaces:
SmimeObject, SmimeSignedObject

public class SmimeSigned
extends java.lang.Object
implements SmimeSignedObject

A S/MIME Signed Message.


Constructor Summary
SmimeSigned()
Create an empty SmimeSigned.
SmimeSigned(java.io.InputStream is)
Create a SmimeSigned.
SmimeSigned(javax.mail.internet.MimeBodyPart content)
Create a SmimeSigned.
SmimeSigned(javax.mail.internet.MimeBodyPart content, boolean useCompression)
Create a SmimeSigned.

Method Summary
void addCertificate(oracle.security.crypto.cert.X509 cert)
Add a Certificate.
void addCRL(oracle.security.crypto.cert.CRL crl)
Add a CRL.
void addSignature(PrivateKey signerKey, oracle.security.crypto.cert.X509 signerCert, AlgorithmIdentifier digestAlgID)
Add a Signature.
void addSignature(PrivateKey signerKey, oracle.security.crypto.cert.X509 signerCert, AlgorithmIdentifier digestAlgID, oracle.security.crypto.cert.AttributeSet signedAttributes)
Add a Signature.
void addSignature(PrivateKey signerKey, oracle.security.crypto.cert.X509 signerCert, AlgorithmIdentifier digestAlgID, java.util.Date timeStamp)
Add a Signature.
void addSignature(PrivateKey signerKey, oracle.security.crypto.cert.X509 signerCert, AlgorithmIdentifier digestAlgID, java.util.Date timeStamp, SmimeCapabilities smimeCaps)
Add a Signature.
void addSignature(PrivateKey signerKey, oracle.security.crypto.cert.X509 signerCert, AlgorithmIdentifier digestAlgID, SmimeCapabilities smimeCaps)
Add a Signature.
java.lang.String generateContentType()
Returns the content type.
java.lang.String generateContentType(boolean useStandardContentTypes)
Returns the content type.
java.util.Vector getCertificates()
Returns the list of X509 certificates included with this signed data object.
java.util.Vector getCRLs()
Returns the list of CRLs included with this signed data object.
javax.mail.internet.MimeBodyPart getEnclosedBodyPart()
Returns the message content that was signed.
EquivalentLabels getEquivalentLabels(oracle.security.crypto.cert.X509 signerCert)
Returns the EquivalentLabels if present or null.
ESSSecurityLabel getESSSecurityLabel(oracle.security.crypto.cert.X509 signerCert)
Returns the ESSSecurityLabel if present or null.
MLExpansionHistory getMLExpansionHistory(oracle.security.crypto.cert.X509 signerCert)
Returns the MLExpansionHistory if present or null.
oracle.security.crypto.cms.ESSReceipt getReceipt()
Returns the Receipt if this object is a signed receipt.
ReceiptRequest getReceiptRequest(oracle.security.crypto.cert.X509 signerCert)
Returns the ReceiptRequest if present or null.
SigningCertificate getSigningCertificate(oracle.security.crypto.cert.X509 signerCert)
Returns the SigningCertificate Attribute if present or null.
boolean isSignedReceipt()
Indicates if this Object is a signed receipt.
java.util.Enumeration signers()
Returns the list of signers.
void verify(oracle.security.crypto.cert.CertificateTrustPolicy trustPolicy)
Verify the Signature using the specified trust policy.
void verify(oracle.security.crypto.cert.CertificateTrustPolicy trustPolicy, javax.mail.Address[] senderAddresses)
Verify the Signature using the specified trust policy and list of email addresses.
void verifySignature(oracle.security.crypto.cert.X509 signerCert)
Verify the Signature using the specified certificate.
void verifySignature(oracle.security.crypto.cert.X509 signerCert, javax.mail.Address[] senderAddresses)
Verify the Signature using the specified certificate and list of email addresses.
void writeTo(java.io.OutputStream os, java.lang.String mimeType)
Writes this SmimeSigned to the given output stream.

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

SmimeSigned

public SmimeSigned()
Create an empty SmimeSigned.

SmimeSigned

public SmimeSigned(javax.mail.internet.MimeBodyPart content)
            throws javax.mail.MessagingException,
                   java.io.IOException
Create a SmimeSigned.
Parameters:
content - The message content.
Throws:
javax.mail.MessagingException - An error occurred while setting the message content.
java.io.IOException - The message content is empty.

SmimeSigned

public SmimeSigned(javax.mail.internet.MimeBodyPart content,
                   boolean useCompression)
            throws javax.mail.MessagingException,
                   java.io.IOException
Create a SmimeSigned.
Parameters:
content - The message content.
useCompression - Indicate if the content must be compressed.
Throws:
javax.mail.MessagingException - An error occurred while setting the message content.
java.io.IOException - The message content is empty.

SmimeSigned

public SmimeSigned(java.io.InputStream is)
            throws java.io.IOException
Create a SmimeSigned.
Parameters:
is - The input stream.
Throws:
java.io.IOException - An I/O error occurred or the input encoding was incorrect.

Method Detail

addCertificate

public void addCertificate(oracle.security.crypto.cert.X509 cert)
Add a Certificate.
Parameters:
cert - The X509 certificate.

addCRL

public void addCRL(oracle.security.crypto.cert.CRL crl)
Add a CRL.
Parameters:
crl - The CRL.

addSignature

public void addSignature(PrivateKey signerKey,
                         oracle.security.crypto.cert.X509 signerCert,
                         AlgorithmIdentifier digestAlgID)
                  throws InvalidKeyException,
                         SignatureException,
                         AlgorithmIdentifierException
Add a Signature.
Parameters:
signerKey - The private key of the signer.
signerCert - The X509 certificate of the signer.
digestAlgID - The digest algorithm.
Throws:
AlgorithmIdentifierException - The digest or signature algorithm is not supported.
SignatureException - An error occurred during signature generation.
InvalidKeyException - The private key is not valid.

addSignature

public void addSignature(PrivateKey signerKey,
                         oracle.security.crypto.cert.X509 signerCert,
                         AlgorithmIdentifier digestAlgID,
                         java.util.Date timeStamp)
                  throws InvalidKeyException,
                         SignatureException,
                         AlgorithmIdentifierException
Add a Signature.
Parameters:
signerKey - The private key of the signer.
signerCert - The X509 certificate of the signer.
digestAlgID - The digest algorithm.
timeStamp - The Signing Time.
Throws:
AlgorithmIdentifierException - The digest or signature algorithm is not supported.
SignatureException - An error occurred during signature generation.
InvalidKeyException - The private key is not valid.

addSignature

public void addSignature(PrivateKey signerKey,
                         oracle.security.crypto.cert.X509 signerCert,
                         AlgorithmIdentifier digestAlgID,
                         SmimeCapabilities smimeCaps)
                  throws InvalidKeyException,
                         SignatureException,
                         AlgorithmIdentifierException
Add a Signature.
Parameters:
signerKey - The private key of the signer.
signerCert - The X509 certificate of the signer.
digestAlgID - The digest algorithm.
smimeCaps - The Smime Capabilities.
Throws:
AlgorithmIdentifierException - The digest or signature algorithm is not supported.
SignatureException - An error occurred during signature generation.
InvalidKeyException - The private key is not valid.

addSignature

public void addSignature(PrivateKey signerKey,
                         oracle.security.crypto.cert.X509 signerCert,
                         AlgorithmIdentifier digestAlgID,
                         java.util.Date timeStamp,
                         SmimeCapabilities smimeCaps)
                  throws InvalidKeyException,
                         SignatureException,
                         AlgorithmIdentifierException
Add a Signature.
Parameters:
signerKey - The private key of the signer.
signerCert - The X509 certificate of the signer.
digestAlgID - The digest algorithm.
timeStamp - The Signing Time.
smimeCaps - The Smime Capabilities.
Throws:
AlgorithmIdentifierException - The digest or signature algorithm is not supported.
SignatureException - An error occurred during signature generation.
InvalidKeyException - The private key is not valid.

addSignature

public void addSignature(PrivateKey signerKey,
                         oracle.security.crypto.cert.X509 signerCert,
                         AlgorithmIdentifier digestAlgID,
                         oracle.security.crypto.cert.AttributeSet signedAttributes)
                  throws InvalidKeyException,
                         SignatureException,
                         AlgorithmIdentifierException
Add a Signature.

The contentType, messageDigest, signingTime and smimeCapabilities must not be present in the AttributeSet signedAttributes.

Parameters:
signerKey - The private key of the signer.
signerCert - The X509 certificate of the signer.
digestAlgID - The digest algorithm.
signedAttributes - The set of signed attributes.
Throws:
AlgorithmIdentifierException - The digest or signature algorithm is not supported.
SignatureException - An error occurred during signature generation.
InvalidKeyException - The private key is not valid.

getReceipt

public oracle.security.crypto.cms.ESSReceipt getReceipt()
Returns the Receipt if this object is a signed receipt.
Returns:
A ESSReceipt if present or null otherwise.

getEnclosedBodyPart

public javax.mail.internet.MimeBodyPart getEnclosedBodyPart()
                                                     throws InvalidInputException,
                                                            javax.mail.MessagingException
Returns the message content that was signed.
Specified by:
getEnclosedBodyPart in interface SmimeSignedObject
Returns:
The message content as a MimeBodyPart.
Throws:
InvalidInputException - The message content type is not correct.
javax.mail.MessagingException - An error occurred while initializing the content.

isSignedReceipt

public boolean isSignedReceipt()
Indicates if this Object is a signed receipt.

If the S/MIME message content type parameters are missing, it will be treated as a signed message but the data content handler.

Returns:
If true this object is wrapped; false otherwise.

getCertificates

public java.util.Vector getCertificates()
Returns the list of X509 certificates included with this signed data object.
Specified by:
getCertificates in interface SmimeSignedObject
Returns:
A Vector containing X509 objects or null if no list of certificates is present.

getCRLs

public java.util.Vector getCRLs()
Returns the list of CRLs included with this signed data object.
Specified by:
getCRLs in interface SmimeSignedObject
Returns:
A Vector containing CRL objects or null if no list of CRLs is present.

signers

public java.util.Enumeration signers()
Returns the list of signers.
Specified by:
signers in interface SmimeSignedObject
Returns:
A Vector containing CMSSignerInfo objects.

verifySignature

public void verifySignature(oracle.security.crypto.cert.X509 signerCert)
                     throws AuthenticationException,
                            oracle.security.crypto.cms.UnknownSignerException
Verify the Signature using the specified certificate.
Specified by:
verifySignature in interface SmimeSignedObject
Parameters:
signerCert - The X509 certificate.
Throws:
AuthenticationException - Signature verification failed.
oracle.security.crypto.cms.UnknownSignerException - The specified certificate does not belong to any of the message signers.

verifySignature

public void verifySignature(oracle.security.crypto.cert.X509 signerCert,
                            javax.mail.Address[] senderAddresses)
                     throws AuthenticationException,
                            oracle.security.crypto.cms.UnknownSignerException
Verify the Signature using the specified certificate and list of email addresses.
Specified by:
verifySignature in interface SmimeSignedObject
Parameters:
signerCert - The X509 certificate.
Throws:
AuthenticationException - Signature verification failed or the email address in the certificate did not match any in the email address list.
oracle.security.crypto.cms.UnknownSignerException - The specified certificate does not belong to any of the message signers.

verify

public void verify(oracle.security.crypto.cert.CertificateTrustPolicy trustPolicy)
            throws AuthenticationException
Verify the Signature using the specified trust policy.
Specified by:
verify in interface SmimeSignedObject
Parameters:
trustPolicy - The certificate trust policy.
Throws:
AuthenticationException - Signature verification failed.

verify

public void verify(oracle.security.crypto.cert.CertificateTrustPolicy trustPolicy,
                   javax.mail.Address[] senderAddresses)
            throws AuthenticationException
Verify the Signature using the specified trust policy and list of email addresses.
Specified by:
verify in interface SmimeSignedObject
Throws:
AuthenticationException - Signature verification failed or the email address in the certificate did not match any in the email address list.

getESSSecurityLabel

public ESSSecurityLabel getESSSecurityLabel(oracle.security.crypto.cert.X509 signerCert)
                                     throws AuthenticationException,
                                            oracle.security.crypto.cms.UnknownSignerException
Returns the ESSSecurityLabel if present or null.

The signature of the SignerInfo that covers the ESSSecurityLabel is first verified. Then, it verifies that all the ESSSecurityLabel's in the signed message are identical.

Specified by:
getESSSecurityLabel in interface SmimeSignedObject
Returns:
A valid security label.
Throws:
AuthenticationException - Signature verification did not succeed on any SignerInfo.
oracle.security.crypto.cms.UnknownSignerException - No valid security label could be found.

getEquivalentLabels

public EquivalentLabels getEquivalentLabels(oracle.security.crypto.cert.X509 signerCert)
                                     throws AuthenticationException,
                                            oracle.security.crypto.cms.UnknownSignerException
Returns the EquivalentLabels if present or null.

The signature of the SignerInfo that covers the EquivalentLabels is first verified. Then, it verifies that all the EquivalentLabels in the signed message are identical.

Specified by:
getEquivalentLabels in interface SmimeSignedObject
Returns:
A valid equivalent labels.
Throws:
AuthenticationException - Signature verification did not succeed on any SignerInfo.
oracle.security.crypto.cms.UnknownSignerException - No valid equivalent labels could be found.

getSigningCertificate

public SigningCertificate getSigningCertificate(oracle.security.crypto.cert.X509 signerCert)
                                         throws AuthenticationException,
                                                oracle.security.crypto.cms.UnknownSignerException
Returns the SigningCertificate Attribute if present or null.

The signature of the SignerInfo that covers the SigningCertificate is verified.

Specified by:
getSigningCertificate in interface SmimeSignedObject
Returns:
A valid signing certificate.
Throws:
AuthenticationException - Signature verification did not succeed on any SignerInfo.
oracle.security.crypto.cms.UnknownSignerException - No valid signing certificate could be found.

getMLExpansionHistory

public MLExpansionHistory getMLExpansionHistory(oracle.security.crypto.cert.X509 signerCert)
                                         throws AuthenticationException,
                                                oracle.security.crypto.cms.UnknownSignerException
Returns the MLExpansionHistory if present or null.

The signature of the SignerInfo that covers the MLExpansionHistory is first verified. Then, it verifies that all the MLExpansionHistory's in the signed message are identical.

Specified by:
getMLExpansionHistory in interface SmimeSignedObject
Returns:
A valid mailing list expansion history.
Throws:
AuthenticationException - Signature verification did not succeed on any SignerInfo.
oracle.security.crypto.cms.UnknownSignerException - No valid mailing list expansion history could be found.

getReceiptRequest

public ReceiptRequest getReceiptRequest(oracle.security.crypto.cert.X509 signerCert)
                                 throws AuthenticationException,
                                        oracle.security.crypto.cms.UnknownSignerException
Returns the ReceiptRequest if present or null.

The signature of the SignerInfo that covers the ReceiptRequest is first verified. Then, it verifies that all the ReceiptRequest's in the signed message are identical.

Specified by:
getReceiptRequest in interface SmimeSignedObject
Returns:
A valid receipt request.
Throws:
AuthenticationException - Signature verification did not succeed on any SignerInfo.
oracle.security.crypto.cms.UnknownSignerException - No valid receipt request could be found.

generateContentType

public java.lang.String generateContentType(boolean useStandardContentTypes)
Returns the content type.
Specified by:
generateContentType in interface SmimeObject
Parameters:
useStandardContentTypes - If true the standard content type is generated; If false the experimental content type is generated.
Returns:
The content type string.

generateContentType

public java.lang.String generateContentType()
Returns the content type.
Specified by:
generateContentType in interface SmimeObject
Returns:
The content type string.

writeTo

public void writeTo(java.io.OutputStream os,
                    java.lang.String mimeType)
             throws java.io.IOException,
                    javax.mail.MessagingException
Writes this SmimeSigned to the given output stream. Relevant canonicalizations, such as transforming text line-breaks to CRLF, are applied.
Specified by:
writeTo in interface SmimeObject
Parameters:
os - The output stream to which this SmimeEnveloped will be written.
mimeType - Ignored.
Throws:
javax.mail.MessagingException - An error occurred while writing the smime message.
java.io.IOException - An I/O error occurred.

Oracle Security Developer Tools S/MIME Java API Reference
10g Release 2 (10.1.2.0.2)

B15567-01


Copyright © 2005 , Oracle. All rights reserved.