/// <summary> /// Runs on a thread pool thread periodically. /// </summary> /// <param name="o"></param> private void Verify(object o) { lock (singleThreadedVerify) { try { //No verification of license store needed; they can be replaced by user ILicenseStore s = c.Plugins.GetOrInstall <ILicenseStore>(new LicenseStore(this.LicenseCacheFilePattern)); //Get all encrypted licenses and // Decrypt them, grouping by normalized domain name var licenses = RemovedExpired(DecryptAll(s.GetLicenses())); //Fix all possible pendingFeatures using existing license data. UpdateFeatureStatus(licenses); if (pendingFeatures.Count > 0) { //Send off https request based on appId and pendingFeatures pairs. //Get List<byte> in return. var newLicenses = DecryptAll(RequestLicenses(pendingFeatures)); if (newLicenses.Count > 0) { //Update cached feature statuses UpdateFeatureStatus(newLicenses); s.SetLicenses(ExportLicenses(Merge(licenses, newLicenses))); } } } finally { lastEndedVerification = DateTime.UtcNow; } } }
public ProductLicenseManager(ITraceManager traceManager, string publicXmlKey, ILicenseStore licenseStore, IMachineIdentifierProvider identifierService, IUserInformationProvider userInfoProvider) { _traceManager = traceManager; _cryptoService = new RSACryptoServiceProvider(); _cryptoService.FromXmlString(publicXmlKey); _licenseStore = licenseStore; _identifierService = identifierService; _userInfoProvider = userInfoProvider; }
public VerifyAction(IHttpClient httpClient, string password, Guid appId, ILicenseStore licenseStore, Dictionary<string, Dictionary<Guid, FeatureState>> featureStates, Dictionary<string, List<Guid>> pendingFeatures) { this.httpClient = httpClient; this.password = password; this.appId = appId; this.licenseStore = licenseStore; this.featureStates = featureStates; this.pendingFeatures = pendingFeatures; }
public VerifyAction(IHttpClient httpClient, string password, Guid appId, ILicenseStore licenseStore, Dictionary <string, Dictionary <Guid, FeatureState> > featureStates, Dictionary <string, List <Guid> > pendingFeatures) { this.httpClient = httpClient; this.password = password; this.appId = appId; this.licenseStore = licenseStore; this.featureStates = featureStates; this.pendingFeatures = pendingFeatures; }
public WhenPendingFeaturesStillExistAfterUpdatingFromLocalCacheTests() { featureOne = Guid.NewGuid(); featureTwo = Guid.NewGuid(); featureThree = Guid.NewGuid(); var httpClient = Substitute.For <IHttpClient>(); string keyPair = Helpers.GenerateKeyPairXml(); var domainLicense = Helpers.GenerateDomainLicense(new List <Guid> { featureOne, featureThree }); httpClient.Send(Arg.Any <HttpRequest>()).Returns(new HttpResponse { Content = Helpers.GenerateValidXmlResponseFromKeyHub(keyPair, new List <DomainLicense> { domainLicense }) }); licenseStore = Substitute.For <ILicenseStore>(); licenseStore.GetLicenses().Returns(new List <byte[]>()); var featureStates = new Dictionary <string, Dictionary <Guid, FeatureState> > { { "domain.com", new Dictionary <Guid, FeatureState> { { featureOne, FeatureState.Pending }, { featureTwo, FeatureState.Pending }, { featureThree, FeatureState.Pending } } } }; var pendingFeatures = new Dictionary <string, List <Guid> > { { "domain.com", new List <Guid> { featureOne, featureTwo, featureThree } } }; verifyAction = new VerifyAction(httpClient, keyPair, Guid.NewGuid(), licenseStore, featureStates, pendingFeatures); verifyAction.Finished += verifyAction_Finished; }
public WhenLocalCacheContainsLicenseInformationTests() { featureOne = Guid.NewGuid(); featureTwo = Guid.NewGuid(); featureThree = Guid.NewGuid(); featureFour = Guid.NewGuid(); featureFive = Guid.NewGuid(); featureSix = Guid.NewGuid(); featureSeven = Guid.NewGuid(); var httpClient = Substitute.For <IHttpClient>(); string keyPair = Helpers.GenerateKeyPairXml(); // featureOne and featureThree belong to an expired license var expiredDomainLicense = new DomainLicense( "expired.com", "John Doe", DateTime.UtcNow.AddYears(-1), DateTime.UtcNow.AddHours(24).AddYears(-1), new List <Guid> { featureOne, featureThree } ); var issued = DateTime.UtcNow; var expires = DateTime.UtcNow.AddHours(24); // featureTwo and featureFive have already been verified var cachedDomainLicense = new DomainLicense( "domain.com", "John Doe", issued, expires, new List <Guid> { featureTwo, featureFive } ); // featureSix and featureSeven are Pending, but only featureSix will be enabled var keyHubDomainLicense = new DomainLicense( "domain.com", "John Doe", issued, expires, new List <Guid> { featureTwo, featureFour, // Rejected in the past is now enabled featureFive, featureSix // Pending new feature } ); httpClient.Send(Arg.Any <HttpRequest>()).Returns(new HttpResponse { Content = Helpers.GenerateValidXmlResponseFromKeyHub(keyPair, new List <DomainLicense> { keyHubDomainLicense }) }); licenseStore = Substitute.For <ILicenseStore>(); licenseStore.GetLicenses().Returns(new List <byte[]> { expiredDomainLicense.SerializeAndEncrypt(keyPair), cachedDomainLicense.SerializeAndEncrypt(keyPair) }); var featureStates = new Dictionary <string, Dictionary <Guid, FeatureState> > { { "expired.com", new Dictionary <Guid, FeatureState> { { featureOne, FeatureState.Enabled }, { featureThree, FeatureState.Enabled } } }, { "domain.com", new Dictionary <Guid, FeatureState> { { featureTwo, FeatureState.Enabled }, { featureFour, FeatureState.Rejected }, { featureFive, FeatureState.Enabled }, { featureSix, FeatureState.Pending }, { featureSeven, FeatureState.Pending } } } }; var pendingFeatures = new Dictionary <string, List <Guid> > { { "domain.com", new List <Guid> { featureSix, featureSeven } } }; verifyAction = new VerifyAction(httpClient, keyPair, Guid.NewGuid(), licenseStore, featureStates, pendingFeatures); verifyAction.Finished += verifyAction_Finished; }
public LicensingManager(ILicenseStore store) { Store = store; }
public LicenseManager(ILicenseStore store) { this.Store = store; }
/// <summary> /// Initializes a new instance of the <see cref="InstalledLicenseContainer"/> class. /// </summary> /// <param name="store">The store.</param> /// <param name="verifier">The verifier.</param> /// <param name="log">The log.</param> public InstalledLicenseContainer(ILicenseStore store, ISignatureVerifier verifier, ILog log) { _store = store; _verifier = verifier; _log = log; }