Esempio n. 1
0
        private void SetMstCredentials(ITranslationProviderCredentialStore credentialStore, GenericCredentials creds, bool persistCred)
        { //used to set credentials
            // we are only setting and getting credentials for the uri with no parameters...kind of like a master credential
            var myUri = new Uri("mtenhancedprovidermst:///");

            var cred = new TranslationProviderCredential(creds.ToCredentialString(), persistCred);

            credentialStore.RemoveCredential(myUri);
            credentialStore.AddCredential(myUri, cred);
        }
Esempio n. 2
0
        private void OKClicked(object sender, EventArgs e)
        {
            int?port = GetPort();

            if (!port.HasValue)
            {
                DialogResult = DialogResult.None;
                string error = string.Format("The port must be a valid port between {0} and {1}.", IPEndPoint.MinPort, IPEndPoint.MaxPort);
                MessageBox.Show(error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            GenericCredentials credentials = GetCredentials();

            if (!AuthenticateCredentials(credentials))
            {
                return;
            }

            var creds = new TranslationProviderCredential(credentials.ToCredentialString(), Options.PersistCredentials);

            credentialStore.AddCredential(Options.Uri, creds);

            if (setDefaultTM.Checked)
            {
                PluginConfiguration.CurrentInstance.DefaultConnection = new Connection(
                    host: Options.Host,
                    port: Options.Port
                    );
                PluginConfiguration.CurrentInstance.SaveToFile();
            }
            else if (!setDefaultTM.Checked &&
                     PluginConfiguration.CurrentInstance.DefaultConnection.HasValue &&
                     PluginConfiguration.CurrentInstance.DefaultConnection.Value.Host == Options.Host &&
                     PluginConfiguration.CurrentInstance.DefaultConnection.Value.Port == Options.Port)
            {
                PluginConfiguration.CurrentInstance.DefaultConnection = null;
                PluginConfiguration.CurrentInstance.SaveToFile();
            }
        }
        private void SetMstCredentials(ITranslationProviderCredentialStore credentialStore, GenericCredentials creds, bool persistCred)
        {
            //used to set credentials
            // we are only setting and getting credentials for the uri with no parameters...kind of like a master credential
            Uri myUri = new Uri("mtenhancedprovidermst:///");

            TranslationProviderCredential cred = new TranslationProviderCredential(creds.ToCredentialString(), persistCred);
            credentialStore.RemoveCredential(myUri);
            credentialStore.AddCredential(myUri, cred);
        }