Exemplo n.º 1
0
        public Task <PermissionSet> GetPermissions(IReadOnlyList <SignatureEvidence> authentication, LedgerPath path, bool recursiveOnly, string recordName)
        {
            PermissionSet currentPermissions = PermissionSet.Unset;

            foreach (Acl acl in permissions)
            {
                if (acl.IsMatch(authentication, path, recursiveOnly, recordName))
                {
                    currentPermissions = currentPermissions.Add(acl.Permissions);
                }
            }

            return(Task.FromResult(currentPermissions));
        }
Exemplo n.º 2
0
        public async Task <PermissionSet> GetPermissions(IReadOnlyList <SignatureEvidence> identities, LedgerPath path, bool recursiveOnly, string recordName)
        {
            PermissionSet currentPermissions = PermissionSet.Unset;

            Record record = await this.store.GetRecord(new RecordKey(RecordType.Data, path, AclResourceName));

            if (record.Value.Value.Count == 0)
            {
                return(PermissionSet.Unset);
            }

            IReadOnlyList <Acl> permissions;

            try
            {
                permissions = Acl.Parse(Encoding.UTF8.GetString(record.Value.ToByteArray()), path, keyEncoder);
            }
            catch (JsonReaderException)
            {
                return(PermissionSet.Unset);
            }
            catch (NullReferenceException)
            {
                return(PermissionSet.Unset);
            }

            foreach (Acl acl in permissions)
            {
                if (acl.IsMatch(identities, path, recursiveOnly, recordName))
                {
                    currentPermissions = currentPermissions.Add(acl.Permissions);
                }
            }

            return(currentPermissions);
        }