Exemplo n.º 1
0
        private static string GetAuthorizationHeader()
        {
            var config = AcmSettings.Load();
            AuthenticationResult result = null;

            var context = new AuthenticationContext(string.Format(
                                                        config.Login,
                                                        config.TenantId));

            var thread = new Thread(() =>
            {
                result = context.AcquireToken(
                    config.ApiEndpoint,
                    config.ClientId,
                    new Uri(config.RedirectUri));
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Name = "AquireTokenThread";
            thread.Start();
            thread.Join();

            if (result == null)
            {
                throw new InvalidOperationException("Failed to obtain the JWT token");
            }

            return(result.AccessToken);
        }
Exemplo n.º 2
0
        private void LoadSubscriptions()
        {
            var config = AcmSettings.Load();

            comboSubscription.Items.Clear();
            foreach (var sub in config.Subscriptions.OrderBy(s => s.Value))
            {
                comboSubscription.Items.Add($"{sub.Value}={sub.Key}");
            }
        }
Exemplo n.º 3
0
 private void LoadSettings(AcmSettings settings)
 {
     txtLogin.Text             = settings.Login;
     txtTenantId.Text          = settings.TenantId;
     txtApiEndpoint.Text       = settings.ApiEndpoint;
     txtClientId.Text          = settings.ClientId;
     txtRedirectUri.Text       = settings.RedirectUri;
     txtFileZillaLocation.Text = settings.FileZillaLocation;
     DataGridHelpers.FillDataGridFromDictionary(gridSubscriptions, settings.Subscriptions);
 }
Exemplo n.º 4
0
        private void btnFilezilla_Click(object sender, EventArgs e)
        {
            if (_currentApp == null)
            {
                return;
            }

            var fileZillaLocation = AcmSettings.Load().FileZillaLocation;

            Process.Start(fileZillaLocation, _currentApp.FtpSettings.FilezillaArgument);
        }
Exemplo n.º 5
0
        private void SaveSettings()
        {
            var settings = new AcmSettings
            {
                Login             = txtLogin.Text,
                TenantId          = txtTenantId.Text,
                ApiEndpoint       = txtApiEndpoint.Text,
                ClientId          = txtClientId.Text,
                RedirectUri       = txtRedirectUri.Text,
                Subscriptions     = DataGridHelpers.DataGridToDictionary(gridSubscriptions),
                FileZillaLocation = txtFileZillaLocation.Text
            };

            AcmSettings.Save(settings);
        }
Exemplo n.º 6
0
 private void Settings_Load(object sender, EventArgs e)
 {
     LoadSettings(AcmSettings.Load());
 }