protected override void ProcessRecord()
        {
            var communicationKey = Convert.FromBase64String(CommunicationKeyAsBase64);

            if (communicationKey.Length != 32)
            {
                throw new NotSupportedException("Communication key must be 256 bits long.");
            }

            var envelope = new Hashtable
            {
                { "version", 1 },
                { "com_key_id", CommunicationKeyId.ToString() },
                { "message", LicenseToken }
            };

            // Copy the expiration from the "message" structure if they are defined.
            if (LicenseToken.ContainsKey("begin_date"))
            {
                envelope["begin_date"] = LicenseToken["begin_date"];
            }

            if (LicenseToken.ContainsKey("expiration_date"))
            {
                envelope["expiration_date"] = LicenseToken["expiration_date"];
            }

            // Now we have the outer structure ready. Convert to JSON and then sign.
            var json = JsonConvert.SerializeObject(envelope);

            WriteVerbose(json);

            // The output is the signed JOSE object, short-form serialized.
            var joseObject = JWT.Encode(json, communicationKey, JwsAlgorithm.HS256);

            WriteObject(joseObject);
        }