public void SetTenorAPIKey(string apiKey)
 {
     SetDefault("TenorAPIKey",
                WindowsCipherManager.Encrypt(
                    apiKey,
                    "TenorAPIKey"));
 }
        public string GetCurrentUserLogin()
        {
            if (CurrentUser.IsTemporary())
            {
                return(CurrentUser.Login);
            }

            var currentUserLogin =
                GetDefault("CurrentUserLogin");

            try
            {
                return(WindowsCipherManager.Decrypt(
                           currentUserLogin,
                           "CurrentUserLogin"));
            }
            catch (CryptographicException)
            {
                SetCurrentUserLogin(
                    currentUserLogin);

                return(WindowsCipherManager.Decrypt(
                           GetDefault("CurrentUserLogin"),
                           "CurrentUserLogin"));
            }
            catch (FormatException)
            {
                SetCurrentUserLogin(
                    currentUserLogin);

                return(WindowsCipherManager.Decrypt(
                           GetDefault("CurrentUserLogin"),
                           "CurrentUserLogin"));
            }
        }
        public string GetTenorAPIKey()
        {
            var tenorApiKey =
                GetDefault("TenorAPIKey");

            if (string.IsNullOrEmpty(tenorApiKey))
            {
                return("TKAGGYAX27OJ");
            }

            try
            {
                return(WindowsCipherManager.Decrypt(
                           tenorApiKey,
                           "TenorAPIKey"));
            }
            catch (CryptographicException)
            {
                SetTenorAPIKey(
                    tenorApiKey);

                return(WindowsCipherManager.Decrypt(
                           GetDefault("TenorAPIKey"),
                           "TenorAPIKey"));
            }
            catch (FormatException)
            {
                SetTenorAPIKey(
                    tenorApiKey);

                return(WindowsCipherManager.Decrypt(
                           GetDefault("TenorAPIKey"),
                           "TenorAPIKey"));
            }
        }
        public string GetUserRocketPassword(string login)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                return(CurrentUser.RocketPassword);
            }

            return(WindowsCipherManager.Decrypt(
                       Get(login, "UserRocketPassword"),
                       $"UserRocketPassword-{login}"));
        }
        public string GetUserToken(string login)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                return(CurrentUser.Token);
            }

            return(WindowsCipherManager.Decrypt(
                       Get(login, "UserToken"),
                       $"UserToken-{login}"));
        }
        public void SetCurrentUserLogin(string login)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                return;
            }

            SetDefault("CurrentUserLogin",
                       WindowsCipherManager.Encrypt(
                           login,
                           "CurrentUserLogin"));
        }
        public int GetUserId(string login)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                return(CurrentUser.Id);
            }

            var userId = WindowsCipherManager.Decrypt(
                Get(login, "UserId"),
                $"UserId-{login}");

            return(!string.IsNullOrEmpty(userId)
                ? userId.ToInt()
                : -1);
        }
        public void SetUserId(string login, int id)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                CurrentUser = new User(
                    CurrentUser.Login,
                    CurrentUser.Token,
                    id,
                    CurrentUser.RocketPassword,
                    CurrentUser.StoreType);

                return;
            }

            Set(login, "UserId",
                WindowsCipherManager.Encrypt(
                    id.ToString(),
                    $"UserId-{login}"));
        }
        public void SetUserToken(string login, string token)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                CurrentUser = new User(
                    CurrentUser.Login,
                    token,
                    CurrentUser.Id,
                    CurrentUser.RocketPassword,
                    CurrentUser.StoreType);

                return;
            }

            Set(login, "UserToken",
                WindowsCipherManager.Encrypt(
                    token,
                    $"UserToken-{login}"));
        }