Пример #1
0
 private void LoadData(object sender, EventArgs e)
 {
     textBoxComment.ReadOnly    = true;
     textBoxComment.BorderStyle = 0;
     textBoxComment.BackColor   = this.BackColor;
     textBoxComment.TabStop     = false;
     dataManager.LoadUserData();
     textBoxObjectStorageEndPoint.Text = dataManager.GetValue(DataManager.Category.ObjectStorage, DataManager.Key.Endpoint);
     textBoxAccessKey.Text             = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey);
     textBoxSecretKey.Text             = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey);
     textBoxBucketName.Text            = dataManager.GetValue(DataManager.Category.ObjectStorage, DataManager.Key.Bucket);
 }
Пример #2
0
        private void LoadData(object sender, EventArgs e)
        {
            dataManager.LoadUserData();
            textBoxApiGatewayEndpoint.Text = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);

            string isSaveKeyYn = dataManager.GetValue(DataManager.Category.Login, DataManager.Key.IsSaveKeyYn);

            if (isSaveKeyYn.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                checkBoxSave.Checked  = true;
                textBoxAccessKey.Text = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey);
                textBoxSecretKey.Text = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey);
            }
            else
            {
                checkBoxSave.Checked = false;
            }
        }
Пример #3
0
 private async Task ObjectStorageBucketCheck()
 {
     try
     {
         ObjectStorage o = new ObjectStorage(
             logClientConfig.GetValue(Category.Api, Key.AccessKey),
             logClientConfig.GetValue(Category.Api, Key.SecretKey),
             dataManager.GetValue(DataManager.Category.ObjectStorage, DataManager.Key.Endpoint)
             );
         if (!await o.IsExistsBucket(bucket))
         {
             throw new Exception("object storage bucket does not exists");
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #4
0
        private void KeyServerTypeClicked(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;
            string      radioButtonText = rb.Name;

            string serverUrl = logClientConfig.GetValue(LogClient.Category.Encryption, LogClient.Key.GetCryptionKeyUrl);

            textBoxAccessKey.Text  = LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey);
            textBoxSecretKey.Text  = LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey);
            textBoxKeyTag.Text     = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.KeyTag);
            textBoxCiphertext.Text = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.Ciphertext);
            if (radioButtonText.Equals("radioButtonLocalKey"))
            {
                textBoxKey.Enabled          = true;
                textBoxKeyTag.Enabled       = false;
                textBoxCiphertext.Enabled   = false;
                textBoxAccessKey.Enabled    = false;
                textBoxSecretKey.Enabled    = false;
                buttonGetCiphertext.Enabled = false;
            }

            if (radioButtonText.Equals("radioButtonNcpKms"))
            {
                textBoxKey.Enabled          = true;
                textBoxKeyTag.Enabled       = true;
                textBoxCiphertext.Enabled   = true;
                textBoxAccessKey.Enabled    = true;
                textBoxSecretKey.Enabled    = true;
                buttonGetCiphertext.Enabled = true;
            }

            if (radioButtonText.Equals("radioButtonRemoteKeyServer"))
            {
                textBoxKey.Enabled          = false;
                textBoxKeyTag.Enabled       = false;
                textBoxCiphertext.Enabled   = false;
                textBoxAccessKey.Enabled    = true;
                textBoxSecretKey.Enabled    = true;
                buttonGetCiphertext.Enabled = false;
            }
        }
