public ActionResult License() { NippsLicense nippsLicense = new NippsLicense { Type = "", ValidFor = "", IssuedBy = "", LicensedTo = "", Version = "", Services = null }; try { string svcUrl = CommonHelper.LicenseManagerServiceUrl + "LicenseService/Get"; NippsLicenseResponse licenseResponse = RestHelper.RestGet <NippsLicenseResponse>(svcUrl); if (licenseResponse.Result == Result.OK) { nippsLicense = licenseResponse.License; } } catch (Exception ex) { Logger.Error(ex.ToString()); } return(View(nippsLicense)); }
public static void Validate() { string sha1a = ""; string sha1b = ""; string license = ""; string binPath = HttpContext.Current.Server.MapPath("~\\bin"); if (!File.Exists(LicenseBasePath + "pri_client.pem")) { if (File.Exists(binPath + "\\pri_client.pem")) { File.Copy(binPath + "\\pri_client.pem", LicenseBasePath + "pri_client.pem"); } } if (!File.Exists(LicenseBasePath + "pub_netas.pem")) { if (File.Exists(binPath + "\\pub_netas.pem")) { File.Copy(binPath + "\\pub_netas.pem", LicenseBasePath + "pub_netas.pem"); } } using (StreamReader sr = File.OpenText(LicenseFileName)) { string line; bool isSha1a = false; bool isSha1b = false; license = sr.ReadLine(); _License = Newtonsoft.Json.JsonConvert.DeserializeObject <NippsLicense>(license); while (!sr.EndOfStream) { line = sr.ReadLine(); if (line.Equals("---BEGIN SHA1 A---")) { isSha1a = true; isSha1b = false; continue; } else if (line.Equals("---BEGIN SHA1 B---")) { isSha1b = true; isSha1a = false; continue; } else if (line.Equals("---END SHA1 A---") || line.Equals("---END SHA1 B---")) { isSha1a = false; isSha1b = false; continue; } if (isSha1a) { sha1a += line; } else if (isSha1b) { sha1b += line; } } } int rc = LicenseSha1(LicenseBasePath, license, sha1a, sha1b); if (rc != 0) { File.Delete(LicenseFileName); _License = null; NLog.LogManager.GetCurrentClassLogger().Error("License is violated by SHA1."); throw new AccessViolationException(LicenseFileName); } LicenseDll(); }