package com.nailabs.abac.process; import com.nailabs.abac.trust.*; import com.nailabs.abac.test.*; import edu.stanford.peer.rbtm.credential.*; import edu.stanford.peer.rbtm.engine.*; import java.util.*; /** * A negotiation context contains all the objects necessary for performing * a trust negotiation transaction. */ public class NegotiationContext { // The frontiers for self are static in a context. /** This a shared data structure for accessing a principal's credentials */ protected FrontierManager frontier; /** The strategy for processing nodes in this negotiation. */ protected Strategy strategy; /** The trust target graph used to store the nodes */ protected TTG trustGraph; /** The remote negotiator in a two party negotiation */ protected Entity oppo; /** Credentials received from the opponent negotiator */ protected GraphEngine oppoCred; /** Observer for logging ttg information */ protected PropertiesObserver observer; /** Construct a new context for a specific negotiation */ public NegotiationContext(HashMap mediationInfo) { Entity self = (Entity)mediationInfo.get("EntityID"); Entity peer = (Entity)mediationInfo.get("Peer"); mediationInfo.put("context", this); frontier = FrontierManager.getFrontier(self); oppo = peer; observer = new PropertiesObserver(self); trustGraph = new TTG(this); trustGraph.addObserver(observer); strategy = StrategyFactory.getStrategy(mediationInfo); strategy.addObserver(observer); } /** public accessor method for the trust target graph */ public TTG getGraph() { return trustGraph; } /** public accessor mehotd for the processing instance */ public Strategy getStrategy() { return strategy; } /** public accessor method for the opponent */ public Entity getOpponent() { return oppo; } /** public accessor method for the frontier functions */ public FrontierManager getFrontier() { return frontier; } /** public accessor method for the local negotiator's identity */ public Entity getSelf() { return frontier.getSelf(); } /** adds a list of credentials from the opponent */ public void addCredentials(LinkedList otherCreds) { oppoCred.addCredentials(otherCreds); } /** Is the given credential a member of cS */ public boolean isTraceable(StaticCredential cred) { return frontier.isSelfReachable(cred); } public boolean subjectTracesAll(RoleName name) { return frontier.subjectTracesAll(name); } /** lookup method for Ack policy */ public EntityExpression getAck(EntityExpression e) { return frontier.getAck(e); } /** lookup method for AC policy */ public EntityExpression getAC(Credential cred) { return frontier.getAC(cred); } public String toString() { StringBuffer buff = new StringBuffer("[NegotiationContext "); buff.append(frontier).append(", "); buff.append(trustGraph).append(", "); buff.append(strategy).append("]"); return(buff.toString()); } }