Modifying /lib/security/java.policy


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Modifying /lib/security/java.policy

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Posts
    4

    Modifying /lib/security/java.policy

    Hi guys... just a quick question...
    If I have a program that opens and writes to the java.security file, and then I use the program to create and load an aglet, would the policies that I specified through the program apply to the aglet ?


    Thanks a million !!

  2. #2
    Join Date
    Jun 2004
    Posts
    199
    If that is the properties file the JVM you are using is pointing to, it should. Then again it might be already loaded. I'm not sure if there is a way to reload it. Might voliate the security. If you launch the applet in a new JVM it might be ok.

  3. #3
    Join Date
    Aug 2004
    Posts
    4
    Thank mnuttall ...
    I am now having a problem with java security policies and in particular, the java.util.property permission. It would be really appreciated and great if you could help me out a lil.

    Ok here it goes.

    I have a jar file with all these classes that I am extending in it. The jar file is in C:\NetAgent. so, the file name is C:\NetAgent\Bee20s.jar. I have another class that extends a class called "AgentWrapper". Class AgentWrapper is located in the jar file.

    Now, I have another class "public class AwNode extends AgentWrapper". AwNode is located in the path C:\NetAgent\AgentWrapperNode\

    I have a policy as such:

    grant codeBase "file:/C:/NetAgent/*" {
    permission java.util.PropertyPermission "*", "read, write";
    permission java.io.FilePermission "C:\\NetAgent\\-", "read, write, delete, execute";
    };

    I have added this policy to the java.security file.
    Now I keep getting security exceptions but I don't know why. I get this exception when I am run AwNode with the security manager.

    Exception in thread "main" java.security.AccessControlException: access denied (
    java.util.PropertyPermission * read,write)
    at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:270)
    at java.security.AccessController.checkPermission(AccessController.java:
    401)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
    at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:
    1259)
    at java.lang.System.getProperties(System.java:500)
    at com.toshiba.beegent.AgentWrapper.getClassDirectory(AgentWrapper.java:
    853)
    at com.toshiba.beegent.AgentWrapper.<init>(AgentWrapper.java:116)
    at AwNode.<init>(AwNode.java:10)
    at AwNode.main(AwNode.java:21)



    However, everything seems to run ok when I modify the policy to be:

    grant codeBase "file:/C:/NetAgent/*" {
    permission java.util.PropertyPermission "*", "read, write";
    permission java.io.FilePermission "C:\\NetAgent\\-", "read, write, delete, execute";
    };

    All I want to be able to do is to have control over AwNode. I believe I must provide the right permissions to Bee20s.jar to be able to do this.

    Thanks for your help.. Much appreciated !

  4. #4
    Join Date
    Aug 2004
    Posts
    4
    oops...
    the second policy should be
    grant codeBase "file:/C:/NetAgent/-" {
    permission java.util.PropertyPermission "*", "read, write";
    permission java.io.FilePermission "C:\\NetAgent\\-", "read, write, delete, execute";
    };


    sorry...

  5. #5
    Join Date
    Jun 2004
    Posts
    199
    Sorry I didn't get back with you.

    I've not had to do alot with policy files. I've probably should have but all my projects have been in house so there has been little need.

    I suggest checking out the forums on java.sun or one of the main java newsgroups (check out google).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center