Beispiel #1
0
        public Jws CreateJws <T>(T obj, IDictionary <string, string> additionalHeaderProperties = null, dynamic unprotectedHeader = null)
        {
            var result      = new Jws();
            var jsonPayload = JsonConvert.SerializeObject(obj, JsonSettings);

            result.Payload = Base64Url.Serialize(jsonPayload);
            var protectedHeader = signatureProvider.ProtectedHeader;

            AddAdditionalProtectedHeaders(additionalHeaderProperties, protectedHeader);
            result.Protected = Base64Url.Serialize((string)JsonConvert.SerializeObject(protectedHeader, JsonSettings));
            result.Header    = unprotectedHeader;
            result.Signature = Base64Url.Serialize(signatureProvider.ComputeSignature(Encoding.UTF8.GetBytes($"{result.Protected}.{result.Payload}")));
            return(result);
        }