public MainWindow() { InitializeComponent(); try { var rsaPublicKey = RSAKeyGenerator.GetPublicKeyAsXml(); RsaPublicKey = rsaPublicKey; } catch (Exception) { RsaPublicKey = "No RSA public key available"; } }
public static SecurityToken ValidateToken(string token, string validIssuer, string validAudience) { var publicKey = RSAKeyGenerator.GetPublicKeyAsXml(); var test = RSA.Create(); test.FromXmlString(publicKey); var securityKey = new RsaSecurityKey(test.ExportParameters(false)); var handler = new JwtSecurityTokenHandler(); var validationParams = new TokenValidationParameters { RequireSignedTokens = true, IssuerSigningKey = securityKey, ValidAudience = validAudience, ValidIssuer = validIssuer }; var claimsPrincipal = handler.ValidateToken(token, validationParams, out var validatedToken); return(validatedToken); }
public MainWindow() { InitializeComponent(); try { BrowserManager.Initialize(); ShowApiLoadingDialog = false; try { var rsaPublicKey = RSAKeyGenerator.GetPublicKeyAsXml(); RsaPublicKey = rsaPublicKey; } catch (Exception) { RsaPublicKey = "No RSA public key available"; } } catch (Exception) { MessageBox.Show( @"The application does not have sufficient priveleges to write to the registry. Try starting again in administrator modus if you would like the applicastion to do the neccessary configurations."); } }