Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.security.policy  RSS feed

 
cory wilkerson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a bit vague on java's security policy architecture. I have an RMI server setting out at x.x.x.x and would like to have my client connect to it but not via an "all" permission grant. Does anyone know what the specifics I need to specify are?
I was thinking java.net.SocketPermission which appears to let me connect out to the server, but then I run into a class loader denied issue...anyone have any experience in this realm? Please assist...stack trace follows
--------------------------------------------
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: access to class loader denied
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:83)
at Client.main(Client.java:14)
-----------------------------------------------
 
James Cook
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you have a new RMISecurityManager set up or you will only be able to load local classes on your classpath.
Net.socketpermission needs to be at least listen, accept, connect, giving the name of the DNS to which you are accessing
e.g. put into a file called, say mypolicy.txt
grant
{
permission java.net.SocketPermission "localhost:1024-", "listen,accept,connect";
};
where the 1024- means port 1024 or higher (unprivileged ones, in other words). If you don't specify a port, it applies to all ports.
You also need to specify the security policy filename you are using as a System property to the program e.g.
java -Djava.security.policy=file:///C:/jre/lib/security/mypolicy.txt program_name
Hope these pointers help.
Cheers, James.
Sun Certified Java 2 Developer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!