[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: RE : [cobalt-developers] Need help with tomcat.policy with Javamail



Hi Jack,

there is suggestion if you don't want to give AllPermission to your
virtual hosts, it is very dangerous.
When you try to use SMTP with your domain name and you use
> private String host = "stage.icarian.com";
in your mail servlet, you need to give such permission to your domain:
permission java.net.SocketPermission "stage.icarian.com:25-",
"connect,accept,listen,resolve";

You need to state port 25, it is SMTP service. You can write 25- or 25
without "-" if don't allow to use rest of services.

You need to give this permission to this domain only, see your tomcat.policy
file for:
grant codeBase "file:/home/sites/{codeBaseOfDomain"icarian.com"}/web/-" {...

You cannot use tomcat.policy.custom for it because all strings from
tomcat.policy.custom will be added to each domain (codeBase).
You must edit tomcat.policy instead, but please note: cobalt's script
will rewrite tomcat.policy per each Tomcat reload.
Simple solution: remove appropriate lines from
/usr/java/jakarta-tomcat/bin/cobalt_config.pl
Best solutions: rewrite cobalt_config.pl with more intelligent code.

Best regards,
Alex

> -----Original Message-----
> From: cobalt-developers-admin@xxxxxxxxxxxxxxx
> [mailto:cobalt-developers-admin@xxxxxxxxxxxxxxx]On Behalf Of
> jack.chu@xxxxxxxxxxx
> Sent: Thursday, July 19, 2001 12:43 AM
> To: cobalt-developers@xxxxxxxxxxxxxxx
> Cc: jack.chu@xxxxxxxxxxx
> Subject: RE : [cobalt-developers] Need help with tomcat.policy
> with Javamail
>
>
>
> Hi Tim,
>
>  I've created the /usr/java/jakarta-tomcat/conf/tomcat.policy.custom file
> with the permissions you suggested. I even gave AllPermission.
>
> I checked the tomcat.policy file after I restarted the server and verified
> that the new permission is there.
>
> I still get the java.security.AccessControlException:access denied
> (java.net.SocketPermission stage.icarian.com resolve) error.
>
> Has anyone on this list gotten the JavaMail to work with servlets??
>
> Thanks for any help.
> Jack
>
>
>
>
>
>
>  Hi Jack,
>
> You'll need to give more permission to the servlet. Create a file called:
>
>   /usr/java/jakarta-tomcat/conf/tomcat.policy.custom
>
>   Put in the following line:
>
> permission
> java.net.SocketPermission"localhost:1024-","connect,accept,listen,
> resolve";
>
>   This should do the trick. If not, and you're sure you trust all the
> servlets running on your machine,  you can give the servlet full
> permissions
> by adding:
>
>   permission java.security.AllPermission;
>
> to tomcat.policy.custom.
>
> _Tim
>
> On 7/16/01 10:48 AM, " jack.chu@xxxxxxxxxxx
> <mailto:jack.chu@xxxxxxxxxxx> "
> < jack.chu@xxxxxxxxxxx <mailto:jack.chu@xxxxxxxxxxx> > wrote:
>
> > Hi,
> >
> > I have a java servlet sending a email via smtp using JavaMail.
> The servlet
> > sends out the email fine when executed through telnet session.
> When I run
> > the servlet thru Tomcat, I get a java.security.AccessControlException:
> > access denied (java.net.SocketPermission stage.icarian.com
> resolve) error.
> >
> > I'm assuming it's a security manager problem. I may be wrong. I need to
> know
> > how to configure the tomcat.policy.custom file to fix this problem.
> >
> > The servlet code:
> > import java.util.*;
> > import java.io.*;
> > import javax.mail.*;
> > import javax.mail.internet.*;
> > import javax.activation.*;
> >
> > public class Mailer {
> >
> > private String host = "stage.icarian.com";
> > private String to;
> > private String from;
> > private String subject;
> >
> > public Mailer(String to, String from, String subject) {
> >   this.to = to;
> >   this.from = from;
> >   this.subject = subject;
> > }
> >
> > public void send() {
> >   Properties props = new Properties();
> >   props.setProperty("mail.smtp.host",host);
> >   Session s = Session.getInstance(props,null);
> >   try {
> >     MimeMessage msg = new MimeMessage(s);
> >     msg.setFrom(new InternetAddress(from));
> >     msg.addRecipient(msg.RecipientType.TO, new InternetAddress(to));
> >     msg.setSubject(subject);
> >     msg.setText("");
> >     Transport transport = s.getTransport("smtp");
> >     transport.connect();
> >     transport.send(msg);
> >
> >
> > //      Transport.send(msg);
> >   } catch (MessagingException mex) {
> >     mex.printStackTrace();
> >   }
> > }
> >
> >
> > My tomcat.policy file
> > grant codeBase "file:/home/sites/site4/web/-" {
> > permission java.net.SocketPermission "localhost:1024-",
> "listen,connect";
> > permission java.util.PropertyPermission "*", "read,write";
> > permission java.lang.RuntimePermission "accessClassInPackage.sun.io";
> > permission java.io.FilePermission "-", "read,write,delete";
> > };
> >
> > Thanks for any help.
> > Jack
> >
> >
> >
> > _______________________________________________
> > cobalt-developers mailing list
> > cobalt-developers@xxxxxxxxxxxxxxx
> <mailto:cobalt-developers@xxxxxxxxxxxxxxx>
> > http://list.cobalt.com/mailman/listinfo/cobalt-developers
> <http://list.cobalt.com/mailman/listinfo/cobalt-developers>
> >
>
>
> _______________________________________________
> cobalt-developers mailing list
> cobalt-developers@xxxxxxxxxxxxxxx
> http://list.cobalt.com/mailman/listinfo/cobalt-developers
>
>