package com.nailabs.abac.process; import java.util.*; import edu.stanford.peer.rbtm.credential.*; /** * The acknowledgement policy specifies which opponents can be allowed * to receive acknowledgement of credentials possessed by this negotiator. */ public class AckPolicy implements edu.stanford.peer.rbtm.RBTMConstants, java.io.Serializable { /** The policy data store */ public HashMap factMap = new HashMap(FACT_MAP_SIZE); /** Add a fact from the supplied strings */ public void addAckFact(String base, String roleName, String expr) { try { factMap.put(new Role(base, roleName), StaticCredential.getEntityExpression(expr)); } catch(Exception ex) { if(DEBUG)ex.printStackTrace(); } } /** Add a fact from the supplied object */ public void addAckFact(EntityExpression role, EntityExpression req) { factMap.put(role, new AckFact(role, req)); } /** Return a vector of sensitive roles for the predicate */ public Vector getSensitiveRoles() { return new Vector(factMap.keySet()); } /** * Useful for forward discovery. * @return a set of all roles which satisfy the sensitive requirements */ public Vector getRequiredRoles() { return new Vector(factMap.values()); } /** Query policy for the required role to unlock the role expression */ public EntityExpression requires(EntityExpression key) { AckFact fact = (AckFact)factMap.get((Object)key); if(fact == null) return null; else return (EntityExpression)fact.getRequirement(); } /** Returns the underlying storage data structure in a printable format */ public String toString() { return factMap.toString(); } }