private void SecureFolderThread() { string FolderSecureAssembly = ConfigurationSettings.AppSettings["FolderSecure"]; try { ISecureFolder SecureFolder = new InstantiateElement().CreateNewInstance(FolderSecureAssembly) as ISecureFolder; string FolderToLock = TargetEntity; folderBrowserDialog1.Reset(); try { SecureFolder.LockFolder(FolderToLock, PasswordToLock); } catch (Exception LockFailed) { new RemoveTemporaryFiles().Remove(); MessageBox.Show("Folder locking failed as a result of the exception: " + LockFailed.Message, "Locking failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (ArgumentNullException NamespaceNotFound) { MessageBox.Show("The folder cannot be locked because, one or more files of Secure Bin has been corrupted", "Locking failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Invoke(Quit); }
public void LockFile(string filepath, string password) { Validate PasswordValidate = new PasswordValidation(password); PasswordValidate.ValidateData(); Validate FileExistsValidate = new SBNExists(Path.GetFileName(filepath)); FileExistsValidate.ValidateData(); CreateSTF GenerateSTF = new CreateSTF(filepath, HEADERCODE, ENDMARKER); GenerateSTF.GenerateSTF(); IEncrypt Encrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Encrypter_Assembly"], Path.GetFileName(filepath), password) as IEncrypt; Encrypter.EncryptFile(); string STFFilename = ConfigurationSettings.AppSettings["AllEntityLocation"] + Path.GetFileName(filepath) + "." + ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]; if (File.Exists(STFFilename)) { File.Delete(STFFilename); } if (bool.Parse(ConfigurationSettings.AppSettings["DeleteSource"]) == true) { if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } } }
private void SecureFileThread() { try { ISecureFile SecureFile = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["FileSecure"]) as ISecureFile; SecureFile.LockFile(TargetEntity, PasswordToLock); } catch (Exception LockFailed) { new RemoveTemporaryFiles().Remove(); MessageBox.Show("File locking failed as a result of the exception: " + LockFailed.Message, "Locking failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Invoke(Quit); }
private void UnlockFile() { try { string FileSecureAssembly = ConfigurationSettings.AppSettings["FileSecure"]; ISecureFile SecureFile = new InstantiateElement().CreateNewInstance(FileSecureAssembly) as ISecureFile; SecureFile.UnlockFile(EntityName, UnlockDest, UnlockPassword); IProcess ProcessObject = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["ProcessNamespace"], UnlockDest) as IProcess; ProcessObject.RunProcess(); } catch (Exception UnlockException) { new RemoveTemporaryFiles().Remove(); MessageBox.Show(EntType.ToString() + " unlocking failed as a result of the following exception : " + UnlockException.Message, EntType.ToString() + " unlocking failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Invoke(Quit); }
public void UnlockFolder(string Filename, string NewRoot, string Password) { #region Unlock Folder Implementation Validate PasswordValidate = new PasswordValidation(Password); PasswordValidate.ValidateData(); string SBNFilename = GetSBNName(Filename); string STFFilename = GetSTFName(Filename); IDecrypt Decrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Decrypter_Assembly"], Path.GetFileName(SBNFilename), Password) as IDecrypt; try { Decrypter.DecryptFile(); } catch (Exception DecryptException) { throw (new ApplicationException("Incorrect password")); } ExtractSTF ExtractSTFFile = new ExtractSTF(STFFilename); UnlockParameters STFContents = ExtractSTFFile.ExtractSTFContents(); VerifySTFIntegrity CheckIntegrity = new VerifySTFIntegrity(); if (!CheckIntegrity.Verify(STFContents.FooterCode)) { throw (new ApplicationException("Incorrect password")); } DirectoryStructure CreateNewDirStructure = new DirectoryStructure(NewRoot, STFContents.XmlHeirarchy); CreateNewDirStructure.CreateDirectoryStructure(); RestoreFiles RestoreFilesFromSTF = new RestoreFiles(STFContents.XmlHeirarchy, STFContents.FileAttributes, NewRoot, STFFilename); RestoreFilesFromSTF.ExecuteRestore(); if (System.IO.File.Exists(STFFilename)) { System.IO.File.Delete(STFFilename); } if (System.IO.File.Exists(ConfigurationSettings.AppSettings["AllEntityLocation"] + SBNFilename)) { System.IO.File.Delete(ConfigurationSettings.AppSettings["AllEntityLocation"] + SBNFilename); } if (System.IO.File.Exists("GeneratedHierarchy.xml")) { System.IO.File.Delete("GeneratedHierarchy.xml"); } #endregion }
public void LockFolder(string absoluteFolderPath, string Password) { #region LockFolder implementation LockParameters.FlushAll(); Validate PasswordValidate = new PasswordValidation(Password); PasswordValidate.ValidateData(); string DirectoryName = GetLeafDirectoryName(absoluteFolderPath); Validate FolderExistsValidate = new SBNExists(Path.GetFileName(DirectoryName)); FolderExistsValidate.ValidateData(); CreateFolderHierarchy createFolderHierarchy = new CreateFolderHierarchy(absoluteFolderPath); Root fileSystemHierarchyManager = createFolderHierarchy.FolderHierarchy; string DirName = Path.GetFileName(absoluteFolderPath); ConfigurationManager SaveConfiguration = new ConfigurationManager(); SaveConfiguration.WriteFileHierarchyXml("HierarchySize.xml", fileSystemHierarchyManager); System.IO.FileInfo finfo = new FileInfo("HierarchySize.xml"); long SizeOfXmlBlock = finfo.Length; try { CreateSTF STF = new CreateSTF(SECURITYCODE, SizeOfXmlBlock, DirName, ENDMARKER, fileSystemHierarchyManager); } catch (Exception ex) { throw (new ApplicationException(ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"] + " File Creation Failed")); } IEncrypt Encrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Encrypter_Assembly"], DirName, Password) as IEncrypt; Encrypter.EncryptFile(); System.IO.File.Delete(ConfigurationSettings.AppSettings["AllEntityLocation"] + DirName + "." + ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]); if (bool.Parse(ConfigurationSettings.AppSettings["DeleteSource"]) == true) { if (System.IO.Directory.Exists(absoluteFolderPath)) { System.IO.Directory.Delete(absoluteFolderPath, true); } } if (System.IO.File.Exists("HierarchySize.xml")) { System.IO.File.Delete("HierarchySize.xml"); } #endregion }
private void RefreshView() { #region Explore area refresh view ExploreArea.Items.Clear(); IUISystem UserInterface = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["UI"], (ConfigurationSettings.AppSettings["SecureExtension"])) as IUISystem; List <string> ListOfFolders = UserInterface.ListAllFolders(false); List <string> ListOfFiles = UserInterface.ListAllFiles(false); foreach (string folderitem in ListOfFolders) { ListViewItem itemfolder = new ListViewItem(folderitem); itemfolder.ImageIndex = 1; ExploreArea.Items.Add(itemfolder); } foreach (string fileitem in ListOfFiles) { ListViewItem itemfile = new ListViewItem(fileitem); itemfile.ImageIndex = 0; ExploreArea.Items.Add(itemfile); } GC.Collect(); #endregion }
public void UnlockFile(string filename, string destination, string password) { Validate PasswordValidate = new PasswordValidation(password); PasswordValidate.ValidateData(); IDecrypt Decrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Decrypter_Assembly"], GetSBNName(filename), password) as IDecrypt; try { Decrypter.DecryptFile(); } catch (Exception DecryptFailure) { throw (new ApplicationException("Incorrect password")); } ExtractSTF STFContents = new ExtractSTF(); UnlockParameters FileUnlockParams = STFContents.ExtractContents(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"])); if (!Directory.Exists(destination)) { throw (new ApplicationException("The destination directory does not exists")); } else { RestoreFile RestoreOriginalFile = new RestoreFile(); RestoreOriginalFile.ExecuteRestore(FileUnlockParams, string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]), destination); if (File.Exists(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]))) { File.Delete(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"])); } if (File.Exists(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureExtension"]))) { File.Delete(string.Format("{0}{1}.{2}", ConfigurationSettings.AppSettings["AllEntityLocation"], filename, ConfigurationSettings.AppSettings["SecureExtension"])); } } }
private void toolStripDeleteButton_Click(object sender, EventArgs e) { if (ExploreArea.SelectedItems.Count == 1) { if (MessageBox.Show("Are you sure, you want to delete the secured " + SelectedEntity.ToString().ToLower() + " " + ExploreArea.SelectedItems[0].Text + "?", "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string FileName = ExploreArea.SelectedItems[0].Text; IUISystem UserInterface = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["UI"], (ConfigurationSettings.AppSettings["SecureExtension"])) as IUISystem; try { UserInterface.DeleteFile(FileName); } catch (Exception DeleteException) { MessageBox.Show("Deletion failed as a result of the following exception : " + DeleteException.Message); } RefreshView(); } } else { toolStripDeleteButton.Enabled = false; } }
private void emailLabel_Click(object sender, EventArgs e) { IProcess SendMail = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["ProcessNamespace"], "mailto:[email protected]") as IProcess; SendMail.RunProcess(); }