public void NoHeadersAdded() { WebHeaderCollection headers = new WebHeaderCollection(); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual(String.Empty, authenticationHeader.AuthenticationType); }
public void NonStandardAuthenticationHeaderAdded() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add(HttpResponseHeader.WwwAuthenticate, "Foo"); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual("Foo", authenticationHeader.AuthenticationType); }
public void IsBasicAuthentication() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add(HttpResponseHeader.WwwAuthenticate, "Basic realm='localhost'"); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual("Basic", authenticationHeader.AuthenticationType); }
public void DigestAuthenticationSchemeAdded() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add(HttpResponseHeader.WwwAuthenticate, "Digest realm='test'"); headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual("Digest,NTLM", authenticationHeader.AuthenticationType); }
public void IsWindowsAuthentication() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add(HttpResponseHeader.WwwAuthenticate, "Negotiate"); headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual("Negotiate,NTLM", authenticationHeader.AuthenticationType); }
public void ManyAuthenticationSchemesAdded() { WebHeaderCollection headers = new WebHeaderCollection(); headers.Add(HttpResponseHeader.WwwAuthenticate, "Negotiate"); headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); headers.Add(HttpResponseHeader.WwwAuthenticate, "Basic realm='test'"); HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); Assert.AreEqual("Negotiate,NTLM,Basic", authenticationHeader.AuthenticationType); }
/// <summary> /// Called after an asynchronous web services search has /// completed. /// </summary> void DiscoveryCompleted(IAsyncResult result) { AsyncDiscoveryState state = (AsyncDiscoveryState)result.AsyncState; WebServiceDiscoveryClientProtocol protocol = state.Protocol; // Check that we are still waiting for this particular callback. bool wanted = false; lock (this) { wanted = Object.ReferenceEquals(discoveryClientProtocol, protocol); } if (wanted) { DiscoveredWebServicesHandler handler = new DiscoveredWebServicesHandler(DiscoveredWebServices); try { DiscoverAnyAsync asyncDelegate = (DiscoverAnyAsync)((AsyncResult)result).AsyncDelegate; DiscoveryDocument doc = asyncDelegate.EndInvoke(result); if (!state.Credential.IsDefaultAuthenticationType) { AddCredential(state.Uri, state.Credential); } Invoke(handler, new object[] { protocol }); } catch (Exception ex) { if (protocol.IsAuthenticationRequired) { HttpAuthenticationHeader authHeader = protocol.GetAuthenticationHeader(); AuthenticationHandler authHandler = new AuthenticationHandler(AuthenticateUser); Invoke(authHandler, new object[] { state.Uri, authHeader.AuthenticationType }); } else { LoggingService.Error("DiscoveryCompleted", ex); Invoke(handler, new object[] { null }); } } } }