Java Code Examples for javax.activation.CommandMap#getDefaultCommandMap()
The following examples show how to use
javax.activation.CommandMap#getDefaultCommandMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BindingImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void initializeJavaActivationHandlers() { // DataHandler.writeTo() may search for DCH. So adding some default ones. try { CommandMap map = CommandMap.getDefaultCommandMap(); if (map instanceof MailcapCommandMap) { MailcapCommandMap mailMap = (MailcapCommandMap) map; // registering our DCH since javamail's DCH doesn't handle if (!cmdMapInitialized(mailMap)) { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); } } } catch (Throwable t) { // ignore the exception. } }
Example 2
Source File: BindingImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void initializeJavaActivationHandlers() { // DataHandler.writeTo() may search for DCH. So adding some default ones. try { CommandMap map = CommandMap.getDefaultCommandMap(); if (map instanceof MailcapCommandMap) { MailcapCommandMap mailMap = (MailcapCommandMap) map; // registering our DCH since javamail's DCH doesn't handle if (!cmdMapInitialized(mailMap)) { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); } } } catch (Throwable t) { // ignore the exception. } }
Example 3
Source File: Mail.java From mobikul-standalone-pos with MIT License | 6 votes |
public Mail() { _host = ApplicationConstants.HOST_FOR_MAIL; // default smtp server _port = "465"; // default smtp port _sport = "587"; // default socketfactory port _user = ""; // username _pass = ""; // password _from = ""; // email sent from _subject = ""; // email subject _body = ""; // email body _debuggable = false; // debug mode on or off - default off _auth = true; // smtp authentication - default on _multipart = new MimeMultipart(); // There is something wrong with MailCap, javamail can not find a handler for the multipart // /mixed part, so this bit needs to be added. 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); }
Example 4
Source File: BindingImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void initializeJavaActivationHandlers() { // DataHandler.writeTo() may search for DCH. So adding some default ones. try { CommandMap map = CommandMap.getDefaultCommandMap(); if (map instanceof MailcapCommandMap) { MailcapCommandMap mailMap = (MailcapCommandMap) map; // registering our DCH since javamail's DCH doesn't handle if (!cmdMapInitialized(mailMap)) { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); } } } catch (Throwable t) { // ignore the exception. } }
Example 5
Source File: BindingImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void initializeJavaActivationHandlers() { // DataHandler.writeTo() may search for DCH. So adding some default ones. try { CommandMap map = CommandMap.getDefaultCommandMap(); if (map instanceof MailcapCommandMap) { MailcapCommandMap mailMap = (MailcapCommandMap) map; // registering our DCH since javamail's DCH doesn't handle if (!cmdMapInitialized(mailMap)) { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); } } } catch (Throwable t) { // ignore the exception. } }
Example 6
Source File: BindingImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void initializeJavaActivationHandlers() { // DataHandler.writeTo() may search for DCH. So adding some default ones. try { CommandMap map = CommandMap.getDefaultCommandMap(); if (map instanceof MailcapCommandMap) { MailcapCommandMap mailMap = (MailcapCommandMap) map; // registering our DCH since javamail's DCH doesn't handle if (!cmdMapInitialized(mailMap)) { mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler"); mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler"); mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler"); } } } catch (Throwable t) { // ignore the exception. } }
Example 7
Source File: InitJCE.java From james-project with Apache License 2.0 | 6 votes |
/** * 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; } }
Example 8
Source File: Mail.java From AccelerationAlert with Apache License 2.0 | 5 votes |
public Mail() { _host = "smtp.gmail.com"; // default smtp server _port = "465"; // default smtp port _sport = "465"; // default socketfactory port _user = ""; // username _pass = ""; // password _from = ""; // email sent from _subject = ""; // email subject _body = ""; // email body _debuggable = false; // debug mode on or off - default off _auth = true; // smtp authentication - default on _multipart = new MimeMultipart(); // There is something wrong with MailCap, javamail can not find a // handler for the multipart/mixed part, so this bit needs to be added. 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); }
Example 9
Source File: SendMailTask.java From FlexibleLogin with MIT License | 5 votes |
@Override public void run() { ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try (Transport transport = session.getTransport()) { // Prevent UnsupportedDataTypeException: no object DCH for MIME type multipart/alternative // cf. https://stackoverflow.com/questions/21856211/unsupporteddatatypeexception-no-object-dch-for-mime-type Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mc.addMailcap("text/html;; x-java-content-handler=flexiblelogin.mail.handlers.text_html"); mc.addMailcap("text/xml;; x-java-content-handler=flexiblelogin.mail.handlers.text_xml"); mc.addMailcap("text/plain;; x-java-content-handler=flexiblelogin.mail.handlers.text_plain"); mc.addMailcap("multipart/*;; x-java-content-handler=flexiblelogin.mail.handlers.multipart_mixed"); mc.addMailcap("message/rfc822;; x-java-content- handler=flexiblelogin.mail.handlers.message_rfc822"); MailConfig mailConfig = plugin.getConfigManager().getGeneral().getMail(); //connect to host and send message if (!transport.isConnected()) { String password = mailConfig.getPassword(); transport.connect(mailConfig.getHost(), mailConfig.getAccount(), password); } transport.sendMessage(mail, mail.getAllRecipients()); player.sendMessage(plugin.getConfigManager().getText().getMailSent()); } catch (NoSuchProviderException providerEx) { plugin.getLogger().error("Transport provider not found", providerEx); plugin.getLogger().error("Registered providers: {}", Arrays.asList(session.getProviders())); player.sendMessage(plugin.getConfigManager().getText().getErrorExecutingCommand()); } catch (MessagingException messagingEx) { plugin.getLogger().error("Error sending mail", messagingEx); player.sendMessage(plugin.getConfigManager().getText().getErrorExecutingCommand()); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } }
Example 10
Source File: BCCryptoHelper.java From OpenAs2App with BSD 2-Clause "Simplified" License | 5 votes |
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); }
Example 11
Source File: MailTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 12
Source File: MailTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 13
Source File: MailTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 14
Source File: MailTest.java From hottub with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 15
Source File: MailTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 16
Source File: MailTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 17
Source File: MailTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 18
Source File: MailTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 19
Source File: MailTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static void workaroundJAFSetup() { MailcapCommandMap mailMap = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); mailMap.addMailcap("multipart/mixed;;x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); }
Example 20
Source File: BaseSession.java From OpenAs2App with BSD 2-Clause "Simplified" License | 2 votes |
/** * 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); }