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

Change SecurityManager in Runtime

 
John Chien
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there any way for my application to change SecurityManager on runtime ?
Scenario is as follow:
1) I am running in remote mode. In the middle, I want to change it to local mode. When in the remote mode, there is a SecurityManager. If I change it to local mode, the SecurityManager will stop application from reading the database. I would like set the SecurityManager to be null.
2) I am in local mode. The application does not have SecurityManager installed. In the middle, I would like to change to remote mode. The remote mode will require the application to install the SecurityManager.
How can I change the SecurityManager in the runtime ? Should I play on policy file instead of SecurityManager ? Should I remove SecurityManager ?
Thanks,
John Chien
 
John Chien
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I solved the problem by playing on the policy file.
I gave the permission to read and write db.db in the security policy file.
However, I am still interesetd in knowing how I can change SecurityManager in run time.
Does anybody have any idea about doing so ?
Thanks,
John Chien
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Basically, you extend the Security Manager, and use that instance.
HTH,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John, I would suggest not using a SecurityManager on the submission at all. It isn't necessary because we aren't doing dynamic downloading of stubs.

But it is still good to learn, if you want.
Mark
 
John Chien
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max, MarK:
Thank you for the answer.
I understand Mark's view.
We do not do class downloading. It is not required for the assignment.
However, I have already submitted the assignment with SecurityManager. Certainly, I tested it with two machine - Window 2000 and Window XP before submission.
I found that if we are in remote mote originally, we are going to have problem when we change to local mode. Because the application still has the SecurityManager. It just try to connect to local database. The SecurityManager will prevent the application from reading the local database. That's the reason I made change in policy file to give the client capability to read/write the database file.
Although I submmited the assignment with SecurityManager, I DO agree with Mark that we do not need SecurityManager in this assignment. It did cause several troubles when I was testing.
However, it is really good to know.
Max, your answer is good. Do you know any book or materials that talks about implementing a SecurityManager. I do not know what I should implement by extending a SecurityManager.
Is it possible to turn a SecurityManager OFF at run time and turn it ON sometime later ?

Thanks,
John Chien
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic