Exemplo n.º 1
0
        public string Publish(int culture, string product, string version, string encryptedLicenseKey, string category, string name, string company, string email, string data)
        {
            Rsa privateKey = GetPrivateKey(product);

            if (privateKey == null)
            {
                throw new InvalidOperationException(ExceptionMessages.FormatNullPrivateKey(product));
            }

            string     responseString;
            LicenseKey licenseKey;

            try
            {
                licenseKey = LicenseKey.DecryptFromString(privateKey, encryptedLicenseKey);

                LicensePublisherResponse response = GetLicense(new CultureInfo(culture), product, new Version(version), licenseKey, category, name, company, email, data);
                License license = response.License;

                if (license == null)
                {
                    responseString = LicenseClient.ErrorHeader + response.ErrorMessage;
                }
                else
                {
                    responseString = LicenseManager.SignLicense(privateKey, license);
                }
            }
            finally
            {
                if (!_cachePrivateKey)
                {
                    ((IDisposable)privateKey).Dispose();
                }
            }

            return(licenseKey.Encrypt(responseString));
        }
Exemplo n.º 2
0
 /// <summary>Gets the requested license.</summary>
 /// <param name="cultureInfo">The license client culture.</param>
 /// <param name="product">The product name.</param>
 /// <param name="version">The product version.</param>
 /// <param name="licenseKey">The license key.</param>
 /// <param name="category">The license category.</param>
 /// <param name="name">The user name.</param>
 /// <param name="company">The user company.</param>
 /// <param name="email">The user email address.</param>
 /// <param name="data">The data to set for the license.</param>
 /// <returns>The requested <see cref="License" /> or an error message encapsulated in a <see cref="LicensePublisherResponse" /> object.</returns>
 /// <remarks>The error message should respect the provided client culture.</remarks>
 protected abstract LicensePublisherResponse GetLicense(CultureInfo cultureInfo, string product, Version version, LicenseKey licenseKey, string category, string name, string company, string email, string data);
Exemplo n.º 3
0
        /// <summary>Gets <see cref="License" /> from <see cref="LicensePublisher" /> using specified culture.</summary>
        /// <param name="cultureInfo">The specified culture information.</param>
        /// <param name="product">The product name.</param>
        /// <param name="version">The product version.</param>
        /// <param name="licenseKey">The license key.</param>
        /// <param name="category">The license category.</param>
        /// <param name="name">The user name.</param>
        /// <param name="company">The user company.</param>
        /// <param name="email">The user email address.</param>
        /// <param name="data">The data to set in the license.</param>
        /// <returns>The response from <see cref="LicensePublisher" /> which encapsulates a <see cref="License" /> object or
        /// an error message.</returns>
        public LicensePublisherResponse GetLicense(CultureInfo cultureInfo, string product, Version version, LicenseKey licenseKey, string category, string name, string company, string email, string data)
        {
            string encryptedResponse = base.Channel.Publish(cultureInfo.LCID, product, version.ToString(), licenseKey.EncryptToString(PublicKey), category, name, company, email, data);
            string response          = licenseKey.Decrypt(encryptedResponse);

            if (response.StartsWith(ErrorHeader, StringComparison.Ordinal))
            {
                string errorMessage = response.Substring(ErrorHeader.Length, response.Length - ErrorHeader.Length);
                return(new LicensePublisherResponse(errorMessage));
            }
            else
            {
                return(new LicensePublisherResponse(LicenseManager.VerifySignedLicense(PublicKey, response)));
            }
        }
Exemplo n.º 4
0
 /// <overloads>Gets <see cref="License" /> from <see cref="LicensePublisher" />.</overloads>
 /// <summary>Gets <see cref="License" /> from <see cref="LicensePublisher" /> using current thread's culture.</summary>
 /// <param name="product">The product name.</param>
 /// <param name="version">The product version.</param>
 /// <param name="licenseKey">The license key.</param>
 /// <param name="category">The license category.</param>
 /// <param name="name">The user name.</param>
 /// <param name="company">The user company.</param>
 /// <param name="email">The user email address.</param>
 /// <param name="data">The data to set in the license.</param>
 /// <returns>The response from <see cref="LicensePublisher" /> which encapsulates a <see cref="License" /> object or
 /// an error message.</returns>
 public LicensePublisherResponse GetLicense(string product, Version version, LicenseKey licenseKey, string category, string name, string company, string email, string data)
 {
     return(GetLicense(CultureInfo.CurrentCulture, product, version, licenseKey, category, name, company, email, data));
 }
Exemplo n.º 5
0
 /// <exclude/>
 public static bool Equals(LicenseKey value1, LicenseKey value2)
 {
     return(value1._key == value2._key);
 }