Exemple #1
0
 private static void ValidateJiraSettings(JiraSettings settings)
 {
     if (string.IsNullOrWhiteSpace(settings.Host))
     {
         throw new ArgumentException("Host must be specified.");
     }
 }
        private void HandleOkClick(object sender, RoutedEventArgs e)
        {
            List <string> validationErrors = new List <string>();

            if (!Uri.IsWellFormedUriString(_baseUrlTextBox.Text, UriKind.Absolute))
            {
                validationErrors.Add("Base URL is invalid.");
            }
            if (string.IsNullOrEmpty(_userNameTextBox.Text))
            {
                validationErrors.Add("User name cannot be empty.");
            }
            if (string.IsNullOrEmpty(_passwordBox.Password))
            {
                validationErrors.Add("Password cannot be empty.");
            }

            if (validationErrors.Any())
            {
                MessageBox.Show(this, string.Join(Environment.NewLine, validationErrors), "Invalid values", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                ProvidedSettings = new JiraSettings(new Uri(_baseUrlTextBox.Text), _userNameTextBox.Text, _passwordBox.Password);
                DialogResult     = true;
            }
        }
        public JiraApiClient GetClientWithNewSettings(JiraSettings jiraSettings)
        {
            _jiraSettingsStorage.Set(jiraSettings);

            JiraApiClient result = new JiraApiClient(jiraSettings);

            return(result);
        }
        public void Set(JiraSettings jiraSettings)
        {
            byte[]        serializedJiraSettings = _binarySerializer.Serialize <JiraSettings, JiraSettingsProtobufContract>(jiraSettings);
            EncryptedData encryptedJiraSettings  = _dataEncryptor.Encrypt(serializedJiraSettings);

            byte[] serializedEncryptedJiraSettings = _binarySerializer.Serialize <EncryptedData, EncryptedDataProtobufContract>(encryptedJiraSettings);

            _applicationStorageFolder.StoreBytes(JiraSettingsFileName, serializedEncryptedJiraSettings);
        }
Exemple #5
0
 public JiraApiClient(JiraSettings jiraSettings)
 {
     _baseUrl    = jiraSettings.BaseUrl;
     _restClient = new RestClient(new Uri(jiraSettings.BaseUrl, "rest/api/2"))
     {
         Authenticator = new HttpBasicAuthenticator(jiraSettings.UserName, jiraSettings.Password)
     };
     _restClient.AddHandler("application/json", new DynamicJsonDeserializer());
 }
        public JiraApiClient TryToGetClientWithPreviouslyProvidedSettings()
        {
            JiraApiClient result = null;

            JiraSettings jiraSettings = _jiraSettingsStorage.Get();

            if (jiraSettings != null)
            {
                result = new JiraApiClient(jiraSettings);
            }

            return(result);
        }
        public Startup(IConfiguration configuration, IWebHostEnvironment env)
        {
            Configuration = configuration;

            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables()
                          .AddJsonFile("appsettings.local.json", optional: true, reloadOnChange: true);

            Configuration = builder.Build();

            JiraSettings = Configuration.GetSection(nameof(JiraSettings)).Get <JiraSettings>();
        }
        public JiraSettings Get()
        {
            JiraSettings result = null;

            if (_applicationStorageFolder.FileExists(JiraSettingsFileName))
            {
                byte[]        encryptedBytes = _applicationStorageFolder.GetBytes(JiraSettingsFileName);
                EncryptedData encryptedData  = _binarySerializer.Deserialize <EncryptedData, EncryptedDataProtobufContract>(encryptedBytes);

                byte[] decryptedData = _dataEncryptor.Decrypt(encryptedData);
                result = _binarySerializer.Deserialize <JiraSettings, JiraSettingsProtobufContract>(decryptedData);
            }

            return(result);
        }
Exemple #9
0
 public JiraClient(JiraSettings jiraSettings)
 {
     _jiraSettings = jiraSettings;
 }
Exemple #10
0
 public JiraClient(JiraSettings settings)
 {
     jiraSettings = settings;
 }
Exemple #11
0
        public JiraClient()
        {
            var settingsComponent = SettingsComponent.GetComponent <JiraSettingsComponent>();

            jiraSettings = settingsComponent.GetSettings();
        }
Exemple #12
0
 private static Atlassian.Jira.Jira CreateJira(JiraSettings settings)
 {
     return(Atlassian.Jira.Jira.CreateRestClient(settings.Host, settings.User, settings.Password));
 }
 public async Task SaveSettings([FromBody] JiraSettings settings)
 {
     await _settingsService.Set(Const.PluginName, settings);
 }