protected sealed override PasswordAuthentication GetPasswordAuthentication() { string host = GetRequestingHost(); int port = GetRequestingPort(); foreach (CachedAuthenticator.CachedAuthentication ca in cached) { if (ca.host.Equals(host) && ca.port == port) { return ca.ToPasswordAuthentication(); } } PasswordAuthentication pa = PromptPasswordAuthentication(); if (pa != null) { CachedAuthenticator.CachedAuthentication ca_1 = new CachedAuthenticator.CachedAuthentication (host, port, pa.GetUserName(), new string(pa.GetPassword())); Add(ca_1); return ca_1.ToPasswordAuthentication(); } return null; }
protected sealed override PasswordAuthentication GetPasswordAuthentication() { string host = GetRequestingHost(); int port = GetRequestingPort(); foreach (CachedAuthenticator.CachedAuthentication ca in cached) { if (ca.host.Equals(host) && ca.port == port) { return(ca.ToPasswordAuthentication()); } } PasswordAuthentication pa = PromptPasswordAuthentication(); if (pa != null) { CachedAuthenticator.CachedAuthentication ca_1 = new CachedAuthenticator.CachedAuthentication (host, port, pa.GetUserName(), new string(pa.GetPassword())); Add(ca_1); return(ca_1.ToPasswordAuthentication()); } return(null); }
/// <summary>Add a cached authentication for future use.</summary> /// <remarks>Add a cached authentication for future use.</remarks> /// <param name="ca">the information we should remember.</param> public static void Add(CachedAuthenticator.CachedAuthentication ca) { cached.AddItem(ca); }