|
IAIK CMS/SMIME Toolkit API Documentation
Version 6.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectiaik.smime.PKCS10Content
public class PKCS10Content
This class can be used to create S/MIME application/pkcs10 emails in combination with the javax.mail package.
S/MIMEv2 (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 handling MIME messages, consult the JavaMail specification.
For using the IAIK-CMS S/MIME library, you also will need the following packages:
iaik_jce(_full).jar (IAIK-JCE Core Crypto Library).
iaik_eccelerate.jar (IAIK ECC Library; if you want to use Elliptic Curve Cryptography).
mail.jar (JavaMail API).
activation.jar (Java Activation Framework; required for JDK versions < 1.6).
# # IAIK 'mailcap' file entries # multipart/signed;; x-java-content-handler=iaik.smime.signed_content application/x-pkcs7-signature;; x-java-content-handler=iaik.smime.signed_content application/x-pkcs7-mime;; x-java-content-handler=iaik.smime.encrypted_content application/x-pkcs10;; x-java-content-handler=iaik.smime.pkcs10_content application/pkcs7-signature;; x-java-content-handler=iaik.smime.signed_content application/pkcs7-mime;; x-java-content-handler=iaik.smime.encrypted_content application/pkcs10;; x-java-content-handler=iaik.smime.pkcs10_contentThe content handlers are registered by copying the mailcap file into the lib directory of your JDK (<JDK-HOME>/lib). Alternatively you may register the IAIK-S/MIME mailcap file dynamically by using the default command map:
String mailcapFileName = ...; MailcapCommandMap mc = new MailcapCommandMap(mailcapFileName); CommandMap.setDefaultCommandMap(mc);Or you may add the IAIK mailcap entries to the default mailcap command map, e.g.:
MailcapCommandMap mc = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
mc.addMailcap("multipart/signed;; x-java-content-handler=iaik.smime.signed_content");
mc.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=iaik.smime.signed_content");
mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=iaik.smime.encrypted_content");
mc.addMailcap("application/pkcs7-signature;; x-java-content-handler=iaik.smime.signed_content");
mc.addMailcap("application/pkcs7-mime;; x-java-content-handler=iaik.smime.encrypted_content");
mc.addMailcap("application/x-pkcs10;; x-java-content-handler=iaik.smime.pkcs10_content");
mc.addMailcap("application/pkcs10;; x-java-content-handler=iaik.smime.pkcs10_content");
CommandMap.setDefaultCommandMap(mc);
For a more detailed description of mailcap handling consult the Javadoc of the Activation
Framework.
When creating a new PKCS10Content to be sent per default the new S/MIME content type
application/pkcs10 is used. For using the old type (application/x-pkcs10)
call the static useNewContentTypes method of the SMimeParameters class before creating a new PKCS10Content
object, e.g.:
//switch to old content types SMimeParameters.useNewContentTypes(false); //create a PKCS10Content PKCS10Content pkcs10 = new PKCS10Content(); ...
| Constructor Summary | |
|---|---|
PKCS10Content()
Creates a new PKCS10Content object. |
|
PKCS10Content(javax.activation.DataSource dataSource)
Constructs a PKCS10Content object from the given data source. |
|
| Method Summary | |
|---|---|
iaik.pkcs.pkcs10.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(iaik.pkcs.pkcs10.CertificateRequest request)
Sets the PKCS#10 request for this PKCS10Content. |
void |
setHeaders(javax.mail.Part part)
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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(javax.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 the
JavaBeans Activation Framework (JAF) sepecification.
dataSource - the DataSource supplying the request
java.io.IOException - if an I/O error occurs during reading the object| Method Detail |
|---|
public java.lang.String getContentType()
MimeMessage msg = ...; PKCS10Content pkcs10 = new PKCS10Content(); ... msg.setContent(pkcs10, pkcs10.getContentType()); ...
public void setCertRequest(iaik.pkcs.pkcs10.CertificateRequest request)
request - the PKCS#10 certificate request to be sentpublic iaik.pkcs.pkcs10.CertificateRequest getCertRequest()
public void setHeaders(javax.mail.Part part)
Content-Disposition: attachment";
filename="smime.p10"
Content-Transfer-Encoding: base64
part - the Part to which to add the headers
public void writeTo(java.io.OutputStream os)
throws java.io.IOException,
javax.mail.MessagingException
os - the output stream
java.io.IOException - if an error occurs writing to the stream
javax.mail.MessagingException - if an error occurs when fetching the data to be written
|
IAIK CMS/SMIME Toolkit API Documentation
Version 6.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
|
v6.1 (c) 2002 IAIK, (c) 2003 - 2025 SIC |
|