source: fedd/abac-src/rbtm/engine/RoleProofNode.java @ cdb62d9

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

ABAC sources from Cobham

  • Property mode set to 100644
File size: 4.1 KB
Line 
1package edu.stanford.peer.rbtm.engine;
2
3import java.util.*;
4
5import edu.stanford.peer.rbtm.credential.*;
6import edu.stanford.peer.rbtm.util.*;
7
8/**
9 * A proof node which represents a role in the credential graph.
10 */
11public class RoleProofNode extends AbstractProofNode
12{
13        /**
14         * A map for managing all the partial solutions per intersection that arrive
15         */
16   static protected PartialSolutionMap partialSolutions = 
17                 new PartialSolutionMap();
18
19   /** A forwarlinking monitor which handles linking goals */
20        private ForwardLinkingMonitor monitor;
21
22    protected RoleProofNode(ProofGraph graph, Role re, int trackType) {
23        super(graph, re, trackType);
24    }
25
26    public HashSet getChain(int size, EntityExpression target) {
27        if(target.equals(getRoleExp())) {
28            System.out.println("\n@@@@@ creating set of size " + size);
29            return new HashSet(size);
30        }
31        System.out.println("\n@@@@@ this = " + getRoleExp());   
32        ResultEvidenceMap solutions = getBackwardSolutions();
33        //ProofNode nextNode =(ProofNode)solutions.getResultEvidence(target);
34        HashSet soln = (HashSet)solutions.getResultEvidence(target);
35        System.out.println("solutions = " + solutions);
36        System.out.println("soln = " + soln);
37        //In the end, there can be only ONE . . .
38        ProofNode nextNode =(ProofNode)soln.iterator().next();
39        System.out.println("\n@@@@@ next = " + nextNode.getRoleExp() );
40        size++;
41        HashSet set = nextNode.getChain(size, target);
42        System.out.println("\n@@@@@ children  = " + nextNode.getChildren());
43        HashSet results = 
44            (HashSet)nextNode.getChildren().getResultEvidence(getRoleExp());
45        Iterator evidence = results.iterator();
46        while(evidence.hasNext()) {
47            set.add((Credential)evidence.next());
48        }
49        return set;
50    }
51
52    public void additionalBackwardProcess() {
53        Iterator  credIt = getGraph().findCredentialsDefiningRole((Role)getRoleExp());
54        while (credIt.hasNext()) {
55            StaticCredential credential = (StaticCredential) credIt.next();
56            ProofNode node = getGraph().addBackwardNode(credential.getSubject());
57            node.addChild(this, credential);
58            //if(addRole)backwardSolutionAdded(this, getRoleExp());
59        }
60    }
61
62    public void additionalForwardProcess() {
63                Role thisRole = (Role)getRoleExp();
64                // Make itself a forward solution to itself
65                forwardSolutionAdded(this, thisRole);
66               
67                if (monitor == null) {
68                ProofNode node = getGraph().addForwardNode(thisRole.getBase());
69                        monitor = new ForwardLinkingMonitor();
70                node.addForwardListener(monitor);
71                }
72    }
73         /**
74          * Adds a forward solution but propagating the solution backwards along
75          * the credential chain. If s is a partial solution and all k pieces have
76          * arrived, then add edge from this node to the intersection.
77          */
78         public void forwardSolutionAdded(ProofNode s, ForwardSolution r) {
79                  EntityExpression expr = s.getRoleExp();
80                  Iterator iCreds = getGraph().findCredentialsByPartialSubject(expr);
81                 
82                  super.forwardSolutionAdded(s, r);
83                  if(iCreds.hasNext()) {  // if s is partial solution of intersection(s)
84                                StaticCredential credential = (StaticCredential) iCreds.next();
85                                Intersection i = (Intersection)credential.getSubject();                         
86                                if(partialSolutions.addPartialSolution(i, expr)) {
87                                         ProofNode node = getGraph().addForwardNode(i);
88                                         node.addParent(node, r);
89                                }
90                  } 
91         }
92
93    class ForwardLinkingMonitor implements ForwardSolutionListener {
94        public void forwardSolutionAdded(ProofNode s,  ForwardSolution sol) {
95                        if (sol instanceof Role) {
96                                Role  role = (Role)sol;
97                                if (role.getName() instanceof RPermission) {
98                                        return;
99                                }
100                                LinkedRole linkedRole = 
101                                         new LinkedRole(role, ((Role)getRoleExp()).getName());
102                                //if (getGraph().hasCredentialsForSubject(linkedRole)) {
103                                ProofNode node = getGraph().addForwardNode(linkedRole);
104                                node.addParent(RoleProofNode.this, s);
105                                // addProofEdge(this, node, s);
106                        }
107        }
108
109            public String toString() {
110                return "Monitor " + getRoleExp();
111            }
112    }
113       
114       
115} // End of class RoleProofNode
116
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.