aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JavaMail problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JavaMail problem" Watch "JavaMail problem" New topic
Author

JavaMail problem

P.Jamieson
Greenhorn

Joined: Apr 30, 2003
Posts: 21
Hi
I have some example JavaMail code. I have deployed it into my application. However, it complains about denied access to 1 line, system properties. Can you tell me how to overcome this problem and the best way to integrate this into my application (i.e. session bean).
Thanks!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you reproduce the actual error message for us?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
P.Jamieson
Greenhorn

Joined: Apr 30, 2003
Posts: 21
Thanks for the reply...
Here is the exception:
java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
This happens when I try to get system properties in order to connect to my mail server. I also tried some other code from Sun that uses JSP with the JavaMail. I tried it and I get the same error. I am sure that it is a security setting, but I am not sure how to do this in the descriptor.
P.Jamieson
Greenhorn

Joined: Apr 30, 2003
Posts: 21
I was able to make a change in the security.policy file from a "read" permission to a "read,write" permission. That has solved the problem. However, is this the best way? Have I compromized my web security?
As follows...
// permissions for default domain
grant {
permission java.net.SocketPermission "*", "connect";
permission java.util.PropertyPermission "*", "read,write";
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
In general, you should keep your security on as tight a leech as possible. I'd try to add another grant for the "read, write" PropertyPermission for a more specific code base instead of "everything".
P.Jamieson
Greenhorn

Joined: Apr 30, 2003
Posts: 21
Thanks, I'll give that a try...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JavaMail problem