Setting up JavaMail datasource with SSL, username and password

View: New views
14 Messages — Rating Filter:   Alert me  

Setting up JavaMail datasource with SSL, username and password

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm having difficulty figuring out how to set up a JavaMail datasource
that uses TLS SSL, username and password.  To do this in JavaCode:

>      ...
>         Properties props = new Properties();
>         props.put("mail.smtp.auth", "true");
>         props.put("mail.smtp.host", "smtp.host.foo");
>         props.put("mail.smtp.port", "587");
>         props.put("mail.from", "foo@...");
>
>         Authenticator auth = Utils.getAuthenticator();
>         Session session = Session.getInstance(props, auth);
>         session.setDebug(false);
>         ...
>
>
>
>     public static Authenticator getAuthenticator() {
>         return new Authenticator() {
>             @Override
>             protected PasswordAuthentication
> getPasswordAuthentication() {
>                 return new PasswordAuthentication(user, password);
>             }
>         };
>     }

It looks like it can't be done simply by adding properties to the
JavaMail DataSource since the roller app needs to be able to use the
username and password.   Does Roller have such a feature?

BTW I'm using GlassFish V2.


Thanks,
Ryan



Re: Setting up JavaMail datasource with SSL, username and password

by Alex Coles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jun 30, 2008, at 10:21 PM, Ryan de Laplante wrote:

> Hi,
>
> I'm having difficulty figuring out how to set up a JavaMail  
> datasource that uses TLS SSL, username and password.  To do this in  
> JavaCode:
>
>> ...
>
> It looks like it can't be done simply by adding properties to the  
> JavaMail DataSource since the roller app needs to be able to use the  
> username and password.   Does Roller have such a feature?
>
> BTW I'm using GlassFish V2.
>
>
> Thanks,
> Ryan
>
>

Hi Ryan,

Just out of interest, is there any reason you don't want to setup a  
JNDI Mail session?

Alex


Re: Setting up JavaMail datasource with SSL, username and password

by Dave-401 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 30, 2008 at 4:21 PM, Ryan de Laplante <ryan@...> wrote:
> I'm having difficulty figuring out how to set up a JavaMail datasource that
> uses TLS SSL, username and password.  To do this in JavaCode:
>>     ...
>>        Properties props = new Properties();
>>        props.put("mail.smtp.auth", "true");
...
> It looks like it can't be done simply by adding properties to the JavaMail
> DataSource since the roller app needs to be able to use the username and
> password.   Does Roller have such a feature?
>
> BTW I'm using GlassFish V2.

