/// <summary>
        ///     Saves the license key.
        /// </summary>
        public override void Save()
        {
            // Check whether vendor-authorisation is required.
            if (!this.IsPersisted || !this.ComputeHash().SequenceEqual(this.Provider.Security.License.FetchById(this.Id).ComputeHash()) || this.Status == LicenseStatus.Invalid)
            {
                // Obtain the required license key.
                LicenseKey licenseKey = LicenseKey.PrivateKey;
                if (licenseKey != null)
                {
                    this.ModifiedData.Signature = licenseKey.Sign(this.ComputeHash());
                }
            }

            this._status = null;

            // Recompute the status and save if the license has not been invalidated.
            if (this.Status != LicenseStatus.Invalid)
            {
                base.Save();
                this.Provider.Security.License.Reset();
            }
        }
        /// <summary>
        ///     Saves the public and private elements of the license key.
        /// </summary>
        internal void Save(String filename, Boolean includePrivate)
        {
            Byte[] oidValue = LicenseKey.SetAsnData(0x06, LicenseKey.RsaObjectIdentifier);
            Byte[] oidNulls = LicenseKey.SetAsnData(0x05, new Byte[0]);
            Byte[] oidBlock = LicenseKey.SetAsnData(0x30, oidValue.Concat(oidNulls));
            Byte[] keyValue = LicenseKey.SetAsnData(0x02, this.Parameters.Modulus).Concat(LicenseKey.SetAsnData(0x02, this.Parameters.Exponent)).ToArray();
            if (includePrivate)
            {
                keyValue = keyValue.Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.D)).Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.P)).Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.Q)).Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.DP)).Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.DQ)).Concat(
                    LicenseKey.SetAsnData(0x02, this.Parameters.InverseQ)).ToArray();
            }
            Byte[] rsaValue = LicenseKey.SetAsnData(0x30, keyValue);
            Byte[] rsaBlock = LicenseKey.SetAsnData(0x03, rsaValue);
            Byte[] asnBlock = LicenseKey.SetAsnData(0x30, oidBlock.Concat(rsaBlock));

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("----- BEGIN " + (includePrivate ? "PRIVATE" : "PUBLIC") + " RSA KEY -----");
            builder.AppendLine();
            builder.AppendLine(Convert.ToBase64String(asnBlock, Base64FormattingOptions.InsertLineBreaks));
            builder.AppendLine();
            builder.AppendLine("----- END " + (includePrivate ? "PRIVATE" : "PUBLIC") + " RSA KEY -----");
            File.WriteAllText(filename, builder.ToString());
        }