public void AddApiEndpoint(string apiEndpoint)
 {
     _namedApiEndpoints[apiEndpoint] = apiEndpoint;
     if (!ApiEndpoints.Contains(apiEndpoint))
     {
         ApiEndpoints.Add(apiEndpoint);
     }
 }
 public void AddApiEndpoints(List <string> apiEndpoints)
 {
     foreach (string apiEndpoint in apiEndpoints)
     {
         _namedApiEndpoints[apiEndpoint] = apiEndpoint;
         if (!ApiEndpoints.Contains(apiEndpoint))
         {
             ApiEndpoints.Add(apiEndpoint);
         }
     }
 }
Ejemplo n.º 3
0
        public async Task <Contact> AddContact(string login)
        {
            var contact = await HttpClientWrapper.GetAsync <Contact>(ApiEndpoints.GetUserInfo(login));

            var key     = _cryptographyProvider.AES.CreateKey();
            var request = new AddContactRequest()
            {
                ContactName  = login,
                SymmetricKey = _cryptographyProvider.RSA.Encrypt(key.Key, contact.PublicKey),
                IV           = _cryptographyProvider.RSA.Encrypt(key.IV, contact.PublicKey)
            };

            contact = await HttpClientWrapper.PostAsync <Contact>(ApiEndpoints.Add(_userSettings.User.Login, login), request);

            var properties = _propertyHandler.Load();

            properties.Keys.Add(login, key);
            _propertyHandler.Save(properties);
            _userSettings.Keys.TryAdd(login, key);

            _userSettings.User.Contacts.Add(contact);
            return(contact);
        }