コード例 #1
0
        public void TestMalformedPayload()
        {
            string res = jwt.GetPayload(token);

            Assert.IsTrue(SecurityUtils.compareStrings(res, ""));
            Assert.IsTrue(jwt.HasError());
        }
コード例 #2
0
        public void TestNegative1()
        {
            options.AddHeaderParameter("pepe", "whatever");
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
コード例 #3
0
        public void TestNegative1()
        {
            claimslevel2.setClaim("pepe", "whatever");
            bool verification = jwt.DoVerify(token, "HS256", claimslevel1, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
コード例 #4
0
        public void GenerateToken()
        {
            string hexaKey = keyGen.doGenerateKey("GENERICRANDOM", 256);

            options.SetSecret(hexaKey);
            token = jwt.DoCreate("HS256", claims, options);
            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            True(verification, jwt);
        }
        public void TestNegative_JustSign()
        {
            JWTOptions options1 = new JWTOptions();
            string     hexaKey1 = keyGen.doGenerateKey("GENERICRANDOM", 256);

            options1.SetSecret(hexaKey1);
            bool verification = jwt.DoVerifyJustSignature(token, "HS256", options1);

            Assert.IsFalse(verification);
            Assert.IsTrue(jwt.HasError());
        }
コード例 #6
0
        private void bulkTest_shouldWork(PrivateKeyManager key, CertificateX509 cert, string alg, string curve)
        {
            options.SetPrivateKey(key);
            options.SetCertificate(cert);
            string token = jwt.DoCreate(alg, claims, options);

            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerify(token, alg, claims, options);

            True(verification, jwt);
        }
コード例 #7
0
        public void TestNegative()
        {
            rList.addIDToRevocationList(ID);
            bool verification = jwt.DoVerify(token, "HS256", claims, options);

            Assert.IsFalse(verification);
            Assert.IsFalse(jwt.HasError());
        }
コード例 #8
0
        public void TestDomains()
        {
            options.SetSecret(hexaKey);
            string token = jwt.DoCreate("HS256 ", claims, options);

            Assert.IsFalse(jwt.HasError());
            bool verification = jwt.DoVerifyJustSignature(token, " HS256", options);

            True(verification, jwt);
        }
コード例 #9
0
        public void Test_sha256_1024_PEM()
        {
            String            pathKey = Path.Combine(path_RSA_sha256_1024, "sha256d_key.pem");
            PrivateKeyManager key     = new PrivateKeyManager();

            key.Load(pathKey);
            options.SetPrivateKey(key);
            String alg   = "RS256";
            String token = jwt.DoCreate(alg, claims, options);

            Assert.IsFalse(SecurityUtils.compareStrings("", token));
            Assert.IsFalse(jwt.HasError());
        }