Hi !
For my application I allow users to modify several settings and one of
them is the list of IP which are authorized to connect to a server
socket.
I know that consists in using SocketPermission class.
The stuff is that configuration should be intuitive so I want users do
not have to modify directly the java.policy file but just a simple
properties file.
Does it possible to modify programmatically java.policy? Or have I to
develop a routine that perform this check (IP related), so without
using AccessController and SecurityManager?
Thanks a lot for your advices.
-o--
Shin - 06 Dec 2005 17:05 GMT
I may not understand your situation correctly, but here is a few
options I can think of:
1. the user can have a customized policy file, say, test.policy, and
this can be passed to the application when lauching java
2. you can consider using AccessController.doPriviledged(..) in your
class where you first check whether the IP is allowed, then wrap the
connection code inside a priviledged action.
The list of allowed IPs can be build at the start of the program by
reading some regular file user can modifiy.
-Shin