Exemple #1
0
        /// <summary>
        /// Called when the main form is shown.
        /// </summary>
        /// <param name="sender">Sender of the event.</param>
        /// <param name="e">The event arguments.</param>
        private async void MainForm_Shown(object sender, EventArgs e)
        {
            var signerKey = await CryptoUtil.ReadFirstRsaPublicKey(Properties.Settings.Default.SignerKey, new HttpClient());

            OAuthConfig.SignerKey = signerKey.RSAKey;
            EntClient             = new EntClient()
            {
                OAuthConfig = OAuthConfig
            };

            // This sample application always requires sign-on / authorization against the 10Duke entitlement service.
            EnsureAuthorization();
            if (EntClient.IsAuthorized())
            {
                ShowWelcomeMessage();
                ShowComputerId();
                StoreAuthorization();
            }
            else
            {
                // If the authorization process was cancelled, close this form. This will cause the whole application
                // to be closed.
                Close();
            }
        }
 /// <summary>
 /// Checks that either a previously stored valid authorization against the 10Duke Entitlement Service exists,
 /// or launches embedded browser for signing on and getting the authorization.
 /// </summary>
 private void EnsureAuthorization()
 {
     if (!UseStoredAuthorization())
     {
         EntClient.AuthorizeSync();
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MainForm"/> class.
 /// </summary>
 public MainForm()
 {
     InitializeComponent();
     comboBoxConsumeMode.SelectedIndex = 0;
     listViewAuthorizationDecisions.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     EntClient = new EntClient()
     {
         OAuthConfig = OAuthConfig
     };
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     // This sample application always requires sign-on / authorization against the 10Duke entitlement service.
     EnsureAuthorization();
     if (EntClient.IsAuthorized())
     {
         ShowWelcomeMessage();
         ShowComputerId();
         StoreAuthorization();
     }
     else
     {
         // If the authorization process was cancelled, close this form. This will cause the whole application
         // to be closed.
         Close();
     }
 }