|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.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 (
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 | |
---|---|
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(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 objectMethod Detail |
---|
public 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(javax.mail.Part part)
Content-Disposition: attachment"; filename="smime.p10" Content-Transfer-Encoding: base64
part
- the Part to which to add the headerspublic void writeTo(java.io.OutputStream os) throws java.io.IOException, javax.mail.MessagingException
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
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |