source: fedd/abac-src/ttg/test/ClientAuthenticationService.java @ 53dfd4b

axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change on this file since 53dfd4b was 8780cbec, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

ABAC sources from Cobham

  • Property mode set to 100644
File size: 3.1 KB
Line 
1package com.nailabs.abac.test;
2
3import com.nailabs.abac.process.*;
4import edu.stanford.peer.rbtm.credential.*;
5import java.rmi.*;
6import java.rmi.server.*;
7import java.rmi.registry.*;
8import java.util.*;
9
10public class ClientAuthenticationService extends UnicastRemoteObject
11    implements NegotiatorFactory
12{
13    static HashMap configs = new HashMap();
14
15    public static final int PORT = 6666;
16    FrontierManager frontiers;
17    boolean isDone = false;
18
19    static {
20        try {
21            LocateRegistry.createRegistry(1099);
22        } catch(Exception ex) {
23            ex.printStackTrace();
24        }
25    }
26
27    public ClientAuthenticationService(int port) 
28        throws RemoteException
29    {
30        super();
31    }
32
33    public ClientAuthenticationService() throws RemoteException
34    {
35        this(PORT);
36    }
37
38    public Remote getNegotiator(String entity, Negotiator peer) 
39        throws RemoteException
40    {
41        if(!FrontierManager.getFrontiers().contains(entity))return null;
42        Entity self = new SimpleEntity(entity);
43        Entity oppo = peer.getSelf();
44        HashMap config = (HashMap)configs.get(self);
45        config.put("Peer", oppo);
46        NegotiationContext context = new NegotiationContext(config);
47        TextGraphObserver observer = new TextGraphObserver(entity);
48        RMINegotiator agent = null;
49        Remote stub = null;
50        // grab a set of credential graph engines
51        System.out.println("Received request for " + entity + " from " +
52                           oppo.toString());
53        try {
54            agent = new RMINegotiator(context);
55            context.getGraph().addObserver(observer);
56            //stub =  (Negotiator)exportObject(agent);
57            stub = (agent == null)? null: toStub(agent);
58        }
59        catch(Exception ex) {
60            ex.printStackTrace();
61        }
62        System.out.println("agent = " + agent);
63        System.out.println("stub = " + stub);
64        // construct a new negotiation context
65        return stub;
66    }
67
68    public void kill() throws RemoteException { isDone = true; }
69
70    public static void main(String arg[]) 
71    {
72        //if (System.getSecurityManager() == null) {
73        //    System.setSecurityManager(new RMISecurityManager());
74        //}
75
76        System.out.print("Loading from ");
77        for(int i = 0; i < arg.length; i++) 
78        {
79            System.out.print(arg[i]);
80            //check for int port number (TBD)
81            HashMap config = TestEngine.loadConfiguration(arg[i]);
82            Entity id = (Entity)config.get("EntityID");
83            System.out.println("Loading configuration for " + id);
84            //System.out.print(" (config = ");
85            //System.out.print(config);
86            //System.out.println("), ");
87            FrontierManager.addFrontier(config);
88            configs.put(id, config);
89        }
90        System.out.println(".");
91        try {
92            ClientAuthenticationService service = 
93                new ClientAuthenticationService();
94            Naming.rebind("ClientAuthenticationService", service);
95        }
96        catch(Exception ex) {
97            ex.printStackTrace();
98        }
99    }
100}
101
102
103
Note: See TracBrowser for help on using the repository browser.