示例#1
0
        public void TestMethod2()
        {
            var payload = "Test";
            var kid = "Sample";
            var key = "1234567890123456";

            var jwsToken = new Jose().Configuration(
                JoseBuilders.JsonSignatureCompactSerializationBuilder()
                    .Header(new JoseHeader(JsonWebAlgorithm.HS256, JsonWebAlgorithm.NONE, kid))
                    .Payload(payload)
                    .Key(key)
                ).Serialization();

            var serializeAction = new Jose().Configuration(
                JoseBuilders.CompactDeserializationBuilder()
                    .SerializedSource(jwsToken)
                    .Key(key)
                );

            var result = serializeAction.Deserialization();
            var header = serializeAction.GetHeader();

            Assert.AreEqual(payload, result);
            Assert.AreEqual(kid, header.Kid);
        }
示例#2
0
        public void TestMethod1()
        {
            var payload = "Test";
            var kid = "Sample";
            var key = "1234567890123456";

            var jweToken = new Jose().Configuration(
                JoseBuilders.JsonEncryptionCompactSerializationBuilder()
                    .Header(new JoseHeader(JsonWebAlgorithm.A128KW, JsonWebAlgorithm.A128CBC_HS256, kid))
                    .Payload(payload)
                    .Key(key)
                ).Serialization();

            Console.WriteLine("JWE = " + jweToken);

            var serializeAction = new Jose().Configuration(
                JoseBuilders.CompactDeserializationBuilder()
                    .SerializedSource(jweToken)
                    .Key(key)
                );

            var result = serializeAction.Deserialization();
            var header = serializeAction.GetHeader();

            Assert.AreEqual(payload, result);
            Assert.AreEqual(kid, header.Kid);
        }