Ejemplo n.º 1
0
        private static string GetLicenseFilename(PackageLicenseDefinition packageLicenseDefinition)
        {
            string productName = packageLicenseDefinition.ProductName;

            if (productName.Length > _maximumProductNameLength)
            {
                productName = productName.Substring(productName.Length - _maximumProductNameLength);
            }

            return(Path.Combine(_packageLicenseDirectory, productName + LicenseFileExtension));
        }
Ejemplo n.º 2
0
        public static void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition)
        {
            XDocument doc = new XDocument(
                new XElement("License",
                    new XElement("Name", licenseDefinition.ProductName),
                    new XElement("InstallationId", licenseDefinition.InstallationId),
                    new XElement("ProductId", licenseDefinition.ProductId),
                    new XElement("Permanent", licenseDefinition.Permanent),                                        
                    new XElement("Expires", licenseDefinition.Expires),
                    new XElement("LicenseKey", licenseDefinition.LicenseKey),
                    new XElement("PurchaseUrl", licenseDefinition.PurchaseUrl)
                )
            );

            string filename = GetLicenseFilename(licenseDefinition);

            licenseDefinition.LicenseFileName = filename;

            doc.SaveToFile(filename);
        }
Ejemplo n.º 3
0
        public static void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition)
        {
            XDocument doc = new XDocument(
                new XElement("License",
                             new XElement("Name", licenseDefinition.ProductName),
                             new XElement("InstallationId", licenseDefinition.InstallationId),
                             new XElement("ProductId", licenseDefinition.ProductId),
                             new XElement("Permanent", licenseDefinition.Permanent),
                             new XElement("Expires", licenseDefinition.Expires),
                             new XElement("LicenseKey", licenseDefinition.LicenseKey),
                             new XElement("PurchaseUrl", licenseDefinition.PurchaseUrl)
                             )
                );

            string filename = GetLicenseFilename(licenseDefinition);

            licenseDefinition.LicenseFileName = filename;

            doc.SaveToFile(filename);
        }
Ejemplo n.º 4
0
        private static PackageLicenseDefinition TryLoadLicenseFile(string filePath)
        {
            XDocument doc = XDocumentUtils.Load(filePath);

            var licenseDefinition = new PackageLicenseDefinition
            {
                ProductName     = doc.Descendants("Name").Single().Value,
                InstallationId  = (Guid)doc.Descendants("InstallationId").Single(),
                ProductId       = (Guid)doc.Descendants("ProductId").Single(),
                Permanent       = (bool)doc.Descendants("Permanent").Single(),
                Expires         = (DateTime?)doc.Descendants("Expires").SingleOrDefault() ?? DateTime.MaxValue,
                LicenseKey      = doc.Descendants("LicenseKey").Single().Value,
                PurchaseUrl     = doc.Descendants("PurchaseUrl").SingleOrDefault()?.Value ?? "",
                LicenseFileName = filePath
            };

            if (licenseDefinition.InstallationId != InstallationInformationFacade.InstallationId)
            {
                Log.LogError(LogTitle, $"The license for the product '{licenseDefinition.ProductId}' ({licenseDefinition.ProductName}) does not match the current installation");
                return(null);
            }

            return(licenseDefinition);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Stores the given license defintion.
 /// </summary>
 /// <param name="licenseDefinition">The license definition to store</param>
 public static void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition)
 {
     ImplementationFactory.CurrentFactory.StatelessPackageLicenseHelper.StoreLicenseDefinition(licenseDefinition);
 }
 /// <summary>
 /// <see cref="Composite.Core.PackageSystem.PackageLicenseHelper"/>
 /// </summary>
 /// <param name="licenseDefinition"></param>
 public virtual void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition)
 {
     LicenseDefinitionManager.StoreLicenseDefinition(licenseDefinition);
 }
Ejemplo n.º 7
0
        private static PackageLicenseDefinition TryLoadLicenseFile(string filePath)
        {
            XDocument doc = XDocumentUtils.Load(filePath);

            var licenseDefinition = new PackageLicenseDefinition
            {
                ProductName = doc.Descendants("Name").Single().Value,
                InstallationId = (Guid)doc.Descendants("InstallationId").Single(),
                ProductId = (Guid)doc.Descendants("ProductId").Single(),
                Permanent = (bool)doc.Descendants("Permanent").Single(),
                Expires = (doc.Descendants("Expires").Any() ? (DateTime)doc.Descendants("Expires").Single() : DateTime.MaxValue),
                LicenseKey = doc.Descendants("LicenseKey").Single().Value,
                PurchaseUrl = (doc.Descendants("PurchaseUrl").Any() ? doc.Descendants("PurchaseUrl").Single().Value : ""),
                LicenseFileName = filePath
            };

            if (licenseDefinition.InstallationId != InstallationInformationFacade.InstallationId)
            {
                Log.LogError(LogTitle, string.Format("The license for the product '{0}' ({1}) does not match the current installation", licenseDefinition.ProductId, licenseDefinition.ProductName));
                return null;
            }

            return licenseDefinition;
        }
Ejemplo n.º 8
0
        private static string GetLicenseFilename(PackageLicenseDefinition packageLicenseDefinition)
        {
            string productName = packageLicenseDefinition.ProductName;

            if (productName.Length > _maximumProductNameLength)
            {
                productName = productName.Substring(productName.Length - _maximumProductNameLength);
            }

            return Path.Combine(_packageLicenseDirectory, productName + LicenseFileExtension);
        }
 /// <summary>
 /// Stores the given license defintion.
 /// </summary>
 /// <param name="licenseDefinition">The license definition to store</param>
 public static void StoreLicenseDefinition(PackageLicenseDefinition licenseDefinition)
 {
     ImplementationFactory.CurrentFactory.StatelessPackageLicenseHelper.StoreLicenseDefinition(licenseDefinition);
 }