public static License KeyToLicenseUnsafe(IDecoder decoder, string key) { char c; string text = LicenseConverter.ExtractKeyBody(key, out c); if (text == null) { return(null); } char c2 = c; if (c2 != 'C') { switch (c2) { case 'N': { NewLicenseSerializer newLicenseSerializer = new NewLicenseSerializer(); return(newLicenseSerializer.Deserialize(text, decoder)); } case 'P': { PlainLicenseSerializer plainLicenseSerializer = new PlainLicenseSerializer(); return(plainLicenseSerializer.Deserialize(text)); } } return(null); } OldLicenseSerializer oldLicenseSerializer = new OldLicenseSerializer(); return(oldLicenseSerializer.Deserialize(text, decoder)); }
public static License KeyToLicense(IDecoder decoder, string key) { try { return(LicenseConverter.KeyToLicenseUnsafe(decoder, key)); } catch (Exception ex) { Log.ReportException(ex); } return(null); }
private License LoadLicense() { License license = null; try { string text = this.privateStorer.LoadKey(); if (text != null && text.Length > 0) { license = LicenseConverter.KeyToLicense(this.decoder, text); } else { text = this.publicStorer.LoadKey(); license = LicenseConverter.KeyToLicense(this.decoder, text); } } catch (Exception ex) { Log.ReportException(ex); } if (license != null && LicenseVerificator.IsCorrect(license) && LicenseVerificator.IsPregenerated(license)) { License license2 = this.LoadOldLicense(); if (license2 != null && LicenseVerificator.IsCorrect(license2) && !LicenseVerificator.IsPregenerated(license2)) { if (LicenseVerificator.IsOutdatedForVersion2x(license2)) { license2.UpgradeEvaluation = true; license2.StartTime = license.StartTime; license2.EndTime = license.EndTime; license = license2; } else { license = license2; } } } else { if (license == null) { License license3 = this.LoadOldLicense(); if (license3 != null && LicenseVerificator.IsCorrect(license3)) { license = license3; } } } return(license); }
public bool IsValidKey(string key) { bool result; try { key = KeyStringFormatter.ParseKey(key); License license = LicenseConverter.KeyToLicense(this.decoder, key); result = LicenseVerificator.IsValid(license, DateTime.UtcNow); } catch (LicensingException) { result = false; } return(result); }
public bool RegisterKey(string key) { key = KeyStringFormatter.ParseKey(key); License license = LicenseConverter.KeyToLicense(this.decoder, key); if (!LicenseVerificator.IsValid(license, DateTime.UtcNow)) { return(false); } this.privateStorer.SaveKey(key); this.CacheLicense(license); if (this.RegistrationChanged != null) { this.RegistrationChanged(this); } return(true); }
private License LoadOldLicense() { License result = null; try { string text = this.privateStorer.LoadOldKey(); if (text != null && text.Length > 0) { result = LicenseConverter.KeyToLicense(this.decoder, text); } else { text = this.publicStorer.LoadOldKey(); result = LicenseConverter.KeyToLicense(this.decoder, text); } } catch (Exception ex) { Log.ReportException(ex); } return(result); }
public License ParseKey(string key) { key = KeyStringFormatter.ParseKey(key); return(LicenseConverter.KeyToLicense(this.decoder, key)); }