@Override protected PasswordAuthentication getPasswordAuthentication() { if (m_config.getUserAuth() != null) { final UserAuth userAuth = m_config.getUserAuth(); return new PasswordAuthentication(userAuth.getUserName(), userAuth.getPassword()); } LOG.debug("No user authentication configured."); return new PasswordAuthentication(null,null); } };
userAuth.setUserName(PropertiesUtils.getProperty(props, "org.opennms.core.utils.authenticateUser", userAuth.getUserName())); userAuth.setPassword(PropertiesUtils.getProperty(props, "org.opennms.core.utils.authenticatePassword", userAuth.getPassword()));
props.put("mail." + protocol + ".user", userAuth.getUserName()); props.put("mail." + protocol + ".port", readmailHost.getPort()); props.put("mail." + protocol + ".starttls.enable", readmailHost.getReadmailProtocol().isStartTls());
userAuth.setUserName(PropertiesUtils.getProperty(props, "org.opennms.core.utils.authenticateUser", userAuth.getUserName())); userAuth.setPassword(PropertiesUtils.getProperty(props, "org.opennms.core.utils.authenticatePassword", userAuth.getPassword()));
props.put("mail." + protocol + ".user", userAuth.getUserName()); props.put("mail." + protocol + ".port", readmailHost.getPort()); props.put("mail." + protocol + ".starttls.enable", readmailHost.getReadmailProtocol().isStartTls());
@Override protected PasswordAuthentication getPasswordAuthentication() { if (m_config.getUserAuth() != null) { final UserAuth userAuth = m_config.getUserAuth(); return new PasswordAuthentication(userAuth.getUserName(), userAuth.getPassword()); } LOG.debug("No user authentication configured."); return new PasswordAuthentication(null,null); } };
/** * <p>Constructor for JavaReadMailer.</p> * * @param config a {@link org.opennms.netmgt.config.javamail.ReadmailConfig} object. * @param closeOnDelete a {@link java.lang.Boolean} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public JavaReadMailer(final ReadmailConfig config, Boolean closeOnDelete) throws JavaMailerException { if (closeOnDelete != null) { m_deleteOnClose = closeOnDelete; } m_config = config; final UserAuth userAuth = getUserAuth(config); m_session = Session.getInstance(configureProperties(), createAuthenticator(userAuth.getUserName(), userAuth.getPassword())); }
/** * <p>Constructor for JavaReadMailer.</p> * * @param config a {@link org.opennms.netmgt.config.javamail.ReadmailConfig} object. * @param closeOnDelete a {@link java.lang.Boolean} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public JavaReadMailer(final ReadmailConfig config, Boolean closeOnDelete) throws JavaMailerException { if (closeOnDelete != null) { m_deleteOnClose = closeOnDelete; } m_config = config; final UserAuth userAuth = getUserAuth(config); m_session = Session.getInstance(configureProperties(), createAuthenticator(userAuth.getUserName(), userAuth.getPassword())); }
final ReadmailHost readmailHost = readMailConfig.getReadmailHost(); final UserAuth userAuth = readMailConfig.getUserAuth(); LOG.debug("retrieveAckMessages: creating JavaReadMailer with config: host: {} port: {} ssl: {} transport: {} user: {} password: {}", readmailHost.getHost(), readmailHost.getPort(), readmailHost.getReadmailProtocol().isSslEnable(), readmailHost.getReadmailProtocol().getTransport(), userAuth == null? null : userAuth.getUserName(), userAuth == null? null : userAuth.getPassword());
LOG.debug("authenticating to {}", sendmailHost.getHost()); final UserAuth userAuth = m_config.getUserAuth(); t.connect(sendmailHost.getHost(), sendmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); } else { LOG.debug("not authenticating to {}", sendmailHost.getHost());
LOG.debug("authenticating to {}", sendmailHost.getHost()); final UserAuth userAuth = m_config.getUserAuth(); t.connect(sendmailHost.getHost(), sendmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); } else { LOG.debug("not authenticating to {}", sendmailHost.getHost());
/** * <p>retrieveMessages</p> * * @return a {@link java.util.List} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public List<Message> retrieveMessages() throws JavaMailerException { Message[] msgs; Folder mailFolder = null; final ReadmailHost readmailHost = getReadmailHost(m_config); final UserAuth userAuth = getUserAuth(m_config); try { m_store = m_session.getStore(readmailHost.getReadmailProtocol().getTransport()); m_store.connect(readmailHost.getHost(), (int)readmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); mailFolder = m_store.getFolder(m_config.getMailFolder()); mailFolder.open(Folder.READ_WRITE); msgs = mailFolder.getMessages(); } catch (NoSuchProviderException e) { throw new JavaMailerException("No provider matching:"+readmailHost.getReadmailProtocol().getTransport()+" from config:"+m_config.getName(), e); } catch (MessagingException e) { throw new JavaMailerException("Problem reading messages from configured mail store", e); } return new ArrayList<Message>(Arrays.asList(msgs)); }
/** * <p>retrieveMessages</p> * * @return a {@link java.util.List} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public List<Message> retrieveMessages() throws JavaMailerException { Message[] msgs; Folder mailFolder = null; final ReadmailHost readmailHost = getReadmailHost(m_config); final UserAuth userAuth = getUserAuth(m_config); try { m_store = m_session.getStore(readmailHost.getReadmailProtocol().getTransport()); m_store.connect(readmailHost.getHost(), (int)readmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); mailFolder = m_store.getFolder(m_config.getMailFolder()); mailFolder.open(Folder.READ_WRITE); msgs = mailFolder.getMessages(); } catch (NoSuchProviderException e) { throw new JavaMailerException("No provider matching:"+readmailHost.getReadmailProtocol().getTransport()+" from config:"+m_config.getName(), e); } catch (MessagingException e) { throw new JavaMailerException("Problem reading messages from configured mail store", e); } return new ArrayList<Message>(Arrays.asList(msgs)); }
/** * <p>retrieveMessages</p> * * @param term a {@link javax.mail.search.SearchTerm} object. * @return a {@link java.util.List} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public List<Message> retrieveMessages(SearchTerm term) throws JavaMailerException { Message[] msgs; Folder mailFolder = null; final ReadmailHost readmailHost = getReadmailHost(m_config); final UserAuth userAuth = getUserAuth(m_config); try { Store store = m_session.getStore(readmailHost.getReadmailProtocol().getTransport()); store.connect(readmailHost.getHost(), (int)readmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); mailFolder = store.getFolder(m_config.getMailFolder()); mailFolder.open(Folder.READ_WRITE); msgs = mailFolder.search(term); } catch (NoSuchProviderException e) { throw new JavaMailerException("No provider matching:"+readmailHost.getReadmailProtocol().getTransport()+" from config:"+m_config.getName(), e); } catch (MessagingException e) { throw new JavaMailerException("Problem reading messages from configured mail store", e); } List<Message> msgList = Arrays.asList(msgs); return msgList; }
/** * <p>retrieveMessages</p> * * @param term a {@link javax.mail.search.SearchTerm} object. * @return a {@link java.util.List} object. * @throws org.opennms.javamail.JavaMailerException if any. */ public List<Message> retrieveMessages(SearchTerm term) throws JavaMailerException { Message[] msgs; Folder mailFolder = null; final ReadmailHost readmailHost = getReadmailHost(m_config); final UserAuth userAuth = getUserAuth(m_config); try { Store store = m_session.getStore(readmailHost.getReadmailProtocol().getTransport()); store.connect(readmailHost.getHost(), (int)readmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword()); mailFolder = store.getFolder(m_config.getMailFolder()); mailFolder.open(Folder.READ_WRITE); msgs = mailFolder.search(term); } catch (NoSuchProviderException e) { throw new JavaMailerException("No provider matching:"+readmailHost.getReadmailProtocol().getTransport()+" from config:"+m_config.getName(), e); } catch (MessagingException e) { throw new JavaMailerException("Problem reading messages from configured mail store", e); } List<Message> msgList = Arrays.asList(msgs); return msgList; }