Exemple #1
0
        public void CheckPermission(HttpContext context, string path, int action)
        {
            string relativePath = Core.IO.Path.GetRelativePath(path);
            string strB         = Core.IO.Path.GetRoot(relativePath).ToLower();
            string str4         = strB;

            if ((str4 == null) || ((str4 != "pub") && (str4 != "public")))
            {
                AccountInfo currentUser = Instance.GetCurrentUser(context);
                string      user        = Core.IO.Path.GetUser(path);
                if (string.IsNullOrEmpty(user))
                {
                    user = currentUser.Name;
                }
                AccountInfo userInfo = AccountImpl.Instance.GetUserInfo(user);
                if ((userInfo.Type == 0L) || !userInfo.ContainsMember(currentUser.Name))
                {
                    if (userInfo.ID != currentUser.ID)
                    {
                        throw new PermissionException();
                    }
                    if (string.IsNullOrEmpty(relativePath) && ((this.RootDirectoryPermission & action) != action))
                    {
                        throw new PermissionException();
                    }
                    if (string.Compare(relativePath, strB, true) == 0)
                    {
                        if (strB == "public")
                        {
                            if ((this.RootPublicSubItemsPermission & action) != action)
                            {
                                throw new PermissionException();
                            }
                        }
                        else if ((this.RootSubItemsPermission & action) != action)
                        {
                            throw new PermissionException();
                        }
                    }
                    else if ((strB == "public") && ((this.PublicSubItemsPermission & action) != action))
                    {
                        throw new PermissionException();
                    }
                }
            }
        }
Exemple #2
0
        public void CheckPermission(HttpContext context, string path, int action)
        {
            string relative     = Path.GetRelativePath(path);
            string relativeRoot = Path.GetRoot(relative).ToLower();
            bool   isRootItem   = String.Compare(relative, relativeRoot, true) == 0;

            if ((relativeRoot == "pub") && !isRootItem && action == IOPermission.Read)
            {
                return;
            }
            if ((relativeRoot == "public") && !isRootItem && action == IOPermission.Read)
            {
                return;
            }

            AccountInfo currentUser = ServerImpl.Instance.GetCurrentUser(context);

            if (currentUser != null && currentUser.ID == 3)
            {
                return;
            }

            int owner = Path.GetUser(path);

            if (owner == 0)
            {
                owner = currentUser.ID;
            }
            AccountInfo ownerInfo = AccountImpl.Instance.GetUserInfo(owner);

            if (ownerInfo.Type == 1 && (ownerInfo.ContainsMember(currentUser.ID) || ownerInfo.SubType == 3))
            {
                return;
            }

            if (relativeRoot == "message" && ownerInfo.Type == 1)
            {
                try
                {
                    string[] nodes = relative.Split(new char[] { '/' }, 3, StringSplitOptions.RemoveEmptyEntries);
                    if (nodes.Length >= 2)
                    {
                        int msg_id = Convert.ToInt32(nodes[1].Substring(3));
                        if (!MessageImpl.Instance.CheckPermission(currentUser.ID, msg_id))
                        {
                            throw new PermissionException();
                        }
                        if (action == IOPermission.Read)
                        {
                            return;
                        }
                    }
                }
                catch
                {
                }
            }

            if (currentUser == null || ownerInfo.ID != currentUser.ID)
            {
                throw new PermissionException();
            }

            if (String.IsNullOrEmpty(relative) && (RootDirectoryPermission & action) != action)
            {
                throw new PermissionException();
            }

            if (String.Compare(relative, relativeRoot, true) == 0)
            {
                if (relativeRoot == "public")
                {
                    if ((RootPublicSubItemsPermission & action) != action)
                    {
                        throw new PermissionException();
                    }
                }
                else
                {
                    if ((RootSubItemsPermission & action) != action)
                    {
                        throw new PermissionException();
                    }
                }
            }
            else
            {
                if (relativeRoot == "public")
                {
                    if ((PublicSubItemsPermission & action) != action)
                    {
                        throw new PermissionException();
                    }
                }
                else
                {
                }
            }
        }