public override DataTypeValue Evaluate(DataTypeValue[] _params, EvaluationContext ctx) { int size = _params.Length; if (size == paramsnum && _params[0] is AnyURIDataType && _params[1] is StringDataType) { try { Attributes _Attributes = Attributes.GetInstance(NodeFactory.GetInstanceFromString(_params[1].Value)); if (_params[0].Equals(_Attributes.Category) == false) { throw new IllegalExpressionEvaluationException(Indeterminate.IndeterminateSyntaxError); } var newctx = new EvaluationContext(ctx); newctx.Request.replaceAttributes(_Attributes); var ps = new PolicySchema(newctx.RootPolicyId); ps.evluate(newctx); if (newctx.GetResult(ps.RootElementID).Decision.IsPermit) { return(BooleanDataType.True); } if (newctx.GetResult(ps.RootElementID).Decision.IsDeny) { return(BooleanDataType.False); } } catch (Indeterminate ex) { throw new IllegalExpressionEvaluationException(ex.Message); } } throw new IllegalExpressionEvaluationException(stringIdentifer); }
public virtual void InitializePolicy(string policyDir, string policyID) { this.ps = PolicySchema.GetInstance(policyID); PolicySchema.AddPolicyLanguageModelFromDir(policyDir); //ps.encode(new OutputStream(System.Console.Out), new Indentation()); }
public virtual Result Evaluate(Request req, PolicySchema ps) { var ctx = new EvaluationContext(req); ps.evluate(ctx); ctx.RootPolicyId = ps.RootElementID; return(ctx.GetResult(ps.RootElementID)); }
public virtual Response Evaluate(Request req, PolicySchema ps) { var pdp = new PDP(); Result r = pdp.Evaluate(req, ps); this.DoObligations(r); this.DoAssociatedAdvice(r); var resp = new Response(); resp.XMLHeaderAttributes = req.XMLHeaderAttributes; resp.AddResult(r); return(resp); }