private void SetKeyElementsFromJson(AsymmetricKeyPair key) { PrivateExponentTextBox.Text = key.PrivateExponent; ExponentOneTextBox.Text = key.ExponentOne; ExponentTwoTextBox.Text = key.ExponentTwo; PublicExponentTextBox.Text = key.PublicExponent; CoeficientTextBox.Text = key.Coefficient; ModulusTextBox.Text = key.Modulus; PrimeOneTextBox.Text = key.PrimeOne; PrimeTwoTextBox.Text = key.PrimeTwo; }
private void GenerateKeyButton_Click(object sender, EventArgs e) { var asymetricKey = new AsymmetricKeyPair(PrivateExponentTextBox.Text, ExponentOneTextBox.Text, ExponentTwoTextBox.Text, PublicExponentTextBox.Text, CoeficientTextBox.Text, ModulusTextBox.Text, PrimeOneTextBox.Text, PrimeTwoTextBox.Text); var jsonToken = new JsonWebToken(EmailTextBox.Text, ExpirationPicker.Value, asymetricKey); var token = jsonToken.Serialize(); var result = new ResultForm(token); result.ShowDialog(this); }
private void button1_Click(object sender, EventArgs e) { var jsonImport = new GetFromJsonForm(); var result = jsonImport.ShowDialog(); if (result == DialogResult.OK) { try { var json = JObject.Parse(jsonImport.Json); var account = json["serviceAccount"]["email"]; EmailTextBox.Text = (string)account; var key = AsymmetricKeyPair.FromJson(json); SetKeyElementsFromJson(key); } catch (Exception exception) { MessageBox.Show($"There was a problem converting the given json to private key elements: {exception.Message}"); } } }
public JsonWebToken(string account, DateTimeOffset expiration, AsymmetricKeyPair privateServiceKey) { this.Account = account ?? throw new ArgumentNullException(nameof(account)); this.Expiration = expiration; this.privateServiceKey = privateServiceKey ?? throw new ArgumentNullException(nameof(privateServiceKey)); }