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 }); }
public LicenseViewModel(LicenseInfo licenseInfo, INavigationService navigationService, IProcessService processService, ILicenseService licenseService, ILicenseValidationService licenseValidationService, IUIVisualizerService uiVisualizerService, IMessageService messageService, ILanguageService languageService, ILicenseModeService licenseModeService) { Argument.IsNotNull(() => licenseInfo); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); Argument.IsNotNull(() => licenseModeService); _navigationService = navigationService; _processService = processService; _licenseService = licenseService; _licenseValidationService = licenseValidationService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; _languageService = languageService; _licenseModeService = licenseModeService; LicenseInfo = licenseInfo; Title = licenseInfo.Title; XmlData = new ObservableCollection <XmlDataModel>(); Paste = new TaskCommand(OnPasteExecuteAsync); ShowClipboard = new TaskCommand(OnShowClipboardExecuteAsync); PurchaseLinkClick = new Command(OnPurchaseLinkClickExecute); AboutSiteClick = new Command(OnAboutSiteClickExecute); RemoveLicense = new TaskCommand(OnRemoveLicenseExecuteAsync, OnRemoveLicenseCanExecute); }
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); } }
private void btnOk_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(txtProductID.Text); string productKey = txtProductKey.Text; //Check valid if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); //Decrypt license key if (km.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "PhongNguyen"; if (kv.Type == LicenseType.TRIAL) { lic.Day = kv.Expiration.Day; lic.Month = kv.Expiration.Month; lic.Year = kv.Expiration.Year; } //Save license key to file km.SaveSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), lic); MessageBox.Show("You have been successfully registered.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { MessageBox.Show("Your product key is invalid.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
internal static bool IsEnterpriseServerLicense(string serialNumber) { bool result = false; // extract info license LicenseInfo license = CreateLicenseFromSerial(serialNumber); // if (license != null) { switch (license.Type) { case LicenseTypes.ApplicationsInstallerModule: case LicenseTypes.BackupRestoreModule: case LicenseTypes.ECommerceModule: case LicenseTypes.EnterpriseServer250WebSites: case LicenseTypes.EnterpriseServer50WebSites: case LicenseTypes.EnterpriseServerModulesPack: case LicenseTypes.EnterpriseServerUnlimitedWebSites: case LicenseTypes.Gold: case LicenseTypes.Monthly: case LicenseTypes.Standard: case LicenseTypes.Enterprise: case LicenseTypes.HyperVEnterpriseModuleSystem10: case LicenseTypes.SiteSpark: result = true; break; } } // return(result); }
private async Task FillLicense(FeatureCell cell, IPackage package) { if (package == null || package.LicenseUrl == null) { FillWithNA(cell); return; } cell.DisplayUri = package.LicenseUrl; LicenseInfo licenseInfo = null; try { licenseInfo = await this.licenseResolver.GetLicenseInfo(package.LicenseUrl); } catch (HttpDataRequestException ex) { cell.State = FeatureState.Neutral; cell.DisplayValue = ((int)ex.StatusCode).ToString(); return; } if (licenseInfo == null) { cell.State = FeatureState.Neutral; cell.DisplayValue = "unrecognized"; return; } cell.DisplayValue = licenseInfo.ShortName; }
private void simpleButton1_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(txt_proudect.Text); string proudectKey = Txt_key.Text; if (km.ValidKey(ref proudectKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(proudectKey, ref kv)) { LicenseInfo lc = new LicenseInfo(); lc.ProductKey = proudectKey; lc.FullName = "solution Company for SoftWare"; if (kv.Type == LicenseType.TRIAL) { lc.Day = kv.Expiration.Day; lc.Month = kv.Expiration.Month; lc.Year = kv.Expiration.Year; } km.SaveSuretyFile(string.Format(@"{0}\key.lic", Application.StartupPath), lc); MessageBox.Show("you have been successfuly registred", "message", MessageBoxButtons.OK, MessageBoxIcon.Information); Properties.Settings.Default.ProudectKey = "YES"; Properties.Settings.Default.Save(); this.Close(); } } else { MessageBox.Show("your proudect key is invalid", "message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnOK_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(txtProductID.Text); string productKey = txtProductKey.Text; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "FoxLearn"; if (kv.Type == LicenseType.TRIAL) { lic.Day = kv.Expiration.Day; lic.Month = kv.Expiration.Month; lic.Year = kv.Expiration.Year; } //km.SaveSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), lic); km.SaveSuretyFile(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Key.lic", lic); MessageBox.Show("You have been successfully registered", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Your product key is invalid", "Meesage", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void frmAbout_Load(object sender, EventArgs e) { lbProductID.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(lbProductID.Text); LicenseInfo lic = new LicenseInfo(); km.LoadSuretyFile(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Key.lic", ref lic); string productKey = lic.ProductKey; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { lbProductName.Text = "VISA"; lbProductKey.Text = productKey; if (kv.Type == LicenseType.TRIAL) { lbLicenseType.Text = string.Format("{0} days", (kv.Expiration - DateTime.Now.Date).Days); } else { lbLicenseType.Text = "Full"; } } } }
private void frmAbout_Load(object sender, EventArgs e) { _lblProductId.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(_lblProductId.Text); LicenseInfo lic = new LicenseInfo(); int value = km.LoadSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), ref lic); string productKey = lic.ProductKey; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { //_lblProductName.Text = "Phần mềm chấm điểm"; _lblProductKey.Text = productKey; if (kv.Type == LicenseType.TRIAL) { _lblLicenseType.Text = string.Format("Bản dùng thử còn {0} ngày", (kv.Expiration - DateTime.Now.Date).Days); } else { _lblLicenseType.Text = "Bản quyền đã kích hoạt"; } } } }
private void About_Load(object sender, EventArgs e) { txt_proudect.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(txt_proudect.Text); LicenseInfo lc = new LicenseInfo(); int value = km.LoadSuretyFile(string.Format(@"{0}\key.lic", Application.StartupPath), ref lc); string proudectKey = lc.ProductKey; if (km.ValidKey(ref proudectKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(proudectKey, ref kv)) { txt_name.Text = "solution Company for SoftWare"; Txt_key.Text = proudectKey; if (kv.Type == LicenseType.TRIAL) { txt_Licence.Text = string.Format("{0} days", (kv.Expiration - DateTime.Now.Date).Days); } else { txt_Licence.Text = "Full"; } } } }
protected override void OnLoad( EventArgs e ) { Database db = new Database(); License[] licenses = (from l in db.Licenses orderby l.Priority, l.LicenseId descending select l).ToArray(); List<LicenseInfo> licenseInfos = new List<LicenseInfo>(); for ( int i = 0; i < licenses.Length; i++ ) { License license = licenses[i]; LicenseInfo licenseInfo = new LicenseInfo {LicenseId = license.LicenseId}; ParsedLicense parsedLicense = ParsedLicenseManager.GetParsedLicense( license.LicenseKey ); if ( parsedLicense == null ) { licenseInfo.LicenseType = "INVALID"; } else { licenseInfo.LicenseType = parsedLicense.LicenseType.ToString(); licenseInfo.MaxUsers = parsedLicense.UserNumber; licenseInfo.CurrentUsers = db.GetActiveLeads( license.LicenseId, VirtualDateTime.UtcNow ); licenseInfo.ProductCode = parsedLicense.Product.ToString(); licenseInfo.GraceStartTime = license.GraceStartTime; licenseInfo.Status = license.Priority >= 0 ? "Active" : "Disabled"; licenseInfo.MaintenanceEndDate = parsedLicense.SubscriptionEndDate; } licenseInfos.Add( licenseInfo ); } this.noLicensePanel.Visible = licenseInfos.Count == 0; this.GridView1.DataSource = licenseInfos; this.GridView1.DataBind(); }
private void simpleButton1_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(txtProductID.Text); string productKey = txtProductKey.Text; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "EmdSoft"; if (kv.Type == LicenseType.TRIAL) { lic.Day = kv.Expiration.Day; lic.Month = kv.Expiration.Month; lic.Year = kv.Expiration.Year; } km.SaveSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), lic); MessageBox.Show("Etkinleştirme işlemi gerçekleştirildi.", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { MessageBox.Show("Ürün anahtarı geçersiz.", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void ok_btn_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(productid_lbl.Text); string productKey = productkey_txt.Text; //Check valid if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); //Decrypt license key if (km.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "ABCD BANK"; //Save license key to file km.SaveSuretyFile(string.Format(@"{0}\active.lic", Application.StartupPath), lic); MessageBox.Show("You have been successfully registered.", "ABCD BANK", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Dispose(); Login_form lgf = new Login_form(); lgf.Show(); } } else { MessageBox.Show("Your product key is invalid.", "ABCD BANK", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private bool IsRegistration() { string ProductId = ComputerInfo.GetComputerId(); KeyManager key = new KeyManager(ProductId); LicenseInfo lic = new LicenseInfo(); try { key.LoadSuretyFile(string.Format("Key.lic"), ref lic); if (lic.ProductKey == null) { var form = new Views.RegistrationProduct(); form.ShowDialog(); if (form.Success) { return(true); } } else { string productKey = lic.ProductKey; if (key.ValidKey(ref productKey)) { return(true); } } } catch (Exception ex) { Helpers.ShowMessage(ex.Message); } return(false); }
public void Check_export_licence() { var file_path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Bimcc.BimEngine.lic"; LicenseInfo licenseInfo = new LicenseInfo(); if (File.Exists(file_path)) { string LicenseKey = LicenseSession.LoadLicenseKeyFromFile(file_path); licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine", LicenseKey); } else { licenseInfo = LicenseSession.GetLicenseInfo("Bimcc", "Bimcc.BimEngine"); } if (licenseInfo.IsActivated) { textBox_company.Enabled = false; textBox_data.Enabled = false; textBox_mail.Enabled = false; textbox_HardwareId.Enabled = false; textbox_HardwareId.BackColor = Color.MediumSpringGreen; } }
private void button1_Click(object sender, EventArgs e) { KeyManager km = new KeyManager(tbProductID.Text); string productKey = tbProductKey.Text; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "Imad khamkhami"; if (kv.Type == LicenseType.TRIAL) { lic.Day = kv.Expiration.Day; lic.Month = kv.Expiration.Month; lic.Year = kv.Expiration.Year; } km.SaveSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), lic); MessageBox.Show("You Have been successfully registred", "Message", MessageBoxButtons.OK, MessageBoxIcon.Question); this.Dispose(); } } else { MessageBox.Show("Your Product Key is Invalide ! ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FrmAbout_Load(object sender, EventArgs e) { try { Cursor = Cursors.WaitCursor; txtProdutoID_.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(txtProdutoID_.Text); LicenseInfo Lic = new LicenseInfo(); int value = km.LoadSuretyFile(string.Format(@"{0}\Key.Lic", Application.StartupPath), ref Lic); string produtoKey = Lic.ProductKey; if (km.ValidKey(ref produtoKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(produtoKey, ref kv)) { txtProdutoNome.Text = Lic.FullName; txtProdutoKey_.Text = produtoKey; if (kv.Type == LicenseType.TRIAL) { txtLicenceType.Text = string.Format("{0} Dias", (kv.Expiration - DateTime.Now.Date).Days); } else { txtLicenceType.Text = "FULL"; } } } } finally { Cursor = Cursors.Default; } }
private void metroButton1_Click(object sender, EventArgs e) { KeyManager keyManagerObj = new KeyManager(txtProductID.Text); string productKey = txtProductKey.Text; if (keyManagerObj.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (keyManagerObj.DisassembleKey(productKey, ref kv)) { LicenseInfo lic = new LicenseInfo(); lic.ProductKey = productKey; lic.FullName = "Pastry Management System"; if (kv.Type == LicenseType.TRIAL) { lic.Day = kv.Expiration.Day; lic.Month = kv.Expiration.Month; lic.Year = kv.Expiration.Year; } keyManagerObj.SaveSuretyFile(string.Format(@"{0}\key.lic", Application.StartupPath), lic); MsgBox.Information("You have been successfully registered the product"); Hide(); } } else { MsgBox.Error("Your product key is invalid"); Hide(); } }
public AboutForm() { this.InitializeComponent(); this.Text = string.Format("About {0}", (object)Global.Setup.Product.Name); this.lblProductName.Text = Global.Setup.Product.Name; this.lblVersion.Text = string.Format("Version {0} {1}", (object)Global.Setup.Product.Version.ToString(3), Global.Setup.Product.Platform); this.lblCopyright.Text = Global.Setup.Product.Copyright; this.tbxDescription.Text = this.AssemblyDescription; LicenseInfo license = Framework.Installation.GetLicense(); if (license.Licensed != null) { this.tbxDescription.Text = string.Format("Licensed to:{0} {1}{0} {2}{0}{0}Comment:{0} {3}", Environment.NewLine, (object)(((SortedList <string, string>)license.KeyValueList).ContainsKey("User") ? ((SortedList <string, string>)license.KeyValueList)["User"] : string.Empty), (object)(((SortedList <string, string>)license.KeyValueList).ContainsKey("Company") ? ((SortedList <string, string>)license.KeyValueList)["Company"] : string.Empty), (object)(((SortedList <string, string>)license.KeyValueList).ContainsKey("Comment") ? ((SortedList <string, string>)license.KeyValueList)["Comment"] : string.Empty)); } else { this.tbxDescription.Text = "Unlicensed copy."; } try { this.logoPictureBox.Image = (Image)Icon.ExtractAssociatedIcon(Application.ExecutablePath).ToBitmap(); } catch { } }
public void TypicalEmbedInJson() { // example var license = new CreativeCommonsLicense(true, false, CreativeCommonsLicense.DerivativeRules.Derivatives); license.RightsStatement = "Please acknowledge using 'Based on work of SIL International'"; var json = "{\"license\":'" + license.Token + "\",\"rights\":\"" + license.RightsStatement + "\"}"; // store json somewhere. // parse json and get var token = "custom"; // from license field var rights = "Academic Institutions may use this free of charge"; // reconstitute the license var recoveredLicense = LicenseInfo.FromToken(token); license.RightsStatement = rights; Assert.That(recoveredLicense, Is.InstanceOf <CustomLicense>()); Assert.That(LicenseInfo.FromToken("ask"), Is.InstanceOf <NullLicense>()); var ccLicense = LicenseInfo.FromToken("by-nc-sa"); Assert.That(ccLicense, Is.InstanceOf <CreativeCommonsLicense>()); Assert.That(((CreativeCommonsLicense)ccLicense).AttributionRequired, Is.True); }
private void frmAbout_Load(object sender, EventArgs e) { lblProductID.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(lblProductID.Text); LicenseInfo lic = new LicenseInfo(); //Get license information from license file int value = km.LoadSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), ref lic); string productKey = lic.ProductKey; //Check valid if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); //Decrypt license key if (km.DisassembleKey(productKey, ref kv)) { lblProductName.Text = "*****@*****.**"; lblProductKey.Text = productKey; if (kv.Type == LicenseType.TRIAL) { lblLicenseType.Text = string.Format("{0} days", (kv.Expiration - DateTime.Now.Date).Days); } else { lblLicenseType.Text = "Full"; } } } }
public void Fresh(LicenseInfo licenseInfo) { textBox1.Text = "Bimcc.BimEngine.Revit"; textBox2.Text = licenseInfo.ProductVersion.ToString(); textBox3.Text = licenseInfo.ReleaseDate.ToLongDateString(); textBox4.Text = licenseInfo.IsActivated.ToString(); textBox5.Text = licenseInfo.LicenseMode.ToString(); textBox6.Text = licenseInfo.LicenseStatus.ToString(); textBox7.Text = licenseInfo.HardwareId.ToString(); textBox8.Text = licenseInfo.ClientName.ToString(); textBox9.Text = licenseInfo.LicenseExpiration.ToLongDateString(); textBox10.Text = licenseInfo.SubscriptionExpiration.ToLongDateString(); if (licenseInfo.IsActivated == false) { button_ok.Enabled = false; textBox4.BackColor = Color.Red; textBox5.BackColor = Color.Red; textBox6.BackColor = Color.Red; } else { button_ok.Enabled = true; textBox4.BackColor = Color.MediumSpringGreen; textBox5.BackColor = Color.MediumSpringGreen; textBox6.BackColor = Color.MediumSpringGreen; } }
string InitGrid(List <LicenseInfo> licenseInfos) { mainForm.licenseAppList.Clear(); // 设置表格数据 DataTable dt = new DataTable(); for (int i = 0; i < colNames.Count; i++) { dt.Columns.Add(colNames[i]); } string errorInfo = ""; for (int i = 0; i < licenseInfos.Count; i++) { LicenseInfo oLicenseInfo = licenseInfos[i]; if (oLicenseInfo.IsUsed.ToLower() != "true") { continue; } if (string.IsNullOrEmpty(oLicenseInfo.ErrorInfo)) { for (int mIndex = 0; mIndex < oLicenseInfo.ModuleInfos.Count; mIndex++) { string appName = oLicenseInfo.ModuleInfos[mIndex].AppName; DataRow dtRow = dt.NewRow(); string LicenseFile = string.Format("{0} -- [{1}]", i + 1, oLicenseInfo.LicenseType); dtRow[colNames[0]] = LicenseFile; dtRow[colNames[1]] = appName; dtRow[colNames[2]] = oLicenseInfo.ModuleInfos[mIndex].LicenseCount; dtRow[colNames[3]] = oLicenseInfo.ModuleInfos[mIndex].LicenseUsed; dtRow[colNames[4]] = oLicenseInfo.ModuleInfos[mIndex].ExpiryDate; dtRow[colNames[5]] = oLicenseInfo.uuid; dt.Rows.Add(dtRow); if (mainForm.licenseAppList.IndexOf(appName) >= 0) { continue; } mainForm.licenseAppList.Add(appName); } } else { errorInfo = oLicenseInfo.ErrorInfo; } } gridControl.DataSource = dt; gridView.Columns[colNames[0]].GroupIndex = 0; gridView.Columns[colNames[5]].Visible = false; gridView.ExpandAllGroups(); int j = 0; return(errorInfo); }
public IRequestBuilder WithLicenseInfo(LicenseInfo licenseInfo) { _request.LicenseLogin = licenseInfo.Login; _request.LicenseKey = licenseInfo.Key; return(this); }
private void frmAbout_Load(object sender, EventArgs e) { lblProductID.Text = ComputerInfo.GetComputerId(); KeyManager km = new KeyManager(lblProductID.Text); LicenseInfo lic = new LicenseInfo(); int value = km.LoadSuretyFile(string.Format(@"key.lic", Application.StartupPath), ref lic); string productKey = lic.ProductKey; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { lblName.Text = "Pastry Management System"; lblProductKey.Text = productKey; if (kv.Type == LicenseType.TRIAL) { lblLicenseType.Text = string.Format("{0} days", (kv.Expiration - DateTime.Now.Date).Days); } else { lblLicenseType.Text = "Full"; } } } }
private void Activation_Load(object sender, EventArgs e) { Size = new Size(Size.Width, 168); if (Settings.Default.ProductKey.Equals("Unlicensed")) { info = LicenseInfo.CreateUnlicensedInfo(); lblActivationStatus.Text = "Status: No valid product key was found."; } else { info = LicenseEngine.GetLicenseInfo(Settings.Default.ProductKey); if (info.IsEmpty) { lblActivationStatus.Text = "Status: No valid product key was found."; } else { txtProductKey.Text = Settings.Default.ProductKey.Substring(0, 15) + "******-******-..."; lblActivationStatus.Text = "Status: Product activated. No further action needed."; Size = new Size(Size.Width, 370); } } infoPropGrid.SelectedObject = info; }
/// <summary> /// /// </summary> /// <param name="skuDetail"></param> /// <returns></returns> public LicenseInfo CreateLicenseInfo(SKUDetailInfo skuDetail) { LicenseInfo obj = new LicenseInfo(); obj.SKUID = skuDetail.SKUID; obj.SKUType = skuDetail.SKUType; obj.Qty = skuDetail.Qty; obj.QtySpecified = skuDetail.QtySpecified; if (skuDetail.SKUType == Constants.SKUType.OPTION.ToString()) { obj.VersionSeqNo = -1; obj.LicenseKey = skuDetail.OptionLicenseKey; obj.ReleaseDateSpecified = false; } else { VersionInfoWithLicense[] versions = skuDetail.VersionList; VersionInfoWithLicense latestVersion = versions.OrderByDescending(o => o.VersionSeqNo).FirstOrDefault <VersionInfoWithLicense>(); // CALL GET LICENSE FOR GIVEN SKU AND GET LICENSE KEY if (latestVersion != null) { obj.ImageUrl = latestVersion.ImageUrl; obj.IsShippedVersion = latestVersion.IsShippedVersion; obj.Version = latestVersion.Version; obj.VersionSeqNo = latestVersion.VersionSeqNo; obj.VersionType = latestVersion.VersionType; obj.LicenseKey = latestVersion.LicenseKey; } } return(obj); }
private void btnOK_Click(object sender, EventArgs e) { KeyManager Km = new KeyManager(txtProductID.Text); string productKey = txtProductKey.Text; if (Km.ValidKey(ref productKey)) { KeyValuesClass Kv = new KeyValuesClass(); if (Km.DisassembleKey(productKey, ref Kv)) { LicenseInfo Lic = new LicenseInfo(); Lic.ProductKey = productKey; Lic.FullName = "XENOS"; if (Kv.Type == LicenseType.TRIAL) { Lic.Day = Kv.Expiration.Day; Lic.Month = Kv.Expiration.Month; Lic.Year = Kv.Expiration.Year; } Km.SaveSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), Lic); MessageBox.Show("Successfully registered.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { MessageBox.Show("Your product key is invalid.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void LoadLicenseFile(string filename) { try { using (FileStream fs = File.OpenRead(filename)) { using (StreamReader sr = new StreamReader(fs)) { string[] licInfo = _security.Decrypt(sr.ReadToEnd()).Split(new[] { '|' }); _licenseInfo = new LicenseInfo { ClientName = licInfo[0], Type = Convert.ToInt16(licInfo[1], CultureInfo.InvariantCulture), Timestamp = Convert.ToDateTime(licInfo[2], CultureInfo.InvariantCulture) }; if (_licenseInfo.Type == 0) { _licenseInfo.ValidDays = Convert.ToInt32(licInfo[3], CultureInfo.InvariantCulture); } _loaded = true; } } } catch (Exception ex) { throw new SecurityException("Could not load license file. " + Environment.NewLine + "Error:" + ex.Message); } }
private void frmRegistration_FormClosing(object sender, FormClosingEventArgs e) { KeyManager km = new KeyManager(ComputerInfo.GetComputerId()); LicenseInfo lic = new LicenseInfo(); bool isActive = false;//bien kiem tra kich hoat int value = km.LoadSuretyFile(string.Format(@"{0}\Key.lic", Application.StartupPath), ref lic); string productKey = lic.ProductKey; if (km.ValidKey(ref productKey)) { KeyValuesClass kv = new KeyValuesClass(); if (km.DisassembleKey(productKey, ref kv)) { if (kv.Type == LicenseType.TRIAL) { //dung thu ma con ngay thi cho chay if ((kv.Expiration - DateTime.Now.Date).Days > 0) { isActive = true; } } else { isActive = true; } } } // neu khong con ngay su dung, thoat khoi chuong trinh if (!isActive) { MessageBox.Show("Vui lòng kích hoạt bản quyền để sử dụng. Xin cám ơn.", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Exit(); } }
/// <summary> /// Initializes a new instance of the <see cref="LicenseViewModel" /> class. /// </summary> /// <param name="licenseInfo">The single license model.</param> /// <param name="navigationService">The navigation service.</param> /// <param name="processService">The process service.</param> /// <param name="licenseService">The license service.</param> /// <param name="licenseValidationService">The license validation service.</param> /// <param name="uiVisualizerService">The uiVisualizer service.</param> /// <param name="messageService">The message service.</param> /// <exception cref="ArgumentNullException">The <paramref name="licenseInfo" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="navigationService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="processService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="licenseService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="uiVisualizerService" /> is <c>null</c>.</exception> public LicenseViewModel(LicenseInfo licenseInfo, INavigationService navigationService, IProcessService processService, ILicenseService licenseService, ILicenseValidationService licenseValidationService, IUIVisualizerService uiVisualizerService, IMessageService messageService) { Argument.IsNotNull(() => licenseInfo); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); _navigationService = navigationService; _processService = processService; _licenseService = licenseService; _licenseValidationService = licenseValidationService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; LicenseInfo = licenseInfo; Title = licenseInfo.Title; XmlData = new ObservableCollection<XmlDataModel>(); Paste = new TaskCommand(OnPasteExecuteAsync); ShowClipboard = new Command(OnShowClipboardExecute); PurchaseLinkClick = new Command(OnPurchaseLinkClickExecute); AboutSiteClick = new Command(OnAboutSiteClickExecute); RemoveLicense = new TaskCommand(OnRemoveLicenseExecuteAsync, OnRemoveLicenseCanExecute); }
public LicenseInfo GetLicenseInfo() { var licenseInfo = new LicenseInfo(); licenseInfo.Title = "Catel"; licenseInfo.ImageUri = "/Orc.LicenseManager.Client.WPF.Example;component/Resources/Images/logo_with_text.png"; licenseInfo.Text = "Catel is a company made in 2010 and is dolor sit amet, consectetur adipiscing elit. Etiam nec sem sit amet felis blandit semper. Morbi tempus ligula urna, feugiat rhoncus dolor elementum non."; licenseInfo.InfoUrl = "http://www.catelproject.com/"; licenseInfo.PurchaseUrl = "http://www.catelproject.com/product/buy/642"; return licenseInfo; }
/// <summary> /// Geocodes the specified address. /// </summary> /// <param name="address">The address.</param> /// <param name="result">The result.</param> /// <returns> /// True/False value of whether the address was standardized was succesfully /// </returns> public override bool Geocode( Rock.CRM.Address address, out string result ) { if ( address != null ) { var registeredUser = new RegisteredUser(); registeredUser.UserID = AttributeValue("UserID"); registeredUser.Password = AttributeValue("Password"); var licenseInfo = new LicenseInfo(); licenseInfo.RegisteredUser = registeredUser; var client = new USAddressVerificationSoapClient(); SIWsOutputOfUSAddress verifyResult; SubscriptionInfo info = client.VerifyAddressUSA( licenseInfo, address.Street1, address.Street2, string.Format("{0} {1} {2}", address.City, address.State, address.Zip), string.Empty, string.Empty, CasingEnum.PROPER, out verifyResult ); if (verifyResult != null) { result = verifyResult.ServiceStatus.StatusNbr.ToString(); if ( verifyResult.ServiceStatus.StatusNbr == 200 ) { USAddress usAddress = verifyResult.ServiceResult; if ( usAddress != null && usAddress.GeoCode != null ) { address.Latitude = usAddress.GeoCode.Latitude; address.Longitude = usAddress.GeoCode.Longitude; return true; } } } else result = "Null Result"; } else result = "Null Address"; return false; }
/// <summary> /// Standardizes the specified address. /// </summary> /// <remarks> /// The StrikeIron address verification will also attempt to geocode the address. If this /// geocode is succesful, the Geocode information of the address will be updated also. /// </remarks> /// <param name="location">The location.</param> /// <param name="result">The result.</param> /// <returns> /// True/False value of whether the address was standardized was succesfully /// </returns> public override bool Standardize( Rock.Model.Location location, out string result ) { if ( location != null ) { var registeredUser = new RegisteredUser(); registeredUser.UserID = GetAttributeValue("UserID"); registeredUser.Password = GetAttributeValue("Password"); var licenseInfo = new LicenseInfo(); licenseInfo.RegisteredUser = registeredUser; var client = new USAddressVerificationSoapClient(); SIWsOutputOfUSAddress verifyResult; SubscriptionInfo info = client.VerifyAddressUSA( licenseInfo, location.Street1, location.Street2, string.Format("{0} {1} {2}", location.City, location.State, location.Zip), string.Empty, string.Empty, CasingEnum.PROPER, out verifyResult ); if (verifyResult != null) { result = verifyResult.ServiceStatus.StatusNbr.ToString(); if ( verifyResult.ServiceStatus.StatusNbr == 200 ) { USAddress usAddress = verifyResult.ServiceResult; if ( usAddress != null && usAddress.GeoCode != null ) { location.Street1 = usAddress.AddressLine1; location.Street2 = usAddress.AddressLine2; location.City = usAddress.City; location.State = usAddress.State; location.Zip = usAddress.ZIPPlus4; if ( usAddress.GeoCode != null ) { location.GeocodeAttemptedServiceType = "StrikeIron"; location.GeocodeAttemptedResult = "200"; location.GeocodedDateTime = DateTime.Now; location.SetLocationPointFromLatLong( usAddress.GeoCode.Latitude, usAddress.GeoCode.Longitude ); } return true; } } } else result = "Null Result"; } else result = "Null Address"; return false; }
public bool AddLicense(string clientAlias, string key, bool replace) { //validate input if ((clientAlias.Length < 1)||(key.Length != m_keyLength)) { m_errorMsg = string.Format("Invalid client ID or key\nClientAlias = {0}\nKey = {1}", clientAlias, key); return false; } int index = GetLicenseIndex(clientAlias); if ((index >= 0) && (!replace)) { m_errorMsg = string.Format("Client not added. License already exists for {0}", clientAlias); return false; } LicenseInfo Client = new LicenseInfo(); if ( !ValidateClient(ref Client, clientAlias, key) ) { string tempMsg = m_errorMsg; m_errorMsg = string.Format("Unable to validate license key for client ID {0}\n{1}", clientAlias, tempMsg); return false; } if (index >= 0) //replace existing { m_clientList[index].Copy(Client); } else //append to end { m_clientList.Add(Client); } //update the license file if (!UpdateLicenseFile()) return false; //create client folders if needed string clientFolder = m_dataPathRoot + clientAlias; try { if (!Directory.Exists(clientFolder)) Directory.CreateDirectory(clientFolder); clientFolder += "\\upload"; if (!Directory.Exists(clientFolder)) Directory.CreateDirectory(clientFolder); } catch (Exception ex) { m_errorMsg = string.Format("Unable to create client folder\nPath = {0}", clientFolder); m_errorMsg += "\nException: " + ex.Message; if (ex.InnerException != null) m_errorMsg += "\nInnerException: " + ex.InnerException.Message; return false; } return true; }
private static LicenseInfo CreateLicenseFromSerial(string serialNumber) { int componentKey = 0; int versionKey = 0; // extract info license bool validSerial = ExtractLicenseInfo(serialNumber, out componentKey, out versionKey); if (!validSerial) return null; LicenseInfo license = new LicenseInfo(); license.SerialNumber = serialNumber; license.Type = (LicenseTypes)componentKey; license.Version = versionKey; license.Active = true; return license; }
/// <summary> /// Notifies about license changed. /// </summary> /// <param name="info">License info.</param> public void NotifyLicenseChanged(LicenseInfo info) { RuntimeHub.NotifyLicenseChanged(info); }
public string CreateSignature(LicenseInfo licenseInformation) { SHA384Managed shaM = new SHA384Managed(); byte[] data; MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write((int)licenseInformation.kind); if (licenseInformation.kind == LicenseType.NodeLocked) { bw.Write(licenseInformation.computerID); } bw.Write(licenseInformation.passCode); foreach (FeatureInfo feature in licenseInformation.features) { bw.Write(feature.featureName); bw.Write(feature.timeDepend); if (feature.timeDepend) { bw.Write(feature.expiration.ToString()); } bw.Write(feature.maxCount); } int nLen = (int)ms.Position + 1; bw.Close(); ms.Close(); data = ms.GetBuffer(); data = shaM.ComputeHash(data, 0, nLen); string result = ""; foreach (byte dbyte in data) { result += dbyte.ToString("X2"); } return result; }
private bool ValidateClient(ref LicenseInfo Client, string clientAlias, string key) { if (!CleanText(ref clientAlias, m_clientAliasLength)) return false; if (!ExtractClientInfo(ref Client, key)) return false;//fill client info from the provided key //recalculate the key using the provided clientAlias string calcKey = CalcLicenseKey(clientAlias, Client.tier, Client.toolFlags); //compare client IDs and keys //string tempID = clientAlias.Substring(0, Client.clientAlias.Length); //Not needed because of clean... if ((!calcKey.Equals(key)) || (!clientAlias.Equals(Client.clientAlias))) { m_errorMsg = "Invalid key or client ID."; //invalid clients are disabled, but left in list, so keep client ID... Client.Clear(); Client.clientAlias = clientAlias; return false; } //Check to see if this client can use this tool if (!IsToolAllowed(Client, ToolType)) { m_errorMsg = "License is not authorized for this product."; Client.isValid = false; //key is valid in general, just not for this tool, so leave toolFlags etc alone return false; } Client.isValid = true; return true; }
private bool LoadLicenseFile() { List<string> clientAliases = new List<string>(); List<string> keys = new List<string>(); //read client-key pairs from the external license file StreamReader licenseFile = null; try { licenseFile = new StreamReader(m_licenseFilename); } catch (Exception) { m_errorMsg = String.Format("\nCould not open license file {0}.\n\n", m_licenseFilename); return false; } string tempLine; string[] tempSplit; char delimeter = '\t'; int count = 0; while (true) //read until end of file { tempLine = licenseFile.ReadLine(); if (tempLine == null) break; if (tempLine.Length == 0) break; tempSplit = tempLine.Split(delimeter); if (tempSplit.Length != 2) { m_errorMsg = string.Format( "Error: trouble reading license %d in license file %s.\nThis client will be disabled.", count + 1, m_licenseFilename); //skip this entry and allow the rest of the licenses to stand //TODO: should this be logged? continue; } clientAliases.Add(tempSplit[0]); keys.Add(tempSplit[1]); count++; } licenseFile.Close(); if (count < 1) return false; //must be at least one license to return true; // always wipe out the list when reloading m_clientList = new List<LicenseInfo>(); for (int i = 0; i < count; i++) { //always add the client to the list --validator will clear content if license is invalid LicenseInfo client = new LicenseInfo(); ValidateClient(ref client, clientAliases[i], keys[i]); m_clientList.Add(client); } return true; }
public void Copy(LicenseInfo li) { clientAlias = li.clientAlias; tier = li.tier; maxUsers = li.maxUsers; toolFlags = li.toolFlags; key = li.key; isValid = li.isValid; }
protected virtual bool ExtractClientInfo(ref LicenseInfo Client, string key) { string code = DeInterleave(key); if (code == null) { m_errorMsg = "Invalid key length."; Client.Clear(); return false; } if (code.Length != m_codeLength) { //this should never be reached, but was added while debugging m_errorMsg = "Invalid code length."; Client.Clear(); return false; } int version = AlphaDecode(key.Substring(0, 1)); //first character of the key is always the version if (version != m_version) { m_errorMsg = "Invalid license key."; Client.Clear(); return false; } //character 0 was the version, 1 is tier, 2 & 3 are toolFlags Client.tier = AlphaDecode(code.Substring(1, 1)); Client.toolFlags = (byte)AlphaDecode(code.Substring(2, 2)); Client.clientAlias = UnMangleClientAliasAlpha(code.Substring(4)); SetTierMaximums(ref Client); Client.key = key; return true; }
private void SetTierMaximums(ref LicenseInfo Client) { switch (Client.tier) { case 0: //invalid Client.maxUsers = 0; break; case 1: //bronze Client.maxUsers = 5000; break; case 2: //silver Client.maxUsers = 20000; break; case 3: //gold Client.maxUsers = 100000; break; case 4: //platinum Client.maxUsers = 300000; break; case 5: //titanium Client.maxUsers = int.MaxValue; break; default: goto case 0; } }
public LicenseInfo GetLicenseInfo(string clientAlias) { LicenseInfo Client = new LicenseInfo(); Client.Clear(); //empty client response will signal error int index = GetLicenseIndex(clientAlias); if (index < 0) //unable to find client in list; { //error message compiled in GetLicenseIndex return Client; } // invalid clients are disabled, but left in list, so need to check here... if (!m_clientList[index].isValid) //invalid client (bad key or not authorized for this tool) { //error message compiled in GetLicenseIndex return Client; } //valid client Client.Copy(m_clientList[index]); Client.key = ""; //do not release the key externally return Client; }
private bool IsToolAllowed(LicenseInfo Client, ToolTypes tool) { if (tool == ToolTypes.LicenseGenerator) return true; byte thisTool = (byte)(Math.Pow(2, (int)tool)); return (thisTool & Client.toolFlags) > 0; }