1 | package edu.stanford.peer.rbtm.engine; |
---|
2 | |
---|
3 | import java.util.*; |
---|
4 | import edu.stanford.peer.rbtm.credential.*; |
---|
5 | /** |
---|
6 | * A proof node which respresents an entity in the credential graph. |
---|
7 | */ |
---|
8 | public class EntityProofNode extends AbstractProofNode |
---|
9 | { |
---|
10 | /** |
---|
11 | * A map for managing all the partial solutions per intersection that arrive |
---|
12 | */ |
---|
13 | static protected PartialSolutionMap partialSolutions = |
---|
14 | new PartialSolutionMap(); |
---|
15 | |
---|
16 | /** |
---|
17 | * Default constructor |
---|
18 | */ |
---|
19 | protected EntityProofNode(ProofGraph graph, Entity re, int trackType) { |
---|
20 | super(graph, re, trackType); |
---|
21 | } |
---|
22 | |
---|
23 | public void additionalBackwardProcess() { |
---|
24 | //backwardSolutionAdded(this, getRoleExp()); |
---|
25 | } |
---|
26 | |
---|
27 | public void additionalForwardProcess() { |
---|
28 | |
---|
29 | } |
---|
30 | |
---|
31 | /** |
---|
32 | * Adds a forward solution but propagating the solution backwards along |
---|
33 | * the credential chain. If s is a partial solution and all k pieces have |
---|
34 | * arrived, then add edge from this node to the intersection. |
---|
35 | */ |
---|
36 | public void forwardSolutionAdded(ProofNode s, ForwardSolution r) { |
---|
37 | super.forwardSolutionAdded(s, r); |
---|
38 | EntityExpression expr = s.getRoleExp(); |
---|
39 | System.out.println("Additional forward processing on " + getRoleExp() + |
---|
40 | " where s = " + expr); |
---|
41 | Iterator iCreds = getGraph().findCredentialsByPartialSubject(expr); |
---|
42 | while(iCreds.hasNext()) { // if s is partial solution of intersection(s) |
---|
43 | StaticCredential credential = (StaticCredential) iCreds.next(); |
---|
44 | Intersection i = (Intersection)credential.getSubject(); |
---|
45 | System.out.println(getRoleExp() + " matches partial solution " + i); |
---|
46 | if(partialSolutions.addPartialSolution(i, expr)) { |
---|
47 | ProofNode node = getGraph().addForwardNode(i); |
---|
48 | node.addParent(node, r); |
---|
49 | } |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | |
---|