Forum Stats

  • 3,851,375 Users
  • 2,263,968 Discussions
  • 7,904,690 Comments

Discussions

Programatically setting security Policy

843811
843811 Member Posts: 49,851 Green Ribbon
I'm trying to reduce the number of arguments that have to pass to my program. I have a configuration file that I would like to specify java.* properties in, and have my program set them as needed.

How do I set the Policy file for the VM without specifying java.security.policy on the command line. I tried:

System.setProperty("java.security.policy", "my policy file" )

When is that system property read?

charlie

Comments

  • 843811
    843811 Member Posts: 49,851 Green Ribbon
    I guess by default if u dont specify any Polciy file u get the default Policy with default Permissions automatically..
    If u need to specify yr own policy then i guess u need to specify yr policy file...
  • 843811
    843811 Member Posts: 49,851 Green Ribbon
    here's what you have to do:
    extend the class:
    (in jdk 1.2) java.security.auth.Policy
    (in jdk 1.3/1.4) java.security.Policy

    and set up the policy in that code with permissions (and also override the getPermissions, etc methods (except for the setPolicy().

    Then in your file java.security set the property "policy.provider" to your myPolicy class.

    Then you'll have to make sure you give your code permissions to do what it needs to do.
This discussion has been closed.