I don't believe you can set username/password for container managed
mail sessions on Tomcat or Glassfish. That's why we have the plain old
mail setup (i.e. not container managed, not JNDI), which does allow
you to set username/password -- but does not do anything to configure
SSL (your code example doesn't seem to do SSL either).

Here's what you'd add to your roller-custom.properties file to setup
mail with username and password:

        mail.configurationType=properties
        mail.hostname=smtp-server.example.com
        mail.username=scott
        mail.password=tiger

- Dave

Re: Setting up JavaMail datasource with SSL, username and password

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Just out of interest, is there any reason you don't want to setup a
> JNDI Mail session?
I am using a JNDI Mail Session in GlassFish V2.  I'm asking which
properties I need to add to it so that I can have both SSL and
username/password.

> I don't believe you can set username/password for container managed
> mail sessions on Tomcat or Glassfish. That's why we have the plain old
> mail setup (i.e. not container managed, not JNDI), which does allow
> you to set username/password -- but does not do anything to configure
> SSL (your code example doesn't seem to do SSL either).
>
> Here's what you'd add to your roller-custom.properties file to setup
> mail with username and password:
>
>         mail.configurationType=properties
>         mail.hostname=smtp-server.example.com
>         mail.username=scott
>         mail.password=tiger
>  
I found this example on the net:

        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.socketFactory.fallback", "false");
        props.put("mail.debug", "true");

        Session session = Session.getInstance(props);

That gets me SSL in my JavaMail datasource, but not username/password.  
If I choose to use roller-custom.properties to configure mail instead of
my JNDI datasource, I can do username/password but not SSL.   Can Roller
be enhanced to allow both?   As it is now I can't use the SMTP server at
work, my ISP, or gmail because they all require SSL, username and
password.  


Thanks,
Ryan


Re: Setting up JavaMail datasource with SSL, username and password

by Dave-401 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 30, 2008 at 10:50 PM, Ryan de Laplante <ryan@...> wrote:

> I found this example on the net:
>       Properties props = new Properties();
>       props.put("mail.smtp.host", "smtp.gmail.com");
>       props.put("mail.smtp.auth", "true");
>       props.put("mail.smtp.port", "465");
>       props.put("mail.smtp.socketFactory.port", "465");
>       props.put("mail.smtp.socketFactory.class",
> "javax.net.ssl.SSLSocketFactory");
>       props.put("mail.smtp.socketFactory.fallback", "false");
>       props.put("mail.debug", "true");

Nice. Sounds like we need to allow those same properties to be
specified in roller-custom.properties. I think the code that
reads/reacts to mail property settings is all in a single
"MailProvider" class, so it would be easy to patch ;-)

- Dave

Re: Setting up JavaMail datasource with SSL, username and password

by Stephan Mühlstrasser-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Montag, den 30.06.2008, 22:50 -0400 schrieb Ryan de Laplante:

>
> That gets me SSL in my JavaMail datasource, but not username/password.  
> If I choose to use roller-custom.properties to configure mail instead of
> my JNDI datasource, I can do username/password but not SSL.   Can Roller
> be enhanced to allow both?   As it is now I can't use the SMTP server at
> work, my ISP, or gmail because they all require SSL, username and
> password.  

Note also that authentication Roller 4.0 via username/password does not
work in general because of bug 1694:

http://issues.apache.org/roller/browse/ROL-1694

Regards
Stephan


disabling log4j

by abhay srivastava-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
   I have a roller 4.0 setup on Tomcat with mysql as database. I was curious how do I disable log4j logging in roller ?

Regards,




Re: disabling log4j

by Alex Coles :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Jul 2, 2008, at 1:54 AM, abhay srivastava wrote:

> Hello,
>    I have a roller 4.0 setup on Tomcat with mysql as database. I was  
> curious how do I disable log4j logging in roller ?
>
> Regards,

If you check the example roller.properties in the roller-install-
guide.pdf, you'll see you have pretty granular control over what gets  
logged. But to start off with, try setting the default logging level  
to the lowest possible value:
log4j.rootCategory=FATAL, roller

Alex

Re: Setting up JavaMail datasource with SSL, username and password

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dave wrote:

> On Mon, Jun 30, 2008 at 10:50 PM, Ryan de Laplante <ryan@...> wrote:
>  
>> I found this example on the net:
>>       Properties props = new Properties();
>>       props.put("mail.smtp.host", "smtp.gmail.com");
>>       props.put("mail.smtp.auth", "true");
>>       props.put("mail.smtp.port", "465");
>>       props.put("mail.smtp.socketFactory.port", "465");
>>       props.put("mail.smtp.socketFactory.class",
>> "javax.net.ssl.SSLSocketFactory");
>>       props.put("mail.smtp.socketFactory.fallback", "false");
>>       props.put("mail.debug", "true");
>>    
>
> Nice. Sounds like we need to allow those same properties to be
> specified in roller-custom.properties. I think the code that
> reads/reacts to mail property settings is all in a single
> "MailProvider" class, so it would be easy to patch ;-)
>
> - Dave
>
>  
I think this will be very helpful:

http://forums.java.net/jive/message.jspa?messageID=283824#283824

I will be giving it a try on GlassFish tonight.


Ryan



Re: Setting up JavaMail datasource with SSL, username and password

