package fr.lifl.stc.stan.dsl; import java.util.ArrayList; import org.apache.bcel.generic.Type; import org.apache.bcel.generic.ObjectType; public class PolicyManager { private ArrayList shareWith = new ArrayList(); private ArrayList strictSecret = new ArrayList(); private ArrayList secret = new ArrayList(); void addShareWith(ShareWith p) { shareWith.add(p); } void addStrictSecret(String s) { strictSecret.add(new ObjectType(s)); } void addSecret(Secret p) { secret.add(p); } ArrayList getSecretFieldsFor(Type clazz) { for(Secret s: secret) if ( s.getSources().contains(clazz) ) return s.getSecretFields(); return new ArrayList(); } boolean strictSecretHas(Type t) { return strictSecret.contains(t); } boolean shareWithHas(Type src, Type dst) { for(ShareWith sw : shareWith) { if ( sw.getSources().contains(src) && sw.getTargets().contains(dst) ) return true; } return false; } public String toString() { return "Share With = " + shareWith + "\n" + "Strict Secret = " + strictSecret + "\n" + "Secret = " + secret ; } }