/** * Returns email store. * * @param session {@link Session} * @return {@link com.sun.mail.pop3.POP3SSLStore} */ @Override protected POP3SSLStore getStore(final Session session) { final SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) authenticator; final URLName url; if (simpleAuthenticator == null) { url = new URLName( PROTOCOL_POP3, host, port, StringPool.EMPTY, null, null); } else { final PasswordAuthentication pa = simpleAuthenticator.getPasswordAuthentication(); url = new URLName( PROTOCOL_POP3, host, port, StringPool.EMPTY, pa.getUserName(), pa.getPassword()); } return new POP3SSLStore(session, url); }
/** * Returns email store. * * @param session {@link Session} * @return {@link com.sun.mail.imap.IMAPSSLStore} */ @Override protected IMAPSSLStore getStore(final Session session) { SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) authenticator; final URLName url; if (simpleAuthenticator == null) { url = new URLName( PROTOCOL_IMAP, host, port, StringPool.EMPTY, null, null); } else { final PasswordAuthentication pa = simpleAuthenticator.getPasswordAuthentication(); url = new URLName( PROTOCOL_IMAP, host, port, StringPool.EMPTY, pa.getUserName(), pa.getPassword()); } return new IMAPSSLStore(session, url); }
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
if (pw != null) { if (user == null) { user = pw.getUserName(); password = pw.getPassword(); } else if (user.equals(pw.getUserName())) { password = pw.getPassword(); null, user); if (pw != null) { user = pw.getUserName(); password = pw.getPassword();
if (pw != null) { if (user == null) { user = pw.getUserName(); password = pw.getPassword(); } else if (user.equals(pw.getUserName())) { password = pw.getPassword(); null, user); if (pw != null) { user = pw.getUserName(); password = pw.getPassword();
private static Session getSession(String smtpHost, String smtpPort, String smtpUser, String smtpPass) { Authenticator authenticator = new Authenticator(smtpUser, smtpPass); Properties properties = new Properties(); properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName()); properties.setProperty("mail.smtp.auth", Boolean.TRUE.toString()); properties.setProperty("mail.smtp.host", smtpHost); properties.setProperty("mail.smtp.port", smtpPort); properties.setProperty("mail.smtp.user", smtpUser); properties.setProperty("mail.smtp.timeout", "20000"); properties.setProperty("mail.smtp.starttls.enable", Boolean.TRUE.toString()); return Session.getInstance(properties, authenticator); }
private void refreshPassword() { if (debug) out.println("DEBUG: refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
public MailSender(IMailConfig aMailConfig) { _serverproperties = new Properties(); _serverproperties.put("mail.smtp.host", aMailConfig.getStmphost()); _serverproperties.put("mail.smtp.port", aMailConfig.getStmpport()); if (aMailConfig.isRequiredAuthentication()) { authenticator = new MailSenderAuthenticator(aMailConfig.getUsername(), aMailConfig.getPassword()); _serverproperties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName()); _serverproperties.setProperty("mail.smtp.auth", "true"); } }
properties.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName()); session = Session.getInstance(properties, authenticator); } else {
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
private void refreshPassword() { if (logger.isLoggable(Level.FINE)) logger.fine("refresh password, user: " + traceUser(user)); InetAddress addr; try { addr = InetAddress.getByName(host); } catch (UnknownHostException e) { addr = null; } PasswordAuthentication pa = session.requestPasswordAuthentication(addr, port, name, null, user); if (pa != null) { user = pa.getUserName(); password = pa.getPassword(); } }
/** * Returns email store. * * @param session {@link Session} * @return {@link com.sun.mail.pop3.POP3SSLStore} */ @Override protected POP3SSLStore getStore(final Session session) { final SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) authenticator; final URLName url; if (simpleAuthenticator == null) { url = new URLName( PROTOCOL_POP3, host, port, StringPool.EMPTY, null, null); } else { final PasswordAuthentication pa = simpleAuthenticator.getPasswordAuthentication(); url = new URLName( PROTOCOL_POP3, host, port, StringPool.EMPTY, pa.getUserName(), pa.getPassword()); } return new POP3SSLStore(session, url); }
/** * Returns email store. * * @param session {@link Session} * @return {@link com.sun.mail.imap.IMAPSSLStore} */ @Override protected IMAPSSLStore getStore(final Session session) { SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) authenticator; final URLName url; if (simpleAuthenticator == null) { url = new URLName( PROTOCOL_IMAP, host, port, StringPool.EMPTY, null, null); } else { final PasswordAuthentication pa = simpleAuthenticator.getPasswordAuthentication(); url = new URLName( PROTOCOL_IMAP, host, port, StringPool.EMPTY, pa.getUserName(), pa.getPassword()); } return new IMAPSSLStore(session, url); }
Credentials credentials = new SimpleCredentials(auth.getUserName(), auth.getPassword().toCharArray()); session = repository.login(credentials);
@Test public void testDefaultAuthenticatorConstructor() { //insert code testing basic functionality final String strUsername = "user.name"; final String strPassword = "user.pwd"; final DefaultAuthenticator authenticator = new DefaultAuthenticator(strUsername, strPassword); assertTrue( PasswordAuthentication.class.isInstance( authenticator.getPasswordAuthentication())); assertEquals( strUsername, authenticator.getPasswordAuthentication().getUserName()); assertEquals( strPassword, authenticator.getPasswordAuthentication().getPassword()); }
@Test public void testGetSetAuthentication() { // setup final String strUsername = "user.name"; final String strPassword = "user.pwd"; email.setAuthentication(strUsername, strPassword); // this is cast into DefaultAuthenticator for convenience // and give us access to the getPasswordAuthentication fn final DefaultAuthenticator retrievedAuth = (DefaultAuthenticator) email.getAuthenticator(); // tests assertEquals( strUsername, retrievedAuth.getPasswordAuthentication().getUserName()); assertEquals( strPassword, retrievedAuth.getPasswordAuthentication().getPassword()); }
@Test public void testGetSetAuthenticator() { // setup final String strUsername = "user.name"; final String strPassword = "user.pwd"; final DefaultAuthenticator authenticator = new DefaultAuthenticator(strUsername, strPassword); email.setAuthenticator(authenticator); // this is cast into DefaultAuthenticator for convenience // and give us access to the getPasswordAuthentication fn final DefaultAuthenticator retrievedAuth = (DefaultAuthenticator) email.getAuthenticator(); // tests assertEquals( strUsername, retrievedAuth.getPasswordAuthentication().getUserName()); assertEquals( strPassword, retrievedAuth.getPasswordAuthentication().getPassword()); }