Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HELP Needed with RMI example  RSS feed

 
Con Lu
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will firstly describe how my RMI example works fine WITHOUT a Security Manager. Then I will describe the problems when running WITH a Security Manager
WITHOUT A SECURITY MANAGER
The following files are included in directory C:\A\B\C\bank on machine C1
BankInterface.class
ASBBank.class (Remote object implementing BankInterface.class)
ASBBank_Skel.class
ASBBank_Stub.class
ATMServer.class
The following files are included in directory C:\D\E\F\bank on machine C2
BankInterface.class
ASBBank_Skel.class
ASBBank_Stub.class
ATMClient.class
Steps when run successfully without a security manager
On C1
1) Set classpath to c:\A\B\C
2) Go to c:\A\B\C
3) Type command: start rmiregistry 2010
4) Start server by: java bank.ATMServer C1:2010
On C2
1) Set classpath to c:\D\E\F
2) Go to c:\D\E\F
3) Type command: java bank.ATMClient C1:2010
Program works!!!
WITH A SECURITY MANAGER
When using a security policy file the following changes are made:-
On C1
1) ATMServer main method is changed to include following code:-
if(System.getSecurityManager() == null)
System.setSecurityManager(new
RMISecurityManager());
2) Create security policy file c:\security\java.policy as follows:-
grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept";
};
Steps when run unsuccessfully
On C1
1) Go to c:\A\B\C
2) Type command: start rmiregistry 2010
3) Start server by:
java
-Djava.security.policy=c:\security\java.policy bank.ATMServer C1:2010
4) Result:
Error – java.security.AccessControlException: access denied (java.net.SocketPermission C1 resolve)
QUERIES:
1)What am I doing wrong – how can I get the application to work?
2)Even if I got the server to work on C1, is it necessary to create a separate security policy for C2, as well as set a Security Manager in ATMClient similar to in ATMServer?
3)Could it be that other security policies (some also named java.policy) for other applications (such as WebLogic etc) on my machine are overriding my specific security policy file?
Any help would be very much appreciated, as I am getting really frustrated (as evidenced by my number of posts!?)
 
Marco Barenkamp
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the message says that you are not allowed to "resolve" the host.
Add "resolve" to the permission and everything should work as expected.
grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve";
};
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!