private bool FromConfiguration() { string vault = TestConfigurationManager.TryGetEnvironmentOrAppSetting("VaultUrl"); string authClientId = TestConfigurationManager.TryGetEnvironmentOrAppSetting("AuthClientId"); string authSecret = TestConfigurationManager.TryGetEnvironmentOrAppSetting("AuthClientSecret"); string standardVaultOnlyString = TestConfigurationManager.TryGetEnvironmentOrAppSetting("StandardVaultOnly"); bool result; if (!bool.TryParse(standardVaultOnlyString, out result)) { result = false; } if (string.IsNullOrWhiteSpace(vault) || string.IsNullOrWhiteSpace(authClientId) || string.IsNullOrWhiteSpace(authSecret)) { return(false); } else { this.vaultAddress = vault; this._ClientCredential = new ClientCredential(authClientId, authSecret); this.standardVaultOnly = result; return(true); } }
protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var requestUri = request.RequestUri; var authority = string.Empty; var targetUri = requestUri; // NOTE: The KmsNetworkUrl setting is purely for development testing on the // Microsoft Azure Development Fabric and should not be used outside that environment. string networkUrl = TestConfigurationManager.TryGetEnvironmentOrAppSetting("KmsNetworkUrl"); if (!string.IsNullOrEmpty(networkUrl)) { authority = targetUri.Authority; targetUri = new Uri(new Uri(networkUrl), targetUri.PathAndQuery); request.Headers.Add("Host", authority); request.RequestUri = targetUri; } return(base.SendAsync(request, cancellationToken).ContinueWith <HttpResponseMessage>(response => { return response.Result; })); }
private bool FromConfiguration() { string vault = TestConfigurationManager.TryGetEnvironmentOrAppSetting("VaultUrl"); string authClientId = TestConfigurationManager.TryGetEnvironmentOrAppSetting("AuthClientId"); string authSecret = TestConfigurationManager.TryGetEnvironmentOrAppSetting("AuthClientSecret"); if (string.IsNullOrWhiteSpace(vault) || string.IsNullOrWhiteSpace(authClientId) || string.IsNullOrWhiteSpace(authSecret)) { return(false); } else { this.vaultAddress = vault; this._ClientCredential = new ClientCredential(authClientId, authSecret); return(true); } }