public class PKCS10Content
extends java.lang.Object
S/MIME (Secure/Multipurpose Internet Mail Extensions) specifies the application/pkcs10 type for providing a format for sending a PKCS#10 certification request to a certification authority.
When using this class for creating a application/pkcs10 message, first use the
class iaik.pkcs.pkcs10.CertificateRequest of IAIK-JCE for creating the request, and
subsequently incorporate it into the PKCS#10 message by means of the setCertRequest method, e.g.:
// create or load a PKCS#10 request: CertificateRequest request = ...; // create a new PKCS10Content: PKCS10Content pkcs10 = new PKCS10Content(); // set the request: pkcs10.setCertRequest(request); // prepare for sending and send: MimeMessage msg = new MimeMessage(session); ... // set the content msg.setContent(pkcs10, pkcs10.getContentType()); // let the PKCS10Content update some message headers pkcs10.setHeaders(msg); Transport.send(msg);For more information about the JavaMail architecture, and how to parsing messages, consult Sun´s JavaMail specification.
For using the IAIK-JCE S/MIME classes, an application also may need the packages:
# Default mailcap file for the JavaMail System # # for our content-handlers # text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed message/*;; x-java-content-handler=com.sun.mail.handlers.message_rfc822 # # IAIK 'mailcap' file # multipart/signed;; x-java-content-handler=iaik.security.smime.signed_content application/x-pkcs7-signature;; x-java-content-handler=iaik.security.smime.signed_content application/x-pkcs7-mime;; x-java-content-handler=iaik.security.smime.encrypted_content application/x-pkcs10;; x-java-content-handler=iaik.security.smime.pkcs10_content application/pkcs7-signature;; x-java-content-handler=iaik.security.smime.signed_content application/pkcs7-mime;; x-java-content-handler=iaik.security.smime.encrypted_content application/pkcs10;; x-java-content-handler=iaik.security.smime.pkcs10_contentWhen creating a new PKCS10Content to be sent per default the old S/MIME content type application/x-pkcs10 is used. For using the new type application/pkcs10 call the static
useNewContentTypes method of the SMimeParameters class before creating a new PKCS10Content
object, e.g.:
//switch to new content types SMimeParameters.useNewContentTypes(true); //create a SignedContent PKCS10Content pkcs10 = new PKCS10Content(); ...
| Constructor and Description |
|---|
PKCS10Content()
Creates a new PKCS10Content object.
|
PKCS10Content(jakarta.activation.DataSource dataSource)
Constructs a PKCS10Content object from the given data source.
|
| Modifier and Type | Method and Description |
|---|---|
CertificateRequest |
getCertRequest()
Returns the PKCS#10 request sent with this message.
|
java.lang.String |
getContentType()
Returns the ContentType and any attached parameters of this PKCS10 content.
|
void |
setCertRequest(CertificateRequest request)
Sets the PKCS#10 request for this PKCS10Content.
|
void |
setHeaders(jakarta.mail.Message message)
Sets additional headers of the message containing this PKCS10Content.
|
void |
writeTo(java.io.OutputStream os)
Writes this PKCS10Content DER encoded to the given output stream.
|
public PKCS10Content()
Use the setCertRequest method
for specifying a certificate request, e.g.:
// create or load a PKCS#10 request: CertificateRequest request = ...; // create a new PKCS10Content: PKCS10Content pkcs10 = new PKCS10Content(); // set the request: pkcs10.setCertRequest(request); // prepare for sending and send: MimeMessage msg = new MimeMessage(session); ... // set the content msg.setContent(pkcs10, pkcs10.getContentType()); // let the PKCS10Content update some message headers pkcs10.setHeaders(msg); Transport.send(msg);
public PKCS10Content(jakarta.activation.DataSource dataSource)
throws java.io.IOException
pkcs10_content supplying the data
source.
For more information on data handling using the
javax.activation.DataSource for "MIME type based" data
access, see Sun´s
JavaBeans Activation Framework (JAF) sepecification.
dataSource - the DataSource supplying the requestjava.io.IOException - if an I/O error occurs during reading the objectpublic java.lang.String getContentType()
MimeMessage msg = ...; PKCS10Content pkcs10 = new PKCS10Content(); ... msg.setContent(pkcs10, pkcs10.getContentType()); ...
public void setCertRequest(CertificateRequest request)
request - the PKCS#10 certificate request to be sentpublic CertificateRequest getCertRequest()
public void setHeaders(jakarta.mail.Message message)
Content-Disposition: attachment";
filename="smime.p10"
Content-Transfer-Encoding: base64
message - message to add the headerspublic void writeTo(java.io.OutputStream os)
throws java.io.IOException,
jakarta.mail.MessagingException
java.io.IOException - if an error occurs writing to the streamjakarta.mail.MessagingException - if an error occurs when fetching the data to be written