Example #1
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);
        }
Example #2
0
        private void ShareWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (this.ShareTaskWaitingList.Count != 0)
            {
                for (int i = this.ShareTaskWaitingList.Count - 1; i >= 0; i--)
                {
                    ShareTaskUnit worker = this.ShareTaskWaitingList[i];
                    PublicKey     pubkey = worker.PK;
                    //Key1
                    PRE_KEY key = ProxyReEncryption.GenKey(
                        PreKeyring.UserKey.PK1,
                        PreKeyring.UserKey.PK2,
                        PreKeyring.UserKey.SK1,
                        PreKeyring.UserKey.SK2);

                    //Key_pk2
                    PRE_PK key2_pk = ProxyReEncryption.GenPK(pubkey.PK1, pubkey.PK2);

                    //ReKey
                    PRE_Cipher reKey = ProxyReEncryption.KeyEncrypt(key, key2_pk, worker.Key);

                    String cpyRef = this.DropboxController.GetCopyRef(
                        this.DropboxController.SecuruStikFolder2RemoteDropboxPath(worker.FilePath));
                    if (String.IsNullOrEmpty(cpyRef))
                    {
                        continue;//获取copyref失败处理
                    }
                    else
                    {
                        worker.CpyRef = cpyRef;
                    }

                    SecuruStik.Protocal.SharingInfo si = new SecuruStik.Protocal.SharingInfo(
                        this.Email,
                        pubkey.ID,
                        Path.GetFileName(worker.FilePath),
                        worker.CpyRef,
                        reKey.E, reKey.F, reKey.U, reKey.W);

                    Request r = new Request(MessageType.Request_SetSharingInfo, this.DropboxController.Email, si);
                    this.ProxyServerController.Send(r);
                    this.ShareTaskWaitingList.Remove(worker);
                    SecuruStikMessageQueue.SendMessage_Share_End(Path.GetFileName(worker.FilePath), worker.ID_TO);
                }
            }
        }
Example #3
0
 public void ReceivePKInfo(PublicKey pubkey)
 {
     for (int i = this.ShareTaskSuspendList.Count - 1; i >= 0; i--)
     {
         ShareTaskUnit shareTaskWorker = this.ShareTaskSuspendList[i];
         if (shareTaskWorker.ID_TO == pubkey.ID)
         {
             shareTaskWorker.PK = pubkey;
             this.ShareTaskSuspendList.Remove(shareTaskWorker);
             this.ShareTaskWaitingList.Add(shareTaskWorker);
         }
     }
     if (!this.ShareWorker.IsBusy)
     {
         this.ShareWorker.RunWorkerAsync();
     }
 }
Example #4
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;
        }