[8780cbec] | 1 | package com.nailabs.abac.process; |
---|
| 2 | |
---|
| 3 | import java.util.*; |
---|
| 4 | import edu.stanford.peer.rbtm.credential.*; |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * The acknowledgement policy specifies which opponents can be allowed |
---|
| 8 | * to receive acknowledgement of credentials possessed by this negotiator. |
---|
| 9 | */ |
---|
| 10 | public class AckPolicy implements edu.stanford.peer.rbtm.RBTMConstants, |
---|
| 11 | java.io.Serializable { |
---|
| 12 | /** The policy data store */ |
---|
| 13 | public HashMap factMap = new HashMap(FACT_MAP_SIZE); |
---|
| 14 | |
---|
| 15 | /** Add a fact from the supplied strings */ |
---|
| 16 | public void addAckFact(String base, String roleName, String expr) { |
---|
| 17 | try { |
---|
| 18 | factMap.put(new Role(base, roleName), |
---|
| 19 | StaticCredential.getEntityExpression(expr)); |
---|
| 20 | } |
---|
| 21 | catch(Exception ex) { |
---|
| 22 | if(DEBUG)ex.printStackTrace(); |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | /** Add a fact from the supplied object */ |
---|
| 27 | public void addAckFact(EntityExpression role, EntityExpression req) { |
---|
| 28 | factMap.put(role, new AckFact(role, req)); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | /** Return a vector of sensitive roles for the predicate */ |
---|
| 32 | public Vector getSensitiveRoles() { |
---|
| 33 | return new Vector(factMap.keySet()); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | * Useful for forward discovery. |
---|
| 38 | * @return a set of all roles which satisfy the sensitive requirements |
---|
| 39 | */ |
---|
| 40 | public Vector getRequiredRoles() { |
---|
| 41 | return new Vector(factMap.values()); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /** Query policy for the required role to unlock the role expression */ |
---|
| 45 | public EntityExpression requires(EntityExpression key) { |
---|
| 46 | AckFact fact = (AckFact)factMap.get((Object)key); |
---|
| 47 | if(fact == null) |
---|
| 48 | return null; |
---|
| 49 | else |
---|
| 50 | return (EntityExpression)fact.getRequirement(); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /** Returns the underlying storage data structure in a printable format */ |
---|
| 54 | public String toString() { |
---|
| 55 | return factMap.toString(); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | } |
---|