Refine search
this.session = Session.getInstance( this.prop, null ); this.session.setDebug( log.isDebug() ); if ( this.port == -1 ) { this.port = ? MailConnectionMeta.DEFAULT_SSL_POP3_PORT : MailConnectionMeta.DEFAULT_SSL_IMAP_PORT ); URLName url = new URLName( protocolString, server, port, "", username, password ); this.store = ( protocol == MailConnectionMeta.PROTOCOL_POP3 ) url = null; } else { this.session = Session.getInstance( this.prop, null ); this.session.setDebug( log.isDebug() ); if ( protocol == MailConnectionMeta.PROTOCOL_MBOX ) { this.store = this.session.getStore( new URLName( protocolString + ":" + server ) ); } else { this.store = this.session.getStore( protocolString );
/** * Return a URLName representing this service. The returned URLName * does <em>not</em> include the password field. <p> * * Subclasses should only override this method if their * URLName does not follow the standard format. <p> * * The implementation in the Service class returns (usually a copy of) * the <code>url</code> field with the password and file information * stripped out. * * @return the URLName representing this service * @see URLName */ public URLName getURLName() { URLName url = this.url; // snapshot if (url != null && (url.getPassword() != null || url.getFile() != null)) return new URLName(url.getProtocol(), url.getHost(), url.getPort(), null /* no file */, url.getUsername(), null /* no password */); else return url; }
if ( ( folder.getType() & Folder.HOLDS_MESSAGES ) == 0 ) { throw new KettleException( BaseMessages.getString( PKG, "MailConnection.DefaultFolderCanNotHoldMessage" ) ); this.folder = getRecursiveFolder( foldername ); if ( this.folder == null || !this.folder.exists() ) { throw new KettleException( BaseMessages.getString( PKG, "JobGetMailsFromPOP.InvalidFolder.Label" ) ); PKG, "MailConnection.OpeningFolderInWriteMode.Label", getFolderName() ) ); this.folder.open( Folder.READ_WRITE ); } else { if ( log.isDebug() ) { log.logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.FolderOpened.FullName", this.folder.getFullName() ) ); log.logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.FolderOpened.Url", this.folder.getURLName().toString() ) ); log.logDebug( BaseMessages.getString( PKG, "JobGetMailsFromPOP.FolderOpened.Subscribed", "" + this.folder.isSubscribed() ) );
/** * Constructs a URL from the URLName. * * @return the URL * @exception MalformedURLException if the URL is malformed */ public URL getURL() throws MalformedURLException { return new URL(getProtocol(), getHost(), getPort(), getFile()); }
private void verifyProtocol() { if (StringUtils.hasText(this.storeUri)) { URLName urlName = new URLName(this.storeUri); if (this.protocol == null) { this.protocol = urlName.getProtocol(); } else { Assert.isTrue(this.protocol.equals(urlName.getProtocol()), "The provided 'protocol' does not match that in the 'storeUri'."); } } else { Assert.hasText(this.protocol, "Either the 'storeUri' or 'protocol' is required."); } Assert.hasText(this.protocol, "Unable to resolve protocol."); }
protocol = url.getProtocol(); if (host == null) host = url.getHost(); if (port == -1) port = url.getPort(); user = url.getUsername(); if (password == null) // get password too if we need it password = url.getPassword(); } else { if (password == null && user.equals(url.getUsername())) password = url.getPassword(); file = url.getFile(); host = session.getProperty("mail." + protocol + ".host"); if (user == null) user = session.getProperty("mail." + protocol + ".user"); host = session.getProperty("mail.host"); setURLName(new URLName(protocol, host, port, file, user, null)); pw = session.getPasswordAuthentication(getURLName()); if (pw != null) { setURLName(new URLName(protocol, host, port, file, user, password));
final Address[] any = all.length != 0 ? all : abort.getFrom(); if (any != null && any.length != 0) { t = session.getTransport(any[0]); session.getProperty("mail.transport.protocol"); //Force copy } else { MessagingException me = new MessagingException( t = session.getTransport(); } catch (final MessagingException fail) { throw attach(protocol, fail); final String protocol = t.getURLName().getProtocol(); session.getProperty("mail.host"); session.getProperty("mail.user"); if (InetAddress.getLocalHost() .getCanonicalHostName().length() == 0) { throw new UnknownHostException(); if (InetAddress.getByName(host) .getCanonicalHostName().length() == 0) { throw new UnknownHostException(host);
setURLName(new URLName(protocol, host, port, file, user, null)); pw = session.getPasswordAuthentication(getURLName()); if (pw != null) { InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; setURLName(new URLName(protocol, host, port, file, user, password));
super(session, url); if (url != null) name = url.getProtocol(); this.name = name; logger = new MailLogger(this.getClass(), "DEBUG POP3", session.getDebug(), session.getDebugOut()); isSSL = PropUtil.getBooleanProperty(session.getProperties(), "mail." + name + ".ssl.enable", false); if (isSSL) useFileCache = getBoolProp("filecache.enable"); String dir = session.getProperty("mail." + name + ".filecache.dir"); if (dir != null && logger.isLoggable(Level.CONFIG)) logger.config("mail." + name + ".filecache.dir: " + dir); if (dir != null) fileCacheDir = new File(dir);
debug = session.getDebug(); url = urlname; protocol = url.getProtocol(); host = url.getHost(); port = url.getPort(); user = url.getUsername(); password = url.getPassword(); file = url.getFile(); host = session.getProperty("mail." + protocol + ".host"); if (user == null) user = session.getProperty("mail." + protocol + ".user"); url = new URLName(protocol, host, port, file, user, password);
Session mailSession = Session.getInstance(props); transport = new SMTPTransport(mailSession, new URLName(serverSettings.getSmtpServer())); } else if (serverSettings.getSmtpProtocol() == SmtpProtocol.SMTPS) { transport = new SMTPSSLTransport(mailSession, new URLName(serverSettings.getSmtpServer())); } else if (serverSettings.getSmtpProtocol() == SmtpProtocol.STARTTLS) { transport = new SMTPSSLTransport(mailSession, new URLName(serverSettings.getSmtpServer())); } else { throw new RuntimeException("Unimplemented SMTP protocol: " + serverSettings.getSmtpProtocol());
URLName storeURL = getStore().getURLName(); String fullname = getFullName(); StringBuilder encodedName = new StringBuilder(); return new URLName(storeURL.getProtocol(), storeURL.getHost(), storeURL.getPort(), encodedName.toString(), storeURL.getUsername(),
final Address[] any = all.length != 0 ? all : abort.getFrom(); if (any != null && any.length != 0) { t = session.getTransport(any[0]); session.getProperty("mail.transport.protocol"); //Force copy } else { MessagingException me = new MessagingException( t = session.getTransport(); } catch (final MessagingException fail) { throw attach(protocol, fail); reportUnexpectedSend(abort, verify, null); } else { final String protocol = t.getURLName().getProtocol(); verifyProperties(session, protocol); final String protocol = t.getURLName().getProtocol(); verifyProperties(session, protocol); String mailHost = session.getProperty("mail." String transportHost = t.getURLName().getHost(); if (!isEmpty(transportHost)) { verifyHost(transportHost);
/** * Get a Transport object that implements the specified protocol. * If an appropriate Transport object cannot be obtained, null is * returned. * * @param protocol the Transport protocol * @return a Transport object * @exception NoSuchProviderException If provider for the given * protocol is not found. */ public Transport getTransport(String protocol) throws NoSuchProviderException { return getTransport(new URLName(protocol, null, -1, null, null, null)); }
/** * Get a Transport object for the given URLName. If the requested * Transport object cannot be obtained, NoSuchProviderException is thrown. * * The "scheme" part of the URL string (Refer RFC 1738) is used * to locate the Transport protocol. <p> * * @param url URLName that represents the desired Transport * @return a closed Transport object * @see javax.mail.URLName * @exception NoSuchProviderException If a provider for the given * URLName is not found. */ public Transport getTransport(URLName url) throws NoSuchProviderException { String protocol = url.getProtocol(); Provider p = getProvider(protocol); return getTransport(p, url); }
/** * Create a new {@link Transport} using the {@link Session} returned by {@link JavaMailSenderImpl#getSession() getSession()}. * * @param key A {@link URLName} containing the connection details * @return A new {@link Transport} */ @Override public Object makeObject(Object key) throws Exception { if ((key instanceof URLName) == false) { throw new IllegalArgumentException("Invlid key type"); } log.debug("Creating new Transport"); URLName urlName = (URLName) key; Transport transport = getSession().getTransport(urlName.getProtocol()); transport.connect(urlName.getHost(), urlName.getPort(), urlName.getUsername(), urlName.getPassword()); return transport; }
Session session = Session.getDefaultInstance(new Properties()); Store store = session.getStore(new URLName("mstor:c:/mailbox/MyStore")); store.connect(); // read messages from Inbox.. Folder inbox = store.getDefaultFolder().getFolder("Inbox"); inbox.open(Folder.READ_ONLY); Message[] messages = inbox.getMessages();
public void connect() throws MessagingException { connect(url.getHost(), url.getPort(), url.getUsername(), url.getPassword()); }
protected void openFolder() throws MessagingException { if (this.folder == null) { openSession(); connectStoreIfNecessary(); this.folder = obtainFolderInstance(); } else { connectStoreIfNecessary(); } if (this.folder == null || !this.folder.exists()) { throw new IllegalStateException("no such folder [" + this.url.getFile() + "]"); } if (this.folder.isOpen()) { return; } if (this.logger.isDebugEnabled()) { this.logger.debug("opening folder [" + this.folder.getURLName() + "]"); } this.folder.open(this.folderOpenMode); }
/** * Get a Store object that implements the specified protocol. If an * appropriate Store object cannot be obtained, * NoSuchProviderException is thrown. * * @param protocol the Store protocol * @return a Store object * @exception NoSuchProviderException If a provider for the given * protocol is not found. */ public Store getStore(String protocol) throws NoSuchProviderException { return getStore(new URLName(protocol, null, -1, null, null, null)); }