예제 #1
0
        public string GetToken()
        {
            if (!string.IsNullOrWhiteSpace(_token))
            {
                return(_token);
            }

            lock (LockObject)
            {
                if (!string.IsNullOrWhiteSpace(_token))
                {
                    return(_token);
                }

                _token = GitConfigTokenSource.GetToken();

                if (!string.IsNullOrWhiteSpace(_token))
                {
                    return(_token);
                }

                if (!string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrWhiteSpace(Password))
                {
                    _token = GenerateToken();
                    return(_token);
                }
            }

            const string msg = "Application Settings should contain {0} and {1}, or git config should contain {2}";

            throw new ApplicationException(string.Format(msg, UserNameKey, PasswordKey, GitConfigTokenSource.TokenKey));
        }
예제 #2
0
        private static string GenerateToken()
        {
            var token = GenerateToken(UserName, Password);

            GitConfigTokenSource.SetToken(token);
            RemoveSensitiveData();
            return(token);
        }