I have written a sample RMI application that simply calculates the sum of two numbers.
My server.policy looks like:
grant {
permission java.net.SocketPermission "123.4.567.890:1024-", "accept, resolve";
};
and my client.policy looks like:
grant codeBase "file:/C:/Users/user/Documents/My_Workspace/Project/RMI/-" {
permission java.net.SocketPermission "123.4.567.890:1024-", "connect, resolve";
};
I read the documentation on the syntax of a policy file and learned that when you put a dash after the port number it means "this port number and greater". I don't know much about ports but, if i leave the dash out of the server.policy i get java.security.AccessControlException with random port numbers (seemingly between 50,000 and 65,000) but, if i leave the dash out of the client.policy i get the same java.security.AccessControlException with port number 1099 being the culprit every time.
I am wondering if there is a way to avoid having to put the dash in my policy files in order to allow my RMI application to work correctly.
Also, if it helps or matters at all i am specifying port 1099 in my createRegistry() and getRegistry() methods in the server/client respectively.
There is. If:
all remote objects will share the same port, port 1099.
But why is a dash in a .policy file such a big deal?