mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
@Override public void stop(BundleContext bundleContext) throws Exception { super.stop(bundleContext); CommandMap.setDefaultCommandMap(null); }
private void rebuildCommandMap() { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); OsgiMailcapCommandMap commandMap = new OsgiMailcapCommandMap(); for (MailCap mailcap : mailcaps.values()) { for (String line : mailcap.lines) { commandMap.addMailcap(line, mailcap.bundle); } } CommandMap.setDefaultCommandMap(commandMap); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
/** * Rebuild a new default command map after a change in * the status of bundles providing command maps. */ private void rebuildCommandMap() { MailcapCommandMap commandMap = new MailcapCommandMap(); for (URL url : mailCaps.values()) { try { InputStream is = url.openStream(); try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { commandMap.addMailcap(line); } } finally { is.close(); } } catch (Exception e) { // Ignore } } // this is our new default command map CommandMap.setDefaultCommandMap(commandMap); } }
/** * Rebuild a new default command map after a change in * the status of bundles providing command maps. */ private void rebuildCommandMap() { MailcapCommandMap commandMap = new MailcapCommandMap(); for (URL url : mailCaps.values()) { try { InputStream is = url.openStream(); try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { commandMap.addMailcap(line); } } finally { is.close(); } } catch (Exception e) { // Ignore } } // this is our new default command map CommandMap.setDefaultCommandMap(commandMap); } }
/** * Rebuild a new default command map after a change in * the status of bundles providing command maps. */ private void rebuildCommandMap() { MailcapCommandMap commandMap = new MailcapCommandMap(); for (URL url : mailCaps.values()) { try { InputStream is = url.openStream(); try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { commandMap.addMailcap(line); } } finally { is.close(); } } catch (Exception e) { // Ignore } } // this is our new default command map CommandMap.setDefaultCommandMap(commandMap); } }
/** * Adds a group of content handlers to the Mailcap <code>CommandMap</code>. These handlers are * used by the JavaMail API to encode and decode information of specific mime types. * * @throws OpenAS2Exception If an error occurs while initializing mime types */ private void initJavaMail() throws OpenAS2Exception { MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap( AS2Standards.DISPOSITION_TYPE + ";; x-java-content-handler=org.openas2.lib.util.javamail.DispositionDataContentHandler"); CommandMap.setDefaultCommandMap(mc); }
/** * 初始化。它在设置好用户名、密码、发件人、收件人、主题、正文、主机及端口号之后显示调用。 */ public void init() { multipart = new MimeMultipart(); //发送附件时有时候会报java-mail的Error, eg:javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/related;所以务必添加以下几行代码来确定DCH MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc); props = new Properties(); props.put("mail.smtp.host", host); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", port); props.put("mail.smtp.socketFactory.port", port); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); }
/** * Constructor */ public AS2Session () { /* * Adds a group of content handlers to the Mailcap <code>CommandMap</code>. * These handlers are used by the JavaMail API to encode and decode * information of specific mime types. */ final MailcapCommandMap aCommandMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap (); aCommandMap.addMailcap ("message/disposition-notification;; x-java-content-handler=" + DispositionDataContentHandler.class.getName ()); AccessControllerHelper.run ( () -> { CommandMap.setDefaultCommandMap (aCommandMap); return null; }); }
public BCCryptoHelper () { final MailcapCommandMap aCommandMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap (); aCommandMap.addMailcap ("application/pkcs7-signature;; x-java-content-handler=" + org.bouncycastle.mail.smime.handlers.pkcs7_signature.class.getName ()); aCommandMap.addMailcap ("application/pkcs7-mime;; x-java-content-handler=" + org.bouncycastle.mail.smime.handlers.pkcs7_mime.class.getName ()); aCommandMap.addMailcap ("application/x-pkcs7-signature;; x-java-content-handler=" + org.bouncycastle.mail.smime.handlers.x_pkcs7_signature.class.getName ()); aCommandMap.addMailcap ("application/x-pkcs7-mime;; x-java-content-handler=" + org.bouncycastle.mail.smime.handlers.x_pkcs7_mime.class.getName ()); aCommandMap.addMailcap ("multipart/signed;; x-java-content-handler=" + org.bouncycastle.mail.smime.handlers.multipart_signed.class.getName ()); AccessControllerHelper.run ( () -> { CommandMap.setDefaultCommandMap (aCommandMap); return null; }); }
public void initialize() { Security.addProvider(new BouncyCastleProvider()); MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); 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"); CommandMap.setDefaultCommandMap(mc); }
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
/** * 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. */ public static void init() throws InstantiationException, IllegalAccessException, ClassNotFoundException { if (!initialized) { String bouncyCastleProviderClassName = "org.bouncycastle.jce.provider.BouncyCastleProvider"; 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; } } }
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc);
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc); message.setText(htmlBody); message.setContent(textBody, "text/html");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mc); message.setText(htmlBody); message.setContent(textBody, "text/html");