Exemple #1
0
        public async Task RemoveValueAsync(string context, string key)
        {
            var ctx = DeserializeContext(context);

            key        = key ?? throw new SecureStoreException();
            _dsvClient = await _clientFactory.GetClient(ctx);

            await _dsvClient.DeleteSecretAsync(key);
        }
Exemple #2
0
        public async Task <string> GetValueAsync(string context, string key)
        {
            var ctx = DeserializeContext(context);

            key        = key ?? throw new SecureStoreException();
            _dsvClient = await _clientFactory.GetClient(ctx);

            var response = await _dsvClient.GetSecretAsync(key);

            return(response?.Data["password"].ToString());
        }
Exemple #3
0
        public async Task <string> CreateValueAsync(string context, string key, string value)
        {
            var ctx = DeserializeContext(context);

            value      = value ?? throw new ArgumentNullException(nameof(value));
            _dsvClient = await _clientFactory.GetClient(ctx);

            var response = await _dsvClient.CreateSecretAsync(key, value);

            return(response);
        }
Exemple #4
0
        public async Task ValidateContextAsync(string context)
        {
            var id  = Guid.NewGuid();
            var ctx = DeserializeContext(context);

            _dsvClient = await _clientFactory.GetClient(ctx);

            var response = await _dsvClient.CreateSecretAsync($"validate:{id}", id.ToString());

            await _dsvClient.DeleteSecretAsync(response);
        }
Exemple #5
0
        public async Task <string> UpdateValueAsync(string context, string key, string oldAugumentedKey, string value)
        {
            var ctx = DeserializeContext(context);

            key        = key ?? throw new SecureStoreException();
            _dsvClient = await _clientFactory.GetClient(ctx);

            var response = await _dsvClient.UpdateSecretAsync(key, oldAugumentedKey, value);

            return(response);
        }
Exemple #6
0
        public async Task <Credential> GetCredentialsAsync(string context, string key)
        {
            var ctx = DeserializeContext(context);

            key        = key ?? throw new SecureStoreException();
            _dsvClient = await _clientFactory.GetClient(ctx);

            var response = await _dsvClient.GetSecretAsync(key);

            return(new Credential()
            {
                Username = response.Data["username"].ToString(),
                Password = response.Data["password"].ToString(),
            });
        }