javax.activation.CommandMap Java Examples
The following examples show how to use
javax.activation.CommandMap.
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 hottub 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: 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 #4
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 #5
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 #6
Source File: AttachmentCallbackHandlerTest.java From cxf with Apache License 2.0 | 6 votes |
private void parseAttachment(String attachmentId) throws Exception { Attachment attachment = new AttachmentImpl(attachmentId); // Mock up a DataHandler for the Attachment DataHandler dataHandler = EasyMock.mock(DataHandler.class); dataHandler.setCommandMap(anyObject(CommandMap.class)); EasyMock.expectLastCall(); EasyMock.expect(dataHandler.getInputStream()).andReturn(null); EasyMock.expect(dataHandler.getContentType()).andReturn(null); EasyMock.replay(dataHandler); ((AttachmentImpl)attachment).setDataHandler(dataHandler); AttachmentCallbackHandler callbackHandler = new AttachmentCallbackHandler(Collections.singletonList(attachment)); AttachmentRequestCallback attachmentRequestCallback = new AttachmentRequestCallback(); attachmentRequestCallback.setAttachmentId(AttachmentUtils.getAttachmentId("cid:" + attachmentId)); attachmentRequestCallback.setRemoveAttachments(false); callbackHandler.handle(new Callback[]{attachmentRequestCallback}); List<org.apache.wss4j.common.ext.Attachment> attachments = attachmentRequestCallback.getAttachments(); assertNotNull(attachments); assertEquals(1, attachments.size()); EasyMock.verify(dataHandler); }
Example #7
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 #8
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 #9
Source File: GMailSender.java From vocefiscal-android with Apache License 2.0 | 6 votes |
public GMailSender() { 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 #10
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 #11
Source File: MailClient.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Activate private void activate(){ 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"); }
Example #12
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 #13
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 #14
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 #15
Source File: EMailService.java From sailfish-core with Apache License 2.0 | 5 votes |
public EMailService() { this.settings = new EMailServiceSettings(); MailcapCommandMap mailcapCommandMap = new MailcapCommandMap(); mailcapCommandMap.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); mailcapCommandMap.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); mailcapCommandMap.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); mailcapCommandMap.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); mailcapCommandMap.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); CommandMap.setDefaultCommandMap(mailcapCommandMap); }
Example #16
Source File: AttachmentUtil.java From cxf with Apache License 2.0 | 4 votes |
public static CommandMap getCommandMap() { return COMMAND_MAP; }
Example #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
Source File: MailTest.java From jdk8u60 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 #27
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 #28
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); }