private bool HasFeature(string featureId) { ILicense license = ServerState.Instance.License; if (!IsLicenseValid()) { return(false); } if (!license.IsFeatureValid(featureId)) { return(false); } IFeature feature = license.GetFeature(featureId); if (feature != null) { if (feature.Type == LicenseFeatureType.Off) { return(false); } } if (license.IsFeatureEvaluation(featureId) && license.IsFeatureExpired(featureId)) { return(false); } return(true); }
public static void CheckLicense(ILicense license, ILicense loaded) { Assert.AreEqual(license.LicenseAccessLevel, loaded.LicenseAccessLevel); Assert.AreEqual(license.ApplicationName, loaded.ApplicationName); Assert.AreEqual(license.ExpiryDate, loaded.ExpiryDate); CheckModule(license.RootModule, loaded.RootModule); }
public UsageRights(string owner, string attribution, ILicense license, Uri projectLink) { Owner = owner; Attribution = attribution; GoverningLicense = license; ProjectLink = projectLink; }
public static UIElement ToElement(this ILicense license) { if (license == null) { return(new Label() { Content = ExtensionHelper.ValueUnset }); } Expander expander = new Expander() { Header = license.Name.ToDisplayValue(), Template = Application.Current.Resources["NiceExpanderTemplate"] as ControlTemplate, }; PropertyInfo[] properties = typeof(ILicense).GetProperties(BindingFlags.Instance | BindingFlags.Public); if (properties == null || !properties.Any()) { return(new UIElement()); } Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); Int32 rows = properties.Length; for (Int32 row = 0; row < rows; row++) { grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); PropertyInfo property = properties[row]; Label label = license.ToLabel(property); grid.Children.Add(label); Grid.SetRow(label, row); Grid.SetColumn(label, 0); UIElement value = license.ToValue(property); grid.Children.Add(value); Grid.SetRow(value, row); Grid.SetColumn(value, 1); } expander.Content = grid; return(expander); }
private bool IsFeatureValid(string featureId) { bool ret = true; ILicense license = ServerState.Instance.License; if (license == null) { return(false); } IFeature feature = license.GetFeature(featureId); if (feature == null) { ret = false; } else if (feature.Type == LicenseFeatureType.Off) { ret = false; } else if (feature.Type == LicenseFeatureType.Eval && feature.IsExpired) { ret = false; } else { ret = true; } return(ret); }
private void SetClientConfigLicense() { if (__ClientConfigPresenter != null) { if (ServerState.Instance.License != null) { ILicense license = ServerState.Instance.License; IFeature feature = license.GetFeature(ServerFeatures.MaxConfigurableClients); if (feature != null && feature.Type == LicenseFeatureType.LimitedNumber) { __ClientConfigPresenter.MaxClients = (feature.Counter <= 0) ? int.MaxValue : feature.Counter; } else if (feature != null && feature.Type == LicenseFeatureType.Eval && !feature.IsExpired) { __ClientConfigPresenter.MaxClients = 10; } else if (feature == null) { __ClientConfigPresenter.MaxClients = null; } else { __ClientConfigPresenter.MaxClients = 0; } } else { // // If there is not setting for max clients then there is no limitation // __ClientConfigPresenter.MaxClients = null; } } }
public void can_create_new_instance_using_registry() { clock = StubClock.ForDateTime(2012, 10, 11, 11, 59, 59, 999); SetupRegistryToReturnDate(new DateTime(2012, 10, 11, 12, 0, 0)); license = new BetterLicense(clock, registrySettings.Object, fileSystem.Object); license.Should().BeOfType<BetterLicense>(); }
private void ConfigureMax() { if (ServerState.Instance.License != null) { ILicense license = ServerState.Instance.License; IFeature feature = license.GetFeature(ServerFeatures.MaxConcurrentConnections); if (feature != null && feature.Type == LicenseFeatureType.LimitedNumber) { View.MaxClientsMaxValue = feature.Counter != null && feature.Counter.Value > 0 ? feature.Counter.Value : int.MaxValue; } else if (feature != null && feature.Type == LicenseFeatureType.Eval && !feature.IsExpired) { View.MaxClientsMaxValue = 10; } else { View.MaxClientsMaxValue = 5; } } else { View.MaxClientsMaxValue = 100; } }
public static void InitialLicense(string config, string lic) { dynamic ini; ini = new DynamicIniConfig(config); QcNetLicense newnetlicense; QcLocalLicense newlocallicense; QcTimeLicense newtimelicense; switch (((string)ini.License.IsLocal).ToUpper()) { case "TRUE": LocalModel = true; newlocallicense = new QcLocalLicense(); newlocallicense.SetLicense(QcLicense.ReadLicFile(lic)); License = newlocallicense; break; case "FALSE": LocalModel = false; newnetlicense = new QcNetLicense(); newnetlicense.SetServer(ini.MsgServer.Ip, Convert.ToUInt16(ini.MsgServer.Port)); License = newnetlicense; break; case "ONLY_IGCES_SUPERTIME": //HAHA 超级模式 newtimelicense = new QcTimeLicense(DateTime.Parse("9999-01-01")); License = newtimelicense; break; case "TRIAL": //试用模式 QcLicense timelic = new QcLicense(QcLicense.ReadLicFile(lic), false); XDocument doc = timelic.LicDoc; LocalModel = false; if (doc.Root.Element("单位名称").Value == "TRIAL") { if (DateTime.Now.Subtract(DateTime.Parse(doc.Root.Element("EndDate").Value)).Days <= 0) { newlocallicense = new QcLocalLicense(); newlocallicense.SetLicense(QcLicense.ReadLicFile(lic), false); License = newlocallicense; } else { QcLog.LogString("初始授权失败,试用模式下,试用时间已经超出授权时间,请改用其他模式或重新申请授权"); } } else { QcLog.LogString("初始授权失败,试用模式下,lic文件不是试用授权文件,请改用其他模式或重新申请授权"); } break; } if (License == null) { License = new QcNullLicense(); QcLog.LogString("初始授权失败,请检查授权模式是否正确"); } }
/// <summary> /// Checks for a valid license on Linux machines /// </summary> private bool CheckLicenseLinux(ILicense license) { var pass = false; // Check CPU serial number if (Settings.CheckCpuSerial) { } // Check Hard Drive serial number if (Settings.CheckDiskSerial) { } // Check Ethernet MAC address if (Settings.CheckEthernetMac) { } // Check Wireless MAC address if (Settings.CheckWirelessMac) { } // Check for running in virtual machine if (Settings.CheckVirtualMachine) { } return(pass); }
public static void StoreLicenseInfo(ILicense license) { var domain = AppDomain.CurrentDomain; if (!string.IsNullOrEmpty(license.Type)) { domain.SetData("LicenseType", license.Type); } if (license.IssueDate.HasValue) { domain.SetData("LicenseIssueDate", license.IssueDate.Value); } if (license.ExpireDate.HasValue) { domain.SetData("LicenseExpireDate", license.ExpireDate.Value); } // TODO: Store additional license information like fields, features, restrictions // TODO: Use the following code inside your application to // process the information stored inside the license file // var domain = AppDomain.CurrentDomain; // string licenseType = (string)domain.GetData("LicenseType") ?? string.Empty; // DateTime? issueDate = (DateTime?)domain.GetData("LicenseIssueDate"); // DateTime? expireDate = (DateTime?)domain.GetData("LicenseExpireDate"); }
public void LicenseFiles(ILicense license) { LicenseContainer(license); foreach (string csharpFilename in GetFilesToBeLicensed()) { LicenseFile(license, csharpFilename); } }
private async Task DisableOrganizationAsync(Organization org, ILicense license) { _logger.LogInformation("Organization {0}({1}) has an invalid license and is being disabled.", org.Id, org.Name); org.Enabled = false; org.ExpirationDate = license?.Expires ?? DateTime.UtcNow; org.RevisionDate = DateTime.UtcNow; await _organizationRepository.ReplaceAsync(org); }
public byte[] SignLicense(ILicense license) { if (_globalSettings.SelfHosted || !_certificate.HasPrivateKey) { throw new InvalidOperationException("Cannot sign licenses."); } return(license.Sign(_certificate)); }
void LicenseFile(ILicense license, string licenseFilename) { RaiseFileLicensingStartedEvent(licenseFilename); IFile file = new CSharpfile(licenseFilename); license.License(file); RaiseFileLicensedEvent(licenseFilename); }
public override void Load(string serviceDirectory, string displayName) { bool isLicensed = false; ILicense license = null; if (ServiceLocator.IsRegistered <ILicense>()) { license = ServiceLocator.Retrieve <ILicense>(); } InitializeLicense(); isLicensed = IsLicenseValid(); try { AdvancedSettings settings = AdvancedSettings.Open(serviceDirectory); ServiceDirectory = serviceDirectory; DisplayName = displayName; DicomServer server = ServiceLocator.Retrieve <DicomServer>(); ServiceName = server.Name; GetService(serviceDirectory, displayName); if (!ServiceLocator.IsRegistered <SettingsChangedNotifier>()) { SettingsChangedNotifier configChangedNotifier = new SettingsChangedNotifier(settings); configChangedNotifier.SettingsChanged += new EventHandler(configChangedNotifier_SettingsChanged); configChangedNotifier.Enabled = true; ServiceLocator.Register <SettingsChangedNotifier>(configChangedNotifier); } else { ServiceLocator.Retrieve <SettingsChangedNotifier>().SettingsChanged += new EventHandler(configChangedNotifier_SettingsChanged); } if (isLicensed) { ConfigureRuleProcessor(settings); } } catch (Exception e) { if (_Options == null) { _Options = new RuleProcessorOptions(); } Logger.Global.Error(Source, e.Message); } ConfigureScriptProcessor(serviceDirectory, isLicensed); if (license != null) { license.LicenseChanged += new EventHandler(license_LicenseChanged); } }
private async Task DisableOrganizationAsync(Organization org, ILicense license, string reason) { _logger.LogInformation(Constants.BypassFiltersEventId, null, "Organization {0} ({1}) has an invalid license and is being disabled. Reason: {2}", org.Id, org.Name, reason); org.Enabled = false; org.ExpirationDate = license?.Expires ?? DateTime.UtcNow; org.RevisionDate = DateTime.UtcNow; await _organizationRepository.ReplaceAsync(org); }
private async Task DisablePremiumAsync(User user, ILicense license, string reason) { _logger.LogInformation(Constants.BypassFiltersEventId, null, "User {0}({1}) has an invalid license and premium is being disabled. Reason: {2}", user.Id, user.Email, reason); user.Premium = false; user.PremiumExpirationDate = license?.Expires ?? DateTime.UtcNow; user.RevisionDate = DateTime.UtcNow; await _userRepository.ReplaceAsync(user); }
public void CheckVehicleLicenses(Client player, NetHandle vehicle, int seat) { if (seat == -1) { if (!Licenses.CanUseVehicle(player, vehicle, true)) { ILicense lic = (ILicense)player.getData("MissedLicense"); API.sendNotificationToPlayer(player, "Du hast nicht die nötige Lizenz (\"" + lic.GetHumanReadableName() + "\") für dieses Fahrzeug!"); API.warpPlayerOutOfVehicle(player); } } }
public static void ValidateLicense() { try { ILicense license = BabelLicenseManager.Validate(typeof(LicenseFileCheckWinForm), new LicenseFileCheckWinForm()); StoreLicenseInfo(license); } catch (Exception ex) { OnLicenseValidationFailed(ex.Message); } }
public void SetLicense(string licenseFile, ILicense license) { _License = license; if (_License != null) { Update(licenseFile); } else { Clear(); } }
public void SaveLicense(ILicense license, string path) { if (File.Exists(path)) { File.Delete(path); } string json = GetJson(license); using (var file = new StreamWriter(path)) { file.Write(json); } }
public ILicense Clone(ILicense license) { var ret = new SimpleLicense(); ret.LicenseAccessLevel = license.LicenseAccessLevel; ret.ApplicationName = license.ApplicationName; ret.ExpiryDate = license.ExpiryDate; ret.LicenseeName = license.LicenseeName; ret.RootModule = CloneModule(license.RootModule); return ret; }
private void UpdateUI() { bool exists = ServerState.Instance.ServerService != null; bool isAdmin = UserManager.User.IsAdmin(); ILicense license = ServerState.Instance.License; bool isLicenseValid = IsLicenseValid(); bool canChangeServerSettings = UserManager.User.IsAuthorized(UserPermissions.CanChangeServerSettings); serverSettingsItem.Enabled = (isAdmin || canChangeServerSettings); // always show this one storeSettings.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings)); administration.Enabled = isLicenseValid && (isAdmin); patientUpdater.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings)); autoCopy.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings)); LoggingConfig.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings)); forwarding.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings) && HasFeature(ServerFeatures.Forwarding)); gateway.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings) && HasFeature(ServerFeatures.Gateway)); #if (LEADTOOLS_V19_OR_LATER_MEDICAL_EXTERNAL_STORE) || (LEADTOOLS_V19_OR_LATER) externalStore.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings) && HasFeature(ServerFeatures.ExternalStore)); #endif securityOptions.Enabled = isLicenseValid && (exists && (isAdmin || canChangeServerSettings)); #if (LEADTOOLS_V19_OR_LATER_MEDICAL_VERIFY_ADDINS) || (LEADTOOLS_V19_OR_LATER) // If the addins are not healthy (i.e. cannot access database), then disable the corresponding feature patientUpdater.Enabled = patientUpdater.Enabled && Shell.ServerAddins.PatientUpdaterValid; autoCopy.Enabled = autoCopy.Enabled && Shell.ServerAddins.AutoCopyValid; forwarding.Enabled = forwarding.Enabled && Shell.ServerAddins.ForwarderValid; gateway.Enabled = gateway.Enabled && Shell.ServerAddins.GatewayValid; externalStore.Enabled = externalStore.Enabled && Shell.ServerAddins.ExternalStoreValid; // View.AddFeatureControl(FeatureNames.AutoCopy, autoCopyView, null ) ; #endif // #if (LEADTOOLS_V19_OR_LATER_MEDICAL_VERIFY_ADDINS) || (LEADTOOLS_V19_OR_LATER) securityOptions.Enabled = securityOptions.Enabled && Shell.ServerAddins.SecurityValid; __View.EnableItem(serverSettingsItem.Enabled, serverSettingsItem); __View.EnableItem(storeSettings.Enabled, storeSettings); __View.EnableItem(administration.Enabled, administration); __View.EnableItem(serverSettingsItem.Enabled, serverSettingsItem); __View.EnableItem(patientUpdater.Enabled, patientUpdater); __View.EnableItem(autoCopy.Enabled, autoCopy); __View.EnableItem(LoggingConfig.Enabled, LoggingConfig); __View.EnableItem(forwarding.Enabled, forwarding); __View.EnableItem(gateway.Enabled, gateway); #if (LEADTOOLS_V19_OR_LATER_MEDICAL_EXTERNAL_STORE) || (LEADTOOLS_V19_OR_LATER) __View.EnableItem(externalStore.Enabled, externalStore); #endif __View.EnableItem(securityOptions.Enabled, securityOptions); }
public void Load(string ServerDirectory, string DisplayName) { ILicense license = null; if (ServiceLocator.IsRegistered <ILicense>()) { license = ServiceLocator.Retrieve <ILicense>(); } InitializeLicense(); DB.RegisterDataAccessAgents(ServerDirectory, DisplayName); InitializeOptions(ServerDirectory, DisplayName); }
private LicenseModel BuildModel(ILicense license) { var licenseModel = new LicenseModel { Id = license.Id, Description = license.Description, }; TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); int secondsSinceEpoch = (int)t.TotalSeconds; licenseModel.TimeStamp = secondsSinceEpoch; return(licenseModel); }
private bool IsLicenseValid() { ILicense license = ServerState.Instance.License; if (license == null || license.Features.Count == 0) { return(false); } if (license.IsFeatureExpired(ServerFeatures.GeneralFunctionality)) { return(false); } return(true); }
public static UIElement ToValue(this ILicense license, PropertyInfo property) { if (license == null) { throw new ArgumentNullException(nameof(license)); } if (property == null) { throw new ArgumentNullException(nameof(property)); } Object value = property.GetValue(license); return(value.ToValueElement(ExtensionHelper.ValuePadding)); }
void Instance_LicenseChanged(object sender, EventArgs e) { try { _License = ServerState.Instance.License; if (_License != null) { _FeatureStudyCount = _License.GetFeature(ServerFeatures.MaxStudiesStored); _FeatureSeriesCount = _License.GetFeature(ServerFeatures.MaxSeriesStored); } } catch {} finally { UpdateContainerPagesEnabled(); } }
public SummaryChartPresenter( ISummaryChartView view, IChartEditorAndDisplayPresenter chartEditorAndDisplayPresenter, IIndividualPKAnalysisPresenter pkAnalysisPresenter, IDataColumnToPathElementsMapper dataColumnToPathElementsMapper, IQuantityPathToQuantityDisplayPathMapper quantityDisplayPathMapper, IChartTask chartTask, IObservedDataTask observedDataTask, ILazyLoadTask lazyLoadTask, ILicense license, IChartEditorLayoutTask chartEditorLayoutTask, IChartTemplatingTask chartTemplatingTask) : base(view, chartEditorAndDisplayPresenter, pkAnalysisPresenter, dataColumnToPathElementsMapper, quantityDisplayPathMapper, chartTask, observedDataTask, license, chartEditorLayoutTask, chartTemplatingTask) { _lazyLoadTask = lazyLoadTask; _chartTemplatingTask = chartTemplatingTask; }
/// <inheritdoc/> public bool CheckLicense(ILicense license) { // Reset FailureMessage = null; // Check for inactive if ((Settings.LicenseType & LicenseTypes.UserIdentity) == 0) { return(true); } // Run check FailureMessage = Resources.FailedUserIdentity; // Return result return(false); }
public IActionResult Post(LicenseModel model) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } ILicense license = this.LicenseManager.Default(); license.Description = model.Description; this.LicenseManager.Create(license); var created = this.BuildModel(license); // nope return(this.CreatedAtAction("Get", created)); }
/// <summary> /// This is the constructor for the About Viewmodel /// </summary> /// <param name="starter">An object implementing the IProcessStarter interface</param> /// <param name="manager">A keymanager object</param> /// <param name="license">An object implementing the ILicense interface</param> public AboutViewModel(IProcessStarter starter, IKeyManager manager, ILicense license) { _mailtoClickCommand = new DelegateCommand(mailto); _setApiKeyCommand = new DelegateCommand(setApiKey); _changeThemeCommand = new DelegateCommand(ChangeTheme); _viewLicenseCommand = new DelegateCommand(ViewLicense); AboutText = "This Software is Licensed under the GNU GPL - v3.\nThis Software was designed and written by Johannes Schiemer for his school diploma " + "project. The software is designed to be used in conjunction with the FDR built and engineered by Klaus Obermüller and Alexander Stoiber.\nWe are NOT responsible for any " + "damages created through misuse, user errors or unexpected behaviour. Icons by Smashicons from Flaticons.com" + "\nCredits: See the Licenses"; InfoText = "To load a new Track please select the 'Load' menu option. After loading you should be able to select " + "any of the other menu options where you can enjoy the full functionality of this program"; _handler = starter; _manager = manager; _license = license; }
public void Load(string ServerDirectory, string DisplayName) { ILicense license = null; if (ServiceLocator.IsRegistered <ILicense>()) { license = ServiceLocator.Retrieve <ILicense>(); } InitializeLicense(); InitializeOptions(ServerDirectory, DisplayName); if (ServiceLocator.IsRegistered <DicomServer>()) { _dicomServer = ServiceLocator.Retrieve <DicomServer>(); } }
/// <summary> /// Verifies the <paramref name="license"/> contains a product key that is legitimate and valid for the specified /// <paramref name="currentAppVersion"/>. The returned object is the same instance in memory as the <paramref name="license"/> parameter. /// </summary> /// <param name="license">The license containing the product key to validate. The only property that must be assigned /// prior to calling this method is <see cref="ILicense.ProductKey"/>. This function will assign the remaining properties.</param> /// <param name="currentAppVersion">The version of the currently running application.</param> /// <param name="performWebServiceValidation">if set to <c>true</c> validate the license using a web service invocation /// against a server run by Tech Info Systems. This parameter is ignored in stand-alone versions of GSP, since it /// never invokes a web service.</param> /// <returns> /// Returns an <see cref="ILicense"/> instance containing license information for the product key. /// </returns> public static ILicense ValidateLicense(ILicense license, string currentAppVersion, bool performWebServiceValidation) { license.Email = String.Empty; license.KeyInvalidReason = String.Empty; license.Version = currentAppVersion; license.LicenseType = LicenseLevel.NotSet; license.IsValid = (license.ProductKey.Equals(GlobalConstants.ProductKey) || license.ProductKey.Equals(GlobalConstants.ProductKeyNoPageFooter)); if (!license.IsValid) { license.KeyInvalidReason = "Product key is not valid"; } license.InstallDate = GetFirstGalleryInstallationDate(); license.IsInTrialPeriod = (license.InstallDate.AddDays(GlobalConstants.TrialNumberOfDays) >= DateTime.Today); return(license); }
public static Label ToLabel(this ILicense license, PropertyInfo property) { if (license == null) { throw new ArgumentNullException(nameof(license)); } if (property == null) { throw new ArgumentNullException(nameof(property)); } return(new Label() { Padding = ExtensionHelper.LabelPadding, FontWeight = FontWeights.DemiBold, Content = property.Name.ToDisplayLabel(), }); }
public MyTestLicense(ILicense license) : base(license) { }
public LicenseBase(ILicense license) : this(license.Licensee, license.Type, license.Expires) { }
public LicenseSerializationContainer(ILicense license) { AppName = license.ApplicationName; ExpiryDate = license.ExpiryDate; AccessLevel = license.LicenseAccessLevel; LicenseeName = license.LicenseeName; RootModule = new ModuleSerializationContainer(license.RootModule); }
internal string GetJson(ILicense license) { return JsonConvert.SerializeObject(new LicenseSerializationContainer(license)); }
public EcosApplication(ILicense licenseProvider, IConnection connectionProvider, IStorage storageProvider, ICloud cloudProvider) { if (connectionProvider == null) throw new ArgumentNullException("connectionProvider"); if (storageProvider == null) throw new ArgumentNullException("storageProvider"); if (licenseProvider == null) throw new ArgumentNullException("licenseProvider"); if (cloudProvider == null) throw new ArgumentNullException("cloudProvider"); Current = this; License = licenseProvider; storage = storageProvider; cloud = cloudProvider; connection = connectionProvider; connection.Disconnected += connection_Disconnected; connection.ServerDisconnected += connection_ServerDisconnected; connection.Received += connection_DataReceived; IsConnected = connection.IsConnected; var profiles = storage.GetData(nameof(Profiles), new ObservableCollection<EcosProfile>()); profiles.All(profile => { RegisterProfileNotifications(profile); Profiles.Add(profile); return true; }); Profiles.CollectionChanged += (s, e) => { if (e.NewItems != null) foreach (EcosProfile profile in e.NewItems) RegisterProfileNotifications(profile); NotifyProfilesChanged(); }; }
/// <summary> /// Verifies the <paramref name="license"/> contains a product key that is legitimate and valid for the specified /// <paramref name="currentAppVersion"/>. The returned object is the same instance in memory as the <paramref name="license"/> parameter. /// </summary> /// <param name="license">The license containing the product key to validate. The only property that must be assigned /// prior to calling this method is <see cref="ILicense.ProductKey"/>. This function will assign the remaining properties.</param> /// <param name="currentAppVersion">The version of the currently running application.</param> /// <param name="performWebServiceValidation">if set to <c>true</c> validate the license using a web service invocation /// against a server run by Tech Info Systems. This parameter is ignored in stand-alone versions of GSP, since it /// never invokes a web service.</param> /// <returns> /// Returns an <see cref="ILicense"/> instance containing license information for the product key. /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="license" /> is null.</exception> public static ILicense ValidateLicense(ILicense license, string currentAppVersion, bool performWebServiceValidation) { if (license == null) throw new ArgumentNullException("license"); license.Email = String.Empty; license.KeyInvalidReason = String.Empty; license.Version = currentAppVersion; license.LicenseType = LicenseLevel.NotSet; license.IsValid = (license.ProductKey.Equals(GlobalConstants.ProductKey) || license.ProductKey.Equals(GlobalConstants.ProductKeyNoPageFooter)); if (!license.IsValid) { license.KeyInvalidReason = "Product key is not valid"; } license.InstallDate = GetFirstGalleryInstallationDate(); license.IsInTrialPeriod = (license.InstallDate.AddDays(GlobalConstants.TrialNumberOfDays) >= DateTime.Today); return license; }
public ValidationChainBuilder(ILicense license) { this.license = license; validators = new Queue<ILicenseValidator>(); }
public void SaveLicense(ILicense license, string path) { var extension = Path.GetExtension(path); if(string.IsNullOrEmpty(extension)) { throw new UnsupportedFileTypeException("Cannot choose file strategy without an extension"); } if(extension.First() == '.') { extension = extension.Substring(1); } var saver = Loaders.FirstOrDefault(x => x.Extension == extension); if (saver == null) { throw new UnsupportedFileTypeException("Unsupported filetype " + extension); } saver.SaveLicense(license,path); }
private LicenseInfo getLicenseInfo(String external, ILicense licenseFound) { LicenseInfo licenseInfo = new LicenseInfo(); licenseInfo.LicenseFilename = licenseFound.LicenseFilename; licenseInfo.LicenseType = licenseFound.LicenseType; licenseInfo.Product = licenseFound.Product; licenseInfo.ParentProduct = licenseFound.ParentProduct; licenseInfo.Version = licenseFound.Version; if (_externals != null) { External externalDefinition; _externals.TryGetValue(external, out externalDefinition); if (externalDefinition != null) { if (String.IsNullOrEmpty(licenseInfo.ParentProduct)) { externalDefinition.Apply(licenseInfo); } else { externalDefinition.ApplyToSubProduct(licenseInfo); } } // subproduct external if (!String.IsNullOrEmpty(licenseInfo.ParentProduct)) { External childExternalDefinition; _externals.TryGetValue(licenseInfo.Product, out childExternalDefinition); if (childExternalDefinition != null) { childExternalDefinition.Apply(licenseInfo); } } } if (_folders != null) { foreach (Folder folder in _folders) { licenseInfo.Product = folder.Replace(licenseInfo.Product); licenseInfo.ParentProduct = folder.Replace(licenseInfo.ParentProduct); licenseInfo.LicenseFilename = folder.Replace(licenseInfo.LicenseFilename); } } return licenseInfo; }
/// <summary> /// Persist the specified application settings to the data store. Specify a null value for each parameter whose value is /// not changing. /// </summary> /// <param name="license">A license instance containing the product key for this installation of Gallery Server Pro. The /// product key must be validated before invoking this method.</param> /// <param name="skin">The name of the skin.</param> /// <param name="mediaObjectDownloadBufferSize">The size of each block of bytes when transferring files to streams and vice versa.</param> /// <param name="encryptMediaObjectUrlOnClient">Indicates whether security-sensitive portions of the URL to the media object are /// encrypted when it is sent to the client browser.</param> /// <param name="encryptionKey">The secret key used for the Triple DES algorithm.</param> /// <param name="jQueryScriptPath">The absolute or relative path to the jQuery script file.</param> /// <param name="jQueryMigrateScriptPath">The absolute or relative path to the jQuery Migrate script file.</param> /// <param name="jQueryUiScriptPath">The absolute or relative path to the jQuery UI script file.</param> /// <param name="membershipProviderName">The name of the Membership provider for the gallery users.</param> /// <param name="roleProviderName">The name of the Role provider for the gallery users.</param> /// <param name="enableCache">Indicates whether to store objects in a cache for quicker retrieval.</param> /// <param name="allowGalleryAdminToManageUsersAndRoles">Indicates whether gallery administrators are allowed to create, edit, and delete /// users and roles.</param> /// <param name="allowGalleryAdminViewAllUsersAndRoles">Indicates whether gallery administrators are allowed to see users and roles that /// do not have access to current gallery.</param> /// <param name="maxNumberErrorItems">The maximum number of error objects to persist to the data store.</param> /// <param name="emailFromName">The name associated with the <paramref name="emailFromAddress" /> email address. Emails sent from Gallery Server /// will appear to be sent from this person.</param> /// <param name="emailFromAddress">The email address associated with <paramref name="emailFromName" />. Emails sent from Gallery Server /// will appear to be sent from this email address.</param> /// <param name="smtpServer">Specifies the IP address or name of the SMTP server used to send emails. (Examples: 127.0.0.1, /// Godzilla, mail.yourisp.com)</param> /// <param name="smtpServerPort">Specifies the SMTP server port number used to send emails.</param> /// <param name="sendEmailUsingSsl">Specifies whether e-mail functionality uses Secure Sockets Layer (SSL) to encrypt the connection.</param> public void Save(ILicense license, string skin, int? mediaObjectDownloadBufferSize, bool? encryptMediaObjectUrlOnClient, string encryptionKey, string jQueryScriptPath, string jQueryMigrateScriptPath, string jQueryUiScriptPath, string membershipProviderName, string roleProviderName, bool? enableCache, bool? allowGalleryAdminToManageUsersAndRoles, bool? allowGalleryAdminViewAllUsersAndRoles, int? maxNumberErrorItems, string emailFromName, string emailFromAddress, string smtpServer, string smtpServerPort, bool? sendEmailUsingSsl) { bool productKeyWasChanged = false; lock (_sharedLock) { if (license != null) { productKeyWasChanged = (License.ProductKey != license.ProductKey); License = license; ValidateLicenseTypeConfiguration(); } if (!String.IsNullOrEmpty(skin)) Skin = skin; if (mediaObjectDownloadBufferSize.HasValue) MediaObjectDownloadBufferSize = mediaObjectDownloadBufferSize.Value; if (encryptMediaObjectUrlOnClient.HasValue) EncryptMediaObjectUrlOnClient = encryptMediaObjectUrlOnClient.Value; if (!String.IsNullOrEmpty(encryptionKey)) EncryptionKey = encryptionKey; if (jQueryScriptPath != null) JQueryScriptPath = jQueryScriptPath; if (jQueryScriptPath != null) JQueryMigrateScriptPath = jQueryMigrateScriptPath; if (jQueryUiScriptPath != null) JQueryUiScriptPath = jQueryUiScriptPath; if (!String.IsNullOrEmpty(membershipProviderName)) MembershipProviderName = membershipProviderName; if (!String.IsNullOrEmpty(roleProviderName)) RoleProviderName = roleProviderName; if (enableCache.HasValue) EnableCache = enableCache.Value; if (allowGalleryAdminToManageUsersAndRoles.HasValue) AllowGalleryAdminToManageUsersAndRoles = allowGalleryAdminToManageUsersAndRoles.Value; if (allowGalleryAdminViewAllUsersAndRoles.HasValue) AllowGalleryAdminToViewAllUsersAndRoles = allowGalleryAdminViewAllUsersAndRoles.Value; if (maxNumberErrorItems.HasValue) MaxNumberErrorItems = maxNumberErrorItems.Value; if (emailFromName != null) EmailFromName = emailFromName; if (emailFromAddress != null) EmailFromAddress = emailFromAddress; if (smtpServer != null) SmtpServer = smtpServer; if (smtpServerPort != null) SmtpServerPort = smtpServerPort; if (sendEmailUsingSsl.HasValue) SendEmailUsingSsl = sendEmailUsingSsl.Value; //Factory.GetDataProvider().AppSetting_Save(this); using (var repo = new AppSettingRepository()) { repo.Save(this); } if (productKeyWasChanged) { Factory.ClearWatermarkCache(); //Changing the product key might cause a different watermark to be rendered } } }
public void SaveSignedLicense(string signingKey, ILicense license, string path) { var signedLoaders = Loaders.Where(x => x is ISigningLoaderSaver).Cast<ISigningLoaderSaver>(); var extension = Path.GetExtension(path); if (string.IsNullOrEmpty(extension)) { throw new UnsupportedFileTypeException("Cannot choose file strategy without an extension"); } if (extension.First() == '.') { extension = extension.Substring(1); } var saver = signedLoaders.FirstOrDefault(x => x.Extension == extension); if (saver == null) { throw new UnsupportedFileTypeException("Unsupported filetype " + extension); } saver.SaveSignedLicense(signingKey, license, path); }
public void SaveSignedLicense(string signingKey, ILicense license, string path) { if (File.Exists(path)) { File.Delete(path); } using(var pack = Package.Open(path)) { var licenseString = _inner.GetJson(license); var md5 = GetSignature(GetMd5Hash(licenseString), signingKey); var licensePart = pack.CreatePart( PackUriHelper.CreatePartUri(new Uri(LicenseString, UriKind.Relative)), System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); var signaturePart = pack.CreatePart( PackUriHelper.CreatePartUri(new Uri(SignatureString, UriKind.Relative)), System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); using (var stream = new StreamWriter(licensePart.GetStream())) { stream.Write(licenseString); } var enc = new ASCIIEncoding(); using (var stream = new StreamWriter(signaturePart.GetStream())) { stream.Write(enc.GetString(md5)); } } }
void LicenseContainer(ILicense license) { license.License(this); }