public void FetchJWKKeyAsRSATokenVerificationKey()
        {
            string keysResponse = @"{
             ""keys"": [
              {
               ""kty"": ""RSA"",
               ""alg"": ""RS256"",
               ""use"": ""sig"",
               ""kid"": ""d83ad1bbaac388a4dcb4957e53282a0e7d0bf98a"",
               ""n"": ""temCVy5oxWCEUwHUqGXxvHnySlaZtT_JmHm0zICxsanboYss-b3nOqIXN45L5TyTiNbOBgE6vge2TfIjo_NqXBiKjRNl_g7F4iwl07p2abn3KQ6mgYDlFMhJJOXG4-0dMORBgi3hQi8VajLHJ04FoorZsf__FDb1gvvnPObUQwM="",
               ""e"": ""AQAB""
              }
             ]
            }";

            JsonWebKey jsonWebKey = FetchAndValidateJsonWebKeyWithCommonProperties(keysResponse);

            Assert.AreEqual(0, jsonWebKey.X5c.Count, "x5c should not contain elements ");
            Assert.IsNull(jsonWebKey.X5t, "x5t field should be null");

            RsaTokenVerificationKey tokenVerificationKey = jsonWebKey.AsTokenVerificationKey() as RsaTokenVerificationKey;

            Assert.IsNotNull(tokenVerificationKey);
            RSAParameters parameters = tokenVerificationKey.GetRsaParameters();

            Assert.IsNotNull(parameters);
            Assert.IsNotNull(parameters.Modulus);
            Assert.IsNotNull(parameters.Exponent);
        }
        public void RSATokenVerificationKeyRoundTrip()
        {
            TokenRestrictionTemplate template             = new TokenRestrictionTemplate(TokenType.JWT);
            RsaTokenVerificationKey  tokenVerificationKey = new RsaTokenVerificationKey();
            RSAParameters            inputRsaParameters;

            using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider())
            {
                inputRsaParameters = provider.ExportParameters(true);

                tokenVerificationKey.InitFromRsaParameters(inputRsaParameters);
            }
            Assert.IsNotNull(tokenVerificationKey.RawBody);
            template.Audience = _sampleAudience;
            template.Issuer   = _sampleIssuer;
            template.PrimaryVerificationKey = tokenVerificationKey;
            var templateAsString = TokenRestrictionTemplateSerializer.Serialize(template);

            Assert.IsTrue(templateAsString.Contains("<PrimaryVerificationKey i:type=\"RsaTokenVerificationKey\">"));
            TokenRestrictionTemplate output = TokenRestrictionTemplateSerializer.Deserialize(templateAsString);

            Assert.AreEqual(TokenType.JWT, output.TokenType);
            Assert.IsNotNull(output.PrimaryVerificationKey);
            Assert.IsNotNull(output.PrimaryVerificationKey as RsaTokenVerificationKey);
            RsaTokenVerificationKey key = output.PrimaryVerificationKey as RsaTokenVerificationKey;

            Assert.IsNotNull(key.RawBody);
            RSAParameters outputRsaParametersutParameters = key.GetRsaParameters();

            Assert.IsNotNull(outputRsaParametersutParameters);
            Assert.IsNotNull(outputRsaParametersutParameters.Exponent);
            Assert.IsNotNull(outputRsaParametersutParameters.Modulus);
            //Check that we are storing only public signing key
            Assert.IsNull(outputRsaParametersutParameters.P);
            Assert.IsNull(outputRsaParametersutParameters.Q);
            Assert.IsNull(outputRsaParametersutParameters.D);
            Assert.IsNull(outputRsaParametersutParameters.DP);
            Assert.IsNull(outputRsaParametersutParameters.DQ);
            //Checking that public key matching
            Assert.IsTrue(inputRsaParameters.Exponent.SequenceEqual(outputRsaParametersutParameters.Exponent), "Exponent value mismatch");
            Assert.IsTrue(inputRsaParameters.Modulus.SequenceEqual(outputRsaParametersutParameters.Modulus), "Modulus value mismatch");
        }