package fr.lifl.stc.stan.dsl; public class FlowChecker { private PolicyManager policies; public FlowChecker(PolicyManager pm) { policies = pm; } public boolean check(Flow f) throws FlowCheckerException { // System.out.println("VSS? : " + (f.link & Flow.VSS)); // System.out.println("RSS? : " + (f.link & Flow.RSS)); // System.out.println("RSP? : " + (f.link & Flow.RSP)); // System.out.println("VSP? : " + (f.link & Flow.VSP)); // System.out.println("RPP? : " + (f.link & Flow.RPP)); // System.out.println("RSS? : " + (f.link & Flow.RPP)); // System.out.println("RPS? : " + (f.link & Flow.RPS)); // System.out.println("VPS? : " + (f.link & Flow.VPS)); /* Secret to Public is always forbidden */ if ( (f.link & (Flow.RPS | Flow.VPS) ) != 0 ) throw new FlowCheckerException("Illegal Secret to Public flow : " + f); /* Secret to Secret */ if ( (f.link & (Flow.RSS | Flow.VSS) ) != 0 ) { /* Secret to Secret on same Class */ if ( f.srcType.equals(f.dstType) ) { /* Secret to Secret on same Instance */ if ( f.src == Flow.FLOW_THIS && f.src == f.dst ) { //System.out.println("share this<->this SS"); } /* is it a strict secret ? */ else { if ( policies.strictSecretHas(f.srcType) ) throw new FlowCheckerException("Strict secret violation : " + f); } } else { /* If we have a share with policy for this 'Secret to * Secret', don't complain. */ if ( ! policies.shareWithHas(f.srcType, f.dstType) ) throw new FlowCheckerException("Illegal flow between : " + f); } } return true; } }