Esempio n. 1
0
        public void AddDecryptTask(String file)
        {
            FileInfo f = new FileInfo(file);
            String   fileFullPath_Dropbox = f.FullName;

            //If the file is being encrypted,skip it .
            if (this.LoopBackTool.IsWaitingOrDecrypting(fileFullPath_Dropbox))
            {
                return;
            }

            String fileFullPath_Local = this.DropboxSecuruStikFolder2SecuruStikFolder(fileFullPath_Dropbox);
            String hashValue_Local    = String.Empty;

            // TODO: error handling (it's returning bool (which is ignored) but should perhaps throw  exception)
            ProxyReEncryption.GetHashCode(fileFullPath_Local, ref hashValue_Local);

            FileMetaData fmd = PreKeyring.FileInfo_Query(fileFullPath_Local);

            if (fmd == null)
            {
                this.LostKeyFile.Add(fileFullPath_Dropbox);
            }
            else if (!File.Exists(fileFullPath_Local) || fmd.PlainTextHash != hashValue_Local)
            {
                // If the local file does not exist, redecrypt the file
                string hashValue_Dropbox = "";
                ProxyReEncryption.GetHashCode(fileFullPath_Local, ref hashValue_Dropbox);
                this.LoopBackTool.AddDecryptTask(fileFullPath_Dropbox, fileFullPath_Local, hashValue_Dropbox, (UInt64)f.Length, fmd.Key);
            }
        }
Esempio n. 2
0
        public Boolean AddShareTask(String id_to, String filePath)
        {
            if (System.IO.File.Exists(filePath) == false)
            {
                return(false);
            }
            FileMetaData fmd = PreKeyring.FileInfo_Query(filePath);

            if (fmd == null)
            {
                return(false);
            }

            ShareTaskUnit shareUnit = new ShareTaskUnit(id_to, filePath, fmd.Key);

            if (!this.IsPKExist(shareUnit.ID_TO))
            {
                this.ShareTaskSuspendList.Add(shareUnit);
            }
            else
            {
                shareUnit.PK = GetRequestedPK(shareUnit.ID_TO);
                this.ShareTaskWaitingList.Add(shareUnit);
            }

            if (!this.ShareWorker.IsBusy)
            {
                this.ShareWorker.RunWorkerAsync();
            }
            return(true);
        }
Esempio n. 3
0
        public void AddEncryptTask(string file)
        {
            FileInfo f = new FileInfo(file);

            String fileFullPath_Local = f.FullName;

            //if the file is beeing decrypted, skip it.
            if (this.LoopBackTool.IsWaitingOrEncrypting(file))
            {
                return;
            }

            string fileFullPath_Dropbox = this.SecuruStikFolder2DropboxSecuruStikFolder(fileFullPath_Local);

            string hashValue_DropBox = String.Empty;

            ProxyReEncryption.GetHashCode(fileFullPath_Dropbox, ref hashValue_DropBox);

            FileMetaData fmd = PreKeyring.FileInfo_Query(fileFullPath_Local);

            if (File.Exists(fileFullPath_Dropbox) == false || fmd == null ||
                hashValue_DropBox != fmd.CryptTextHash)
            {
                try
                {
                    String hashValue_Local = String.Empty;
                    ProxyReEncryption.GetHashCode(fileFullPath_Local, ref hashValue_Local);
                    this.LoopBackTool.AddEncryptTask(fileFullPath_Local, fileFullPath_Dropbox, hashValue_Local, (UInt64)f.Length);
                }
                catch (System.Exception ex)
                {
                    log.ErrorFormat("Add Encrypt Task for {0}", file, ex);
                }
            }
        }