예제 #1
0
        void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
        {
            NetworkCredential matchedCredential = credentialCache.GetCredential(uri, credential.AuthenticationType);

            if (matchedCredential != null)
            {
                credentialCache.Remove(uri, credential.AuthenticationType);
            }
            credentialCache.Add(uri, credential.AuthenticationType, credential);
        }
예제 #2
0
        void StartDiscovery(Uri uri, DiscoveryNetworkCredential credential)
        {
            // Abort previous discovery.
            StopDiscovery();

            // Start new discovery.
            discoveryUri = uri;
            DiscoverAnyAsync asyncDelegate = new DiscoverAnyAsync(discoveryClientProtocol.DiscoverAny);
            AsyncCallback    callback      = new AsyncCallback(DiscoveryCompleted);

            discoveryClientProtocol.Credentials = credential;
            IAsyncResult result = asyncDelegate.BeginInvoke(uri.AbsoluteUri, callback, new AsyncDiscoveryState(discoveryClientProtocol, uri, credential));
        }
예제 #3
0
        void AuthenticateUser(Uri uri, string authenticationType)
        {
            DiscoveryNetworkCredential credential = (DiscoveryNetworkCredential)credentialCache.GetCredential(uri, authenticationType);

            if (credential != null)
            {
                StartDiscovery(uri, credential);
            }
            else
            {
                using (UserCredentialsDialog credentialsForm = new UserCredentialsDialog(uri.ToString(), authenticationType)) {
                    if (DialogResult.OK == credentialsForm.ShowDialog())
                    {
                        StartDiscovery(uri, credentialsForm.Credential);
                    }
                }
            }
        }
 public AsyncDiscoveryState(WebServiceDiscoveryClientProtocol protocol, Uri uri, DiscoveryNetworkCredential credential)
 {
     this.protocol   = protocol;
     this.uri        = uri;
     this.credential = credential;
 }