Exemple #1
0
        public string GetConnectionStringForContext(string context)
        {
            try {
                var aes       = AesRepository.GetAes(context);
                var encrypted = ConnectionStringRepository.GetConnectionString(context);
                var decrypted = Decrypt.Base64(encrypted).WithAes(aes);

                return(decrypted);
            } catch (AesRepository.AesRepositoryException e) {
                throw new ConnectionServiceException($"Error retrieving aes: {e.Message}");
            } catch (ConnectionStringRepository.ConnectionStringRepositoryException e) {
                throw new ConnectionServiceException($"Error retrieving connection string: {e.Message}");
            } catch (Exception e) {
                throw new ConnectionServiceException(
                          $"Unknown error when attempting to retrieve connection " +
                          $"string for context '{context}': {e.Message}");
            }
        }
Exemple #2
0
 public ConnectionService()
 {
     AesRepository = new AesRepository();
     ConnectionStringRepository = new ConnectionStringRepository();
 }