public static void RegisterLicense(string licenseKeyText) { string cutomerId = null; try { var parts = licenseKeyText.SplitOnFirst('-'); cutomerId = parts[0]; LicenseKey key; using (new AccessToken(LicenseFeature.Text)) { key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText); } var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) { throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); } if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) { throw new LicenseException("This trial license has expired on {0}." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); } __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) { throw; } var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(cutomerId)) { msg += " The id for this license is '{0}'".Fmt(cutomerId); } throw new LicenseException(msg).Trace(); } }
private static void ValidateLicenseKey(LicenseKey key) { var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) { throw new LicenseException($"This license has expired on {key.Expiry:d} and is not valid for use with this release." + ContactDetails).Trace(); } if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) { throw new LicenseException($"This trial license has expired on {key.Expiry:d}." + ContactDetails).Trace(); } __activatedLicense = key; }
public static LicenseFeature GetLicensedFeatures(this LicenseKey key) { switch (key.Type) { case LicenseType.Free: return(LicenseFeature.Free); case LicenseType.Indie: return(LicenseFeature.Indie); case LicenseType.Business: return(LicenseFeature.Business); case LicenseType.Enterprise: return(LicenseFeature.Enterprise); } throw new ArgumentException("Unknown License Type: " + key.Type); }
private static void ValidateLicenseKey(LicenseKey key) { var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) { throw new LicenseException($"This license has expired on {key.Expiry:d} and is not valid for use with this release." + ContactDetails).Trace(); } if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) { throw new LicenseException($"This trial license has expired on {key.Expiry:d}." + ContactDetails).Trace(); } __activatedLicense = new __ActivatedLicense(key); LicenseWarningMessage = GetLicenseWarningMessage(); if (LicenseWarningMessage != null) { Console.WriteLine(LicenseWarningMessage); } }
public static LicenseFeature GetLicensedFeatures(this LicenseKey key) { switch (key.Type) { case LicenseType.Free: return(LicenseFeature.Free); case LicenseType.Indie: case LicenseType.Business: case LicenseType.Enterprise: case LicenseType.Trial: case LicenseType.Site: return(LicenseFeature.All); case LicenseType.TextIndie: case LicenseType.TextBusiness: case LicenseType.TextSite: return(LicenseFeature.Text); case LicenseType.OrmLiteIndie: case LicenseType.OrmLiteBusiness: case LicenseType.OrmLiteSite: return(LicenseFeature.OrmLiteSku); case LicenseType.AwsIndie: case LicenseType.AwsBusiness: return(LicenseFeature.AwsSku); case LicenseType.RedisIndie: case LicenseType.RedisBusiness: case LicenseType.RedisSite: return(LicenseFeature.RedisSku); default: throw new LicenseException("Unknown License Type: " + key.Type).Trace(); } }
public static void RemoveLicense() { __activatedLicense = null; }
public static void RegisterLicense(string licenseKeyText) { string cutomerId = null; try { var parts = licenseKeyText.SplitOnFirst('-'); cutomerId = parts[0]; LicenseKey key; using (new AccessToken(LicenseFeature.Text)) { key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText); } var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToString("d")) + ContactDetails); __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) throw; var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(cutomerId)) msg += " The id for this license is '{0}'".Fmt(cutomerId); throw new LicenseException(msg); } }
public static string GetHashKeyToSign(this LicenseKey key) { return($"{key.Ref}:{key.Name}:{key.Expiry:yyyy-MM-dd}:{key.Type}"); }
internal __ActivatedLicense(LicenseKey licenseKey) => LicenseKey = licenseKey;
public static string GetHashKeyToSign(this LicenseKey key) { return("{0}:{1}:{2}:{3}".Fmt(key.Ref, key.Name, key.Expiry.ToString("yyyy-MM-dd"), key.Type)); }
public static void RegisterLicense(string licenseKeyText) { JsConfig.InitStatics(); string subId = null; #if !(PCL || NETSTANDARD1_1) var hold = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; #endif try { var parts = licenseKeyText.SplitOnFirst('-'); subId = parts[0]; int subIdInt; if (int.TryParse(subId, out subIdInt) && revokedSubs.Contains(subIdInt)) throw new LicenseException("This subscription has been revoked. " + ContactDetails); var key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText); var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) throw new LicenseException("This trial license has expired on {0}." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) throw; var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(subId)) msg += " The id for this license is '{0}'".Fmt(subId); throw new LicenseException(msg).Trace(); } finally { #if !(PCL || NETSTANDARD1_1) Thread.CurrentThread.CurrentCulture = hold; #endif } }
public static void RegisterLicense(string licenseKeyText) { string cutomerId = null; #if !PCL var hold = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; #endif try { var parts = licenseKeyText.SplitOnFirst('-'); cutomerId = parts[0]; LicenseKey key; using (new AccessToken(LicenseFeature.Text)) { key = PclExport.Instance.VerifyLicenseKeyText(licenseKeyText); } var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); if (key.Type == LicenseType.Trial && DateTime.UtcNow > key.Expiry) throw new LicenseException("This trial license has expired on {0}." .Fmt(key.Expiry.ToString("d")) + ContactDetails).Trace(); __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) throw; var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(cutomerId)) msg += " The id for this license is '{0}'".Fmt(cutomerId); throw new LicenseException(msg).Trace(); } finally { #if !PCL Thread.CurrentThread.CurrentCulture = hold; #endif } }
public static string GetHashKeyToSign(this LicenseKey key) { return("{0}:{1}:{2}".Fmt(key.Ref, key.Name, key.Type)); }
public static bool VerifyLicenseKeyText(this string licenseKeyText, out LicenseKey key) { var publicRsaProvider = new RSACryptoServiceProvider(); publicRsaProvider.FromXmlString(LicensePublicKey); var publicKeyParams = publicRsaProvider.ExportParameters(false); key = licenseKeyText.ToLicenseKey(); var originalData = key.GetHashKeyToSign().ToUtf8Bytes(); var signedData = Convert.FromBase64String(key.Hash); return VerifySignedHash(originalData, signedData, publicKeyParams); }
internal static void RegisterLicense(string licenseKeyText) { string cutomerId = null; try { var parts = licenseKeyText.SplitOnFirst('-'); cutomerId = parts[0]; LicenseKey key; using (new AccessToken(LicenseFeature.Text)) { #if !(SILVERLIGHT || WP) if (!licenseKeyText.VerifyLicenseKeyText(out key)) throw new ArgumentException("licenseKeyText"); #else key = licenseKeyText.ToLicenseKey(); #endif } var releaseDate = Env.GetReleaseDate(); if (releaseDate > key.Expiry) throw new LicenseException("This license has expired on {0} and is not valid for use with this release." .Fmt(key.Expiry.ToShortDateString()) + ContactDetails); __activatedLicense = key; } catch (Exception ex) { if (ex is LicenseException) throw; var msg = "This license is invalid." + ContactDetails; if (!string.IsNullOrEmpty(cutomerId)) msg += " The id for this license is '{0}'".Fmt(cutomerId); throw new LicenseException(msg); } }