private void StorePolicy(PolicyRuleProject rule) { this.EnsurePoliciesFolder(); var repository = new LocalPolicyRuleProjectRepository(this.GetPoliciesStorePath()); repository.Save(rule); }
public PolicyRuleProject CreateBlank() { var rule = this.Parse("{\"then\": {\"effect\": \"deny\"},\"if\": { \"anyof\": []}}"); var ruleProject = new PolicyRuleProject(Guid.NewGuid().ToString(), rule); this.StorePolicy(ruleProject); return(ruleProject); }
public PolicyRuleProject CreateFromExisting(ParseExistingViewModel model) { var jsonToParse = this.GetStringToParse(model); var rule = this.Parse(jsonToParse); var ruleProject = new PolicyRuleProject(Guid.NewGuid().ToString(), rule); this.StorePolicy(ruleProject); return(ruleProject); }
public void Update(string id, string text) { var repository = new LocalPolicyRuleProjectRepository(this.GetPoliciesStorePath()); var project = repository.Get(id); if (project == null) { throw new InvalidOperationException("Rule not found"); } var rule = this.Parse(text); var ruleProject = new PolicyRuleProject(project.Id, rule); this.StorePolicy(ruleProject); }