public void Run(AddEntryVerbOptions options) { var addEntryOpts = new AddEntryUsingKeyFileWorkflowOptions() { CategoryName = options.Category, EntryName = options.NewEntryName, DatFilePath = options.DatFile, StringToEncrypt = options.StringToEncrypt }; var encryptionType = options.GetAlgorithm(); if (encryptionType == EnvCryptAlgoEnum.Rsa) { addEntryOpts.KeyFilePath = options.KeyFile; new AddRsaEntryBuilder().Build().Run(addEntryOpts); } else if (encryptionType == EnvCryptAlgoEnum.Aes) { addEntryOpts.KeyFilePath = options.KeyFile; new AddAesEntryBuilder().Build().Run(addEntryOpts); } else if (encryptionType == EnvCryptAlgoEnum.PlainText) { new AddPlainTextEntryBuilder().Build().Run(addEntryOpts); } else { System.Console.Error.WriteLine("Cannot add entry for encryption type: {0}", encryptionType); } }
public void Run(AddEntryUsingKeyFileWorkflowOptions options) { Contract.Requires <ArgumentNullException>(options != null, "options"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(options.CategoryName), "category name cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(options.DatFilePath), "DAT file path cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(options.EntryName), "entry name cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(options.KeyFilePath), "key file path cannot be null or whitespace"); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(options.StringToEncrypt), "string to encrypt cannot be null or empty"); // ThrowIfNotBuilt(); _workflow.Run(options); }