[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,

I have JavaMail with Tomcat working. Where is your JavaMail's jar files
located? I place it to .../WEB-INF/lib, set AllPermission and all is
working.
If you place your jar files outside of WEB-INF/lib, try to give
AllPermission to jar
files, for example:
grant codeBase "file:/usr/java/lib/-" {
        permission java.security.AllPermission;
};

If you still have problems, please contact, and I will check my working
configuration more precise.

If you need configure SocketPermission try to use port 25 instead 1024

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
>
>