org.bouncycastle.mail.smime.MailcapUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcmail-jdk14 Show documentation
Show all versions of bcmail-jdk14 Show documentation
The Bouncy Castle Java S/MIME APIs for handling S/MIME protocols. This jar contains S/MIME APIs for JDK 1.4. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs. The JavaMail API and the Java activation framework will also be needed.
The newest version!
package org.bouncycastle.mail.smime;
import javax.activation.CommandInfo;
import javax.activation.MailcapCommandMap;
class MailcapUtil
{
static MailcapCommandMap addCommands(MailcapCommandMap mc)
{
CommandInfo[] commands = mc.getAllCommands("application/pkcs7-signature");
boolean bcFound = false;
for (int i = 0; i != commands.length; i++)
{
if ("org.bouncycastle.mail.smime.handlers.pkcs7_signature".equals(commands[i].getCommandClass()))
{
bcFound = true;
break;
}
}
// only call add if we're not there already.
if (!bcFound)
{
mc.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature");
mc.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
mc.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature");
mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
mc.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");
}
return mc;
}
}