Пример #1
0
        internal GitCredentialItem(CredentialItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            _item = item;

            SeedValue();
        }
Пример #2
0
        internal GitCredentialsEventArgs(string uri, CredentialItem[] credentialItems)
        {
            if (credentialItems == null)
                throw new ArgumentNullException("credentialItems");

            var items = new List<GitCredentialItem>();

            foreach (var item in credentialItems)
            {
                items.Add(new GitCredentialItem(item));
            }

            Items = new ReadOnlyCollection<GitCredentialItem>(items);

            Uri = uri;
        }
Пример #3
0
		static bool TryGetPassphrase (URIish uri, CredentialItem[] items, out CredentialItem.StringType passphraseItem)
		{
			var actualUrl = new Uri (uri.ToString ());
			var passphrase = (CredentialItem.StringType) items.FirstOrDefault (i => i is CredentialItem.StringType);
			
			if (items.Length == 1 && passphrase != null) {
				passphraseItem = passphrase;

				var passphraseValue = PasswordService.GetWebPassword (actualUrl);
				if (passphraseValue != null) {
					passphrase.SetValue (passphraseValue);
					return true;
				}
			} else {
				passphraseItem = null;
			}
			
			return false;
		}
Пример #4
0
		static bool TryGetUsernamePassword (URIish uri, CredentialItem[] items, out CredentialItem.Password passwordItem)
		{
			var actualUrl = new Uri (uri.ToString ());
			var username = (CredentialItem.Username) items.FirstOrDefault (i => i is CredentialItem.Username);
			var password = (CredentialItem.Password) items.FirstOrDefault (i => i is CredentialItem.Password);

			if (items.Length == 2 && username != null && password != null) {
				passwordItem = password;

				var cred = PasswordService.GetWebUserNameAndPassword (actualUrl);
				if (cred != null) {
					username.SetValue (cred.Item1);
					password.SetValueNoCopy (cred.Item2.ToArray ());
					return true;
				}
			} else {
				passwordItem = null;
			}

			return false;
		}