package com.nailabs.abac.process; import com.nailabs.abac.trust.*; import com.nailabs.abac.test.*; import java.util.*; /** * An implication edge represents an edge in a trust target graph * (TTG) with accompanying evidence. An implication edge * is proved by a set of credentials (i.e. a chain). */ public class ImplicationEdge extends EdgeOperation { /** Jared: Added this method to make XML processing easier */ public ImplicationEdge() { super(); type = new String("Implication"); } /** * Default constructor * @param parent an upcast StandardTTNode * @param child an upcast TargetNode */ public ImplicationEdge(Goal parent, Goal child, ProcessingState state, HashSet evidence) { super(parent, child, state, evidence); type = new String("Implication"); debug("edge", "state = " + state ); } public void performAdditional(TTG graph) { StandardTTNode parent=(StandardTTNode)graph.getNodeByHash(getParent()); TargetNode child = (TargetNode)graph.getNode(getChild()); debug("perform", "performing " + toString(parent, child)); parent.addImplicationChild(child); child.addImplicationParent(parent); //propagate satisfaction for all nodes int satisfaction = child.getSatisfactionValue(); debug("perform", "child is satified = " + (satisfaction == SatisfactionState.SATISFIED)); //if(child instanceof TrivialTTNode) //parent.receive((TrustTarget)child.getGoal(), //new SatisfactionState(satisfaction)); } public void performNewAdditional(TTG graph) { TTGNode child = graph.getNodeByHash(getChild()); if(child == null) { child = TTGNode.createNode(getChild()); debug("newop", performNewInfo()); // set processing if necessary here if(state != null) { child.getProcessingState().update(state); } else { debug("newop", "warning perform new additional has no state"); } graph.putNodeByHash(child); } performAdditional(graph); } /** Friendly debugging convenience method */ protected void debug(String level, String message) { StringBuffer buff = new StringBuffer("ImplicationEdge: "); buff.append(message); Debug.debug(level, buff.toString()); } public String toString(StandardTTNode parent, TargetNode child) { StringBuffer buff = new StringBuffer("[ImplicationEdge "); buff.append(parent).append(" <<=== "); buff.append(child); return buff.toString(); } public String toString() { StringBuffer buff = new StringBuffer("[ImplicationEdge "); buff.append(getParent()).append(" <<=== "); buff.append(getChild()).append(", state = "); buff.append(state).append(", evidence = "); buff.append(getEvidence()); return buff.toString(); } }