default boolean hasPort () { return getPort () > 0; }
default boolean hasCharset () { return getCharsetObj () != null; }
/** * Check if the "smtps" properties should be used or not. * * @param aSettings * The base settings. May not be <code>null</code>. * @return <code>true</code> to use "smtps". * @since 1.0.1 */ public static boolean isUseSMTPS (@Nonnull final ISMTPSettings aSettings) { return aSettings.isSSLEnabled () || aSettings.isSTARTTLSEnabled (); }
/** * Constructor which copies settings from another object * * @param aOther * The settings to use. May not be <code>null</code>. */ public SMTPSettings (@Nonnull final ISMTPSettings aOther) { this (aOther.getHostName (), aOther.getPort (), aOther.getUserName (), aOther.getPassword (), aOther.getCharsetObj (), aOther.isSSLEnabled (), aOther.isSTARTTLSEnabled (), aOther.getConnectionTimeoutMilliSecs (), aOther.getTimeoutMilliSecs (), aOther.isDebugSMTP ()); }
aNamedSettings.getID (), aNamedSettings.getName (), aSettings.getHostName (), Integer.valueOf (aSettings.getPort ()), aSettings.getCharsetName (), Boolean.valueOf (aSettings.isSSLEnabled ()), Boolean.valueOf (aSettings.isSTARTTLSEnabled ()), Long.valueOf (aSettings.getConnectionTimeoutMilliSecs ()), Long.valueOf (aSettings.getTimeoutMilliSecs ())); return aNamedSettings;
if (aSettings.isSSLEnabled ()) ret.put (ESMTPTransportProperty.SSL_ENABLE.getPropertyName (bSMTPS), Boolean.TRUE.toString ()); if (aSettings.hasUserName ()) ret.put (ESMTPTransportProperty.AUTH.getPropertyName (bSMTPS), Boolean.TRUE.toString ()); if (aSettings.isSTARTTLSEnabled ()) ret.put (ESMTPTransportProperty.STARTTLS_ENABLE.getPropertyName (bSMTPS), Boolean.TRUE.toString ()); com.sun.mail.util.MailSSLSocketFactory.class.getName ()); ret.put (ESMTPTransportProperty.SSL_SOCKETFACTORY_PORT.getPropertyName (bSMTPS), Integer.toString (aSettings.getPort ())); final long nConnectionTimeoutMilliSecs = aSettings.getConnectionTimeoutMilliSecs (); if (nConnectionTimeoutMilliSecs > 0) ret.put (ESMTPTransportProperty.CONNECTIONTIMEOUT.getPropertyName (bSMTPS), final long nTimeoutMilliSecs = aSettings.getTimeoutMilliSecs (); if (nTimeoutMilliSecs > 0) ret.put (ESMTPTransportProperty.TIMEOUT.getPropertyName (bSMTPS), Long.toString (nTimeoutMilliSecs)); ret.put ("mail.debug", Boolean.toString (aSettings.isDebugSMTP ())); ret.put ("mail.debug.auth", Boolean.toString (aSettings.isDebugSMTP ()));
@Nonnull public String getSMTPServerDisplayText () { String ret = m_aSettings.getHostName (); if (m_aSettings.hasPort ()) ret += ":" + m_aSettings.getPort (); if (m_aSettings.hasUserName ()) { ret += "[" + m_aSettings.getUserName (); if (m_aSettings.hasPassword ()) ret += "/****"; ret += ']'; } return ret; }
final boolean bDebugSMTP) setHostName (sHostName); setPort (nPort); setUserName (sUserName); setPassword (sPassword); setCharset (aCharset != null ? aCharset : CSMTP.CHARSET_SMTP_OBJ); setSSLEnabled (bSSLEnabled); setSTARTTLSEnabled (bSTARTTLSEnabled); setConnectionTimeoutMilliSecs (nConnectionTimeoutMilliSecs); setTimeoutMilliSecs (nTimeoutMilliSecs); setDebugSMTP (bDebugSMTP);
sPassword = aSelectedObject.getSMTPSettings ().getPassword (); final SMTPSettings aSMTPSettings = new SMTPSettings (sHostName, nPort, sUserName,
@Nonnull public SMTPSettings getClone () { return new SMTPSettings (this); }
default boolean hasPassword () { return StringHelper.hasText (getPassword ()); }
default boolean hasUserName () { return StringHelper.hasText (getUserName ()); }
@Nonnull public IMicroElement convertToMicroElement (@Nonnull final SMTPSettings aSource, @Nullable final String sNamespaceURI, @Nonnull final String sTagName) { return convertToMicroElementStatic (aSource, sNamespaceURI, sTagName); }
@Nonnull @ContainsSoftMigration public SMTPSettings convertToNative (@Nonnull final IMicroElement eSMTPSettings) { return convertToSMTPSettings (eSMTPSettings); } }
public void registerMicroTypeConverter (@Nonnull final IMicroTypeConverterRegistry aRegistry) { aRegistry.registerMicroElementTypeConverter (EmailAttachment.class, new EmailAttachmentMicroTypeConverter ()); aRegistry.registerMicroElementTypeConverter (EmailAttachmentList.class, new EmailAttachmentListMicroTypeConverter ()); aRegistry.registerMicroElementTypeConverter (EmailData.class, new EmailDataMicroTypeConverter ()); aRegistry.registerMicroElementTypeConverter (FailedMailData.class, new FailedMailDataMicroTypeConverter ()); aRegistry.registerMicroElementTypeConverter (SMTPSettings.class, new SMTPSettingsMicroTypeConverter ()); } }
@Nonnull public static IMicroElement convertToMicroElementStatic (@Nonnull final ISMTPSettings aSMTPSettings, @Nullable final String sNamespaceURI, @Nonnull final String sTagName) { final IMicroElement eSMTPSettings = new MicroElement (sNamespaceURI, sTagName); eSMTPSettings.setAttribute (ATTR_HOST, aSMTPSettings.getHostName ()); eSMTPSettings.setAttribute (ATTR_PORT, aSMTPSettings.getPort ()); eSMTPSettings.setAttribute (ATTR_USER, aSMTPSettings.getUserName ()); eSMTPSettings.setAttribute (ATTR_PASSWORD, aSMTPSettings.getPassword ()); eSMTPSettings.setAttribute (ATTR_CHARSET, aSMTPSettings.getCharsetName ()); eSMTPSettings.setAttribute (ATTR_SSLENABLED, aSMTPSettings.isSSLEnabled ()); eSMTPSettings.setAttribute (ATTR_STARTTLSENABLED, aSMTPSettings.isSTARTTLSEnabled ()); eSMTPSettings.setAttribute (ATTR_CONNECTIONTIMEOUT, aSMTPSettings.getConnectionTimeoutMilliSecs ()); eSMTPSettings.setAttribute (ATTR_TIMEOUT, aSMTPSettings.getTimeoutMilliSecs ()); eSMTPSettings.setAttribute (ATTR_DEBUG_SMTP, aSMTPSettings.isDebugSMTP ()); return eSMTPSettings; }
sPassword = aSelectedObject.getSMTPSettings ().getPassword (); final SMTPSettings aSMTPSettings = new SMTPSettings (sHostName, nPort, sUserName,
@Override @Nonnull protected EChange onInit () { if (!isCreateDefaults ()) return EChange.UNCHANGED; // Create default item with as little data as possible _addItem (new NamedSMTPSettings (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID, CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_NAME, new SMTPSettings (CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_HOST, CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_PORT, null, null, CSMTP.CHARSET_SMTP_OBJ, false))); return EChange.CHANGED; }
@Nullable default String getCharsetName () { final Charset aCharset = getCharsetObj (); return aCharset == null ? null : aCharset.name (); }
final boolean bDebugSMTP = StringParser.parseBool (sDebugSMTP, EmailGlobalSettings.isDebugSMTP ()); return new SMTPSettings (sHost, nPort, sUser,