Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Security Policy File

 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I need to use a SecurityManager, How do I include the location of the policy file when starting the program, without command line inputs ?

Can I change my code to incorporate it? Or Do I have to have it as a Command Line input when I run the code..like the following;
java -Djava.security.policy=java.policy client.URLClient localhost

Would the latter be a bad way of doing this?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

To set a policy programmatically, you could try setting the property at runtime (it's just an ordinary system property, after all), and then installing a security manager. Not sure if it would work that way, though.
 
Kevin Conaway
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sham,

Not sure about your assignment, but mine explicitly forbids a.) Using a SecurityManager and B.) using command line arguments.

Double check your assignment before going further.

Kevin
 
Eiji Seki
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful, my spec prohibits command-line parameters.
If you need that or is having too much dificulties because you cannot use that, maybe you are doing more than you should.
 
Aruneesh Salhotra
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess all the assignments disallow the command line arguments.
 
Sham Delaney
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Yes, I have the B&S assignment. I am a little confused though. Use of a SecurityManager is forbidden, so does that mean i cannot use the following line.
if (System.getSecurityManager() == null)
System.setSecurityManager ( new RMISecurityManager() );

How do I get around this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic