public SecretDecryptionContext(
            IKeyGenerator keyGenerator,
            ISecretStore secretStore,
            ISymmetricEncryptor secretEncryptor,
            ISecretValidator secretValidator,
            IServiceProvider serviceProvider,
            PassawordContext context,
            DecryptionEventArgs decryptEventArgs,
            DecryptionFailedEventArgs decryptFailedEventArgs,
            ILogger <SecretDecryptionContext> logger)
        {
            _secretStore            = secretStore;
            _secretEncryptor        = secretEncryptor;
            _secretValidator        = secretValidator;
            _serviceProvider        = serviceProvider;
            _context                = context;
            _decryptEventArgs       = decryptEventArgs;
            _decryptFailedEventArgs = decryptFailedEventArgs;
            _logger = logger;

            _decryptEventArgs.Context       = this;
            _decryptFailedEventArgs.Context = this;
            EncryptionKey  = keyGenerator.GetDefaultEncryptionKey();
            DecryptionKeys = keyGenerator.GetDecryptionKeys();
        }
Example #2
0
        public ExportJobTask(
            IFhirOperationDataStore fhirOperationDataStore,
            ISecretStore secretStore,
            IOptions <ExportJobConfiguration> exportJobConfiguration,
            ISearchService searchService,
            IResourceToByteArraySerializer resourceToByteArraySerializer,
            IExportDestinationClientFactory exportDestinationClientFactory,
            ILogger <ExportJobTask> logger)
        {
            EnsureArg.IsNotNull(fhirOperationDataStore, nameof(fhirOperationDataStore));
            EnsureArg.IsNotNull(secretStore, nameof(secretStore));
            EnsureArg.IsNotNull(exportJobConfiguration?.Value, nameof(exportJobConfiguration));
            EnsureArg.IsNotNull(searchService, nameof(searchService));
            EnsureArg.IsNotNull(resourceToByteArraySerializer, nameof(resourceToByteArraySerializer));
            EnsureArg.IsNotNull(exportDestinationClientFactory, nameof(exportDestinationClientFactory));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _fhirOperationDataStore         = fhirOperationDataStore;
            _secretStore                    = secretStore;
            _exportJobConfiguration         = exportJobConfiguration.Value;
            _searchService                  = searchService;
            _resourceToByteArraySerializer  = resourceToByteArraySerializer;
            _exportDestinationClientFactory = exportDestinationClientFactory;
            _logger = logger;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TwilioCallWrapper"/> class.
 /// </summary>
 /// <param name="httpClient">The IHttpClientWrapper implementation to use for making REST calls.</param>
 /// <param name="secretStore">The ISecretStore implementation for obtaining secrets.</param>
 public TwilioCallWrapper(
     IHttpClientWrapper httpClient,
     ISecretStore secretStore)
 {
     _httpClient  = httpClient;
     _secretStore = secretStore;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TwilioCallWrapperMock"/> class.
        /// </summary>
        /// <param name="httpClient">The IHttpClientWrapper implementation to use for making REST calls.</param>
        /// <param name="secretStore">The ISecretStore implementation for obtaining secrets.</param>
        public TwilioCallWrapperMock(
            IHttpClientWrapper httpClient,
            ISecretStore secretStore)
        {
            _httpClient = httpClient as HttpClientMock;

            _expectedResponseExceptionsCache = new ConcurrentDictionary <string, Exception>();
        }
Example #5
0
        public Key(ECKind kind = ECKind.Ed25519)
        {
            Curve = Curve.FromKind(kind);
            var bytes = Curve.GeneratePrivateKey();

            Store = new PlainSecretStore(bytes);
            bytes.Flush();
        }
Example #6
0
 public void Save(ISecretStore store)
 {
     store.ValidateRequired("store");
     lock (m_lock)
     {
         string xml = this.ToXml();
         store.PutSecret(StateKeyName, xml);
     }
 }
        public CreateExportRequestHandler(IClaimsExtractor claimsExtractor, IFhirOperationDataStore fhirOperationDataStore, ISecretStore secretStore)
        {
            EnsureArg.IsNotNull(claimsExtractor, nameof(claimsExtractor));
            EnsureArg.IsNotNull(fhirOperationDataStore, nameof(fhirOperationDataStore));
            EnsureArg.IsNotNull(secretStore, nameof(secretStore));

            _claimsExtractor        = claimsExtractor;
            _fhirOperationDataStore = fhirOperationDataStore;
            _secretStore            = secretStore;
        }
Example #8
0
        public void Reset(ISecretStore store)
        {
            store.ValidateRequired("store");

            lock (m_lock)
            {
                Clear();
                store.RemoveSecret(StateKeyName);
            }
        }
Example #9
0
 public HomeController(
     ISecretContextService secretContextService,
     ISecretStore secretStore,
     IConfiguration config,
     ILogger <HomeController> logger)
 {
     _secretContextService = secretContextService;
     _secretStore          = secretStore;
     _config = config;
     _logger = logger;
 }
Example #10
0
        public static ClientState Load(ISecretStore store)
        {
            store.ValidateRequired("store");
            string xml = store.GetSecret(StateKeyName);

            if (String.IsNullOrEmpty(xml))
            {
                return(new ClientState());
            }

            return(HealthVaultClient.Serializer.FromXml <ClientState>(xml));
        }
Example #11
0
        public static IFaceClient AuthenticateService(ISecretStore secretStore)
        {
            //Obtain Secrets from Secret Store
            AzureSettings azureSettings           = new AzureSettings();
            Secret        secret                  = secretStore.Get(azureSettings.SecretPath);
            string        faceRecognitionKey      = secret.Data[azureSettings.FaceRecognitionKeySecretName];
            string        faceRecognitionEndPoint = secret.Data[azureSettings.FaceRecognitionEndpointSecretName];

            return(new FaceClient(new ApiKeyServiceClientCredentials(faceRecognitionKey))
            {
                Endpoint = faceRecognitionEndPoint
            });
        }
Example #12
0
        internal PubKey(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (kind == ECKind.Ed25519 && bytes.Length != 32 || kind != ECKind.Ed25519 && bytes.Length != 33)
            {
                throw new ArgumentException("Invalid public key length", nameof(bytes));
            }

            Curve = Curve.FromKind(kind);
            Store = new PlainSecretStore(bytes);
            if (flush)
            {
                bytes.Flush();
            }
        }
Example #13
0
        internal Key(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (bytes?.Length != 32)
            {
                throw new ArgumentException("Invalid private key length", nameof(bytes));
            }

            Curve = Curve.FromKind(kind);
            Store = new PlainSecretStore(bytes);
            if (flush)
            {
                bytes.Flush();
            }
        }
Example #14
0
        private async Task ExtractInfo(ConsoleButton consoleButton)
        {
            switch (consoleButton.Name)
            {
            //Handle each Button's functionality
            case "Extract Info":
                int workspaceID       = this.Helper.GetActiveCaseID();
                int invoiceArtifactID = this.ActiveArtifact.ArtifactID;

                Guid   modelGuid        = Guid.Empty;
                string documentLocation = String.Empty;

                //Get Model and Document could be made a function to get doc location, but keeping for demo
                int modelArtifactId    = (int)this.ActiveArtifact.Fields[Guids.Invoice.TRAINING_MODEL.ToString()].Value.Value;
                int documentArtifactId = (int)this.ActiveArtifact.Fields[Guids.Invoice.DOCUMENT.ToString()].Value.Value;

                if ((modelArtifactId > 0) && (documentArtifactId > 0))
                {
                    Model model = new Model();
                    await model.ReadModelGuid(Helper.GetServicesManager(), workspaceID, modelArtifactId);

                    modelGuid = model.ModelGuid;

                    IDBContext   workspaceContext = Helper.GetDBContext(workspaceID);
                    string       sql = @"SELECT [Location] FROM [file] WITH(NOLOCK) WHERE [DocumentArtifactId] = @documentArtifactID AND [Type] = 0";
                    SqlParameter documentArtifactIdParam = new SqlParameter("@documentArtifactID", SqlDbType.Int);
                    documentArtifactIdParam.Value = documentArtifactId;
                    documentLocation = workspaceContext.ExecuteSqlStatementAsScalar <String>(sql, new SqlParameter[] { documentArtifactIdParam });
                }

                //get secrets
                AzureSettings azureSettings              = new AzureSettings();
                ISecretStore  secretStore                = this.Helper.GetSecretStore();
                Secret        secret                     = secretStore.Get(azureSettings.SecretPath);
                string        congnitiveServicesKey      = secret.Data[azureSettings.CognitiveServicesKeySecretName];
                string        congnitiveServicesEndPoint = secret.Data[azureSettings.CognitiveServicesEndpointSecretName];

                AzureFormRecognitionService azureFormRecognitionService = new FormRecognition.AzureFormRecognitionService(congnitiveServicesKey, congnitiveServicesEndPoint, Helper);

                Microsoft.Azure.CognitiveServices.FormRecognizer.Models.AnalyzeResult results = await azureFormRecognitionService.AnalyzeForm(azureFormRecognitionService.GetClient(), modelGuid, documentLocation);

                Invoice invoice = new Invoice();

                invoice = invoice.ConvertAnalyzeResultToInvoice(results, Helper);
                IServicesMgr mgr = Helper.GetServicesManager();
                await invoice.UpdateRelativity(mgr, workspaceID, invoiceArtifactID);

                break;
            }
        }
Example #15
0
        internal PubKey(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (bytes.Length < 32)
            {
                throw new ArgumentException("Invalid public key length", nameof(bytes));
            }

            Curve = Curves.GetCurve(kind);
            Store = new PlainSecretStore(bytes);

            if (flush)
            {
                bytes.Flush();
            }
        }
        public void PullRecordingHttpTriggerRun()
        {
            HttpRequest request = CreateHttpPostRequest(_config.InputId, _config.CallSid);

            ExecutionContext context = new ExecutionContext()
            {
                FunctionAppDirectory = Directory.GetCurrentDirectory(),
            };

            string expectedStorageContainerName  = _functionConfig[StorageContainerNameAppSettingName];
            string expectedDestinationPathPrefix = $"{_config.InputId}/file_";
            string expectedBlobEndpoint          = GetBlobEndpoint(_functionConfig[StorageAccessConnectionStringAppSettingName]);
            string expectedFullPathPrefix        = $"{expectedBlobEndpoint}{expectedStorageContainerName}/{expectedDestinationPathPrefix}";

            ISecretStore secretStore = PullRecordingHttpTrigger.Container.GetService <ISecretStore>();

            Secret expectedStorageReadAccessKey = secretStore.GetSecretAsync(_functionConfig[StorageReadAccessKeySecretNameAppSettingName], _functionConfig[AuthorityAppSettingName]).Result;

            IActionResult result = PullRecordingHttpTrigger.Run(request, _log, context).Result;

            Assert.IsInstanceOfType(result, typeof(OkObjectResult));

            OkObjectResult okResult = (OkObjectResult)result;

            Assert.AreEqual(200, okResult.StatusCode);
            Assert.IsInstanceOfType(okResult.Value, typeof(PullRecordingResponse));

            PullRecordingResponse response = (PullRecordingResponse)okResult.Value;

            Assert.AreEqual(_config.CallSid, response.CallSid);
            Assert.IsNotNull(response.RecordingUri);
            Assert.IsTrue(response.RecordingUri.StartsWith(expectedDestinationPathPrefix));
            Assert.IsTrue(response.FullRecordingUrl.StartsWith(expectedFullPathPrefix));
            Assert.IsTrue(response.FullRecordingUrl.EndsWith($"?{expectedStorageReadAccessKey.Value}"));
            Assert.IsTrue(response.RecordingLength > 600000); // Recording size should be ~800KB
            Assert.IsNotNull(response.FullRecordingUrl);

            Assert.AreEqual((int)CommonStatusCode.Ok, response.StatusCode);
            Assert.AreEqual(Enum.GetName(typeof(CommonStatusCode), CommonStatusCode.Ok), response.StatusDesc);

            Assert.IsFalse(response.HasError);
            Assert.AreEqual((int)CommonErrorCode.NoError, response.ErrorCode);
            Assert.IsNull(response.ErrorDetails);

            _log.LogInformation("Writing returned recording URI to test configuration...");
            _config.RecordingUri = response.RecordingUri;
            _config.Save(GlobalTestConstants.TestConfigurationFilePath);
        }
        public void SetDependencies(string tableName)
        {
            var region = RegionEndpoint.EUWest1;
            var km     = new AwsKmsKeyManager(region);
            var config = new AmazonDynamoDBConfig
            {
                RegionEndpoint = region
            };

            var repo = new AwsDynamoProtectedSecretRepository(config, tableName);
            var em   = new EncryptionManager(km);
            var ss   = new SecretStore(repo, em);

            _secretStore = ss;
            _repo        = repo;
        }
        public SecretEncryptionContext(
            IKeyGenerator keyGenerator,
            ISymmetricEncryptor secretEncryptor,
            ISecretStore secretStore,
            PassawordContext context,
            EncryptionEventArgs eventArgs,
            ILogger <SecretEncryptionContext> logger)
        {
            _secretEncryptor = secretEncryptor;
            _secretStore     = secretStore;
            _context         = context;
            _eventArgs       = eventArgs;
            _logger          = logger;

            _eventArgs.Context = this;
            EncryptionKey      = keyGenerator.GetDefaultEncryptionKey();
        }
        public async Task GivenSetSecretFails_WhenCreatingAnExportJob_ThenThrowsOperationFailedException()
        {
            // Set up create export request handler with mock secret store.
            ISecretStore   mockSecretStore = Substitute.For <ISecretStore>();
            HttpStatusCode errorStatusCode = HttpStatusCode.InternalServerError;

            mockSecretStore.SetSecretAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <CancellationToken>())
            .Returns <SecretWrapper>(_ => throw new SecretStoreException(SecretStoreErrors.SetSecretError, innerException: null, statusCode: errorStatusCode));

            _createExportRequestHandler = new CreateExportRequestHandler(_claimsExtractor, _fhirOperationDataStore, mockSecretStore);

            var request = new CreateExportRequest(RequestUrl, DestinationType, ConnectionString);

            OperationFailedException ofe = await Assert.ThrowsAsync <OperationFailedException>(() => _createExportRequestHandler.Handle(request, _cancellationToken));

            Assert.NotNull(ofe);
            Assert.Equal(errorStatusCode, ofe.ResponseStatusCode);
        }
Example #20
0
        public HealthVaultClient(
            AppInfo appInfo,
            ServiceInfo serviceInfo,
            IHttpTransport transport,
            IHttpStreamer streamer,
            ICryptographer cryptographer,
            bool useOnlineAuthModel,
            IWebAuthorizer authorizer)
        {
            appInfo.ValidateRequired("appInfo");
            serviceInfo.ValidateRequired("serviceInfo");
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }
            if (streamer == null)
            {
                throw new ArgumentNullException("streamer");
            }
            if (cryptographer == null)
            {
                throw new ArgumentNullException("cryptographer");
            }
            if (!useOnlineAuthModel && authorizer == null)
            {
                throw new ArgumentNullException("authorizer");
            }

            UseOnlineAuthModel = useOnlineAuthModel;
            m_appInfo          = appInfo;
            m_serviceInfo      = serviceInfo;
            m_transport        = transport;
            m_streamer         = streamer;
            m_cryptographer    = cryptographer;
            m_authorizer       = authorizer;

            m_serviceMethods = new ServiceMethods(this);
            m_recordMethods  = new RecordMethods(this);
            m_shell          = new Shell(this);

            m_secretStore = new SecretStore(MakeStoreName(m_appInfo.MasterAppId));
            m_state       = new ClientState();
            LoadState();
        }
Example #21
0
        }                                                                       //TODO: check key strength

        internal Key(byte[] bytes, ECKind kind, bool flush = false)
        {
            if (bytes.Length < 32)
            {
                throw new ArgumentException("Invalid private key length", nameof(bytes));
            }

            Curve = Curves.GetCurve(kind);

            var privateKey = Curve.GetPrivateKey(bytes);

            Store = new PlainSecretStore(privateKey);

            privateKey.Flush();
            if (flush)
            {
                bytes.Flush();
            }
        }
        public override Response Execute()
        {
            // Update Security Protocol
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            //Construct a response object with default values.
            Response retVal = new Response {
                Success = true, Message = string.Empty
            };

            try
            {
                AzureSettings azureSettings = new AzureSettings();

                //Get the Secret Store interface using a helper
                ISecretStore secretStore = this.Helper.GetSecretStore();

                //Instantiate a Secret object
                Secret secretToWrite = new Secret();

                //Instantiate the Data property of the secret as a Dictionary
                secretToWrite.Data = new Dictionary <string, string>();

                //Set the username value
                secretToWrite.Data.Add(azureSettings.FaceRecognitionKeySecretName, "");                 //TODO: Add your own credentials here

                //Set the password value
                secretToWrite.Data.Add(azureSettings.FaceRecognitionEndpointSecretName, ""); //TODO: Add your own credentials here

                //Write the secret to the Secret Store
                secretStore.Set(azureSettings.SecretPath, secretToWrite);
            }
            catch (Exception ex)
            {
                //Change the response Success property to false to let the user know an error occurred
                retVal.Success = false;
                retVal.Message = ex.ToString();
            }

            return(retVal);
        }
        private async Task SubmitDocuments(ConsoleButton consoleButton)
        {
            try
            {
                switch (consoleButton.Name)
                {
                //Handle each Button's functionality
                case "Submit Documents":
                    int   workspaceId = this.Helper.GetActiveCaseID();
                    int   modelId     = this.ActiveArtifact.ArtifactID;
                    Model model       = new Model();

                    //Get Documents In SavedSearch
                    int savedSearchId = (int)this.ActiveArtifact.Fields[Guids.Model.SAVED_SEARCH_FIELD.ToString()].Value.Value;
                    await model.ReadDocumentsInSavedSeach(Helper.GetServicesManager(), workspaceId, savedSearchId);

                    //Could have made function shared with the other event handler but left here for demo
                    Relativity.API.IDBContext workspaceContext = Helper.GetDBContext(workspaceId);
                    string        documentLocation             = string.Empty;
                    List <string> documentLocations            = new List <string>();
                    foreach (int documentArtifactId in model.DocsInSearch)
                    {
                        string       sql = @"SELECT [Location] FROM [file] WITH(NOLOCK) WHERE [DocumentArtifactId] = @documentArtifactID AND [Type] = 0";
                        SqlParameter documentArtifactIdParam = new SqlParameter("@documentArtifactID", SqlDbType.Int);
                        documentArtifactIdParam.Value = documentArtifactId;
                        documentLocation = workspaceContext.ExecuteSqlStatementAsScalar <String>(sql, new SqlParameter[] { documentArtifactIdParam });
                        documentLocations.Add(documentLocation);
                    }

                    //get secrets
                    AzureSettings azureSettings = new AzureSettings();

                    ISecretStore secretStore                = this.Helper.GetSecretStore();
                    Secret       secret                     = secretStore.Get(azureSettings.SecretPath);
                    string       congnitiveServicesKey      = secret.Data[azureSettings.CognitiveServicesKeySecretName];
                    string       congnitiveServicesEndPoint = secret.Data[azureSettings.CognitiveServicesEndpointSecretName];
                    string       storageAccountKey          = secret.Data[azureSettings.StorageAccountKeySecretName];
                    string       storageAccountName         = secret.Data[azureSettings.StorageAccountNameSecretName];


                    //upload documents to New Container
                    AzureStorageService azureStorageService             = new FormRecognition.AzureStorageService(storageAccountKey, storageAccountName);
                    Microsoft.Azure.Storage.Blob.CloudBlobClient client = azureStorageService.GetClient();
                    string containerPrefix = workspaceId.ToString() + "-" + modelId.ToString();
                    string sasUrl          = azureStorageService.UploadFiles(client, documentLocations, containerPrefix);
                    string containerName   = azureStorageService.ContainerName;

                    //Train model
                    AzureFormRecognitionService azureFormRecognitionService = new FormRecognition.AzureFormRecognitionService(congnitiveServicesKey, congnitiveServicesEndPoint, Helper);
                    Guid modeld = await azureFormRecognitionService.TrainModelAsync(azureFormRecognitionService.GetClient(), sasUrl);

                    model.ModelGuid = modeld;
                    model.SasUrl    = sasUrl;

                    //Update Relativity with data returned
                    await model.UpdateRelativity(Helper.GetServicesManager(), workspaceId, modelId);

                    break;
                }
            }
            catch (Exception e)
            {
                Helper.GetLoggerFactory().GetLogger().LogError(e, "Submit Documents Error");
                throw;
            }
        }
 public SymmetricEncryptor(IConfiguration config, ISecretStore secretStore)
 {
     _defaultKeyIndex = config.GetValue <int>("AppSettings:KeyIndex");
     _secretStore     = secretStore;
 }
        public void Reset(ISecretStore store)
        {
            store.ValidateRequired("store");

            lock (m_lock)
            {
                Clear();
                store.RemoveSecret(StateKeyName);
            }
        }
 public void Save(ISecretStore store)
 {
     store.ValidateRequired("store");
     lock (m_lock)
     {
         string xml = this.ToXml();
         store.PutSecret(StateKeyName, xml);
     }
 }
        public static ClientState Load(ISecretStore store)
        {
            store.ValidateRequired("store");
            string xml = store.GetSecret(StateKeyName);
            if (String.IsNullOrEmpty(xml))
            {
                return new ClientState();
            }

            return HealthVaultClient.Serializer.FromXml<ClientState>(xml);
        }
Example #28
0
 public static void Load(string path)
 {
     _store  = new ChainedSecretStore(new FileSecretStore(path), new EnvironmentVariableSecretStore());
     Service = new SecretService(_store);
 }
Example #29
0
 public SecretService(ISecretStore secretStore)
 {
     _secretStore = secretStore;
 }
Example #30
0
        public HealthVaultClient(
            AppInfo appInfo,
            ServiceInfo serviceInfo,
            IHttpTransport transport,
            IHttpStreamer streamer,
            ICryptographer cryptographer,
            IWebAuthorizer authorizer)
        {
            appInfo.ValidateRequired("appInfo");
            serviceInfo.ValidateRequired("serviceInfo");
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }
            if (streamer == null)
            {
                throw new ArgumentNullException("streamer");
            }
            if (cryptographer == null)
            {
                throw new ArgumentNullException("cryptographer");
            }
            if (authorizer == null)
            {
                throw new ArgumentNullException("authorizer");
            }

            m_appInfo = appInfo;
            m_serviceInfo = serviceInfo;
            m_transport = transport;
            m_streamer = streamer;
            m_cryptographer = cryptographer;
            m_authorizer = authorizer;

            m_serviceMethods = new ServiceMethods(this);
            m_recordMethods = new RecordMethods(this);
            m_shell = new Shell(this);

            m_secretStore = new SecretStore(MakeStoreName(m_appInfo.MasterAppId));
            m_state = new ClientState();
            LoadState();
        }
Example #31
0
 public StoreLocker(ISecretStore store) => Store = store;
 public LocalObjectStore(ISecretStore secretStore)
 {
     _secretStore = secretStore;
 }
 private async Task SetValueInSecretStoreIfIsSecret(ISecretStore secretStore, ApplicationConfiguration configuration, string key, string value)
 {
     if (configuration.Secrets.Contains(value))
     {
         //WriteVerbose($"Saving key {key} to key vault encoded as encoded key {secretStore.EncodeKey(key)}");
         await secretStore.Save(key, value);
     }
 }
 public WeatherForecastController(IConfiguration configuration, ISecretStore secretStore)
 {
     _configuration = configuration;
     _secretStore   = secretStore;
 }
        private async Task SetSecrets(ApplicationConfiguration configuration, ISecretStore secretStore)
        {
            try
            {
                IApplicationResourceSettingNameProvider nameProvider = new ApplicationResourceSettingNameProvider();
                // set the secrets
                foreach (ApplicationComponent component in configuration.ApplicationComponents)
                {
                    IComponentIdentity componentIdentity = new ComponentIdentity(component.Fqn);
                    if (!string.IsNullOrWhiteSpace(component.SqlServerConnectionString))
                    {
                        string key = nameProvider.SqlConnectionString(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.SqlServerConnectionString);
                    }
                    if (!string.IsNullOrWhiteSpace(component.StorageAccountConnectionString))
                    {
                        string key = nameProvider.StorageAccountConnectionString(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.StorageAccountConnectionString);
                    }
                    if (!string.IsNullOrWhiteSpace(component.ServiceBusConnectionString))
                    {
                        string key = nameProvider.ServiceBusConnectionString(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.ServiceBusConnectionString);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DbContextType))
                    {
                        string key = nameProvider.SqlContextType(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DbContextType);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultQueueName))
                    {
                        string key = nameProvider.DefaultQueueName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultQueueName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultBlobContainerName))
                    {
                        string key = nameProvider.DefaultBlobContainerName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultBlobContainerName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultTableName))
                    {
                        string key = nameProvider.DefaultTableName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultTableName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultLeaseBlockName))
                    {
                        string key = nameProvider.DefaultLeaseBlockName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultLeaseBlockName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultSubscriptionName))
                    {
                        string key = nameProvider.DefaultSubscriptionName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultSubscriptionName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultTopicName))
                    {
                        string key = nameProvider.DefaultTopicName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultTopicName);
                    }
                    if (!string.IsNullOrWhiteSpace(component.DefaultBrokeredMessageQueueName))
                    {
                        string key = nameProvider.DefaultBrokeredMessageQueueName(componentIdentity);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, component.DefaultBrokeredMessageQueueName);
                    }

                    foreach (ApplicationComponentSetting setting in component.Settings)
                    {
                        string key = nameProvider.SettingName(componentIdentity, setting.Key);
                        await SetValueInSecretStoreIfIsSecret(secretStore, configuration, key, setting.Value);
                    }
                }
            }
            catch (AggregateException aex)
            {
                foreach (Exception ex in aex.InnerExceptions)
                {
                    WriteError(new ErrorRecord(ex, Guid.NewGuid().ToString(), ErrorCategory.InvalidOperation, null));
                }
            }
            
        }
Example #36
0
 public void TestInitialize()
 {
     _subSecretStore = Substitute.For <ISecretStore>();
 }