Пример #5
0
 private WcfRestServer.WcfResponse FirstKeySetting(string cmdText)
 {
     try
     {
         if ((logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey).Length == 0) &&
             (logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey).Length == 0))
         {
             return(ChangeKeySetting(cmdText));
         }
         else
         {
             wcfResponse.IsSuccess     = false;
             wcfResponse.ResultMessage = "";
             wcfResponse.ErrorMessage  = "The key has already been set and can not be changed.";
             return(wcfResponse);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #6
0
        private void CheckConfigurationKey()
        {
            AppendVerifyLog("*. Encrytpion Key");

            string getCryptionKeyType = logClientConfig.GetValue(LogClient.Category.Encryption, LogClient.Key.GetCryptionKey);
            string keyTag             = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.KeyTag);
            string ciphertext         = LogClient.Config.Instance.GetValue(LogClient.Category.Encryption, LogClient.Key.Ciphertext);

            try
            {
                AppendVerifyLog($"   Current Encrytpion Type : {getCryptionKeyType}");
                if (getCryptionKeyType.Equals("Local", StringComparison.OrdinalIgnoreCase))
                {
                    AppendVerifyLog("   Cryption Key : " + logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey));
                    if (logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey).Length == 0)
                    {
                        AppendVerifyLog($"   [Warning] Cryption Key is too short! (key length is : {logClientConfig.GetValue(Category.Encryption, Key.LocalCryptionKey).Length})");
                    }
                }
                else
                {
                    if (keyTag.Length <= 1)
                    {
                        throw new Exception("   [ERROR] The KMS keytag is not corrent!");
                    }

                    if (ciphertext.Length <= 1)
                    {
                        throw new Exception("   [ERROR] The KMS ciphertext is not corrent!");
                    }

                    var kmsDecrypteParameters = new
                    {
                        ciphertext = ciphertext
                    };
                    var    jt         = JToken.Parse(JsonConvert.SerializeObject(kmsDecrypteParameters));
                    string parameters = jt.ToString(Newtonsoft.Json.Formatting.Indented);

                    SoaCall asyncCall = new SoaCall();
                    var     response  = AsyncHelpers.RunSync <string>(() => asyncCall.WebApiCall(
                                                                          @"https://kms.apigw.ntruss.com",
                                                                          RequestType.POST,
                                                                          @"/keys/v2/" + keyTag + @"/decrypt",
                                                                          parameters,
                                                                          LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey),
                                                                          LogClient.Config.Instance.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey), 5));

                    JsonSerializerSettings options = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };

                    if (!response.Contains("SUCCESS"))
                    {
                        throw new Exception(response);
                    }

                    KmsDecryptResponse KmsDecryptResponse = JsonConvert.DeserializeObject <KmsDecryptResponse>(response, options);
                    AppendVerifyLog("   Cryption KMS key : " + TranString.DecodeBase64(KmsDecryptResponse.data.plaintext));
                }

                AppendVerifyLog($"   Encryption Key Check Result : Success");
            }
            catch (Exception ex)
            {
                AppendVerifyLog(ex.Message);
                AppendVerifyLog("   Encryption Key(KMS) Help Message...");
                AppendVerifyLog("   -----------------------------------------------");
                AppendVerifyLog("   1. Enable subaccount in MC Console.");
                AppendVerifyLog("   2. In the Management Console, create a key for encryption / decryption.");
                AppendVerifyLog("   3. Paste the generated keytag into the SQL Server DBA Tool.");
                AppendVerifyLog("   4. In the SQL Server DBA Tool, type key");
                AppendVerifyLog("   5. Create ciphertext in the SQL Server DBA Tool.");
                AppendVerifyLog("   6. Save.");
                AppendVerifyLog("   -----------------------------------------------");
                throw new Exception("Encryption Key Error!");
            }
        }
        private void Send()
        {
            lock (Lock)
            {
                List <LogDataArgs> permitLogLists = new List <LogDataArgs>();
                try
                {
                    int logLevel = LogLevelQuery().Result;
                    //int logLevel = LogLevelQuery();
                    foreach (var a in buffer)
                    {
                        if ((int)a.Level >= logLevel)
                        {
                            permitLogLists.Add(a);
                        }
                    }

                    if (permitLogLists.Count > 0)
                    {
                        AppLog joyLog = new AppLog
                        {
                            AppName         = Config.Instance.GetValue(Category.Config, Key.AppName),
                            GUID            = Config.Instance.GUID,
                            ClientIpAddress = Config.Instance.LocalIp,
                            LogData         = permitLogLists
                        };
                        var jsonLog = JsonConvert.SerializeObject(joyLog);
                        nlog.Info(jsonLog);

                        if (!ConfigLogType.Equals("Local", StringComparison.OrdinalIgnoreCase))
                        {
                            SoaCall       asyncCall = new SoaCall();
                            Task <string> t         = asyncCall.WebApiCall(config.Url(RequestUrlType.LOG), RequestType.POST, @"Api/Log", jsonLog.ToString(), config.GetValue(Category.Config, Key.AccessKey), config.GetValue(Category.Config, Key.SecretKey));
                            t.Wait();
                        }
                    }
                }
                catch (Exception ex)
                {
                    nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
                }
                finally
                {
                    buffer.Clear();
                    permitLogLists.Clear();
                    firstReceiveTime = DateTime.Now;
                    currentDataCnt   = 0;
                }
            }
        }