public class SMimeParameters
extends java.lang.Object
useNewContentTypes(boolean newType).
Calling this method only is meaningful when creating
a new message.
If newType is set to false the old types
are used (application/x-pkcs7-signature respectively application/x-pkcs7-mime).
If newType is set to false the new types
are used (application/pkcs7-signature respectively application/pkcs7-mime).
Per default the eold types are used.
For changing the types, useNewContentTypes has to be called
before creating a SignedContent
or EncryptedContent object, e.g.:
//switch to new content types SMimeParameters.useNewContentTypes(true); //create a SignedContent boolean implicit = ...; SignedContent sc = new SignedContent(implicit, SignedContent.SIGNED_DATA);For telling JAF the data content handlers for the supported S/MIME types, a RFC1524 mailcap file with the following contents has to be put in the lib directory of your JDK (
# 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_content
The class provides the ability to control the SMIME canonicalization scheme.
The SMIME canonicalization scheme can be set globally using
setCanonicalizer(Canonicalizer), and on a per thread basis using
registerCanonicalizer(Canonicalizer). When a canonicalization
scheme has been registered for a given thread, that scheme is used. When a
canonicalization scheme has not been registered for a given thread, the
global canonicalization scheme is used.
By default, the global canonicalization scheme is set. This scheme is
defined in DefaultCanonicalizer; it ensures that
<CR> and <LF> always occurs together as <CR><LF>
except when binary content transfer encoding is used.
Note that for outging messages the canonicalization scheme is only used when
modelling body parts and multiparts using classes
SMimeBodyPart and
SMimeMultipart, or when supplying a text message
by means of method setText for a multipart/signed
SignedContent object. When parsing an incoming
message the canonicalization scheme is only used for the contents part of a
multipart/signed message.
| Modifier and Type | Method and Description |
|---|---|
static void |
deregisterCanonicalizer()
Deregisters the SMIME canonicalization scheme for the current thread of
execution.
|
static boolean |
getNewContentTypes()
Returns whether new or old content types are used when creating a new
S/Mime message.
|
static void |
registerCanonicalizer(Canonicalizer canonicalizer)
Registers an SMIME canonicalization scheme for the current thread of
execution.
|
static void |
setCanonicalizer(Canonicalizer canonicalizer)
Sets the global SMIME canonicalization scheme.
|
static void |
useNewContentTypes(boolean newType)
Decides whether to use old or new S/MIME content types.
|
public static void useNewContentTypes(boolean newType)
newType is set to false the old types
are used (application/x-pkcs7-signature respectively application/x-pkcs7-mime).
If newType is set to false the new types
are used (application/pkcs7-signature respectively application/pkcs7-mime).
Per default the eold types are used.
newType - true for using new types, false if notpublic static boolean getNewContentTypes()
true if new types (application/pkcs7-signature respectively
application/pkcs7-mime), and false if the old types
(application/x-pkcs7-signature respectively application/x-pkcs7-mime) are
usedpublic static void setCanonicalizer(Canonicalizer canonicalizer)
canonicalizer - the SMIME canonicalization schemepublic static void registerCanonicalizer(Canonicalizer canonicalizer)
Only call this method if you wish to use a canonicalization scheme other
than the default DefaultCanonicalizer.
The registered canonicalization scheme will be used for all canonicalization required during SMIME operations done by the current thread of execution.
canonicalizer - the SMIME canonicalization schemepublic static void deregisterCanonicalizer()
This should be called when the current thread of execution has a registered SMIME canonicalization scheme, but no longer needs to perform any SMIME operations. It simply reclaims the space in the internal registration table; it is good practice to use this API, but not essential.
canonicalizer - the SMIME canonicalization scheme