Пример #1
0
    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();
    }
Пример #2
0
        public bool Can(PolicyAction action, PolicySubject subject)
        {
            var allowed = Policies.ContainsKey(action)
                ? Policies[action].Any(s => s == subject)
                : false;

            return(allowed);
        }
Пример #3
0
 public void Allow(PolicyAction action, params PolicySubject[] subjects)
 {
     if (Policies.ContainsKey(action))
     {
         Policies[action] = subjects.ToList();
     }
     else
     {
         Policies.Add(action, subjects.ToList());
     }
 }
Пример #4
0
 public BasicPolicy(PolicyCondition condition, PolicyAction policyAction)
 {
     this.Condition = condition;
     this.Policy    = policyAction;
 }