Ejemplo n.º 1
0
        private const int BufferSize = 0x10000; // should always be power of 2

        /// <summary>
        /// Instantiate a new PgpEncrypt class with initialized PgpEncryptionKeys.
        /// </summary>
        /// <param name="encryptionKeys"></param>
        /// <exception cref="ArgumentNullException">encryptionKeys is null</exception>
        public PgpEncrypt(PgpEncryptionKeys encryptionKeys)
        {
            if (encryptionKeys == null)
            {
                throw new ArgumentNullException("encryptionKeys", "encryptionKeys is null.");
            }

            m_encryptionKeys = encryptionKeys;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Instantiate a new PgpEncrypt class with initialized PgpEncryptionKeys.
        /// </summary>
        /// <param name="encryptionKeys"></param>
        /// <exception cref="ArgumentNullException">encryptionKeys is null</exception>
        public PgpEncrypt(PgpEncryptionKeys encryptionKeys)
        {
            if (encryptionKeys == null)
            {
                throw new ArgumentNullException("encryptionKeys", "encryptionKeys is null.");
            }

            m_encryptionKeys = encryptionKeys;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the actions for the current working file for encryption and transmission
        /// </summary>
        /// <param name="workingFile"></param>
        private void HandleMovedVendorFile(VendorLite vl, int _count)
        {
            string source = vl.filePath;
                string file = Path.GetFileName(source);
                string dest = String.Format(@"{0}\{1}", Server.MapPath(vl.workingPath), file);
                string PublicKeyFileName = Server.MapPath(vl.publicKeyPath);
                string PrivateKeyFileName = Server.MapPath(appvars.SignPrivateKey);
                VendorType vt = (VendorType)Enum.Parse(typeof(VendorType), vl.VendorName, true);
                string EncryptionFile = String.Format("{0}{1}", dest.Replace(Path.GetFileName(dest), ""), appvars.ReturnNewFileName(vt));

                //Get the user info from their session var...
                SetUserInformation();
                vl.UserID = this.CurrentUser.UserObject.LoginID.ToLower();

                if (!File.Exists(dest))
                {
                    FileStream fs = File.Create(dest);
                    fs.Close();
                }

                File.Copy(source, dest, true);

                PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys(PublicKeyFileName, PrivateKeyFileName, appvars.SignPassWord);
                PgpEncrypt encrypter = new PgpEncrypt(encryptionKeys);

                using (Stream outputStream = File.Create(EncryptionFile))
                {
                    //build out the encypted file...
                    encrypter.EncryptAndSign(outputStream, new FileInfo(dest));

                    //Our file transfer class requires a fully qualified clean-up set...
                    CleanUpFiles cuf = new CleanUpFiles();
                    cuf.EncryptedFilePath = EncryptionFile;
                    cuf.TxtWorkingFilePath = dest;
                    // we'll put in the script path later.... cuf.ClientScriptFilePath = "";
                    //set the vL item's cleanupItems for the next routine..
                    vl.cleanUpItems = cuf;
                }//end using statement

                //construct the object and run it...
                FileTransfer fT = new FileTransfer(vl);
                fT.RunUpload();

                //File the report and store the files before clean-up...
                FileReport fr = new FileReport(vl);
                fr.SubmitReport();

                //clean up...
                FileCleanUp.CleanUpFileTransfer(vl.cleanUpItems);
        }