Exemple #1
0
        void CreateLicFile()
        {
            String tenantName       = "Celestial Being GN-00";
            String tenantIdentifier = String.Join(".", tenantName, GetComputerName());

            DownloadFileInfo rqsFileInfo = License.GetRequestTicket(tenantIdentifier);

            var licInfo = new LicenseInfo {
                RequestTicket = SecurityExt.EncodeBase64UrlFromBytes(rqsFileInfo.FileByteArray),
                ClientName    = tenantName,
                Type          = LicenseType.Trial,
                EffectiveDate = DateTime.Now.AddDays(-3),
                ExpiredDate   = DateTime.Now.AddDays(10),
                UsersCount    = 50,
                Buffer        = 10,
                Modules       = new List <String> {
                    "Report", "Analytics", "Contacts"
                }
            };

            DownloadFileInfo licFile = License.GetLicense(tenantName, licInfo);

            using (var writer = new BinaryWriter(File.Open(GetOutputPath(licFile.Filename), FileMode.Create)))
                foreach (Byte b in licFile.FileByteArray)
                {
                    writer.Write(b);
                }
        }
Exemple #2
0
            // NOTE: call this on clientmachine
            public static DownloadFileInfo GetRequestTicket(String identifier)
            {
                String delimited = String.Join(TestNvy.NameValueItem.ItemDelimiter.ToString(), identifier, GetDelimitedHardwareIds());
                String hwHash    = SecurityExt.Encrypt(delimited, EnxKey, EnxSalt); // NOTE: should be get from config
                String filename  = Path.Combine($"{identifier}.{Guid.NewGuid().ToString("N")}.rqs");

                Byte[] fileBytes;
                using (var stream = new MemoryStream()) {
                    using (var writer = new BinaryWriter(stream)) {
                        writer.Write("RQS");
                        writer.Write(0x82); // R
                        writer.Write(0x81); // Q
                        writer.Write(0x83); // S
                        writer.Write(hwHash);
                        writer.Write(0x82); // R
                        writer.Write(0x81); // Q
                        writer.Write(0x83); // S
                    }

                    fileBytes = stream.ToArray();
                }

                return(new DownloadFileInfo {
                    Filename = filename,
                    FileByteArray = fileBytes,
                    MimeType = BinaryFileMime
                });
            }
Exemple #3
0
            public static DownloadFileInfo GetLicense(String identifier, LicenseInfo license)
            {
                String jsonLic  = JsonConvert.SerializeObject(license);
                String licHash  = SecurityExt.Encrypt(jsonLic, EnxKey, EnxSalt); // NOTE: should be get from config
                String filename = Path.Combine($"{identifier}.{Guid.NewGuid().ToString("N")}.lcs");

                Byte[] fileBytes;
                using (var stream = new MemoryStream()) {
                    using (var writer = new BinaryWriter(stream)) {
                        writer.Write("LCS");
                        writer.Write(0x76); // L
                        writer.Write(0x67); // C
                        writer.Write(0x83); // S
                        writer.Write(licHash);
                        writer.Write(0x76); // L
                        writer.Write(0x67); // C
                        writer.Write(0x83); // S
                    }

                    fileBytes = stream.ToArray();
                }

                return(new DownloadFileInfo {
                    Filename = filename,
                    FileByteArray = fileBytes,
                    MimeType = BinaryFileMime
                });
            }
Exemple #4
0
        void CreateRequestTicket()
        {
            String tenantName       = "Celestial Being GN-00";
            String tenantIdentifier = String.Join(".", tenantName, GetComputerName());

            // Example 1
            DownloadFileInfo requestTicket = License.GetRequestTicket(tenantIdentifier);

            File.WriteAllText(GetOutputPath(requestTicket.Filename), SecurityExt.EncodeBase64UrlFromBytes(requestTicket.FileByteArray));

            // Example 2
            License.SaveRequestTicket(OutputDirPath, tenantIdentifier);
        }