by Ryan de Laplante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 
> I think this will be very helpful:
>
> http://forums.java.net/jive/message.jspa?messageID=283824#283824
>
> I will be giving it a try on GlassFish tonight.
I have created a JavaMail session in GlassFish's JNDI based on the link
above.  I set GlassFish's JavaMail log level to FINEST, restarted app
server, then posted a comment in Roller.  There is no evidence that
JavaMail was used according to GlassFish's server.log, or roller.log.

Next I tried adding the following to roller-custom.properties:

mail.configurationType=jndi
mail.jndi.name=mail/Session

I think that's the default anyway.  I restarted GlassFish and it didn't
make a difference.  No evidence that JavaMail was used, and no emails.


Thanks,
Ryan


Roller on Tomcat 5.0.x

by abhay srivastava-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
   I am curious to know whether Roller 4.0 can work with Tomcat 5.0.x ?

Regards,
Abhay




Re: Roller on Tomcat 5.0.x

by Dave-401 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jul 3, 2008 at 8:32 AM, abhay srivastava <abhay_iitm@...> wrote:
> Hello,
>    I am curious to know whether Roller 4.0 can work with Tomcat 5.0.x ?

Yes, Roller should work fine with Tomcat 5.0, 5.5 and 6.0.

- Dave

Re: Roller on Tomcat 5.0.x

by abhay srivastava-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Dave.
     I had roller running on my personal server and it
worked absolutly fine. I have migrated the roller code to external
hosting service and it has stopped working. They are running

Tomcat 5.0.27
Mysql.

What
should I be checking ? Currently it is not rendering any JSP pages and
now when I try my site it says index.jsp could not be found. I don't
have access to their server. I have been just given a space and I have
to put my stuff there.


ANy help will be greatly appreciated. My site  has been down for four days now.

Regards,
Abhay

---

Winners don't Quit,Quitters don't Win

--- On Thu, 7/3/08, Dave <snoopdave@...> wrote:
From: Dave <snoopdave@...>
Subject: Re: Roller on Tomcat 5.0.x
To: user@..., abhay_iitm@...
Date: Thursday, July 3, 2008, 6:23 PM

On Thu, Jul 3, 2008 at 8:32 AM, abhay srivastava <abhay_iitm@...>
wrote:
> Hello,
>    I am curious to know whether Roller 4.0 can work with Tomcat 5.0.x ?

Yes, Roller should work fine with Tomcat 5.0, 5.5 and 6.0.

- Dave



Re: Roller on Tomcat 5.0.x

by abhay srivastava-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have been told by my hosting provider to change web.xml with proper jsp handlers (servlet-mappings)


As a matter of fact the site is running fine on my server.

I am not sure what to do there ? Can anybody please help me here ?

regards,




---

Winners don't Quit,Quitters don't Win

--- On Thu, 7/3/08, abhay srivastava <abhay_iitm@...> wrote:
From: abhay srivastava <abhay_iitm@...>
Subject: Re: Roller on Tomcat 5.0.x
To: "Dave" <snoopdave@...>
Cc: user@...
Date: Thursday, July 3, 2008, 7:05 PM

Thanks Dave.
     I had roller running on my personal server and it
worked absolutly fine. I have migrated the roller code to external
hosting service and it has stopped working. They are running

Tomcat 5.0.27
Mysql.

What
should I be checking ? Currently it is not rendering any JSP pages and
now when I try my site it says index.jsp could not be found. I don't
have access to their server. I have been just given a space and I have
to put my stuff there.


ANy help will be greatly appreciated. My site  has been down for four days
now.

Regards,
Abhay

---

Winners don't Quit,Quitters don't Win

--- On Thu, 7/3/08, Dave <snoopdave@...> wrote:
From: Dave <snoopdave@...>
Subject: Re: Roller on Tomcat 5.0.x
To: user@..., abhay_iitm@...
Date: Thursday, July 3, 2008, 6:23 PM

On Thu, Jul 3, 2008 at 8:32 AM, abhay srivastava <abhay_iitm@...>
wrote:
> Hello,
>    I am curious to know whether Roller 4.0 can work with Tomcat 5.0.x ?

Yes, Roller should work fine with Tomcat 5.0, 5.5 and 6.0.

- Dave