ASF Bugzilla – Attachment 22697 Details for
Bug 25355
allow to require "TLS/SSL only" for outgoing mails of your SMTPAppender
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Adds SMTPProtocol and SMTPPort properties to SMTPAppender
patch3.txt (text/plain), 3.65 KB, created by
Curt Arnold
on 2008-10-08 15:24:41 UTC
(
hide
)
Description:
Adds SMTPProtocol and SMTPPort properties to SMTPAppender
Filename:
MIME Type:
Creator:
Curt Arnold
Created:
2008-10-08 15:24:41 UTC
Size:
3.65 KB
patch
obsolete
>Index: src/main/java/org/apache/log4j/net/SMTPAppender.java >=================================================================== >--- src/main/java/org/apache/log4j/net/SMTPAppender.java (revision 703006) >+++ src/main/java/org/apache/log4j/net/SMTPAppender.java (working copy) >@@ -67,6 +67,8 @@ > > This class has implemented UnrecognizedElementHandler since 1.2.15. > >+ Since 1.2.16, SMTP over SSL is supported by setting SMTPProtocol to "smpts". >+ > @author Ceki Gülcü > @since 1.0 */ > public class SMTPAppender extends AppenderSkeleton >@@ -85,6 +87,8 @@ > private String smtpHost; > private String smtpUsername; > private String smtpPassword; >+ private String smtpProtocol; >+ private int smtpPort = -1; > private boolean smtpDebug = false; > private int bufferSize = 512; > private boolean locationInfo = false; >@@ -177,13 +181,22 @@ > } catch(SecurityException ex) { > props = new Properties(); > } >+ >+ String prefix = "mail.smtp"; >+ if (smtpProtocol != null) { >+ props.put("mail.transport.protocol", smtpProtocol); >+ prefix = "mail." + smtpProtocol; >+ } > if (smtpHost != null) { >- props.put("mail.smtp.host", smtpHost); >+ props.put(prefix + ".host", smtpHost); > } >+ if (smtpPort > 0) { >+ props.put(prefix + ".port", String.valueOf(smtpPort)); >+ } > > Authenticator auth = null; > if(smtpPassword != null && smtpUsername != null) { >- props.put("mail.smtp.auth", "true"); >+ props.put(prefix + ".auth", "true"); > auth = new Authenticator() { > protected PasswordAuthentication getPasswordAuthentication() { > return new PasswordAuthentication(smtpUsername, smtpPassword); >@@ -191,6 +204,9 @@ > }; > } > Session session = Session.getInstance(props, auth); >+ if (smtpProtocol != null) { >+ session.setProtocolForAddress("rfc822", smtpProtocol); >+ } > if (smtpDebug) { > session.setDebug(smtpDebug); > } >@@ -608,6 +624,49 @@ > return false; > } > >+ /** >+ * Get transport protocol. >+ * Typically null or "smtps". >+ * >+ * @return transport protocol, may be null. >+ * @since 1.2.16 >+ */ >+ public final String getSMTPProtocol() { >+ return smtpProtocol; >+ } >+ >+ /** >+ * Set transport protocol. >+ * Typically null or "smtps". >+ * >+ * @param val transport protocol, may be null. >+ * @since 1.2.16 >+ */ >+ public final void setSMTPProtocol(final String val) { >+ smtpProtocol = val; >+ } >+ >+ /** >+ * Get port. >+ * >+ * @return port, negative values indicate use of default ports for protocol. >+ * @since 1.2.16 >+ */ >+ public final int getSMTPPort() { >+ return smtpPort; >+ } >+ >+ /** >+ * Set port. >+ * >+ * @param val port, negative values indicate use of default ports for protocol. >+ * @since 1.2.16 >+ */ >+ public final void setSMTPPort(final int val) { >+ smtpPort = val; >+ } >+ >+ > } > > class DefaultEvaluator implements TriggeringEventEvaluator { >Index: src/changes/changes.xml >=================================================================== >--- src/changes/changes.xml (revision 703006) >+++ src/changes/changes.xml (working copy) >@@ -63,6 +63,7 @@ > <action action="fix" issue="44386">NTEventLogAppender.dll for 64-bit editions for Microsoft Windows.</action> > <action action="fix" issue="45721">Add configuration of ThrowableRenderers and add org.apache.log4j.EnhancedThrowableRenderer.</action> > <action action="fix" issue="45969">SMTPAppender does not force evaluation of message at request time</action> >+ <action action="fix" issue="25355">Support SSL transport in SMTPAppender</action> > </release> > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25355
: 22697