yoavs       2005/03/23 07:30:57

  Modified:    catalina/src/share/org/apache/naming/factory
                        MailSessionFactory.java
               webapps/docs changelog.xml
  Log:
  Bugzilla 31288.
  
  Revision  Changes    Path
  1.3       +35 -4     
jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/MailSessionFactory.java
  
  Index: MailSessionFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/factory/MailSessionFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MailSessionFactory.java   27 Feb 2004 14:58:54 -0000      1.2
  +++ MailSessionFactory.java   23 Mar 2005 15:30:56 -0000      1.3
  @@ -21,6 +21,8 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Properties;
  +import javax.mail.Authenticator;
  +import javax.mail.PasswordAuthentication;
   import javax.mail.Session;
   import javax.naming.Name;
   import javax.naming.Context;
  @@ -96,7 +98,9 @@
   
           // Create a new Session inside a doPrivileged block, so that JavaMail
           // can read its default properties without throwing Security
  -        // exceptions
  +        // exceptions.
  +        //
  +        // Bugzilla 31288, 33077: add support for authentication.
           return AccessController.doPrivileged( new PrivilegedAction() {
                public Object run() {
   
  @@ -104,16 +108,43 @@
                       Properties props = new Properties();
                       props.put("mail.transport.protocol", "smtp");
                       props.put("mail.smtp.host", "localhost");
  +
  +                    String password = null;
  +
                       Enumeration attrs = ref.getAll();
                       while (attrs.hasMoreElements()) {
                           RefAddr attr = (RefAddr) attrs.nextElement();
  -                        if ("factory".equals(attr.getType()))
  +                        if ("factory".equals(attr.getType())) {
  +                            continue;
  +                        }
  +
  +                        if ("password".equals(attr.getType())) {
  +                            password = (String) attr.getContent();
                               continue;
  +                        }
  +
                           props.put(attr.getType(), (String) 
attr.getContent());
                       }
   
  +                    Authenticator auth = null;
  +                    if (password != null) {
  +                        String user = props.getProperty("mail.smtp.user");
  +                        if(user == null) {
  +                            user = props.getProperty("mail.user");
  +                        }
  +                        
  +                        if(user != null) {
  +                            final PasswordAuthentication pa = new 
PasswordAuthentication(user, password);
  +                            auth = new Authenticator() {
  +                                    protected PasswordAuthentication 
getPasswordAuthentication() {
  +                                        return pa;
  +                                    }
  +                                };
  +                        }
  +                    }
  +
                       // Create and return the new Session object
  -                    Session session = Session.getInstance(props, null);
  +                    Session session = Session.getInstance(props, auth);
                       return (session);
   
                }
  
  
  
  1.247     +3 -0      jakarta-tomcat-catalina/webapps/docs/changelog.xml
  
  Index: changelog.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
  retrieving revision 1.246
  retrieving revision 1.247
  diff -u -r1.246 -r1.247
  --- changelog.xml     23 Mar 2005 15:17:17 -0000      1.246
  +++ changelog.xml     23 Mar 2005 15:30:56 -0000      1.247
  @@ -84,6 +84,9 @@
         <update>
           <bug>32938</bug>: Allow Salted SHA (SSHA) passwords in JNDIRealm. 
(yoavs)
         </update>
  +      <update>
  +        <bug>31288</bug>: Allow SMTP authentication for JNDI 
MailSessionFactory. (yoavs)
  +      </update>
       </changelog>
      </subsection>
      
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to