Ejemplo n.º 1
0
        public bool IsGranted(string principal, Operation operation, string resource)
        {
            var operationString = operation.ToString().ToLowerInvariant();

            if (Denied.Contains(resource, operationString, principal))
            {
                return(false);
            }

            // If read is denied also write should be denied.
            if (operation == Operation.Write && Denied.Contains(resource, Operation.Read.ToString().ToLowerInvariant(), principal))
            {
                return(false);
            }

            if (Granted.Contains(resource, operationString, principal))
            {
                return(true);
            }

            // If write is granted also read should be granted.
            if (operation == Operation.Read &&
                Granted.Contains(resource, Operation.Write.ToString().ToLowerInvariant(), principal))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Can role do Permission.
 /// </summary>
 /// <remarks>Is this role granted with this permission.</remarks>
 /// <param name="permission">Permission.</param>
 /// <returns>Boolean indicating whether it can.</returns>
 public bool Can(Permission permission)
 {
     return(Granted.Contains(permission));
 }