Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path">path of znode we are accessing</param>
        /// <param name="perm">Privileges required for the action</param>
        private void CheckACL(string path, int perm)
        {
            DataAndVersion node;

            _data.TryGetValue(path, out node);
            if (node == null)
            {
                return;
            }
            List <ACL> acl = node.acl;

            if (acl == null || acl.Count == 0)
            {
                return;
            }
            foreach (ZKId authId in _ids)
            {
                if (authId.Scheme == "super")
                {
                    return;
                }
            }
            foreach (ACL a in acl)
            {
                ZKId id = a.Id;
                if ((a.Perms & perm) != 0)
                {
                    if (id.Scheme.ToLower() == "world" && id.Id.ToLower() == "anyone")
                    {
                        return;
                    }
                    foreach (ZKId authId in _ids)
                    {
                        if (authId.Scheme == id.Scheme && authId.Id == id.Id)
                        {
                            return;
                        }
                    }
                }
            }
            throw new KeeperException.NoAuthException();
        }
Ejemplo n.º 2
0
        public void Deserialize(IInputArchive a_, string tag)
        {
            a_.StartRecord(tag);
            this.Type = a_.ReadInt("type");
            this.Zxid = a_.ReadLong("zxid");
            this.Data = a_.ReadBuffer("data");
            IIndex index = a_.StartVector("authinfo");

            if (index != null)
            {
                List <ZKId> zkIdList = new List <ZKId>();
                while (!index.Done())
                {
                    ZKId zkId = new ZKId();
                    a_.ReadRecord((IRecord)zkId, "e1");
                    zkIdList.Add(zkId);
                    index.Incr();
                }
                this.Authinfo = (IEnumerable <ZKId>)zkIdList;
            }
            a_.EndVector("authinfo");
            a_.EndRecord(tag);
        }