Example #1
0
        static void Main(string[] args)
        {
            var accountName     = ConfigurationManager.AppSettings["AccountName"];
            var accountKey      = ConfigurationManager.AppSettings["AccountKey"];
            var itemTable       = ConfigurationManager.AppSettings["ItemTableName"];
            var encryptionKeyId = ConfigurationManager.AppSettings["EncryptionKey"];
            var keyVaultUri     = ConfigurationManager.AppSettings["KeyVaultUri"];
            var clientId        = ConfigurationManager.AppSettings["KeyVaultClientId"];
            var keyVaultCertificateThumbprint = ConfigurationManager.AppSettings["KeyVaultClientCertificateThumbprint"];

            var authService      = new AadAuthService(clientId, keyVaultCertificateThumbprint);
            var keyVaultProvider = new KeyVaultProvider(keyVaultUri, authService);

            var cloudResolver = new GlobalKeyResolver(keyVaultProvider);

            //One-Time job. Should be done by a script
            cloudResolver.AddKey(encryptionKeyId, Guid.NewGuid().ToString()).Wait();

            var kid = keyVaultProvider.GetSecretIdAsync(encryptionKeyId).Result;


            _tableProvider = new TableProvider <ItemEntity>(accountName, accountKey, itemTable, kid, cloudResolver);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("*************************************SECURE ITEM MANAGEMENT*************************************");

            var shouldContinue = true;

            do
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("MENU");
                Console.WriteLine("1. Insert Item");
                Console.WriteLine("2. Get Item By ID");
                Console.WriteLine("3. List all Items by Category");
                Console.WriteLine("Enter any other number to exit");
                Console.Write("> ");

                var option = int.Parse(Console.ReadLine());
                shouldContinue = Operate(option);
            } while (shouldContinue);
        }
Example #2
0
 public GlobalKeyResolver(KeyVaultProvider provider)
 {
     _provider = provider;
     _resolver = new KeyVaultKeyResolver(_provider.Client);
 }