Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// performs the validation for the locks acquired at this time.
        /// all nodes ancestors to child need to be in the RO lock list
        /// parent node needs to be in the RO if permParent is READ, or in the RW if permParent is > READ
        /// child node needs to be in the RO if permChild is READ, or in the RW if permChild is > READ
        /// </summary>
        /// <param name="parent">the parent node</param>
        /// <param name="permParent">the permissions supposed for the parent</param>
        /// <param name="child">the child node</param>
        /// <param name="permChild">the permissions supposed for the child</param>
        public void ValidateLockList(IPersistedData parent, Perm permParent, IPersistedData child, Perm permChild)
        {
            if (!DoLockingValidation)
            {
                return;
            }

            if (parent != null)
            {
                int parentlevel = parent.Node.GetLevel();
                if (permParent == Perm.READ)
                {
                    if (this.AddLockRo(parent.Node, parentlevel))
                    {
                        throw new InvalidOperationException();
                    }
                }
                else if (permParent != Perm.NONE)
                {
                    bool isEphemeral = false;

                    if (child == null || child.IsEphemeral)
                    {
                        isEphemeral = true;
                    }

                    if (this.AddLockRw(parent.Node, permParent, parentlevel, isEphemeral))
                    {
                        throw new InvalidOperationException();
                    }
                }
            }

            if (child != null)
            {
                int level;
                if (parent == null)
                {
                    level = child.Node.GetLevel();
                }
                else
                {
                    level = parent.Node.GetLevel() + 1;
                }

                if (permChild == Perm.READ)
                {
                    if (this.AddLockRo(child.Node, level))
                    {
                        throw new InvalidOperationException();
                    }
                }
                else if (permChild != Perm.NONE)
                {
                    if (this.AddLockRw(child.Node, permChild, level, child.IsEphemeral))
                    {
                        throw new InvalidOperationException();
                    }
                }

                Node n = child.Node;
                while (n != null)
                {
                    n = n.Parent;
                    if (n == null)
                    {
                        break;
                    }

                    if (this.AddLockRo(n, n.GetLevel()))
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
        }
Пример #3
0
 /// <inheritdoc />
 public void ValidateLockList(IPersistedData parent, Perm permParent, IPersistedData child, Perm permChild)
 {
 }
Пример #4
0
 /// <inheritdoc />
 public bool AddLockRw(Node parent, Perm cREATE, int parentLevel, bool isChildEphemeral)
 {
     throw new NotSupportedException();
 }