예제 #1
0
        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"));
            }
        }
예제 #2
0
        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"));
            }
        }
예제 #3
0
        public string GetUserRocketPassword(string login)
        {
            if (CurrentUser.Login == login &&
                CurrentUser.IsTemporary())
            {
                return(CurrentUser.RocketPassword);
            }

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

            return(WindowsCipherManager.Decrypt(
                       Get(login, "UserToken"),
                       $"UserToken-{login}"));
        }
예제 #5
0
        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);
        }