// Add server // // Server for simple example application which computes the sum of two integers // if the sequence number of the call (seqnum) matches the expected value; // otherwise, add() will return 0. // // The sequence of seqnum is established by the SecureRandom // seed during the initial authentication of the RMI connection. // // R. Perry, July 1998 import java.io.*; import java.rmi.server.*; public class AddServer extends UnicastRemoteObject implements Add { private LoginServer L; public AddServer( LoginServer L) throws java.rmi.RemoteException { super(); this.L = L; } public int add( int x, int y, long seqnum) throws java.rmi.RemoteException, java.rmi.server.ServerNotActiveException { System.out.println( "AddServer: add(): called from " + this.getClientHost()); if( !L.verify( seqnum)) // client is unauthenticated or used bad sequence number return 0; return x + y; } }