public void SetPolicy(string policyAction, ApiCondition condition, string policyComment, EffectType policyEffect, string policyPrincipal, string policyResource) { thisPermission = new PermissionStatement { Action = policyAction, ApiConditions = condition, Comment = policyComment, Effect = policyEffect, Principal = policyPrincipal, Resource = policyResource }; Action = PlayerController.GetPolicyAction(policyAction); ApiConditions = condition; Comment = policyComment; Effect = policyEffect; Principal = policyPrincipal; Resource = policyResource; commentText.text = $"<i>{policyComment}</i>"; resourceText.text = $"<b>Resource</b>\n\"{policyResource}\""; actionText.text = "<b>Action</b>\n" + policyAction; principalText.text = "<b>Principal</b>\n" + policyPrincipal; effectText.text = "<b>Effect</b>\n" + policyEffect.ToString(); }
public bool Can(PolicyAction action, PolicySubject subject) { var allowed = Policies.ContainsKey(action) ? Policies[action].Any(s => s == subject) : false; return(allowed); }
public void Allow(PolicyAction action, params PolicySubject[] subjects) { if (Policies.ContainsKey(action)) { Policies[action] = subjects.ToList(); } else { Policies.Add(action, subjects.ToList()); } }
public BasicPolicy(PolicyCondition condition, PolicyAction policyAction) { this.Condition = condition; this.Policy = policyAction; }