[8780cbec] | 1 | package com.nailabs.abac.process; |
---|
| 2 | |
---|
| 3 | import com.nailabs.abac.trust.*; |
---|
| 4 | import com.nailabs.abac.test.*; |
---|
| 5 | import java.util.*; |
---|
| 6 | |
---|
| 7 | /** |
---|
| 8 | * An implication edge represents an edge in a trust target graph |
---|
| 9 | * (<CODE>TTG</CODE>) with accompanying evidence. An implication edge |
---|
| 10 | * is proved by a set of credentials (i.e. a chain). |
---|
| 11 | */ |
---|
| 12 | public class ImplicationEdge extends EdgeOperation { |
---|
| 13 | |
---|
| 14 | /** Jared: Added this method to make XML processing easier */ |
---|
| 15 | public ImplicationEdge() { |
---|
| 16 | super(); |
---|
| 17 | type = new String("Implication"); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | /** |
---|
| 21 | * Default constructor |
---|
| 22 | * @param parent an upcast StandardTTNode |
---|
| 23 | * @param child an upcast TargetNode |
---|
| 24 | */ |
---|
| 25 | public ImplicationEdge(Goal parent, Goal child, ProcessingState state, |
---|
| 26 | HashSet evidence) { |
---|
| 27 | super(parent, child, state, evidence); |
---|
| 28 | type = new String("Implication"); |
---|
| 29 | debug("edge", "state = " + state ); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | public void performAdditional(TTG graph) { |
---|
| 33 | StandardTTNode parent=(StandardTTNode)graph.getNodeByHash(getParent()); |
---|
| 34 | TargetNode child = (TargetNode)graph.getNode(getChild()); |
---|
| 35 | debug("perform", "performing " + toString(parent, child)); |
---|
| 36 | parent.addImplicationChild(child); |
---|
| 37 | child.addImplicationParent(parent); |
---|
| 38 | //propagate satisfaction for all nodes |
---|
| 39 | int satisfaction = child.getSatisfactionValue(); |
---|
| 40 | debug("perform", "child is satified = " + |
---|
| 41 | (satisfaction == SatisfactionState.SATISFIED)); |
---|
| 42 | //if(child instanceof TrivialTTNode) |
---|
| 43 | //parent.receive((TrustTarget)child.getGoal(), |
---|
| 44 | //new SatisfactionState(satisfaction)); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | public void performNewAdditional(TTG graph) { |
---|
| 48 | TTGNode child = graph.getNodeByHash(getChild()); |
---|
| 49 | if(child == null) { |
---|
| 50 | child = TTGNode.createNode(getChild()); |
---|
| 51 | debug("newop", performNewInfo()); |
---|
| 52 | // set processing if necessary here |
---|
| 53 | if(state != null) { |
---|
| 54 | child.getProcessingState().update(state); |
---|
| 55 | } else { |
---|
| 56 | debug("newop", "warning perform new additional has no state"); |
---|
| 57 | } |
---|
| 58 | graph.putNodeByHash(child); |
---|
| 59 | } |
---|
| 60 | performAdditional(graph); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | /** Friendly debugging convenience method */ |
---|
| 64 | protected void debug(String level, String message) { |
---|
| 65 | StringBuffer buff = new StringBuffer("ImplicationEdge: "); |
---|
| 66 | buff.append(message); |
---|
| 67 | Debug.debug(level, buff.toString()); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | public String toString(StandardTTNode parent, TargetNode child) { |
---|
| 72 | StringBuffer buff = new StringBuffer("[ImplicationEdge "); |
---|
| 73 | buff.append(parent).append(" <<=== "); |
---|
| 74 | buff.append(child); |
---|
| 75 | return buff.toString(); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | public String toString() { |
---|
| 79 | StringBuffer buff = new StringBuffer("[ImplicationEdge "); |
---|
| 80 | buff.append(getParent()).append(" <<=== "); |
---|
| 81 | buff.append(getChild()).append(", state = "); |
---|
| 82 | buff.append(state).append(", evidence = "); |
---|
| 83 | buff.append(getEvidence()); |
---|
| 84 | return buff.toString(); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|