List of usage examples for javax.mail MessagingException MessagingException
public MessagingException(String s)
From source file:de.micromata.genome.gwiki.model.GWikiStandardEmailProvider.java
private void setHeaders(GWikiMailHelper helper, Map<String, String> mth) throws MessagingException { String to = mth.get(TO);//from ww w .ja v a2s .c o m if (to == null) { throw new MessagingException("No recipient given"); } helper.setTo(to); if (mth.containsKey(FROM)) { helper.setFrom(mth.get(FROM)); } if (mth.containsKey(SUBJECT)) { helper.setSubject(mth.get(SUBJECT)); } String cc = mth.get(CC); if (cc != null) { helper.setCc(cc); } String bcc = mth.get(BCC); if (bcc != null) { helper.setBcc(bcc); } }
From source file:mitm.application.djigzo.james.mailets.DKIMVerify.java
@Override protected void initMailet() throws MessagingException { dkimHeader = getInitParameter(Parameter.DKIM_HEADER.name, DKIMCommon.DEFAULT_DKIM_HEADER); resultMailAttribute = StringUtils.trimToNull(getInitParameter(Parameter.RESULT_MAIL_ATTRIBUTE.name)); if (resultMailAttribute == null) { throw new MessagingException("resultAttribute is missing."); }// ww w .ja v a2 s.co m loadPublicKey(); }
From source file:com.canoo.webtest.plugins.emailtest.EmailMessageContentFilter.java
private void extractSimpleMessage(final String content, final int partIndex) throws MessagingException { final ByteArrayInputStream byteStream = new ByteArrayInputStream(getRawBytes(content, partIndex)); final byte[] data; try {/*from ww w . j a va 2s .c om*/ final UUDecoder uudc = new UUDecoder(); data = uudc.decodeBuffer(byteStream); } catch (IOException e) { throw new MessagingException("Error Uudecoding attachment: " + e.getMessage()); } if (StringUtils.isEmpty(fContentType)) { throw new StepFailedException("Attribute 'contentType' must be supplied for simple messages.", this); } defineAsCurrentResponse(data, getContentType()); }
From source file:mitm.application.djigzo.james.matchers.SenderHeaderTrigger.java
@Override public void init() throws MessagingException { getLogger().info("Initializing matcher: " + getMatcherName()); property = getCondition();/* ww w . jav a 2s . com*/ if (StringUtils.isBlank(property)) { throw new MessagingException("property condition is missing."); } sessionManager = SystemServices.getSessionManager(); userWorkflow = SystemServices.getUserWorkflow(); messageOriginatorIdentifier = SystemServices.getMessageOriginatorIdentifier(); actionExecutor = DatabaseActionExecutorBuilder.createDatabaseActionExecutor(sessionManager); assert (actionExecutor != null); }
From source file:com.sun.mail.pop3.POP3Folder.java
/** * Always throws <code>MessagingException</code> because no POP3 folders * can contain subfolders./*from w w w . j a va 2 s. c om*/ * * @exception MessagingException always */ public Folder getFolder(String name) throws MessagingException { throw new MessagingException("not a directory"); }
From source file:MessageViewer.java
protected Component getBodyComponent() { //------------ // now get a content viewer for the main type... //------------ try {/* w w w.j ava 2s .c o m*/ DataHandler dh = displayed.getDataHandler(); CommandInfo ci = dh.getCommand("view"); if (ci == null) { throw new MessagingException("view command failed on: " + displayed.getContentType()); } Object bean = dh.getBean(ci); if (bean instanceof Component) { return (Component) bean; } else { throw new MessagingException("bean is not a component " + bean.getClass().toString()); } } catch (MessagingException me) { return new Label(me.toString()); } }
From source file:com.duroty.utils.mail.MessageUtilities.java
/** * This wrapper is used to work around a bug in the sun io inside * sun.io.ByteToCharConverter.getConverterClass(). The programmer uses a * cute coding trick that appends the charset to a prefix to create a * Class name that they then attempt to load. The problem is that if the * charset is not one that they "recognize", and the name has something * like a dash character in it, the resulting Class name has an invalid * character in it. This results in an IllegalArgumentException instead of * the UnsupportedEncodingException that is documented. Thus, we need to * catch the undocumented exception.//from w w w. j a v a 2s . c om * * @param dh The DataHandler from which to get the content. * * @return The content. * * @exception MessagingException if the content charset is unsupported. */ public static Object getDataHandlerContent(DataHandler dh) throws MessagingException { Object result = null; try { result = dh.getContent(); } catch (IllegalArgumentException ex) { throw new MessagingException("content charset is not recognized: " + ex.getMessage()); } catch (IOException ex) { throw new MessagingException("getDataHandlerContent(): " + ex.getMessage()); } return result; }
From source file:mitm.application.djigzo.james.mailets.OTPPasswordGenerator.java
@Override protected String generatePassword(User user, int passwordLength, String passwordID) throws MessagingException { try {/*from www . ja v a 2 s. c o m*/ ActivationContext activationContext = getActivationContext().get(ACTIVATION_CONTEXT_KEY, ActivationContext.class); /* * Check if a collection of client secrets is stored in the context */ ClientSecrets clientSecrets = (ClientSecrets) activationContext.getTag(); if (clientSecrets == null) { /* * Check if the Mail object contains a collection of Client secrets and if so use it */ clientSecrets = new DjigzoMailAttributesImpl(activationContext.getMail()).getClientSecrets(); if (clientSecrets != null) { /* * The Mail object contains a collection of client secrets. Store it in the context * so we can reuse it for the next user */ activationContext.setTag(clientSecrets); } } String clientSecret = null; if (clientSecrets != null) { EncryptedContainer<String> encryptedSecret = clientSecrets.get(user.getEmail()); if (encryptedSecret != null) { clientSecret = encryptedSecret.get(); } } /* * If the client secret for the user was not found in the Mail attributes, * check if it the user properties contain a client secret */ if (StringUtils.isEmpty(clientSecret)) { clientSecret = user.getUserPreferences().getProperties().getClientSecret(); } /* * If the user properties do not contain a client secret for the user use the default secret */ if (StringUtils.isEmpty(clientSecret)) { clientSecret = defaultSecret; } if (clientSecret == null) { throw new MessagingException("No client secret found for user " + user.getEmail()); } return otpGenerator.generate(clientSecret.getBytes(encoding), passwordID.getBytes(encoding), passwordLength); } catch (HierarchicalPropertiesException e) { throw new MessagingException("Error generating OTP password", e); } catch (UnsupportedEncodingException e) { throw new MessagingException("Error generating password. Unsupported encoding", e); } catch (OTPException e) { throw new MessagingException("Error generating OTP password", e); } }
From source file:mitm.application.djigzo.james.mailets.BlackberrySMIMEAdapter.java
private Part findAttachment(MimeMessage containerMessage) throws MessagingException, IOException, PartException { final MutableObject smimePart = new MutableObject(); final MutableObject octetPart = new MutableObject(); PartListener partListener = new PartScanner.PartListener() { @Override/*from ww w. j ava 2 s. c o m*/ public boolean onPart(Part parent, Part part, Object context) throws PartException { try { if (ArrayUtils.contains(part.getHeader(DjigzoHeader.MARKER), DjigzoHeader.ATTACHMENT_MARKER_VALUE)) { smimePart.setValue(part); /* * we found the part with the marker so we can stop scanning */ return false; } /* * Fallback scanning for octet-stream in case the template does not contain a DjigzoHeader.MARKER */ if (part.isMimeType("application/octet-stream")) { octetPart.setValue(part); } return true; } catch (MessagingException e) { throw new PartException(e); } } }; PartScanner partScanner = new PartScanner(partListener, MAX_DEPTH); partScanner.scanPart(containerMessage); Part result = (Part) smimePart.getValue(); if (result == null) { result = (Part) octetPart.getValue(); if (result != null) { logger.debug("Marker not found. Using octet-stream instead."); } else { throw new MessagingException("Unable to find the attachment part in the template."); } } return result; }
From source file:com.linagora.james.mailets.GuessClassificationMailet.java
private Optional<Integer> parseTimeout() throws MessagingException { try {// w w w .ja v a 2 s. c o m Optional<Integer> result = Optional.ofNullable(getInitParameter(TIMEOUT_IN_MS)).map(Integer::valueOf); if (result.filter(value -> value < 1).isPresent()) { throw new MessagingException("Non strictly positive timeout for " + TIMEOUT_IN_MS + ". Got " + getInitParameter(TIMEOUT_IN_MS)); } return result; } catch (NumberFormatException e) { throw new MessagingException("Expecting " + TIMEOUT_IN_MS + " to be a strictly positive integer. Got " + getInitParameter(TIMEOUT_IN_MS)); } }