public void LoadLawsFromJavaScriptFile() { JudgeAnderson judge = new JudgeAnderson(); judge.Load(new FileInfo("JusticeDepartment.js")); judge.Principal = new GenericPrincipal( new GenericIdentity("rico"), new string[] { "BankUser" }); object account = new { Owner = "rico", Balance = decimal.Zero }; judge.Enforce("CanWithdrawFromAccount", account); judge.Enforce("CanDepositToAccount", account); judge.Enforce("CanDisplayBalance", account); }
public void SimpleJavaScriptRuleFail() { JudgeAnderson judge = new JudgeAnderson(); judge.Load(@"function CanSeeBankAccount(principal) { return principal.IsInRole('BankingConsultant'); }"); judge.Principal = new GenericPrincipal( WindowsIdentity.GetCurrent(), new string[0]); judge.Enforce("CanSeeBankAccount"); }