public static string GetLicenseName(LicenseType type) { switch (type) { case LicenseType.MIT: return("MIT"); case LicenseType.SimplifiedBSD: return("Simplified BSD"); case LicenseType.zLibLibPng: return("zlib/libpng"); case LicenseType.ISC: return("ISC"); case LicenseType.WTFPLv2: return("WTFPL Version 2"); case LicenseType.FreePL: return("Free Public License 1.0.0"); case LicenseType.PublicDomain: return("Public Domain"); case LicenseType.CopyLeft: case LicenseType.Commercial: case LicenseType.Other: return("Other"); default: throw new NotSupportedException(); } }
private void SetLicenseType() { // Trial version is ignored at this moment Type = string.IsNullOrWhiteSpace(LicenseModel.expires) ? LicenseType.Personal : LicenseType.Commercial; }
/// <summary> /// Creates the license key. /// </summary> /// <param name="LicenseType">Type of the license (client|server).</param> /// <returns></returns> /// <remarks>Documented by Dev04, 2009-02-11</remarks> public static string CreateLicenseKey(string LicenseType) { bool even; LicenseType lt = (LicenseType)Enum.Parse(typeof(LicenseType), LicenseType, true); even = (lt == Methods.LicenseType.Server); string LicenseKey = ""; string block = ""; int i = 0; int blocks = 4; do { block = CreateKeyBlock(even).ToString(); if (!LicenseKey.Contains(block) && i < blocks) { if (i == 0) { LicenseKey = block; } else { LicenseKey = LicenseKey + "-" + block; } i++; } } while (i < blocks); return(LicenseKey); }
/// <summary> /// Called as we change the application type - determine whether or not a count is valid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbLicenseType_SelectionChanged(object sender, EventArgs e) { LicenseType selectedType = cbLicenseType.SelectedItem.DataValue as LicenseType; lblLicenseCount.Enabled = selectedType.PerComputer; nupLicenseCount.Enabled = selectedType.PerComputer; }
/// <summary> /// Initialize the data displayed on the license tab /// </summary> private void InitializeLicenseTab() { // Load the application license types // Populate the list view with the existing license types LicenseTypesDAO lwDataAccess = new LicenseTypesDAO(); DataTable licenseTypesTable = lwDataAccess.EnumerateLicenseTypes(); // Iterate through the returned items cbLicenseType.BeginUpdate(); foreach (DataRow row in licenseTypesTable.Rows) { LicenseType licenseType = new LicenseType(row); cbLicenseType.Items.Add(licenseType, licenseType.Name); } cbLicenseType.SortStyle = ValueListSortStyle.Ascending; cbLicenseType.EndUpdate(); // OK are we editing an existing definition or trying to create a new one? if (_applicationLicense.LicenseID == 0) { cbLicenseType.SelectedIndex = 0; footerPictureBox.Image = Properties.Resources.application_license_add_corner; this.Text = "Add Application License"; } else { footerPictureBox.Image = Properties.Resources.application_license_edit_corner; this.Text = "Edit Application License"; cbLicenseType.SelectedIndex = cbLicenseType.FindStringExact(_applicationLicense.LicenseTypeName); nupLicenseCount.Value = _applicationLicense.Count; } tbApplication.Text = _applicationName; }
public async Task <IActionResult> CreateLicenceType([FromBody] LicenseType licenseType) { if (licenseType != null) { licenseType.Id = Guid.NewGuid(); try { _context.Add(licenseType); await _context.SaveChangesAsync(); return(Json(new { msg = "Success" })); } catch (Exception ee) { return(Json(new { msg = "Failed" })); } } return(Json(new { msg = "No Data" })); }
/// <summary> /// Returns the license format string, with {0} representing the authors, and {1} the copyright date. /// </summary> public static string GetLicenseFormatString(LicenseType type) { switch (type) { case LicenseType.MIT: return(LicenseManagement.ReadManifestResource("MIT_FS.txt")); case LicenseType.SimplifiedBSD: return(LicenseManagement.ReadManifestResource("SimplifiedBSD_FS.txt")); case LicenseType.zLibLibPng: return(LicenseManagement.ReadManifestResource("Zlib-Libpng_FS.txt")); case LicenseType.ISC: return(LicenseManagement.ReadManifestResource("ISC_FS.txt")); case LicenseType.WTFPLv2: return(LicenseManagement.ReadManifestResource("WTFPLv2_FS.txt")); case LicenseType.FreePL: return(LicenseManagement.ReadManifestResource("FPLv1_FS.txt")); case LicenseType.PublicDomain: return(LicenseManagement.ReadManifestResource("PublicDomain_FS.txt")); case LicenseType.CopyLeft: case LicenseType.Commercial: case LicenseType.Other: default: throw new NotSupportedException(); } }
void OnGUI() { EditorGUILayout.Space(5f); EditorGUILayout.BeginVertical(); //GUILayout.Label("Project Prefix (Recommend no changed)"); //prefix = EditorGUILayout.TextField(prefix); EditorGUILayout.LabelField("Company Name"); companyName = EditorGUILayout.TextField(companyName); EditorGUILayout.Space(5f); EditorGUILayout.LabelField("Project Name"); projectName = EditorGUILayout.TextField(projectName); EditorGUILayout.Space(5f); EditorGUILayout.LabelField("License Type"); licenseType = (LicenseType)EditorGUILayout.EnumPopup(licenseType); EditorGUILayout.Space(5f); if (GUILayout.Button("Generate")) { CreateUpmProject(); } EditorGUILayout.BeginVertical(); }
public static string ResolveLicenseTypeName(LicenseType src) { var ownership = string.Empty; switch (src.Kind) { case LicenseKinds.Fighter: ownership = "zawodnika"; break; case LicenseKinds.Coach: ownership = "trenera"; break; case LicenseKinds.Judge: ownership = "sędziego"; break; case LicenseKinds.Gym: ownership = "klubowa"; break; } var duration = src.OneOff ? "jednorazowa" : $"na {src.Duration} dni"; return($"Licencja {ownership} {duration}"); }
public string getLicenseTypeName(LicenseType licenseType) { switch (licenseType) { case LicenseType.AllRightsReserved: return("All Rights Reserved."); case LicenseType.AttributionCC: return("Creative Commons: Attribution License."); case LicenseType.AttributionNoDerivativesCC: return("Creative Commons: Attribution No Derivatives License."); case LicenseType.AttributionNoncommercialCC: return("Creative Commons: Attribution Non-Commercial License."); case LicenseType.AttributionNoncommercialNoDerivativesCC: return("Creative Commons: Attribution Non-Commercial, No Derivatives License."); case LicenseType.AttributionNoncommercialShareAlikeCC: return("Creative Commons: Attribution Non-Commercial, Share-alike License."); case LicenseType.AttributionShareAlikeCC: return("Creative Commons: Attribution Share-alike License."); case LicenseType.NoKnownCopyrightRestrictions: return("No Known Copyright Resitrctions (Flickr Commons)."); case LicenseType.UnitedStatesGovernmentWork: return("United States Government Work"); } return(string.Empty); }
public License(Guid id, Guid userId, LicenseType type, DateTime expiryDate) { Id = id; UserId = userId; Type = type; ExpiryDate = expiryDate; }
/// <summary> /// Initializes a new instance of the <see cref="LicensePublic" /> class. /// </summary> /// <param name="id">id (required).</param> /// <param name="createdAt">createdAt (required).</param> /// <param name="updatedAt">updatedAt (required).</param> /// <param name="key">The key used to activate this license. Treat this like a password. (required).</param> /// <param name="revoked">revoked (required).</param> /// <param name="suspended">suspended (required).</param> /// <param name="totalActivations">totalActivations (required).</param> /// <param name="totalDeactivations">totalDeactivations (required).</param> /// <param name="validity">validity (required).</param> /// <param name="allowedActivations">allowedActivations (required).</param> /// <param name="serverSyncGracePeriod">serverSyncGracePeriod (required).</param> /// <param name="serverSyncInterval">serverSyncInterval (required).</param> /// <param name="leaseDuration">leaseDuration (required).</param> /// <param name="productId">productId (required).</param> /// <param name="metadata">metadata (required).</param> /// <param name="type">type (required) (default to "LicensePublic").</param> /// <param name="notes">notes.</param> /// <param name="name">The license name used for the package. (required).</param> /// <param name="annotations">An optional dictionary to add annotations to inputs. These annotations will be used by the client side libraries..</param> /// <param name="url">A URL to the license used for the package..</param> public LicensePublic ( string id, DateTime createdAt, DateTime updatedAt, string key, bool revoked, bool suspended, int totalActivations, int totalDeactivations, int validity, int allowedActivations, int serverSyncGracePeriod, int serverSyncInterval, int leaseDuration, string productId, List <LicenseMetadata> metadata, LicenseType type, // Required parameters Dictionary <string, string> annotations = default, string url = default, string notes = default // Optional parameters ) : base(annotations: annotations, url: url) // BaseClass { // to ensure "id" is required (not null) this.Id = id ?? throw new ArgumentNullException("id is a required property for LicensePublic and cannot be null"); this.CreatedAt = createdAt; this.UpdatedAt = updatedAt; // to ensure "key" is required (not null) this.Key = key ?? throw new ArgumentNullException("key is a required property for LicensePublic and cannot be null"); this.Revoked = revoked; this.Suspended = suspended; this.TotalActivations = totalActivations; this.TotalDeactivations = totalDeactivations; this.Validity = validity; this.AllowedActivations = allowedActivations; this.ServerSyncGracePeriod = serverSyncGracePeriod; this.ServerSyncInterval = serverSyncInterval; this.LeaseDuration = leaseDuration; // to ensure "productId" is required (not null) this.ProductId = productId ?? throw new ArgumentNullException("productId is a required property for LicensePublic and cannot be null"); // to ensure "metadata" is required (not null) this.Metadata = metadata ?? throw new ArgumentNullException("metadata is a required property for LicensePublic and cannot be null"); this.LicenseType = type; this.Notes = notes; // Set non-required readonly properties with defaultValue }
/// <summary> /// Creates a new instance of the <see cref="SlickUploadModule" /> class. /// </summary> public SlickUploadModule() { _licenseType = LicenseType.Evaluation; _licenseScope = LicenseScope.WebSite; //_license = (KrystalwareRuntimeLicense)new KrystalwareLicenseProvider().GetLicense(null, typeof(SlickUploadModule), this, false); _license = (KrystalwareRuntimeLicense)KrystalwareLicenseProvider.GetLicense(typeof(SlickUploadModule), "<RSAKeyValue><Modulus>tk384UItx23mrOJcdDqipI05NXJKZAbUL0ewFaloFzpUBFV8AQd1hUSZ9XVgNAPqBLej9rUz4v08vi2rQ/fqJXtWieQSdwa7fe+ZjaS2qYGeBWZVpEDXwT5fG63+c2MlLjX0fKMQ7FU0OkZPo76Sj1O5cIjMlX9nvOQnevW0ABM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"); List<string> licensedUrls = new List<string>(); if (_license != null) { foreach (RuntimeLicensedProduct product in _license.LicensedProducts) { if (product.AssemblyName.EndsWith(".SlickUpload") && Convert.ToInt32(product.Version) >= 6 && DateTime.Now <= product.ExpirationDate) { // changed to fix obfuscation issue // if (product.Type > _licenseType) if (product.Type != _licenseType) _licenseType = product.Type; // changed to fix obfuscation issue // if (product.Scope > _licenseScope) if (product.Scope != _licenseScope) _licenseScope = product.Scope; if (!string.IsNullOrEmpty(product.LicenseUrl)) licensedUrls.Add("." + product.LicenseUrl); } } } _licensedUrls = licensedUrls.ToArray(); }
public EntitlementTokenData(string licensePurchaser, LicenseType licenseType, int seatsPurchased, DateTime etokenExpirationDate) { this.LicenseType = licenseType; this.LicensePurchaser = licensePurchaser; this.SeatsPurchased = seatsPurchased; this.EtokenExpirationDate = etokenExpirationDate; }
public LicenseTypeInfo(LicenseType licenseType) { LicenseType = licenseType; switch (LicenseType) { case LicenseType.Free: TypeName = "Free"; break; case LicenseType.Paid: TypeName = "Paid"; break; case LicenseType.CanBePaid: TypeName = "Can be paid"; break; case LicenseType.FreeForPersonalUse: TypeName = "Free for personal use"; break; default: TypeName = string.Empty; break; } }
public static string LicenseTypeAsString(this LicenseType licenseType) { switch (licenseType) { case LicenseType.Domain: return("Domain"); break; case LicenseType.IP: return("IP"); break; case LicenseType.Unlimited: return("Unlimited"); break; case LicenseType.SourceCode: return("Source Code"); break; default: return("Domain"); break; } }
/// <summary> /// Called to delete the selected license type after confirmation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnDeleteLicenseType_Click(object sender, EventArgs e) { // Sanity check - ensure that we have an item selected if (lvLicenseTypes.SelectedItems.Count == 0) { return; } // Get the database object LicensesDAO lwDataAccess = new LicensesDAO(); // First ensure that we do not have any references to this license type as we // cannot delete it if we have LicenseType deleteLicenseType = lvLicenseTypes.SelectedItems[0].Tag as LicenseType; DataTable references = lwDataAccess.EnumerateLicenses(deleteLicenseType); if (references.Rows.Count != 0) { MessageBox.Show("Cannot delete this license type as Licenses exist which refer to it.", "Delete Failed"); return; } // No references but we should still confirm the delete if (MessageBox.Show("Are you certain that you want to delete this license type?", "Confirm Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) { LicenseTypesDAO licensesTypesDAO = new LicenseTypesDAO(); licensesTypesDAO.LicenseTypeDelete(deleteLicenseType); } this.RefreshView(); }
public static LicenseHelper Instance(LicenseType type) { lock (LockObj) { if (_helperCache == null) { _helperCache = new ConcurrentDictionary <LicenseType, LicenseHelper>(); } LicenseHelper helper; if (_helperCache.ContainsKey(type) && _helperCache.TryGetValue(type, out helper)) { return(helper); } helper = new LicenseHelper(type); if (InitCacheHandler != null) { var list = InitCacheHandler(type); if (list != null && list.Any()) { helper.SetCache(list); } } _helperCache.TryAdd(type, helper); return(helper); } }
internal LicenseHelper(LicenseType type) { _licenseType = type; _codeLength = 8; var codeLength = type.GetType().GetField(type.ToString()).GetCustomAttribute<CodeLengthAttribute>(); if (codeLength != null) _codeLength = codeLength.Length; _cacheCodes = new List<string>(); }
protected License(string licensee, LicenseType type, byte[] verificationData) { if (string.IsNullOrEmpty(licensee)) throw new ArgumentNullException(nameof(licensee)); if (verificationData == null) throw new ArgumentNullException(nameof(verificationData)); Licensee = licensee; Type = type; IsValid = ValidateLicense(verificationData); }
protected License(string licensee, LicenseType type, byte[] verificationData) { if (string.IsNullOrEmpty(licensee)) throw new ArgumentNullException("licensee"); if (verificationData == null) throw new ArgumentNullException("verificationData"); _licensee = licensee; _type = type; _isValid = ValidateLicense(verificationData); }
public void ReturnsRightValue(LicenseType licenseType, string expirationDateString, string currentDateString, bool expectedValue) { var expirationDate = DateTime.ParseExact(expirationDateString, "yyyy-MM-dd", CultureInfo.CurrentCulture); var currentDate = DateTime.ParseExact(currentDateString, "yyyy-MM-dd", CultureInfo.CurrentCulture); var licenseBuilder = License.New().As(licenseType).ExpiresAt(expirationDate); var license = licenseBuilder.CreateAndSignWithPrivateKey(TestEnvironment.LicenseKeys.Private, TestEnvironment.LicenseKeys.PassPhrase); var expirationBehavior = new PreventUsageOfAnyVersionExpirationBehavior(); Assert.AreEqual(expectedValue, expirationBehavior.IsExpired(license, expirationDate, currentDate)); }
public string Generate(string name, Guid id, DateTime expirationDate, IDictionary<string, string> extendedData, LicenseType licenseType, bool extendedDataAsElements = false) { using (var rsa = new RSACryptoServiceProvider()) { rsa.FromXmlString(privateKey); var doc = CreateDocument(id, name, expirationDate, extendedData, licenseType, extendedDataAsElements); var signature = GetXmlDigitalSignature(doc, rsa); doc.FirstChild.AppendChild(doc.ImportNode(signature, true)); var ms = new MemoryStream(); var writer = XmlWriter.Create(ms,new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 }); doc.Save(writer); ms.Position = 0; return new StreamReader(ms).ReadToEnd(); } }
private static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, LicenseType licenseType) { var doc = new XmlDocument(); var license = doc.CreateElement("license"); doc.AppendChild(license); var idAttr = doc.CreateAttribute("id"); license.Attributes.Append(idAttr); idAttr.Value = id.ToString(); var expirDateAttr = doc.CreateAttribute("expiration"); license.Attributes.Append(expirDateAttr); expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture); var licenseAttr = doc.CreateAttribute("type"); license.Attributes.Append(licenseAttr); licenseAttr.Value = licenseType.ToString(); var nameEl = doc.CreateElement("name"); license.AppendChild(nameEl); nameEl.InnerText = name; return doc; }
public static LicenseHelper Instance(LicenseType type) { lock (LockObj) { if (_helperCache == null) _helperCache = new ConcurrentDictionary<LicenseType, LicenseHelper>(); LicenseHelper helper; if (_helperCache.ContainsKey(type) && _helperCache.TryGetValue(type, out helper)) return helper; helper = new LicenseHelper(type); if (InitCacheHandler != null) { var list = InitCacheHandler(type); if (list != null && list.Any()) { helper.SetCache(list); } } _helperCache.TryAdd(type, helper); return helper; } }
internal RuntimeLicensedProduct(string assemblyName, string assemblyVersion) { _assemblyName = assemblyName; _version = assemblyVersion; _type = LicenseType.Evaluation; _scope = LicenseScope.WebSite; _expirationDate = DateTime.MaxValue; }
/// <summary> /// Sets the <see cref="LicenseType"/> of the <see cref="ILicense"/>. /// </summary> /// <param name="type">The <see cref="LicenseType"/> of the <see cref="ILicense"/>.</param> /// <returns>The <see cref="ILicenseBuilder"/>.</returns> public ILicenseBuilder As(LicenseType type) { license.Type = type; return this; }
/// <summary> /// Evaluates the a result of LicenseType to determine what further actions /// have to be taken after a license has been found (such as logging or distributing it) /// </summary> /// <param name="type">The type of the result</param> private void EvaluateLicenseType(LicenseType type) { switch (type) { case LicenseType.None: NotifyLicenseLog(3002); break; case LicenseType.NewSingle: MainForm.MySql.Statement(Resources.SqlStrings.SetLicenseDistributed, new MySqlDataParameter("file", _disc.FileId), new MySqlDataParameter("productid", _disc.ProductId), new MySqlDataParameter("licensekey", _licensekey)); NotifyLicenseLog(3000); break; case LicenseType.NewMulti: NotifyLicenseLog(3000); break; case LicenseType.Redistribution: NotifyLicenseLog(3001); break; case LicenseType.NotAvailable: NotifyLicenseLog(3002); break; default: NotifyLicenseLog(3002); break; } }
public DomainLicense Convert(LicenseType licenseType) { switch (licenseType) { case LicenseType.AllRightsReserved: return DomainLicense.AllRightsReserved; case LicenseType.AttributionCC: case LicenseType.AttributionNoDerivativesCC: case LicenseType.AttributionNoncommercialCC: case LicenseType.AttributionNoncommercialNoDerivativesCC: case LicenseType.AttributionNoncommercialShareAlikeCC: case LicenseType.AttributionShareAlikeCC: return DomainLicense.CreativeCommons; } return DomainLicense.Other; }
public void PhotosLicensesSetLicense(string photoId, LicenseType licenseId) { var dictionary = new Dictionary<string, string>(); dictionary.Add("method", "flickr.photos.licenses.setLicense"); dictionary.Add("photo_id", photoId); dictionary.Add("license_id", licenseId.ToString("d")); GetResponse<NoResponse>(dictionary); }
private string AssertLicenseAttributes(IDictionary<string, string> licenseAttributes, LicenseType licenseType) { string version; var errorMessage = string.Empty; licenseAttributes.TryGetValue("version", out version); // note that a 1.0 license might not have version if (version != "3.0") { if (licenseType != LicenseType.Subscription) { throw new LicenseExpiredException("This is not a license for RavenDB 3.0"); } } string maxRam; if (licenseAttributes.TryGetValue("maxRamUtilization", out maxRam)) { if (string.Equals(maxRam, "unlimited", StringComparison.OrdinalIgnoreCase) == false) { MemoryStatistics.MemoryLimit = (int)(long.Parse(maxRam) / 1024 / 1024); } } string maxParallel; if (licenseAttributes.TryGetValue("maxParallelism", out maxParallel)) { if (string.Equals(maxParallel, "unlimited", StringComparison.OrdinalIgnoreCase) == false) { MemoryStatistics.MaxParallelism = Math.Max(2, (int.Parse(maxParallel) * 2)); } } var clasterInspector = new ClusterInspecter(); string claster; if (licenseAttributes.TryGetValue("allowWindowsClustering", out claster)) { if (bool.Parse(claster) == false) { if (clasterInspector.IsRavenRunningAsClusterGenericService()) throw new LicenseExpiredException("Your license does not allow clustering, but RavenDB is running in clustered mode"); } } else { if (clasterInspector.IsRavenRunningAsClusterGenericService()) throw new LicenseExpiredException("Your license does not allow clustering, but RavenDB is running in clustered mode"); } return errorMessage; }
internal LicenseBase(string licensee, LicenseType type, DateTime expires) { Licensee = licensee; Type = type; Expires = expires; }
/// <summary> /// Check License with given license string /// </summary> /// <param name="licenseData">license string</param> /// <returns>result of checking</returns> public static LicenseResult CheckLicense(String password, LicenseType licenseType, String licenseData) { String licensedMacAddress = null; DateTime? expirationDate=null; String[] lines=Regex.Split(licenseData,"\r\n"); foreach (String line in lines) { if(line.Trim().Equals("")) continue; String decryptedData = Crypt.GetCrypt(CryptAlgo.Rijndael, line, password, CryptType.Decrypt); if (decryptedData != null && decryptedData.Contains("macaddress:")) { decryptedData = decryptedData.Remove(0, "macaddress:".Length); licensedMacAddress = decryptedData; } else if (decryptedData != null && decryptedData.Contains("expirationdate:")) { decryptedData = decryptedData.Remove(0, "expirationdate:".Length); expirationDate = Convert.ToDateTime(decryptedData); } } if ((licenseType & LicenseType.MacAddress) == LicenseType.MacAddress) { if (licensedMacAddress == null) return LicenseResult.CorruptedLicense; if (!checkMacAddress(licensedMacAddress)) return LicenseResult.MacAddressMisMatch; } if ((licenseType & LicenseType.ExpireDate) == LicenseType.ExpireDate) { if (!expirationDate.HasValue) return LicenseResult.CorruptedLicense; if (!checkDate(expirationDate.Value)) return LicenseResult.Expired; } return LicenseResult.Success; }
/// <summary> /// Create License and return as string /// </summary> /// <param name="macAddress">mac address which licensed</param> /// <param name="dateTime">expiration date</param> /// <returns></returns> public static String CreateLicense(String password,LicenseType licenseType,String macAddress=null, DateTime? expirationDate=null) { String licenseData = ""; if ((licenseType & LicenseType.MacAddress) == LicenseType.MacAddress) { licenseData += Crypt.GetCrypt(CryptAlgo.Rijndael, "macaddress:" + macAddress, password, CryptType.Encrypt); licenseData += "\r\n"; } if ((licenseType & LicenseType.ExpireDate) == LicenseType.ExpireDate && expirationDate.HasValue) { licenseData += Crypt.GetCrypt(CryptAlgo.Rijndael, "expirationdate:" + expirationDate.Value.ToString("d"), password, CryptType.Encrypt); licenseData += "\r\n"; } return licenseData; }
public static string GenerateTestToken( LicenseType licenseType, String productId, UserLimit userLimit, ExpirationPeriod expirationDays, String purchaserId) { //Note that the AssetId matches that of the Cheezburgers app on the marketplace. //This is just for TEST purposes so that the storefront URL takes you to a valid app page string hardCodedBaseToken = "<r v=\"0\"><t aid=\"WA103524926\" did=\"{3F47392A-2308-4FC6-BF24-740626612B26}\" ad=\"2012-06-19T21:48:56Z\" te=\"2112-07-15T23:47:42Z\" sd=\"2012-02-01\" test=\"true\"/><d>449JFz+my0wNoCm0/h+Ci9DsF/W0Q8rqEBqjpe44KkY=</d></r>"; string userLimitString = string.Empty; switch (userLimit){ case UserLimit.Ten: userLimitString = "10"; break; case UserLimit.Twenty: userLimitString = "20"; break; case UserLimit.Unlimited: userLimitString = "Unlimited"; break; } int expirationDaysNumber = 0; switch (expirationDays) { case ExpirationPeriod.Month: expirationDaysNumber = 30; break; case ExpirationPeriod.Unlimited: expirationDaysNumber = 9999; break; default: expirationDaysNumber = -1; break; } string tokenXml = hardCodedBaseToken; tokenXml = AddAttributesToToken(tokenXml, "pid", productId); tokenXml = AddAttributesToToken(tokenXml, "et", UppercaseFirst(licenseType.ToString())); tokenXml = AddAttributesToToken(tokenXml, "cid", purchaserId); //Set user limit if (licenseType == LicenseType.Free) { tokenXml = AddAttributesToToken(tokenXml, "ts", "0"); } else { tokenXml = AddAttributesToToken(tokenXml, "ts", userLimitString); } //Set site license == unlimited users if (userLimitString == "Unlimited") { tokenXml = AddAttributesToToken(tokenXml, "sl", "true"); } else { tokenXml = AddAttributesToToken(tokenXml, "sl", "false"); } //Set expiration (only supported for Trials) if (licenseType == LicenseType.Trial) { DateTime expirationDate; if (expirationDaysNumber == -1) { //expired token expirationDate = DateTime.UtcNow.Subtract(TimeSpan.FromDays(10)); } else if (expirationDaysNumber == 9999) { //Unlimited trial expirationDate = DateTime.MaxValue; } else { //today + the selected number of days expirationDate = DateTime.UtcNow.AddDays(expirationDaysNumber); } tokenXml = AddAttributesToToken(tokenXml, "ed", expirationDate.ToString("o")); } return tokenXml; }
/// <summary> /// Sets the license for a photo. /// </summary> /// <param name="photoId">The photo to update the license for.</param> /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param> /// <param name="callback">Callback method to call upon return of the response from Flickr.</param> public async Task<FlickrResult<NoResponse>> PhotosLicensesSetLicenseAsync(string photoId, LicenseType license) { CheckRequiresAuthentication(); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("method", "flickr.photos.licenses.setLicense"); parameters.Add("photo_id", photoId); parameters.Add("license_id", license.ToString("d")); return await GetResponseAsync<NoResponse>(parameters); }
public string MakeLicense(uint appType, string company1, string company2, DateTime runout, LicenseType licenseType) { byte[] keyData = new byte[256]; byte oldByte = 0x00; byte writeByte = 0x00; ulong licenseNumber; // fill with random values Random rnd = new Random(); rnd.NextBytes(keyData); // set application type keyData[4] = (byte)((appType >> 24) & 0xFF); keyData[5] = (byte)((appType >> 16) & 0xFF); keyData[6] = (byte)((appType >> 8) & 0xFF); keyData[7] = (byte)((appType >> 0) & 0xFF); // set license type keyData[8] = (byte)licenseType; // set out running date keyData[9] = (byte)runout.Day; keyData[10] = (byte)runout.Month; keyData[11] = (byte)(runout.Year - 2000); // set license number if(!File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\licenses.lst")){ StreamWriter sw = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\licenses.lst"); sw.Close(); } bool newLicense = false; do{ licenseNumber = (ulong)rnd.Next(1000,10000) * 100000000 + (ulong)rnd.Next(1000,10000) * 10000 + (ulong)rnd.Next(1000,10000); string s = String.Empty; StreamReader sr = new StreamReader(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\licenses.lst"); newLicense = true; do{ s = sr.ReadLine(); if (s != null){ string[] temp = s.Split(' '); if (temp[0] == licenseNumber.ToString()) newLicense = false; } }while(s != null); sr.Close(); }while(newLicense == false); StreamWriter sw2 = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\licenses.lst",true); sw2.WriteLine(licenseNumber.ToString() + " " + company1 + " " + " " + company2 + appType.ToString()); sw2.Close(); keyData[12] = (byte)((licenseNumber >> 32) & 0xFF); keyData[13] = (byte)((licenseNumber >> 24) & 0xFF); keyData[14] = (byte)((licenseNumber >> 16) & 0xFF); keyData[15] = (byte)((licenseNumber >> 8) & 0xFF); keyData[16] = (byte)((licenseNumber >> 0) & 0xFF); //set company Encoding ascii = Encoding.ASCII; keyData[50] = (byte) company1.Length; ascii.GetBytes(company1,0,company1.Length,keyData,51); keyData[160] = (byte) company2.Length; ascii.GetBytes(company2,0,company2.Length,keyData,161); //set ITESYS checksum for(int i=0;i<keyLen;i++){ keyData[250+i] = validationKey[i]; } //encode key and write keyfile FileStream fs=new FileStream(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\license.key",FileMode.OpenOrCreate); string output = string.Empty; for(int i=0; i<256; i++){ writeByte = (byte)(keyData[i] ^ oldByte); keyData[i] = (byte)(writeByte ^ validationKey[i%keyLen]); oldByte = keyData[i]; fs.WriteByte(oldByte); output += keyData[i].ToString() + " "; } fs.Close(); return output; }
public void CheckLicense(uint appType) { try{ if(File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\license.key")){ FileStream fs=new FileStream(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\license.key",FileMode.Open); if (fs.Length != 256){ mValid = ValidResult.NoLicensed; fs.Close(); } else{ byte[] keyData = new byte[256]; byte oldByte = 0x00; byte readByte = 0x00; BinaryReader br = new BinaryReader(fs); for (int i=0;i<256;i++){ readByte = br.ReadByte(); keyData[i] = (byte)((readByte ^ validationKey[i % keyLen]) ^ oldByte); oldByte = readByte; } br.Close(); fs.Close(); mValid = ValidResult.OK; //Itesys check if((keyData[250] != validationKey[0]) || (keyData[251] != validationKey[1]) || (keyData[252] != validationKey[2]) || (keyData[253] != validationKey[3]) || (keyData[254] != validationKey[4]) || (keyData[255] != validationKey[5])) mValid = ValidResult.NoLicensed; //Date check DateTime dt= new DateTime(2000 + keyData[11], keyData[10], keyData[9]); mDate = dt; if (keyData[11] != 0xFF){ if (dt < DateTime.Today) mValid = ValidResult.OutOfDate; } // Application check uint verAppType = 0; verAppType = ((uint)keyData[4]<<24)|((uint)keyData[5]<<16)|((uint)keyData[6]<<8)|((uint)keyData[7]); if (verAppType != appType) mValid = ValidResult.NoLicensed; // set license number mLicenseNumber = ((ulong)keyData[12]<<32)|((ulong)keyData[13]<<24)|((ulong)keyData[14]<<16)|((ulong)keyData[15]<<8)|((ulong)keyData[16]); // set company name Encoding ascii = Encoding.ASCII; mCompany1 = ascii.GetString(keyData,51,keyData[50]); mCompany2 = ascii.GetString(keyData,161,keyData[160]); // set license type switch (keyData[8]){ case (byte)LicenseType.Free: mLicenseType = LicenseType.Free; break; case (byte)LicenseType.Commercial: mLicenseType = LicenseType.Commercial; break; case (byte)LicenseType.NonCommercial: mLicenseType = LicenseType.NonCommercial; break; case (byte)LicenseType.Demo: mLicenseType = LicenseType.Demo; break; default: mValid = ValidResult.NoLicensed; break; } } } else{ mValid = ValidResult.NoLicensed; } } catch(System.Exception ex){ mValid = ValidResult.NoLicensed; MessageBox.Show(ex.Message); } }
private static XmlDocument CreateDocument(Guid id, string name, DateTime expirationDate, IDictionary<string,string> extendedData, LicenseType licenseType, bool extendedDataAsElements) { var doc = new XmlDocument(); var license = doc.CreateElement("license"); doc.AppendChild(license); var idAttr = doc.CreateAttribute("id"); license.Attributes.Append(idAttr); idAttr.Value = id.ToString(); var expirDateAttr = doc.CreateAttribute("expiration"); license.Attributes.Append(expirDateAttr); expirDateAttr.Value = expirationDate.ToString("yyyy-MM-ddTHH:mm:ss.fffffff", CultureInfo.InvariantCulture); var licenseAttr = doc.CreateAttribute("type"); license.Attributes.Append(licenseAttr); licenseAttr.Value = licenseType.ToString(); var nameEl = doc.CreateElement("name"); license.AppendChild(nameEl); nameEl.InnerText = name; foreach (var pair in extendedData) { if (extendedDataAsElements) { var el = doc.CreateElement(pair.Key); el.InnerText = pair.Value; license.AppendChild(el); } else { var attrib = doc.CreateAttribute(pair.Key); attrib.Value = pair.Value; license.Attributes.Append(attrib); } } return doc; }
internal RuntimeLicensedProduct(XmlElement el) { _assemblyName = el.GetAttribute("AssemblyName"); _version = el.GetAttribute("Version"); _licenseUrl = el.GetAttribute("LicenseUrl"); try { _expirationDate = DateTime.Parse(el.GetAttribute("ExpirationDate")); } catch { _expirationDate = DateTime.MaxValue; } try { _type = (LicenseType)Enum.Parse(typeof(LicenseType), el.GetAttribute("Type")); } catch { _type = LicenseType.Evaluation; } try { _scope = (LicenseScope)Enum.Parse(typeof(LicenseScope), el.GetAttribute("Scope")); } catch { _scope = LicenseScope.WebSite; } }
/// <summary> /// Sets the license for a photo. /// </summary> /// <param name="photoId">The photo to update the license for.</param> /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param> public void PhotosLicensesSetLicense(string photoId, LicenseType license) { CheckRequiresAuthentication(); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("method", "flickr.photos.licenses.setLicense"); parameters.Add("photo_id", photoId); parameters.Add("license_id", license.ToString("d")); GetResponseNoCache<NoResponse>(parameters); }
public string getLicenseTypeName(LicenseType licenseType){ switch(licenseType){ case LicenseType.AllRightsReserved: return "All Rights Reserved."; case LicenseType.AttributionCC: return "Creative Commons: Attribution License."; case LicenseType.AttributionNoDerivativesCC: return "Creative Commons: Attribution No Derivatives License."; case LicenseType.AttributionNoncommercialCC: return "Creative Commons: Attribution Non-Commercial License."; case LicenseType.AttributionNoncommercialNoDerivativesCC: return "Creative Commons: Attribution Non-Commercial, No Derivatives License."; case LicenseType.AttributionNoncommercialShareAlikeCC: return "Creative Commons: Attribution Non-Commercial, Share-alike License."; case LicenseType.AttributionShareAlikeCC: return "Creative Commons: Attribution Share-alike License."; case LicenseType.NoKnownCopyrightRestrictions: return "No Known Copyright Resitrctions (Flickr Commons)."; case LicenseType.UnitedStatesGovernmentWork: return "United States Government Work"; } return string.Empty; }
public void LoadLicenseTextFromFile(string filename) { mvarLicenseText = System.IO.File.ReadAllText (filename); mvarLicenseType = LicenseType.Unknown; }
/// <summary> /// Generates a new license /// </summary> /// <param name="name">name of the license holder</param> /// <param name="id">Id of the license holder</param> /// <param name="expirationDate">expiry date</param> /// <param name="licenseType">type of the license</param> /// <returns></returns> public string Generate(string name, Guid id, DateTime expirationDate, LicenseType licenseType) { return Generate(name, id, expirationDate, new Dictionary<string, string>(), licenseType); }
/// <summary> /// Generates a new license /// </summary> /// <param name="name">name of the license holder</param> /// <param name="id">Id of the license holder</param> /// <param name="expirationDate">expiry date</param> /// <param name="licenseType">type of the license</param> /// <param name="attributes">extra information stored as key/valye in the license file</param> /// <returns></returns> public string Generate(string name, Guid id, DateTime expirationDate, IDictionary<string, string> attributes, LicenseType licenseType) { using (var rsa = Encryptor.Current.CreateAsymmetrical()) { rsa.FromXmlString(privateKey); var doc = CreateDocument(id, name, expirationDate, attributes, licenseType); var signature = GetXmlDigitalSignature(doc, rsa.Algorithm); doc.FirstChild.AppendChild(doc.ImportNode(signature, true)); var ms = new MemoryStream(); var writer = XmlWriter.Create(ms, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 }); doc.Save(writer); ms.Position = 0; return new StreamReader(ms).ReadToEnd(); } }
/// <summary> /// Sets the license for a photo. /// </summary> /// <param name="photoId">The photo to update the license for.</param> /// <param name="license">The license to apply, or <see cref="LicenseType.AllRightsReserved"/> (0) to remove the current license. Note : as of this writing the <see cref="LicenseType.NoKnownCopyrightRestrictions"/> license (7) is not a valid argument.</param> /// <param name="callback">Callback method to call upon return of the response from Flickr.</param> public void PhotosLicensesSetLicenseAsync(string photoId, LicenseType license, Action<FlickrResult<NoResponse>> callback) { CheckRequiresAuthentication(); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("method", "flickr.photos.licenses.setLicense"); parameters.Add("photo_id", photoId); parameters.Add("license_id", license.ToString("d")); GetResponseAsync<NoResponse>(parameters, callback); }
/// <summary> 设置编码/激活码生成规则 </summary> /// <param name="type"></param> /// <param name="role">总长度,缓存列表,尝试次数</param> public static void SetGenerateRole(LicenseType type, Func<int, List<string>, int, string> role) { var helper = Instance(type); helper.SetGenerateRole(role); }