Esempio n. 1
0
        /// <summary>
        /// Adds the and lock ro.
        /// </summary>
        /// <param name="n">The n.</param>
        /// <param name="level">Level of the node</param>
        /// <returns>true if the lock was acquired with this call. false if it was already acquired</returns>
        public bool AddLockRo(Node n, int level)
        {
            if (n == null)
            {
                throw new ArgumentNullException("n");
            }

            n.Persisted.AppendRead(this.changelist);

            ISessionAuth auth = this.sessionAuth;

            if (!auth.IsSuperSession)
            {
                n.AclAllows(auth, Perm.READ);
            }

            // check for lockdown path
            this.ValidatePathNotInLockDown(n, false);

            if (this.readonlyInterfaceRequiresLocks)
            {
                if (!auth.IsLockFreeSession)
                {
                    this.lockCollections.AddLock(n, level, false);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public bool AddLockRw(Node n, Perm perm, int level, bool isChildEphemeral)
        {
            if (n == null)
            {
                throw new ArgumentNullException("n");
            }

            n.Persisted.AppendRead(this.changelist);

            ISessionAuth auth = this.sessionAuth;

            if (!auth.IsSuperSession)
            {
                n.AclAllows(auth, perm);
            }

            if (this.onlyOnEphemeral)
            {
                bool allowed = true;

                // n is ephemeral --> allowed.

                // n is not ephemeral --> maybe.
                if (!n.Persisted.IsEphemeral)
                {
                    if (perm != Perm.CREATE)
                    {
                        // not CREATE --> disallowed
                        allowed = false;
                    }
                    else
                    {
                        // if child is not ephemeral, disallowed
                        if (!isChildEphemeral)
                        {
                            allowed = false;
                        }
                    }
                }

                if (!allowed)
                {
                    throw new InvalidAclException(Node.BuildPath(n.Persisted), "only ephemerals can be modified by this session");
                }
            }

            // check for lockdown path
            this.ValidatePathNotInLockDown(n, true);

            if (!auth.IsLockFreeSession)
            {
                this.lockCollections.AddLock(n, level, true);
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public bool AddLockRo(Node n, int level)
        {
            if (n == null)
            {
                throw new ArgumentNullException("n");
            }

            if (!this.auth.IsSuperSession)
            {
                n.AclAllows(this.auth, Perm.READ);
            }

            return(false);
        }