source: fedd/abac-src/ttg/test/DiscoveryTest.java @ 8780cbec

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

ABAC sources from Cobham

  • Property mode set to 100644
File size: 3.0 KB
Line 
1package com.nailabs.abac.test;
2
3import java.io.*;
4import java.util.*;
5
6import com.nailabs.abac.credential.*;
7import com.nailabs.abac.process.*;
8import com.nailabs.abac.trust.*;
9import edu.stanford.peer.rbtm.credential.*;
10
11public class DiscoveryTest extends RtmlTest {
12    /** parse the lookup table to map an entity to its host */
13    public static void parsePrepInfo(HashMap conf) {
14        // this method may not be needed once cred domains contain urls
15        String section = "PrepInfo";
16        HashSet propSet = (HashSet)conf.get(section);
17        Properties props = new Properties();
18        try {
19            Iterator i = propSet.iterator();
20            while(i.hasNext()) {
21                props.load(new StringBufferInputStream((String)i.next()));
22            }
23            props.list(System.out);
24            conf.put(section, props);
25        } catch (Exception ex) {
26            //ex.printStackTrace();
27        }
28    }
29
30    public static HashMap loadConfiguration(String name) {
31        HashMap map = RtmlTest.loadConfiguration(name);
32        parsePrepInfo(map);
33        return map;
34    }
35
36
37    public static void main(String arg[]) {
38        HashMap oConf = loadConfiguration((arg.length>0)?arg[0]:"ussh.txt");
39        HashMap vConf = loadConfiguration((arg.length>1)?arg[1]:"sadmir.txt");
40        TrustTarget primaryTT = null;
41
42        // Create frontiers
43        FrontierManager.addFrontier(vConf);
44        FrontierManager.addFrontier(oConf);
45        // Create entities for the negotiators
46        Entity o = (Entity)oConf.get("EntityID");
47        Entity v = (Entity)vConf.get("EntityID");
48
49        System.out.println("vConf = " + vConf.toString());     
50        System.out.println("oConf = " + oConf.toString());
51
52        // Initialize the contexts for each side
53        NegotiationContext oContext = new NegotiationContext(oConf);
54        NegotiationContext vContext = new NegotiationContext(vConf);
55       
56        PropertiesObserver oObs = 
57            new PropertiesObserver(oContext.getSelf());
58        PropertiesObserver vObs = 
59            new PropertiesObserver(vContext.getSelf());
60        RMINegotiator oAgent = null, vAgent = null;
61
62        try {
63        oAgent = new RMINegotiator(oContext);
64        vAgent = new RMINegotiator(vContext);
65        //v = new RtmlEntity("SAdmir", "FakeHashKeySAdmir");
66        //o = new RtmlEntity("USSH", "FakeHashKeyUSSH");
67        System.out.println("opponent = " + o + "," + o.hashCode());
68        System.out.println("verifier = " + v + "," + v.hashCode());
69        Role targetRole = new Role(v, new SimpleRoleName("getsSLocs"));
70        System.out.println("target role = " + targetRole + 
71                           "," + targetRole.hashCode());
72        primaryTT = new TrustTarget(v, targetRole, o);
73
74        oContext.getGraph().addObserver(oObs);
75        oContext.getStrategy().addObserver(oObs);
76        vContext.getGraph().addObserver(vObs);
77        vContext.getStrategy().addObserver(vObs);
78        }
79        catch(Exception ex) {
80            ex.printStackTrace(System.err);
81        }
82        vAgent.setPeer(oAgent);
83        System.out.println("Primary trust target = " + primaryTT);
84        vAgent.setRoot(primaryTT);
85        boolean success = vAgent.negotiate();
86        System.out.println("The negotiation has " + ((success)? "succeeded":
87                           "failed"));
88        oObs.close();
89        vObs.close();
90        System.exit(0);
91    }
92
93}
Note: See TracBrowser for help on using the repository browser.