RMI Database Access Simple Application

RMI Database Access Simple Application

RMI Database Access Application

Before this program, it is advised to read the previous simple application InterestCalculation where the basic notes and guidelines are given. This application adds extra features to the previous application like database access, security features and handling exceptions thrown by each method instead of throwing a generic Exception.

In this Bank application, the client requests the bank to supply name and account balance by supplying account number to the server. The implementation file returns the client data in the form of array list. In the client code, the data is retrieved from the array list and displayed to the user.

Like the previous example, this RMI Database application also includes 4 programs.

1. Remote interface
File Name: Bank.java

2. Implementation Program
File Name: BankImpl.java

3. Server Program
File Name: BankServer.java

The server after binding with the RMI registry, prints a confirmation message (to the server side developer) and this indicates the developer that the server is ready to handle client calls. As long as the remote object b1 has any client reference, b1 is not garbage collected and server does not shut down.

RMI Security Manager

  • The RMI security manager protects access to system data from unauthorized and untrusted downloaded code working on JVM.
  • The security manager checks the downloaded files has permission to local files and do oprations without proper privileges.
  • The security manager restricts the operations for downloaded files to security policy set earlier.

Following sets RMISecurityManager

if (System.getSecurityManager() == null) // if no security is provided
{
System.setSecurityManager(new RMISecurityManager()); // provide with RMI Security manager
}

To work with, the Developer is required to set the policy file to grant required permission effects. Developer still is required to go for digital signatures, export/import digital certificates and keystores etc for more security measuers and are required for sensitive banking applications (using different tools available in the markets).

4. Client Program
File Name: InterestClient.java

This program obtains a reference of the remote object of server and invokes remote methods.

Leave a Reply

Your email address will not be published. Required fields are marked *