protected override void ProcessRecord()
        {
            var baseUri = BaseUri;
            if (string.IsNullOrEmpty(baseUri))
                if (!string.IsNullOrEmpty(BaseService)
                        && WELL_KNOWN_BASE_SERVICES.ContainsKey(BaseService))
                    baseUri = WELL_KNOWN_BASE_SERVICES[BaseService];
                else
                    throw new PSInvalidOperationException("either a base service or URI is required");

            using (var vp = GetVaultProvider(VaultProfile))
            {
                vp.InitStorage(Force);
                var v = new VaultConfig
                {
                    Id = EntityHelper.NewId(),
                    Alias = Alias,
                    Label = Label,
                    Memo = Memo,
                    BaseService = BaseService,
                    BaseUri = baseUri,
                    ServerDirectory = new AcmeServerDirectory()
                };

                vp.SaveVault(v);
            }
        }
Beispiel #2
0
        public static void Init(VaultConfig config, AcmeClient client)
        {
            client.Init();

            if (config.GetInitialDirectory)
                client.GetDirectory(config.UseRelativeInitialDirectory);
        }
Beispiel #3
0
        public static AcmeClient GetClient(VaultConfig config, RegistrationInfo reg)
        {
            var c = GetClient(config);

            c.Signer = GetSigner(reg.SignerProvider);
            c.Signer.Init();
            c.Registration = reg.Registration;

            if (reg.SignerState != null)
            {
                using (var s = new MemoryStream(Convert.FromBase64String(
                        reg.SignerState)))
                {
                    c.Signer.Load(s);
                }
            }
            else
            {
                using (var s = new MemoryStream())
                {
                    c.Signer.Save(s);
                    reg.SignerState = Convert.ToBase64String(s.ToArray());
                }
            }

            return c;
        }
Beispiel #4
0
        public static AcmeClient GetClient(VaultConfig Config)
        {
            var p = Config.Proxy;
            var _Client = new AcmeClient();

            _Client.RootUrl = new Uri(Config.BaseUri);
            _Client.Directory = Config.ServerDirectory;

            if (Config.Proxy != null)
                _Client.Proxy = Config.Proxy.GetWebProxy();

            return _Client;
        }