예제 #1
0
        public NetworkCredential GetCredential(Uri uri, string authType)
        {
            NetworkCredential nc;

            if (tempCredentials.TryGetValue(uri.Host + uri.AbsolutePath, out nc))
            {
                return(nc);                // Exact match
            }
            var dlg = new UserPasswordDialog(uri.Host);

            if (tempCredentials.TryGetValue(uri.Host, out nc) || credentials.TryGetValue(uri.Host, out nc))
            {
                dlg.User     = nc.UserName;
                dlg.Password = nc.Password;
            }
            try {
                if (MessageService.RunCustomDialog(dlg) == (int)ResponseType.Ok)
                {
                    nc = new NetworkCredential(dlg.User, dlg.Password);
                    tempCredentials [uri.Host + uri.AbsolutePath] = nc;
                    tempCredentials [uri.Host] = nc;
                    return(nc);
                }
                Canceled = true;
                return(null);
            } finally {
                dlg.Destroy();
                dlg.Dispose();
            }
        }
예제 #2
0
		public NetworkCredential GetCredential (Uri uri, string authType)
		{
			NetworkCredential nc;
			if (tempCredentials.TryGetValue (uri.Host + uri.AbsolutePath, out nc))
				return nc; // Exact match
			
			UserPasswordDialog dlg = new UserPasswordDialog (uri.Host);
			if (tempCredentials.TryGetValue (uri.Host, out nc) || credentials.TryGetValue (uri.Host, out nc)) {
				dlg.User = nc.UserName;
				dlg.Password = nc.Password;
			}
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) ResponseType.Ok) {
					nc = new NetworkCredential (dlg.User, dlg.Password);
					tempCredentials [uri.Host + uri.AbsolutePath] = nc;
					tempCredentials [uri.Host] = nc;
					return nc;
				}
				else {
					Canceled = true;
					return null;
				}
			} finally {
				dlg.Destroy ();
			}
		}