コード例 #1
0
        public static Dictionary <string, UserFtpServiceData> users_list = new Dictionary <string, UserFtpServiceData>(); // user, key_S

        public void requstForConnectionWithSessionKey(FtpTicketRequst ftpTicketRequst)
        {
            IClientFtpCallBack iClientFtpCallBack = OperationContext.Current.GetCallbackChannel <IClientFtpCallBack>();
            KdcFtpKey          retKeyFromDB       = m_FtpDBservice.getKdcFtpKey("KDC");

            if (retKeyFromDB == null)
            {
                iClientFtpCallBack.finishRequstConnectionProcess(null);
                return;
            }

            byte[] sessionKey = CAes.SimpleDecryptWithPassword(ftpTicketRequst.SessionKeyClientFTPEncryptedForFTP, retKeyFromDB.PassWord);
            string usenameDecryptedWithFtpKdcKey  = CAes.SimpleDecryptWithPassword(ftpTicketRequst.UserNameencryptedForFtpWithFtpKey, retKeyFromDB.PassWord);
            string usenameDecryptedWithSessionKey = CAes.SimpleDecrypt(ftpTicketRequst.UserNameencryptedForFtpWithSessionKey, sessionKey, sessionKey);

            if (usenameDecryptedWithFtpKdcKey == usenameDecryptedWithSessionKey) // OK
            {
                UserFtpServiceData userData = new UserFtpServiceData(sessionKey, iClientFtpCallBack);
                users_list.Add(usenameDecryptedWithFtpKdcKey, userData);

                string   fileNameResult;
                string[] filesPaths = Directory.GetFiles("..\\..\\files\\",
                                                         "*.*", SearchOption.AllDirectories);
                List <string> newFilesNames = new List <string>();

                // Display all the files.
                foreach (string path in filesPaths)
                {
                    fileNameResult = Path.GetFileName(path);
                    string fileNameResultString = CAes.SimpleEncrypt(fileNameResult, sessionKey, sessionKey);
                    newFilesNames.Add(fileNameResultString);
                }

                iClientFtpCallBack.finishRequstConnectionProcess(newFilesNames);
                return;
            }

            iClientFtpCallBack.finishRequstConnectionProcess(null);
        }
コード例 #2
0
ファイル: UserFtpServiceData.cs プロジェクト: lioris/KdcChat
 public UserFtpServiceData(byte[] userSessionKey, IClientFtpCallBack clientFtpCallBack)
 {
     m_clientFtpCallBack = clientFtpCallBack;
     m_sessionKey        = userSessionKey;
 }