Beispiel #1
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, m_Folder))
            {
                try
                {
                    string path = System.IO.Path.Combine(BoxUtil.RunUOFolder, m_Folder);

                    System.IO.Directory.CreateDirectory(path);
                    msg = new GenericOK();
                }
                catch (Exception err)
                {
                    msg = new ErrorMessage("An error occurred when creating the folder:\n\n{0}", err.ToString());
                }
            }
            else
            {
                msg = new ErrorMessage("You can't create folders there");
            }

            return(msg);
        }
Beispiel #2
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, Path.GetDirectoryName(m_Filename)))
            {
                if (RemoteExplorerConfig.VeirfyExtension(m_Filename))
                {
                    try
                    {
                        StreamWriter writer = new StreamWriter(FullPath, false);
                        writer.Write(m_Text);
                        writer.Close();

                        msg = new GenericOK();
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("An I/O error occurred when writing the file.\n\n{0}", err.ToString());
                    }
                }
                else
                {
                    // Extension not supported
                    msg = new ErrorMessage("File type not allowed.");
                }
            }
            else
            {
                // Trying to upload to a folder that isn't registered for the user
                msg = new ErrorMessage("You aren't allowed to manipulate that folder.");
            }

            return(msg);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new BoxFolderInfo object
        /// </summary>
        /// <param name="username">The username of the user registered for acess to the explorer</param>
        public FolderInfo(string username)
        {
            m_Structure = new GenericNode();
            m_Folders   = new System.Collections.ArrayList(RemoteExplorerConfig.GetExplorerFolder(username));

            // Create the folders structure
            foreach (string folder in m_Folders)
            {
                BoxUtil.EnsureFolder(folder);

                GenericNode fNode = new GenericNode(folder);

                DoFolder(Path.Combine(BoxUtil.RunUOFolder, folder), fNode);

                m_Structure.Elements.Add(fNode);
            }
        }
Beispiel #4
0
        public override BoxMessage Perform()
        {
            string     folder = Path.GetDirectoryName(m_Filename);
            BoxMessage msg    = null;

            if (RemoteExplorerConfig.AllowAccess(Username, folder))
            {
                if (File.Exists(FullPath))
                {
                    FileInfo info = new FileInfo(FullPath);

                    if (info.Length <= RemoteExplorerConfig.MaxFileSize)
                    {
                        try
                        {
                            msg = new FileTransport();

                            StreamReader reader = new StreamReader(info.FullName);
                            (msg as FileTransport).Text = reader.ReadToEnd();
                            reader.Close();
                        }
                        catch (Exception err)
                        {
                            msg = new ErrorMessage("An I/O error occurred when reading the file:\n\n", err.ToString());
                        }
                    }
                    else
                    {
                        // File is too big
                        msg = new ErrorMessage("The requested file is too big.");
                    }
                }
                else
                {
                    // File not found
                    msg = new ErrorMessage("The requested file could not be found");
                }
            }
            else
            {
                // Trying to request a file from a folder that isn't registered
                msg = new ErrorMessage("The requested resource isn't available to you.");
            }

            return(msg);
        }
Beispiel #5
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, System.IO.Path.GetDirectoryName(m_Path)))
            {
                if (Directory.Exists(FullPath))
                {
                    try
                    {
                        Directory.Delete(FullPath, true);
                        msg = new GenericOK();
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("Couldn't delete the directory {0}. The following error occurred:\n\n{1}", m_Path, err.ToString());
                    }
                }
                else if (File.Exists(FullPath))
                {
                    try
                    {
                        File.Delete(FullPath);
                        msg = null;
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("Couldn't delete the file {0}. The following error occurred:\n\n{1}", m_Path, err.ToString());
                    }
                }
                else
                {
                    // Not found
                    msg = new ErrorMessage("The requested resource could not be found on the server, please refresh your view.");
                }
            }
            else
            {
                // Can't manipulate that folder
                msg = new ErrorMessage("You aren't allowed to manipulate the folder : {0}", m_Path);
            }

            return(msg);
        }
Beispiel #6
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            string folderOld = Path.GetDirectoryName(m_OldPath);
            string folderNew = Path.GetDirectoryName(m_NewPath);

            string from = Path.Combine(BoxUtil.RunUOFolder, m_OldPath);
            string to   = Path.Combine(BoxUtil.RunUOFolder, m_NewPath);

            if (RemoteExplorerConfig.AllowAccess(Username, folderOld) && RemoteExplorerConfig.AllowAccess(Username, folderNew))
            {
                try
                {
                    if (File.Exists(from))
                    {
                        File.Move(from, to);
                        msg = null;
                    }
                    else if (Directory.Exists(from))
                    {
                        Directory.Move(from, to);
                        msg = new GenericOK();
                    }
                    else
                    {
                        msg = new ErrorMessage("The requested object could not be found ({0})", m_OldPath);
                    }
                }
                catch (Exception err)
                {
                    msg = new ErrorMessage("An error occurred while processing the move request :\n\n{0}", err.ToString());
                }
            }
            else
            {
                msg = new ErrorMessage("You aren't allowed to access that.");
            }

            return(msg);
        }
Beispiel #7
0
        public override AuthenticationResult Authenticate(string password, bool hashed)
        {
            AuthenticationResult auth = base.Authenticate(password, AccountHandler.ProtectPasswords);

            if (auth == AuthenticationResult.Success)
            {
                string[] folders = RemoteExplorerConfig.GetExplorerFolder(Username);

                if (folders != null && folders.Length > 0)
                {
                    m_Folders = new ArrayList(folders);
                    return(AuthenticationResult.Success);
                }
                else
                {
                    return(AuthenticationResult.UnregisteredUser);
                }
            }
            else
            {
                return(auth);
            }
        }