static private bool UpdateLicenseDetails(AuthenticatedLicense license, NinjaTrader.NinjaScript.StrategyBase S) { string s = "EXPIRY:";//20090911 int index = 0; DateTime expiry = DateTime.MinValue; index = license.ProductInfo.IndexOf(s); if (index >= 0) { string[] sub = (license.ProductInfo.Substring(index + s.Length)).Split(new char[] { ' ', ';', ',' }, StringSplitOptions.None); if (sub[0].Length >= 8) { int year = Convert.ToInt32(sub[0].Substring(0, 4)); int month = Convert.ToInt32(sub[0].Substring(4, 2)); int day = Convert.ToInt32(sub[0].Substring(6, 2)); expiry = new DateTime(year, month, day); } if (sub[0].Length == 8 || DateTime.Now < expiry) { LICENSE_FILE = LICENSE_FILE.Replace("|0", "|1"); return(true); } } if (S.Account.Name == "Sim101" || S.Account.Name == "Backtest" || S.Account.Name == "Replay101") { return(true); } // ninjaok = true; return(false); }
public static bool _AuthenticatedLicense(NinjaTrader.NinjaScript.StrategyBase S) { // if (ninjaok) return true; string[] results = LICENSE_FILE.Split(new char[] { '|' }, StringSplitOptions.None); string licence_file = results[0]; if (results[1] == "1") { return(true); } AuthenticatedLicenseProvider provider = new AuthenticatedLicenseProvider(); string basepath = NinjaTrader.Core.Globals.UserDataDir; basepath += "bin\\Custom\\"; AuthenticatedLicense license = null; try { FileInfo f = new FileInfo(basepath + licence_file); if (f != null && f.Length > 0) { license = provider.GetLicense(LICENSE_PARAMETERS, basepath + licence_file, false); } } catch { } if (license == null) { AuthenticatedLicenseProvider.SetParameters(LICENSE_PARAMETERS); AuthenticatedLicenseInstallForm licenseForm = new AuthenticatedLicenseInstallForm(); licenseForm.Text = "Zweistein SpreadTrader"; license = licenseForm.ShowDialog(basepath + licence_file, null); } if (license != null) { provider.ValidateLicense(license); } if (license != null && license.Status == AuthenticatedLicenseStatus.Valid) { if (!UpdateLicenseDetails(license, S)) { System.Windows.Forms.MessageBox.Show("License error:" + license.ProductInfo, licence_file); return(false); } } else { return(false); } // LICENSE_FILE = LICENSE_FILE.Replace("|0", "|1"); ninjaok = true; return(true); }
/// <summary> /// Gets the license checking for blacklisted serial numbers /// </summary> /// <param name="licenseFile">The license file.</param> /// <param name="validateLicense">if set to <c>true</c> [validate license].</param> /// <returns></returns> public override AuthenticatedLicense GetLicense(string licenseFile, bool validateLicense) { AuthenticatedLicense license = base.GetLicense(licenseFile, validateLicense); // Check for blacklisted serial numbers //if (license != null) switch (license.SerialNo) //{ // case 1: // ShowError("{0} License Error", "Please contact " + Solution.Company + " to update your license."); // return null; //} return(license); }
/// <summary> /// Checks the application license. /// </summary> private void CheckLicense() { /// <summary> /// Number of days trial license is valid for /// </summary> const int TRIAL_DAYS = 30; /// <summary> /// License Validation Parameters copied from the License Key Generator /// </summary> const string LICENSE_PARAMETERS = @"<AuthenticatedLicenseParameters> <EncryptedLicenseParameters> <ProductName>LaJust Power Meter</ProductName> <RSAKeyValue> <Modulus>n66mRwUlIE5rGPYLtrCrdDR1yGuOZbyALMEKvO6X2fIqWkTgVtaCKHVnjzxVG1JSOlngHuCtoOypeuL0pNKyxj4/0TGny7mYS5Eas2J0NnDEH2P75FsVzGQ7ESNyns/uXEmtCgzVCtfktW3X7bNQgi3ycb1ZCwJVjVaoQGiuUyM=</Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue> <DesignSignature>X0XJLQFa08k1f6BD9Zte2OyJyW/mk0dro0EYPN9nDM5egOzn1ljCBBGWdPEZmPHz++G7w1uNvTMI/KcIlgUTa/oTJAbd/kOXbDIDliZX1NAPkxtgAdhxiZL/TL3rx9faMdWg78C4jucprOmTCHHAjz1xHtBRoOWbQhV3jT9LhX0=</DesignSignature> <RuntimeSignature>L5hUaIqMKt3xY0jOl8oKcoPnDzLfuZIV5/gHKJt/cqrm6ufnfmynGjNiL24nt2Lqczt+P3HeUSIxnikJJtJ+bRI5d6ljiRuP2vB1yu73gEAU1cF24HKz3v+xMsYmRBdVvuShKCvpLB2JFAjZE9HejFr73p+pCIlsZyZjAn2H930=</RuntimeSignature> <KeyStrength>7</KeyStrength> <ChecksumProductInfo>True</ChecksumProductInfo> <TextEncoding>Base32</TextEncoding> <ShortSerialNo>False</ShortSerialNo> </EncryptedLicenseParameters> <AuthenticationServerURL>http://authsvc.lajust.net/LicenseService/AuthenticationService.asmx</AuthenticationServerURL> <ServerRSAKeyValue> <Modulus>zpt4gdTSKUZTSpbfEL02AJKqNbfeJZ79Xe6Z76dCzX+ntPQL+lusGJ1TUbGpY6SPdLHc++8Dvnl5F+8mT2nBhBNUYtVCohE3GrQin1B/zi42PUvgy/lx4jbW1GfG2blYYqwgp/TOXciQo+aHcuhgpX8w+1azd6zD/gb/yo8asPc=</Modulus> <Exponent>AQAB</Exponent> </ServerRSAKeyValue> </AuthenticatedLicenseParameters>"; // Check for machine names checksums that do not require license files // We don't put the actual machine name in the code for security reasons switch (LicenseUtilities.Checksum(Environment.MachineName.ToUpper())) { case "766": // "LAJUST-MSI" MSI 2200AE All In One Machine case "754": // "LAJUST-PC" Dell Studio One All In One Machine return; } // The license file, the directory will automatically get created if required string licenseFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\LaJust\LaJustPowerMeter.lic"; // Check if there is a valid license for the application MyAuthenticatedLicenseProvider licenseProvider = new MyAuthenticatedLicenseProvider(); _license = licenseProvider.GetLicense(LICENSE_PARAMETERS, licenseFile, true); // Allow forcing of the license dialog using command line option if (Environment.CommandLine.ToUpper().Contains("/LICENSE")) { MyAuthenticatedLicenseInstallForm licenseForm = new MyAuthenticatedLicenseInstallForm(); _license = licenseForm.ShowDialog(Solution.Product, licenseFile, _license); } // If there is no installed license then display the evaluation dialog until // the user installs a license or selects Exit or Continue while (_license == null || _license.Status != AuthenticatedLicenseStatus.Valid) { EvaluationMonitor evaluationMonitor = new IsolatedStorageEvaluationMonitor(LicenseUtilities.Checksum(Solution.Version), true, false); EvaluationDialog evaluationDialog = new EvaluationDialog(evaluationMonitor, Solution.Product) { TrialDays = TRIAL_DAYS, ExtendedTrialDays = TRIAL_DAYS }; EvaluationDialogResult dialogResult = evaluationDialog.ShowDialog(); if (dialogResult == EvaluationDialogResult.Exit) Environment.Exit(0); else if (dialogResult == EvaluationDialogResult.Continue) break; // exit the loop else if (dialogResult == EvaluationDialogResult.InstallLicense) { MyAuthenticatedLicenseInstallForm licenseForm = new MyAuthenticatedLicenseInstallForm(); _license = licenseForm.ShowDialog(Solution.Product, licenseFile, _license); } } }
private void CheckLicense() { const int TRIAL_DAYS = 30; const string LICENSE_PARAMETERS = @"<AuthenticatedLicenseParameters> <EncryptedLicenseParameters> <ProductName>LaJust Power Meter</ProductName> <RSAKeyValue> <Modulus>n66mRwUlIE5rGPYLtrCrdDR1yGuOZbyALMEKvO6X2fIqWkTgVtaCKHVnjzxVG1JSOlngHuCtoOypeuL0pNKyxj4/0TGny7mYS5Eas2J0NnDEH2P75FsVzGQ7ESNyns/uXEmtCgzVCtfktW3X7bNQgi3ycb1ZCwJVjVaoQGiuUyM=</Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue> <DesignSignature>X0XJLQFa08k1f6BD9Zte2OyJyW/mk0dro0EYPN9nDM5egOzn1ljCBBGWdPEZmPHz++G7w1uNvTMI/KcIlgUTa/oTJAbd/kOXbDIDliZX1NAPkxtgAdhxiZL/TL3rx9faMdWg78C4jucprOmTCHHAjz1xHtBRoOWbQhV3jT9LhX0=</DesignSignature> <RuntimeSignature>L5hUaIqMKt3xY0jOl8oKcoPnDzLfuZIV5/gHKJt/cqrm6ufnfmynGjNiL24nt2Lqczt+P3HeUSIxnikJJtJ+bRI5d6ljiRuP2vB1yu73gEAU1cF24HKz3v+xMsYmRBdVvuShKCvpLB2JFAjZE9HejFr73p+pCIlsZyZjAn2H930=</RuntimeSignature> <KeyStrength>7</KeyStrength> <ChecksumProductInfo>True</ChecksumProductInfo> <TextEncoding>Base32</TextEncoding> <ShortSerialNo>False</ShortSerialNo> </EncryptedLicenseParameters> <AuthenticationServerURL>http://authsvc.lajust.net/LicenseService/AuthenticationService.asmx</AuthenticationServerURL> <ServerRSAKeyValue> <Modulus>zpt4gdTSKUZTSpbfEL02AJKqNbfeJZ79Xe6Z76dCzX+ntPQL+lusGJ1TUbGpY6SPdLHc++8Dvnl5F+8mT2nBhBNUYtVCohE3GrQin1B/zi42PUvgy/lx4jbW1GfG2blYYqwgp/TOXciQo+aHcuhgpX8w+1azd6zD/gb/yo8asPc=</Modulus> <Exponent>AQAB</Exponent> </ServerRSAKeyValue> </AuthenticatedLicenseParameters>" ; // Check for machine names checksums that do not require license files // We don't put the actual machine name in the code for security reasons switch (LicenseUtilities.Checksum(Environment.MachineName.ToUpper())) { case "766": // "LAJUST-MSI" MSI 2200AE All In One Machine case "754": // "LAJUST-PC" Dell Studio One All In One Machine return; } // The license file, the directory will automatically get created if required string licenseFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\LaJust\LaJustPowerMeter.lic"; // Check if there is a valid license for the application MyAuthenticatedLicenseProvider licenseProvider = new MyAuthenticatedLicenseProvider(); AuthenticatedLicense license = licenseProvider.GetLicense(LICENSE_PARAMETERS, licenseFile, true); // Allow forcing of the license dialog using command line option if (Environment.CommandLine.ToUpper().Contains("/LICENSE")) { MyAuthenticatedLicenseInstallForm licenseForm = new MyAuthenticatedLicenseInstallForm(); license = licenseForm.ShowDialog(Solution.Product, licenseFile, license); } // If there is no installed license then display the evaluation dialog until // the user installs a license or selects Exit or Continue EvaluationMonitor evaluationMonitor = new IsolatedStorageEvaluationMonitor(LicenseUtilities.Checksum(Solution.Version), false, false); EvaluationDialog evaluationDialog = new EvaluationDialog(evaluationMonitor, Solution.Product) { TrialDays = TRIAL_DAYS, ExtendedTrialDays = TRIAL_DAYS }; while (license == null || license.Status != AuthenticatedLicenseStatus.Valid) { EvaluationDialogResult dialogResult = evaluationDialog.ShowDialog(); if (dialogResult == EvaluationDialogResult.Exit) { Environment.Exit(0); } else if (dialogResult == EvaluationDialogResult.Continue) { break; // exit the loop } else if (dialogResult == EvaluationDialogResult.InstallLicense) { MyAuthenticatedLicenseInstallForm licenseForm = new MyAuthenticatedLicenseInstallForm(); license = licenseForm.ShowDialog(Solution.Product, licenseFile, license); } } // Reset the evaluation monitor if there is a currently valid license, this allows // for another 30 days trial if something should happen to the license if (license != null && license.Status == AuthenticatedLicenseStatus.Valid) { evaluationMonitor.Reset(true); } }