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

java.security.policy problem

 
Harry Cheng
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application can set the security policy file on the command line by

and within the application by

Everything works except when the <file> on command line doesn't exist, and the user is prompted a dialog box to enter the correct file name, then the application calls System.setProperty(). When this happens, it seems that the content of the correct policy file is not read, even System.setProperty() call is successful.
The following is the exception I get. Does anybody know what happen? How to fix it?
Thank you very much.

Exception in thread "main" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:267)
at java.security.AccessController.checkPermission(AccessController.java:394)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:540)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1039)
at java.net.Socket.<init>(Socket.java:257)
at java.net.Socket.<init>(Socket.java:95)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:20)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:115)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:494)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:169)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:313)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:79)
 
jyothi sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If u want to give policy file..why don't u maintain that separately from source code..and u can give the name of that file instead of <file> on the command prompt..and make sure to have that file in the directory from where u start the server or client..
hope this helps
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)

That means you installed an RMI security manager, but since it didn't find your policy file, you didn't have permission to do anything!
You only need a security manager & policy file if you intend to implement downloadable stubs, in which case you also need to specify the codebase when starting your server.
 
Aaron Dressin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I thought this was the case, but when I attempt to open the db file without a security manager, I get an File IO Access violation. What is up with that?
 
Harry Cheng
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Fly:

That means you installed an RMI security manager, but since it didn't find your policy file, you didn't have permission to do anything!

But System.getSecurityManager() came back null.
If the <file> on command line is correct, System.setProperty() never get called. This works.
If the -D is not set, then System.setProperty() is used to set the value from the dialog box, this works too.
The problem occurs only if the <file> on command line doesn't exsit, System.setProperty() is called to set the correct file from the dialog box.
Any idea why?
Thank you.
Harry
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem occurs only if the <file> on command line doesn't exsit, System.setProperty() is called to set the correct file from the dialog box.

Hi :-)
I don't have answer for you but I have an idea. Look at the API for java.security.Policy. This is good description for policy files.
Maybe try to use:

You can see what really you have in your environment.
Maybe this is not helpful but... :-)
Regards
Kinga
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic