public class SmimeEnveloped extends java.lang.Object implements SmimeObject
| Constructor and Description | 
|---|
SmimeEnveloped(java.io.InputStream is)
Create a  
SmimeEnveloped. | 
SmimeEnveloped(MimeBodyPart content, oracle.security.crypto.core.AlgorithmIdentifier contentEncryptionAlgID)
Create a  
SmimeEnveloped. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addRecipient(java.security.cert.X509Certificate cert)
Add a Recipient. 
 | 
void | 
addRecipient(java.security.cert.X509Certificate cert, oracle.security.crypto.core.AlgorithmIdentifier keyEncryptionAlgID)
Add a Recipient. 
 | 
java.lang.String | 
generateContentType()
Returns the content type. 
 | 
java.lang.String | 
generateContentType(boolean useStandardContentTypes)
Returns the content type. 
 | 
oracle.security.crypto.core.AlgorithmIdentifier | 
getContentEncryptionAlgID()
Returns the content encryption algorithm. 
 | 
MimeBodyPart | 
getEnclosedBodyPart(java.security.PrivateKey recipientKey, java.security.cert.X509Certificate recipientCert)
Returns the Decrypted Content. 
 | 
byte[] | 
getEncryptedContent()
Returns the raw content (that is, without decrypting). 
 | 
java.util.Enumeration | 
recipients()
Returns the message recipients. 
 | 
void | 
writeTo(java.io.OutputStream os, java.lang.String mimeType)
Writes this  
SmimeEnveloped to the given output stream. | 
public SmimeEnveloped(MimeBodyPart content,
                      oracle.security.crypto.core.AlgorithmIdentifier contentEncryptionAlgID)
               throws MessagingException,
                      java.io.IOException
SmimeEnveloped.content - The message content.contentEncryptionAlgID - The content encryption algorithm identifier.MessagingException - An error occurred while setting the message content.java.io.IOException
public SmimeEnveloped(java.io.InputStream is)
               throws java.io.IOException
SmimeEnveloped.is - The input stream.java.io.IOException - The input encoding is incorrect or an I/O error occurred.
public MimeBodyPart getEnclosedBodyPart(java.security.PrivateKey recipientKey,
                                        java.security.cert.X509Certificate recipientCert)
                                 throws java.security.NoSuchAlgorithmException,
                                        java.security.InvalidKeyException,
                                        UnknownRecipientException,
                                        java.io.IOException,
                                        java.security.cert.CertificateEncodingException,
                                        oracle.security.crypto.util.InvalidInputException,
                                        MessagingException,
                                        javax.crypto.BadPaddingException,
                                        javax.crypto.IllegalBlockSizeException,
                                        javax.crypto.NoSuchPaddingException
Note the changes in the exceptions
Exceptions no longer thrown - AlgorithmIdentifierException,CipherException
Exceptions introduced - IOException,CertificateEncodingException, NoSuchAlgorithmException,BadPaddingException, IllegalBlockSizeException,NoSuchPaddingException
recipientKey - The private key of the recipient.recipientCert - The X509 certificate of the recipient.java.security.NoSuchAlgorithmException - The content encryption algorithm is not supported.java.security.InvalidKeyException - The private key is not valid.javax.crypto.BadPaddingException - Expected padding mechanism not found.javax.crypto.IllegalBlockSizeException - Data not multiple of the block sizejavax.crypto.NoSuchPaddingException - Requested Padding Mechanism not supportedoracle.security.crypto.util.InvalidInputException - The message content type is incorrect.MessagingException - An error occurred while setting the decrypted content.UnknownRecipientException - The key pair does not belong to message recipient.java.security.cert.CertificateEncodingException - Specifies an encoding errorjava.io.IOException - Input/Output Exception while instantiating X509 from an inputstreampublic oracle.security.crypto.core.AlgorithmIdentifier getContentEncryptionAlgID()
public java.util.Enumeration recipients()
Enumeration of CMSRecipientInfo objects.public byte[] getEncryptedContent()
public java.lang.String generateContentType(boolean useStandardContentTypes)
generateContentType in interface SmimeObjectuseStandardContentTypes - If true the standard content type is generated; If false the experimental content type is generated.public java.lang.String generateContentType()
generateContentType in interface SmimeObject
public void addRecipient(java.security.cert.X509Certificate cert)
                  throws java.security.NoSuchAlgorithmException,
                         javax.crypto.IllegalBlockSizeException,
                         javax.crypto.BadPaddingException,
                         javax.crypto.NoSuchPaddingException,
                         java.security.InvalidKeyException,
                         java.security.cert.CertificateEncodingException,
                         java.io.IOException
cert - The X509 public key certificate.
Note the changes in the method signature
Previously : public void addRecipient (X509)
Now : public void addRecipient (X509Certificate )
Note the changes in the exceptions
Exceptions no longer thrown - AlgorithmIdentifierException,CipherException
Exceptions introduced - IOException,CertificateEncodingException, NoSuchAlgorithmException, IllegalBlockSizeException,BadPaddingException,NoSuchPaddingException
java.security.NoSuchAlgorithmException - The content encryption algorithm is not supported.javax.crypto.BadPaddingException - Expected padding mechanism not found.javax.crypto.IllegalBlockSizeException - Data not multiple of the block sizejavax.crypto.NoSuchPaddingException - Requested Padding Mechanism not supportedjava.security.cert.CertificateEncodingException - Specifies an encoding errorjava.io.IOException - Input/Output Exception while instantiating X509 rom an inputstreamjava.security.InvalidKeyException - The key is invalid
public void addRecipient(java.security.cert.X509Certificate cert,
                         oracle.security.crypto.core.AlgorithmIdentifier keyEncryptionAlgID)
                  throws java.security.NoSuchAlgorithmException,
                         javax.crypto.NoSuchPaddingException,
                         javax.crypto.IllegalBlockSizeException,
                         javax.crypto.BadPaddingException,
                         java.security.InvalidKeyException,
                         java.security.cert.CertificateEncodingException,
                         java.io.IOException
Note the changes in the method signature
Previously : public void addRecipient (X509 ,AlgorithmIdentifier)
Now : public void addRecipient (X509Certificate ,AlgorithmIdentifier)
Note the changes in the exceptions
Exceptions no longer thrown - AlgorithmIdentifierException,CipherException
Exceptions introduced - IOException,CertificateEncodingException, NoSuchAlgorithmException, NoSuchPaddingException,IllegalBlockSizeException,BadPaddingException
cert - The X509 public key certificate.keyEncryptionAlgID - The key transport algorithm.java.security.NoSuchAlgorithmException - The content encryption algorithm is not supported.javax.crypto.BadPaddingException - Expected padding mechanism not found.javax.crypto.IllegalBlockSizeException - Data not multiple of the block sizejavax.crypto.NoSuchPaddingException - Requested Padding Mechanism not supportedjava.security.InvalidKeyException - Invalid key for encryptionjava.security.cert.CertificateEncodingException - Specifies an encoding errorjava.io.IOException - Input/Output Exception while instantiating X509 from an inputstream
public void writeTo(java.io.OutputStream os,
                    java.lang.String mimeType)
             throws java.io.IOException,
                    MessagingException
SmimeEnveloped to the given output stream. Relevant canonicalizations, such as transforming text line-breaks to CRLF, are applied.writeTo in interface SmimeObjectos - The output stream to which this SmimeEnveloped will be written.mimeType - Ignored.java.io.IOException - An I/O error occurred.MessagingException - An error occurred while creating the smime message.