package com.nailabs.abac.test; import com.nailabs.abac.process.*; import edu.stanford.peer.rbtm.credential.*; import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; import java.util.*; public class ClientAuthenticationService extends UnicastRemoteObject implements NegotiatorFactory { static HashMap configs = new HashMap(); public static final int PORT = 6666; FrontierManager frontiers; boolean isDone = false; static { try { LocateRegistry.createRegistry(1099); } catch(Exception ex) { ex.printStackTrace(); } } public ClientAuthenticationService(int port) throws RemoteException { super(); } public ClientAuthenticationService() throws RemoteException { this(PORT); } public Remote getNegotiator(String entity, Negotiator peer) throws RemoteException { if(!FrontierManager.getFrontiers().contains(entity))return null; Entity self = new SimpleEntity(entity); Entity oppo = peer.getSelf(); HashMap config = (HashMap)configs.get(self); config.put("Peer", oppo); NegotiationContext context = new NegotiationContext(config); TextGraphObserver observer = new TextGraphObserver(entity); RMINegotiator agent = null; Remote stub = null; // grab a set of credential graph engines System.out.println("Received request for " + entity + " from " + oppo.toString()); try { agent = new RMINegotiator(context); context.getGraph().addObserver(observer); //stub = (Negotiator)exportObject(agent); stub = (agent == null)? null: toStub(agent); } catch(Exception ex) { ex.printStackTrace(); } System.out.println("agent = " + agent); System.out.println("stub = " + stub); // construct a new negotiation context return stub; } public void kill() throws RemoteException { isDone = true; } public static void main(String arg[]) { //if (System.getSecurityManager() == null) { // System.setSecurityManager(new RMISecurityManager()); //} System.out.print("Loading from "); for(int i = 0; i < arg.length; i++) { System.out.print(arg[i]); //check for int port number (TBD) HashMap config = TestEngine.loadConfiguration(arg[i]); Entity id = (Entity)config.get("EntityID"); System.out.println("Loading configuration for " + id); //System.out.print(" (config = "); //System.out.print(config); //System.out.println("), "); FrontierManager.addFrontier(config); configs.put(id, config); } System.out.println("."); try { ClientAuthenticationService service = new ClientAuthenticationService(); Naming.rebind("ClientAuthenticationService", service); } catch(Exception ex) { ex.printStackTrace(); } } }