diff --git a/TokenGeneratorJWT/Form1.Designer.cs b/TokenGeneratorJWT/Form1.Designer.cs index 59bf5bb..08e2c08 100644 --- a/TokenGeneratorJWT/Form1.Designer.cs +++ b/TokenGeneratorJWT/Form1.Designer.cs @@ -29,6 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); labelSecKey = new Label(); textBoxSecurityKey = new TextBox(); buttonBuildToken = new Button(); @@ -65,8 +66,8 @@ private void InitializeComponent() MenuHamacSha512 = new ToolStripMenuItem(); statusStrip1 = new StatusStrip(); StatusLabelSecurityAlgorithm = new ToolStripStatusLabel(); - StatusLabelVersion = new ToolStripStatusLabel(); toolStripStatusLabel1 = new ToolStripStatusLabel(); + StatusLabelVersion = new ToolStripStatusLabel(); contextMenuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)errorProvider1).BeginInit(); groupBox1.SuspendLayout(); @@ -99,9 +100,9 @@ private void InitializeComponent() // buttonBuildToken.Enabled = false; buttonBuildToken.Font = new Font("Segoe UI", 7F, FontStyle.Bold); - buttonBuildToken.Location = new Point(12, 293); + buttonBuildToken.Location = new Point(7, 186); buttonBuildToken.Name = "buttonBuildToken"; - buttonBuildToken.Size = new Size(192, 23); + buttonBuildToken.Size = new Size(192, 20); buttonBuildToken.TabIndex = 6; buttonBuildToken.Text = "build token (F5)"; buttonBuildToken.UseVisualStyleBackColor = true; @@ -168,12 +169,12 @@ private void InitializeComponent() // textBoxJwtToken.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; textBoxJwtToken.ContextMenuStrip = contextMenuStrip1; - textBoxJwtToken.Location = new Point(12, 322); + textBoxJwtToken.Location = new Point(12, 293); textBoxJwtToken.Multiline = true; textBoxJwtToken.Name = "textBoxJwtToken"; textBoxJwtToken.ReadOnly = true; textBoxJwtToken.ScrollBars = ScrollBars.Both; - textBoxJwtToken.Size = new Size(580, 219); + textBoxJwtToken.Size = new Size(580, 248); textBoxJwtToken.TabIndex = 0; textBoxJwtToken.TabStop = false; // @@ -272,6 +273,7 @@ private void InitializeComponent() groupBox1.Controls.Add(labelExp); groupBox1.Controls.Add(labelIss); groupBox1.Controls.Add(textBoxAudience); + groupBox1.Controls.Add(buttonBuildToken); groupBox1.Controls.Add(labelAud); groupBox1.Font = new Font("Segoe UI", 9F, FontStyle.Bold); groupBox1.Location = new Point(12, 66); @@ -284,9 +286,9 @@ private void InitializeComponent() // buttonAddClaim // buttonAddClaim.Font = new Font("Segoe UI", 7F, FontStyle.Bold); - buttonAddClaim.Location = new Point(14, 151); + buttonAddClaim.Location = new Point(7, 151); buttonAddClaim.Name = "buttonAddClaim"; - buttonAddClaim.Size = new Size(185, 20); + buttonAddClaim.Size = new Size(192, 20); buttonAddClaim.TabIndex = 16; buttonAddClaim.Text = "add claim (F2)"; buttonAddClaim.UseVisualStyleBackColor = true; @@ -391,6 +393,12 @@ private void InitializeComponent() StatusLabelSecurityAlgorithm.Name = "StatusLabelSecurityAlgorithm"; StatusLabelSecurityAlgorithm.Size = new Size(0, 17); // + // toolStripStatusLabel1 + // + toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + toolStripStatusLabel1.Size = new Size(544, 17); + toolStripStatusLabel1.Spring = true; + // // StatusLabelVersion // StatusLabelVersion.DisplayStyle = ToolStripItemDisplayStyle.Text; @@ -398,12 +406,6 @@ private void InitializeComponent() StatusLabelVersion.Size = new Size(45, 17); StatusLabelVersion.Text = "version"; // - // toolStripStatusLabel1 - // - toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - toolStripStatusLabel1.Size = new Size(513, 17); - toolStripStatusLabel1.Spring = true; - // // Form1 // AutoScaleDimensions = new SizeF(7F, 15F); @@ -419,7 +421,7 @@ private void InitializeComponent() Controls.Add(labelSecKey); Controls.Add(textBoxJwtToken); Controls.Add(labelKeyInfo); - Controls.Add(buttonBuildToken); + Icon = (Icon)resources.GetObject("$this.Icon"); MainMenuStrip = menuStripMainMenu; MaximizeBox = false; Name = "Form1"; diff --git a/TokenGeneratorJWT/Form1.cs b/TokenGeneratorJWT/Form1.cs index d70c438..d0dfcbf 100644 --- a/TokenGeneratorJWT/Form1.cs +++ b/TokenGeneratorJWT/Form1.cs @@ -23,8 +23,8 @@ public partial class Form1 : Form public Form1() { InitializeComponent(); - SetParamsForKeyAlgorithm(SecurityAlgorithm,MinKeyLength); - StatusLabelVersion.Text = Assembly.GetEntryAssembly().GetName().Version.ToString(); + SetParamsForKeyAlgorithm(SecurityAlgorithm, MinKeyLength); + StatusLabelVersion.Text = GetVersion(); } private void buttonBuildToken_Click(object sender, EventArgs e) @@ -75,7 +75,15 @@ private void buttonBuildToken_Click(object sender, EventArgs e) signingCredentials: credentials); - TokenString = new JwtSecurityTokenHandler().WriteToken(token); + try + { + TokenString = new JwtSecurityTokenHandler().WriteToken(token); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } PayloadJSON = JsonNode.Parse(token.Payload.SerializeToJson()).ToString(); @@ -201,7 +209,7 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e) } #endregion // MenuEvents - #region helper + #region Helper private void ShowKeylength(TextBox tb) { textBoxKeyLength.Text = (tb.Text.Length * 8).ToString() + " bit"; @@ -240,6 +248,13 @@ private void SetEncryptionAlgorithm(object sender, EventArgs e) break; } } + + private string GetVersion() + { + return $"v{Assembly.GetEntryAssembly().GetName().Version.Major}" + + $".{Assembly.GetEntryAssembly().GetName().Version.Minor}" + + $".{Assembly.GetEntryAssembly().GetName().Version.Build}"; + } #endregion //helper } } diff --git a/TokenGeneratorJWT/Form1.resx b/TokenGeneratorJWT/Form1.resx index 43408a1..bf1f241 100644 --- a/TokenGeneratorJWT/Form1.resx +++ b/TokenGeneratorJWT/Form1.resx @@ -129,4 +129,24 @@ 417, 17 + + + + AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA/j8AAPIP + AADgBwAA8AcAAMADAACAAQAAwYEAAIGDAACAAQAAwAMAAOAPAADgBwAA8E8AAPx/AAD//wAA + + \ No newline at end of file diff --git a/TokenGeneratorJWT/TokenGeneratorJWT.csproj b/TokenGeneratorJWT/TokenGeneratorJWT.csproj index f5e002f..1fcdcee 100644 --- a/TokenGeneratorJWT/TokenGeneratorJWT.csproj +++ b/TokenGeneratorJWT/TokenGeneratorJWT.csproj @@ -6,9 +6,22 @@ enable true enable - 1.3.1 + 1.4.0 + icons8-jwt-128.png + icons8-jwt-128.ico + + + + + + + True + \ + + + diff --git a/TokenGeneratorJWT/icons8-jwt-128.ico b/TokenGeneratorJWT/icons8-jwt-128.ico new file mode 100644 index 0000000..ae6b313 Binary files /dev/null and b/TokenGeneratorJWT/icons8-jwt-128.ico differ diff --git a/icons/icons8-jwt-128.ico b/icons/icons8-jwt-128.ico new file mode 100644 index 0000000..ae6b313 Binary files /dev/null and b/icons/icons8-jwt-128.ico differ diff --git a/icons/icons8-jwt-16tr.ico b/icons/icons8-jwt-16tr.ico new file mode 100644 index 0000000..85b0684 Binary files /dev/null and b/icons/icons8-jwt-16tr.ico differ