source: fedd/abac-src/rbtm/test/EPub.java @ 4adc697

version-1.30
Last change on this file since 4adc697 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 edu.stanford.peer.rbtm.test;
2
3import edu.stanford.peer.rbtm.engine.*;
4import edu.stanford.peer.rbtm.credential.*;
5import edu.stanford.peer.rbtm.util.*;
6
7public class EPub 
8{
9    static GraphEngine mgr = new GraphEngine();
10    static Entity alice = new SimpleEntity("Alice");
11    static Entity bob = new SimpleEntity("Bob");
12    static EntityExpression[] parts;
13
14    public static void main(String arg[]) {
15        loadCredentials();
16        performSearches();
17    }
18
19    public static void performSearches() {
20        System.out.println("Credential Manager contains:");
21        System.out.println(mgr);
22        System.out.println("Forward search on " + alice + ":");
23        System.out.println(mgr.forwardSearch(alice));
24        System.out.println("------------------------------------");
25        System.out.println("Backward search on EPub.student:\n");
26        System.out.println(mgr.backwardSearch(new Role("EPub", "student")));
27        System.out.println("Backward search on EOrg.preferred:\n ");
28        System.out.println(mgr.backwardSearch(new Role("EOrg", "preferred")));
29
30        parts = loadRoles();
31        Intersection i = new Intersection();
32        i.and(parts[0]).and(parts[1]);
33        System.out.println("Backward search on " + i + ":\n ");
34        System.out.println(mgr.backwardSearch(i));
35    }
36
37    public static EntityExpression[] loadRoles() {
38        EntityExpression[] parts = new EntityExpression[2];
39        parts[0] = new Role("EPub", "student");
40        parts[1] = new Role("EOrg", "preferred");
41        return parts;
42    }
43   
44    public static void loadCredentials() {
45        SimpleEntity abu  = new SimpleEntity("ABU"),
46            acm  = new SimpleEntity("ACM"),
47            bbb  = new SimpleEntity("BBB"),
48            eOrg = new SimpleEntity("EOrg"),
49            ePub = new SimpleEntity("EPub"),
50            stateU = new SimpleEntity("StateU");
51        SimpleRoleName stuID = new SimpleRoleName("stuID"),
52            accredited = new SimpleRoleName("accredited"),
53            student = new SimpleRoleName("student"),
54            univ = new SimpleRoleName("university"),
55            member = new SimpleRoleName("member"),
56            preferred = new SimpleRoleName("preferred"),
57                 sale = new SimpleRoleName("sale"), 
58            discount = new SimpleRoleName("spdiscount");
59        Role ePubUniv = new Role(ePub, univ),
60            acmMember = new Role(acm, member),
61            abuAccredited = new Role(abu, accredited);
62        LinkedRole ePubUnivStuID = new LinkedRole(ePubUniv, stuID);
63        Intersection u = new Intersection();
64        u.and(new Role(eOrg, preferred)).and(new Role(ePub, student));
65        mgr.addCredential(new StaticCredential(new Role(ePub, sale),
66                                                                                                                new Role(ePub, discount)));
67        mgr.addCredential(new StaticCredential(ePub, discount, u));
68        mgr.addCredential(new StaticCredential(eOrg, preferred, acmMember));
69        mgr.addCredential(new StaticCredential(acmMember, alice));
70        mgr.addCredential(new StaticCredential(acmMember, bob));
71        mgr.addCredential(new StaticCredential(ePub, student, ePubUnivStuID));
72        mgr.addCredential(new StaticCredential(ePubUniv, abuAccredited));
73        mgr.addCredential(new StaticCredential(abuAccredited, stateU));
74        mgr.addCredential(new StaticCredential(stateU, stuID, alice));
75        mgr.addCredential(new StaticCredential(stateU, stuID, bob));
76        //mgr.addCredential(new StaticCredential());
77    }
78
79}
80
81
82
83
Note: See TracBrowser for help on using the repository browser.