Beispiel #1
0
        public static void Main(string[] args)
        {
            var vem = new VaultExtManager();

            Console.WriteLine("Providers:");
            foreach (var p in vem.FoundProviders)
            {
                Console.WriteLine($"  * {p}");
            }

            Console.WriteLine("ExtInfo:");
            foreach (var ei in vem.ExtInfos)
            {
                Console.WriteLine($"  * {JsonConvert.SerializeObject(ei)}");
                var vp = vem.GetProvider(ei.Name);
                Console.WriteLine("  * Params:");
                foreach (var p in vp.DescribeParams())
                {
                    Console.WriteLine($"    - {JsonConvert.SerializeObject(p)}");
                }
            }

            using (var v = vem.GetProvider("local").Get(new Dictionary <string, object>
            {
                ["RootPath"] = ".\\VAULT_ROOT",
            }))
            {
                Console.WriteLine(v);
            }
        }
Beispiel #2
0
        public static IVault GetVault(string profileName = null)
        {
            if (CustomVaultGetter != null)
            {
                return(CustomVaultGetter());
            }

            profileName = VaultProfileManager.ResolveProfileName(profileName);
            if (string.IsNullOrEmpty(profileName))
            {
                throw new InvalidOperationException("unable to resolve effective profile name");
            }

            var profile = VaultProfileManager.GetProfile(profileName);

            if (profile == null)
            {
                throw new InvalidOperationException("unable to resolve effective profile")
                      .With(nameof(profileName), profileName);
            }

            var provider = VaultExtManager.GetProvider(profile.ProviderName, null);

            if (provider == null)
            {
                throw new InvalidOperationException("unable to resolve Vault Provider")
                      .With(nameof(profileName), profileName)
                      .With(nameof(profile.ProviderName), profile.ProviderName);
            }

            return(provider.GetVault(profile.VaultParameters));
        }