public HomeController(IOptions <SwiftCredentials> credentials, IMemoryCache cache)
        {
            Credentials = credentials.Value;

            Client = new Client(new SwiftAuthManagerWithCache(Credentials, cache));

            Client.SetRetryCount(2)
            .SetLogger(new SwiftLogger());
        }
 public SwiftAuthManagerMemoryCache(IOptions<SwiftServiceOptions> options, IMemoryCache cache)
 {
     var _options = options.Value;
     Credentials = new SwiftCredentials {
         Endpoints = _options.Endpoints,
         Password = _options.Password,
         Username = _options.Username
     };
     this.cache = cache;
 }
        public SwiftAuthManagerDistributedCache(IOptions<SwiftServiceOptions> options, IDistributedCache cache)
        {
            var _options = options.Value;
            Credentials = new SwiftCredentials {
                Endpoints = _options.Endpoints,
                Password = _options.Password,
                Username = _options.Username
            };

            _cache = cache;
        }
        public SwiftAuthManagerMemoryCache(IOptions <SwiftServiceOptions> options, IMemoryCache cache)
        {
            var _options = options.Value;

            Credentials = new SwiftCredentials {
                Endpoints = _options.Endpoints,
                Password  = _options.Password,
                Username  = _options.Username
            };
            this.cache = cache;
        }
        public SwiftAuthManagerDistributedCache(IOptions <SwiftServiceOptions> options, IDistributedCache cache)
        {
            var _options = options.Value;

            Credentials = new SwiftCredentials {
                Endpoints = _options.Endpoints,
                Password  = _options.Password,
                Username  = _options.Username
            };

            _cache = cache;
        }
Exemple #6
0
        public async Task <IActionResult> GetByIdAsync(string swiftCredentialsId)
        {
            SwiftCredentials swiftCredentials = await _swiftCredentialsService.GetByIdAsync(swiftCredentialsId);

            if (swiftCredentials == null)
            {
                return(NotFound());
            }

            var model = Mapper.Map <SwiftCredentialsModel>(swiftCredentials);

            return(Ok(model));
        }
Exemple #7
0
        public async Task UpdateAsync(SwiftCredentials swiftCredentials)
        {
            var existingSwiftCredentials = await _swiftCredentialsRepository.GetByIdAsync(swiftCredentials.Id);

            if (existingSwiftCredentials == null)
            {
                throw new SwiftCredentialsNotFoundException(swiftCredentials.Id);
            }

            await _swiftCredentialsRepository.UpdateAsync(swiftCredentials);

            await _clientSwiftCredentialsCache.ClearAsync("Swift credentials updated");

            await _log.WriteInfoAsync(nameof(SwiftCredentialsService), nameof(UpdateAsync),
                                      swiftCredentials.ToJson(), "Swift credentials updated");
        }
Exemple #8
0
        public async Task InsertAsync(SwiftCredentials swiftCredentials)
        {
            var entity = new SwiftCredentialsEntity(
                GetPartitionKey(swiftCredentials.LegalEntityId),
                GetRowKey())
            {
                LegalEntityId = swiftCredentials.LegalEntityId,
                AssetId       = swiftCredentials.AssetId
            };

            Mapper.Map(swiftCredentials, entity);

            await _storage.InsertAsync(entity);

            await _indexIdStorage.InsertAsync(AzureIndex.Create(
                                                  GetIndexIdPartitionKey(entity.RowKey), GetIndexIdRowKey(entity.RowKey), entity));
        }
Exemple #9
0
        public async Task UpdateAsync(SwiftCredentials swiftCredentials)
        {
            var index = await _indexIdStorage.GetDataAsync(
                GetIndexIdPartitionKey(swiftCredentials.Id),
                GetIndexIdRowKey(swiftCredentials.Id));

            if (index == null)
            {
                return;
            }

            await _storage.MergeAsync(index.PrimaryPartitionKey, index.PrimaryRowKey, entity =>
            {
                Mapper.Map(swiftCredentials, entity);
                return(entity);
            });
        }
Exemple #10
0
        public async Task AddAsync(SwiftCredentials swiftCredentials)
        {
            var existingSwiftCredentials = await _swiftCredentialsRepository
                                           .FindAsync(swiftCredentials.LegalEntityId, swiftCredentials.AssetId);

            if (existingSwiftCredentials.Count > 0)
            {
                throw new SwiftCredentialsAlreadyExistsException(swiftCredentials.LegalEntityId,
                                                                 swiftCredentials.AssetId);
            }

            var legalEntity = await _legalEntityRepository.GetByIdAsync(swiftCredentials.LegalEntityId);

            if (legalEntity == null)
            {
                throw new LegalEntityNotFoundException(swiftCredentials.LegalEntityId);
            }

            await _swiftCredentialsRepository.InsertAsync(swiftCredentials);

            await _log.WriteInfoAsync(nameof(SwiftCredentialsService), nameof(AddAsync),
                                      swiftCredentials.ToJson(), "Swift credentials added");
        }
Exemple #11
0
 public SwiftInitFixture()
 {
     Credentials = GetConfigCredentials();
 }
Exemple #12
0
 public Exporter(Client client, SwiftCredentials credentials)
 {
     this.client = client;
     this.credentials = credentials;
 }
Exemple #13
0
 public SwiftFixture()
 {
     Credentials = GetConfigCredentials();
 }
 public SwiftAuthManagerWithCache(SwiftCredentials credentials, IMemoryCache cache)
 {
     Credentials = credentials;
     this.cache  = cache;
 }
Exemple #15
0
 public Exporter(Client client, SwiftCredentials credentials)
 {
     this.client      = client;
     this.credentials = credentials;
 }
Exemple #16
0
 public Importer(SwiftCredentials credentials, string rootPath)
 {
     this.credentials = credentials;
     this.rootPath = rootPath;
 }
Exemple #17
0
 public Importer(SwiftCredentials credentials, string rootPath)
 {
     this.credentials = credentials;
     this.rootPath    = rootPath;
 }