FileDocCategorySizeDatePackage
InitJCE.javaAPI DocApache James 2.3.13626Fri Jan 12 12:56:26 GMT 2007org.apache.james.security

InitJCE

public class InitJCE extends Object
Security Providers initialization class. The first call of the init method will have the class loader do the job. This technique ensures proper initialization without the need of maintaining the ${java_home}/lib/security/java.security file, that would otherwise need the addition of the following line: security.provider.n=org.bouncycastle.jce.provider.BouncyCastleProvider. The call also registers to the javamail's MailcapCommandMap the content handlers that are needed to work with s/mime mails.

Fields Summary
private static String
bouncyCastleProviderClassName
private static boolean
initialized
Constructors Summary
Methods Summary
public static voidinit()
Method that registers the security provider BouncyCastle as a system security provider. The provider class is dinamically loaded on runtime so there is no need to include the bouncycastle jar in the James distribution. It can be downloaded and installed by the user if she needs it.


                                                                
            
        if (!initialized) {
            Security.addProvider((Provider)Class.forName(bouncyCastleProviderClassName).newInstance());
            
            MailcapCommandMap mailcap = (MailcapCommandMap) CommandMap.getDefaultCommandMap();

            mailcap.addMailcap("application/pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_signature");
            mailcap.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
            mailcap.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_signature");
            mailcap.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
            mailcap.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");

            CommandMap.setDefaultCommandMap(mailcap);
            
            initialized = true;
        } else return;