public void TodoIsNotALicense() { var licenseString = "TODO blah for Microsoft"; var result = new LicenseChecker().Check(new FilePath("ignore"), FileType.Unknown, licenseString); Assert.Equal(LicenseType.NoLicense, result.License); }
public void NoCommentIsNotALicense() { var licenseString = ""; var result = new LicenseChecker().Check(new FilePath("ignore"), FileType.Unknown, licenseString); Assert.Equal(LicenseType.NoLicense, result.License); }
public static string StageBloomD(Book.Book book, BookServer bookServer, WebSocketProgress progress, Color backColor, AndroidPublishSettings settings = null) { progress.Message("PublishTab.Epub.PreparingPreview", "Preparing Preview"); // message shared with Epub publishing if (settings?.LanguagesToInclude != null) { var message = new LicenseChecker().CheckBook(book, settings.LanguagesToInclude.ToArray()); if (message != null) { progress.MessageWithoutLocalizing(message, MessageKind.Error); return(null); } } _stagingFolder?.Dispose(); if (AudioProcessor.IsAnyCompressedAudioMissing(book.FolderPath, book.RawDom)) { progress.Message("CompressingAudio", "Compressing audio files"); AudioProcessor.TryCompressingAudioAsNeeded(book.FolderPath, book.RawDom); } // We don't use the folder found here, but this method does some checks we want done. BookStorage.FindBookHtmlInFolder(book.FolderPath); _stagingFolder = new TemporaryFolder(StagingFolder); var modifiedBook = BloomReaderFileMaker.PrepareBookForBloomReader(book.FolderPath, bookServer, _stagingFolder, progress, settings: settings); progress.Message("Common.Done", "Shown in a list of messages when Bloom has completed a task.", "Done"); return(modifiedBook.FolderPath.ToLocalhost()); }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { SPContext.Current.Web.AllowUnsafeUpdates = true; SPAdministrationWebApplication caWebApp = SPAdministrationWebApplication.Local; //Delete any existing jobs string jobName = "Check License"; foreach (SPJobDefinition job in caWebApp.JobDefinitions) { if (job.Name.ToUpper().Equals(jobName.ToUpper())) { job.Delete(); } } //Schedule new job SPMonthlySchedule schedule4 = new SPMonthlySchedule(); schedule4.BeginDay = 1; schedule4.EndDay = 1; schedule4.BeginHour = 2; schedule4.EndHour = 6; LicenseChecker newJob4 = new LicenseChecker(jobName, caWebApp); newJob4.Schedule = schedule4; newJob4.Update(); } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data); } }
public ActionResult LicenseResetStatusCheck(string systemName) { // Reset state for current store. var result = LicenseChecker.ResetState(systemName); var model = new PluginLicenseModel { IsLicensable = true, LicenseUrl = Url.Action("LicensePlugin", new { systemName = systemName }), LicenseState = result.State, TruncatedLicenseKey = result.TruncatedLicenseKey, RemainingDemoUsageDays = result.RemainingDemoDays }; if (result.Success) { // Reset state for all other stores. var currentStoreId = Services.StoreContext.CurrentStore.Id; var allStores = Services.StoreService.GetAllStores(); foreach (var store in allStores.Where(x => x.Id != currentStoreId && x.Url.HasValue())) { LicenseChecker.ResetState(systemName, store.Url); } NotifySuccess(T("Admin.Common.TaskSuccessfullyProcessed")); } else { NotifyError(result.ToString()); } return(PartialView("Partials/LicenseLabel", model)); }
public void SimpleCopyrightFollowedByExtraWordsIsAnUnknownLicense() { var licenseString = "Copyright (c) Microsoft. All rights reserved. You may only use this under the following terms: your firstborn is ours"; var result = new LicenseChecker().Check(new FilePath("ignore"), FileType.Unknown, licenseString); Assert.Equal(LicenseType.UnknownLicense, result.License); }
void BackgroundUpload(object sender, DoWorkEventArgs e) { var model = (BloomLibraryPublishModel)e.Argument; var book = model.Book; var checker = new LicenseChecker(); var message = checker.CheckBook(book, LanguagesCheckedToUpload.ToArray()); if (message != null) { // Using WriteError allows users to send bug reports: this isn't a bug! _progressBox.WriteMessageWithColor(Color.Red, message); e.Result = "quiet"; // suppress other completion/fail messages return; } _model.UpdateBookMetadataFeatures( _blindCheckBox.Checked, _narrationAudioCheckBox.Checked, _signLanguageCheckBox.Checked); var includeBackgroundMusic = _backgroundMusicCheckBox.Checked; var result = _model.UploadOneBook(book, _progressBox, _parentView, !includeBackgroundMusic, out _parseId); e.Result = result; }
public void AutoGeneratedHeaderIsNotALicense() { var licenseString = "<auto-generated />"; var result = new LicenseChecker().Check(new FilePath("ignore"), FileType.Unknown, licenseString); Assert.Equal(LicenseType.NoLicense, result.License); }
/// <summary> /// Make the preview required for publishing the book. /// </summary> internal void MakePublishPreview() { if (IsMakingPdf) { // Can't start another until current attempt finishes. _makePdfBackgroundWorker.CancelAsync(); while (IsMakingPdf) { Thread.Sleep(100); } } var message = new LicenseChecker().CheckBook(_model.BookSelection.CurrentSelection, _model.BookSelection.CurrentSelection.ActiveLanguages.ToArray()); if (message != null) { MessageBox.Show(message, LocalizationManager.GetString("Common.Warning", "Warning")); return; } // Usually these will have been set by SetModelFromButtons, but the publish button might already be showing when we go to this page. _model.ShowCropMarks = false; // don't want in online preview _model.BookletPortion = PublishModel.BookletPortions.AllPagesNoBooklet; // has all the pages and cover in form suitable for online use _makePdfBackgroundWorker.RunWorkerAsync(); // We normally generate PDFs in the background, but this routine should not return until we actually have one. while (IsMakingPdf) { Thread.Sleep(100); Application.DoEvents(); // Wish we didn't need this, but without it bulk upload freezes making 'preview' which is really the PDF to upload. } }
//控件呈现事件 protected override void Render(HtmlTextWriter writer) { int siteQty; bool isValid, isExpired; //授权验证 LicenseChecker.Check(out isValid, out isExpired, out siteQty); if (!isValid) { writer.Write(licenseMsg); } else if (isExpired) { using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter htw = new HtmlTextWriter(sw)) { base.Render(htw); string str = sw.ToString(); str = str.Insert(str.IndexOf("</body>"), "<div class=\"checkInfo\">\r\n <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n <tr>\r\n <td class=\"td1\"><img src=\"images/checkInfo.gif\" width=\"30\" height=\"30\" /></td>\r\n <td class=\"td2\" width=\"100%\">您正在使用的易分销系统已过授权有效期!<br/>请联系官方(www.shopefx.com)购买软件使用权。</td>\r\n </tr>\r\n </table>\r\n</div>"); writer.Write(str); } } } else { base.Render(writer); } }
void BackgroundUpload(object sender, DoWorkEventArgs e) { var book = (Book.Book)e.Argument; var languages = _languagesFlow.Controls.Cast <CheckBox>(). Where(b => b.Checked).Select(b => b.Tag).Cast <string>().ToList(); var checker = new LicenseChecker(); var message = checker.CheckBook(book, languages.ToArray()); if (message != null) { _progressBox.WriteError(message); e.Result = "quiet"; // suppress other completion/fail messages return; } if (_signLanguageCheckBox.Checked && !string.IsNullOrEmpty(book.CollectionSettings.SignLanguageIso639Code)) { languages.Insert(0, book.CollectionSettings.SignLanguageIso639Code); } book.UpdateMetadataFeatures( isBlindEnabled: _blindCheckBox.Checked, isTalkingBookEnabled: _narrationAudioCheckBox.Checked, isSignLanguageEnabled: _signLanguageCheckBox.Checked, allowedLanguages: languages); var includeNarrationAudio = _narrationAudioCheckBox.Checked; var includeBackgroundMusic = _backgroundMusicCheckBox.Checked; var result = _model.UploadOneBook(book, _progressBox, _parentView, languages.ToArray(), !includeNarrationAudio, !includeBackgroundMusic, out _parseId); e.Result = result; }
private void CheckUsingServerManagedPolicy() { //("MainActivity.CheckUsingServerManagedPolicy"); byte[] salt = new byte[15] { 46, 65, 30, 128, 103, 57, 74, 64, 51, 88, 95, 45, 77, 117, 36 }; string packageName = this.PackageName; string @string = Settings.Secure.GetString(this.ContentResolver, "android_id"); AESObfuscator obfuscator = new AESObfuscator(salt, packageName, @string); ServerManagedPolicy policy = new ServerManagedPolicy(this, obfuscator); this._licenseChecker = new LicenseChecker(this, policy, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAry4fecehDpCohQk4XhiIZX9ylIGUThWZxfN9qwvQyTh53hvnpQl/lCrjfflKoPz6gz5jJn6JI1PTnoBy/iXVx1+kbO99qBgJE2V8PS5pq+Usbeqqmqqzx4lEzhiYQ2um92v4qkldNYZFwbTODYPIMbSbaLm7eK9ZyemaRbg9ssAl4QYs0EVxzDK1DjuXilRk28WxiK3lNJTz4cT38bfs4q6Zvuk1vWUvnMqcxiugox6c/9j4zZS5C4+k+WY6mHjUMuwssjCY3G+aImWDSwnU3w9G41q8EoPvJ1049PIi7GJXErusTYZITmqfonyejmSFLPt8LHtux9AmJgFSrC3UhwIDAQAB"); this._licenseChecker.CheckAccess(this); }
public void SimpleCopyrightIsProbablyAnOpenSourceLicense() { var licenseString = "Copyright (c) Microsoft. All rights reserved."; var result = new LicenseChecker().Check(new FilePath("ignore"), FileType.Unknown, licenseString); Assert.Equal(LicenseType.ValidLicense, result.License); }
public async Task Check_Active_License() { // act var result = await LicenseChecker.CheckLicenseStatus(_licenseModel); // assert Assert.IsTrue(result.Active); }
private void CheckForValidLicence() { //("MainActivity.CheckForValidLicence"); StrictPolicy policy = new StrictPolicy(); this._licenseChecker = new LicenseChecker(this, policy, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAry4fecehDpCohQk4XhiIZX9ylIGUThWZxfN9qwvQyTh53hvnpQl/lCrjfflKoPz6gz5jJn6JI1PTnoBy/iXVx1+kbO99qBgJE2V8PS5pq+Usbeqqmqqzx4lEzhiYQ2um92v4qkldNYZFwbTODYPIMbSbaLm7eK9ZyemaRbg9ssAl4QYs0EVxzDK1DjuXilRk28WxiK3lNJTz4cT38bfs4q6Zvuk1vWUvnMqcxiugox6c/9j4zZS5C4+k+WY6mHjUMuwssjCY3G+aImWDSwnU3w9G41q8EoPvJ1049PIi7GJXErusTYZITmqfonyejmSFLPt8LHtux9AmJgFSrC3UhwIDAQAB"); this._licenseChecker.CheckAccess(this); }
private TemporaryFolder SetupDefaultOfflineLicenseInfo() { var folder = new TemporaryFolder("DefaultOfflineLicenseTest"); LicenseChecker.SetOfflineFolder(folder.FolderPath); LicenseChecker.SetAllowInternetAccess(false); LicenseChecker.WriteObfuscatedFile(folder.FolderPath + "/license.cache", @"{ ""range"": ""Sheet1!A1:B1001"", ""majorDimension"": ""ROWS"", ""values"": [ [ ""content-id\n"", ""language-code"" ], [ ""kingstone.superbible.*"", ""ar\n"" ], [ ""kingstone.superbible.*"", ""tr"" ], [ ""kingstone.superbible.*"", ""fa"" ], [ ""kingstone.superbible.*"", ""zh-CN"" ], [ ""kingstone.superbible.*"", ""in"" ], [ ""kingstone.superbible.*"", ""ne"" ], [ ""kingstone.superbible.*"", ""hi"" ], [ ""kingstone.superbible.*"", ""ru"" ], [ ""kingstone.superbible.*"", ""bn"" ], [ ""kingstone.superbible.ruth"", ""bjn"" ] ] }"); return(folder); }
public void CheckBook_HasMeta_NoAccessToSpreadsheet_ReportsCantTest() { var dom = MakeDomWithLicenseMeta(); LicenseChecker.SetAllowInternetAccess(false); LicenseChecker.SetOfflineFolder(null); var checker = new LicenseChecker(); Assert.That(checker.CheckBook(dom, new[] { "en" }), Is.EqualTo(LicenseChecker.kCannotReachLicenseServerMessage)); }
public void ProblemLanguages_UsesOfflineCacheIfAvailable() { using (var folder = SetupDefaultOfflineLicenseInfo()) { var checker = SimpleTest(true); File.Delete(checker.getCacheFile()); SimpleTest(false); LicenseChecker.SetOfflineFolder(null); SimpleTest(false); LicenseChecker.SetAllowInternetAccess(true); } }
public LicenseCheckService( ILogger <LicenseCheckService> logger, SettingService settings, LicenseChecker licenseChecker, UniflowDbAccessService uniflowDb ) { this.logger = logger; this.settings = settings; this.licenseChecker = licenseChecker; this.uniflowDb = uniflowDb; }
public ActionResult LicensePlugin(string systemName, LicensePluginModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins)) { return(AccessDeniedView()); } var descriptor = _pluginFinder.GetPluginDescriptorBySystemName(systemName); if (descriptor == null || !descriptor.Installed) { return(HttpNotFound()); } var isLicensable = IsLicensable(descriptor); if (!isLicensable) { return(HttpNotFound()); } if (model.StoreLicenses != null) { foreach (var item in model.StoreLicenses) { var result = LicenseChecker.Activate(item.LicenseKey, descriptor.SystemName, item.StoreUrl); if (result == null) { // do nothing, skiped } else if (result.Success) { NotifySuccess(T("Admin.Configuration.Plugins.LicenseActivated")); } else { if (result.IsFailureWarning) { NotifyWarning(result.ToString()); } else { NotifyError(result.ToString()); } return(RedirectToAction("List")); } } } return(RedirectToAction("List")); }
private void CheckLicense() { // Try to use more data here. ANDROID_ID is a single point of attack. //string deviceId = Settings.Secure.GetString(ContentResolver, Settings.Secure.AndroidId); // Construct the LicenseChecker with a policy. //var obfuscator = new AesObfuscator(Salt, this.PackageName, deviceId); StrictPolicy policy = new StrictPolicy(); this.checker = new LicenseChecker(this, policy, Base64PublicKey); this.checker.CheckAccess(this); }
public LicenseCheckService( //SettingService settings, //UniflowDbAccessService uniflowDb, LicenseChecker licenseChecker, ILogger <LicenseCheckService> logger ) { this.logger = logger; //this.settings = settings; this.licenseChecker = licenseChecker; //this.uniflowDb = uniflowDb; }
void Application_BeginRequest(object sender, EventArgs e) { LicenseChecker lc = new LicenseChecker(); string message = string.Empty; bool isCheck = lc.Check(this.Server.MapPath("~/授权文件[北京客户].dat"), out message); if (!isCheck) { this.Response.Write(message); this.Response.End(); } }
public void ProblemLanguages_KeepsExactMatchNeedingTrim_RemovesNotMatched_WritesOfflineCache() { using (var folder = new TemporaryFolder("ProblemLanguages_KeepsExactMatchNeedingTrim_RemovesNotMatched_WritesOfflineCache")) { LicenseChecker.SetOfflineFolder(folder.FolderPath); var checker = SimpleTest(true); Assert.That(File.Exists(checker.getCacheFile())); var json = LicenseChecker.ReadObfuscatedFile(checker.getCacheFile()); Assert.DoesNotThrow(() => DynamicJson.Parse(json)); LicenseChecker.SetOfflineFolder(null); } }
/// <summary> /// Método de processamentoda requisição /// </summary> /// <param name="sqlConnection">Conexão com o banco de dados MS-SQL</param> /// <param name="enterpriseId">ID da empresa</param> /// <param name="method">String com o método que deverá ser processado</param> /// <param name="auth">String com a chave de autenticação.</param> /// <param name="parameters">Dicionário (String, Object) contendo todos os parâmetros necessários</param> public override Object iProcess(IAMDatabase database, Int64 enterpriseId, String method, String auth, Dictionary <String, Object> parameters) { //base.Connection = sqlConnection; method = method.ToLower(); String[] mp = method.Split(".".ToCharArray(), 2); if (mp.Length != 2) { return(null); } if (this.GetType().Name.ToLower() != mp[0]) { return(null); } Acl = ValidateCtrl(database, method, auth, parameters, ExternalAccessControl); if (!Acl.Result) { Error(ErrorType.InvalidParameters, "Not authorized", "", null); return(null); } switch (mp[1]) { case "info": Dictionary <String, Object> result = new Dictionary <String, Object>(); LicenseControl lic = LicenseChecker.GetLicenseData(database.Connection, null, enterpriseId); result.Add("hasLicense", lic.Valid); if (lic.Valid) { result.Add("used", lic.Count); result.Add("available", lic.Entities); } return(result); break; default: Error(ErrorType.InvalidRequest, "JSON-rpc method is unknow.", "", null); return(null); break; } return(null); }
public ActionResult LicenseResetStatusCheck(string systemName) { // Reset state for current store. var result = LicenseChecker.ResetState(systemName); LicenseCheckerResult subShopResult = null; var model = new LicenseLabelModel { IsLicensable = true, LicenseUrl = Url.Action("LicensePlugin", new { systemName = systemName }), LicenseState = result.State, TruncatedLicenseKey = result.TruncatedLicenseKey, RemainingDemoUsageDays = result.RemainingDemoDays }; // Reset state for all other stores. if (result.Success) { var currentStoreId = Services.StoreContext.CurrentStore.Id; var allStores = Services.StoreService.GetAllStores(); foreach (var store in allStores.Where(x => x.Id != currentStoreId && x.Url.HasValue())) { subShopResult = LicenseChecker.ResetState(systemName, store.Url); if (!subShopResult.Success) { result = subShopResult; break; } } } // Notify about result. if (result.Success) { NotifySuccess(T("Admin.Common.TaskSuccessfullyProcessed")); } else { var message = HtmlUtils.ConvertPlainTextToHtml(result.ToString()); if (result.IsFailureWarning) { NotifyWarning(message); } else { NotifyError(message); } } return(PartialView("Partials/LicenseLabel", model)); }
public void ProblemLanguages_KeepsAsteriskMatch() { var checker = new LicenseChecker(); var inputLangs = new String[] { "en", "fr", "ru", "zh-CN" }; var key = "kingstone.superbible.ruth"; bool didCheck; IEnumerable <string> result = checker.GetProblemLanguages(inputLangs, key, out didCheck); Assert.That(didCheck, Is.True); Assert.That(result, Does.Contain("en")); Assert.That(result, Does.Contain("fr")); Assert.That(result, Does.Not.Contain("ru")); Assert.That(result, Does.Not.Contain("zh-CN")); }
public void MakeBooklet() { if (IsMakingPdf) { // Can't start again until this one finishes return; } var message = new LicenseChecker().CheckBook(_model.BookSelection.CurrentSelection, _model.BookSelection.CurrentSelection.ActiveLanguages.ToArray()); if (message != null) { MessageBox.Show(message, LocalizationManager.GetString("Common.Warning", "Warning"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _model.PdfGenerationSucceeded = false; // and so it stays unless we generate it successfully. if (_uploadRadio.Checked) { // We aren't going to display it, so don't bother generating it unless the user actually uploads. // Unfortunately, the completion of the generation process is normally responsible for putting us into // the right display mode for what we generated (or failed to), after this routine puts us into the // mode that shows generation is pending. For the upload button case, we want to go straight to the Upload // mode, so the upload control appears. This is a bizarre place to do it, but I can't find a better one. SetDisplayMode(PublishModel.DisplayModes.Upload); return; } SetDisplayMode(PublishModel.DisplayModes.Working); using (_progress = new SIL.Windows.Forms.Progress.ProgressDialog()) { _progress.Overview = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.Creating", "Creating PDF...", @"Message displayed in a progress report dialog box"); _progress.BackgroundWorker = _makePdfBackgroundWorker; _makePdfBackgroundWorker.ProgressChanged += UpdateProgress; _progress.ShowDialog(); // will start the background process when loaded/showing _makePdfBackgroundWorker.ProgressChanged -= UpdateProgress; _progress.BackgroundWorker = null; if (_progress.ProgressStateResult != null && _progress.ProgressStateResult.ExceptionThatWasEncountered != null) { string shortMsg = L10NSharp.LocalizationManager.GetString(@"PublishTab.PdfMaker.ErrorProcessing", "Error creating, compressing, or recoloring the PDF file", @"Message briefly displayed to the user in a toast"); var longMsg = String.Format("Exception encountered processing the PDF file: {0}", _progress.ProgressStateResult.ExceptionThatWasEncountered); NonFatalProblem.Report(ModalIf.None, PassiveIf.All, shortMsg, longMsg, _progress.ProgressStateResult.ExceptionThatWasEncountered); } } _progress = null; }
public ActionResult LicenseResetStatusCheck(string systemName) { var result = LicenseChecker.ResetStatusCheckDate(systemName); if (result.Success) { NotifySuccess(T("Admin.Common.TaskSuccessfullyProcessed")); } else { NotifyError(result.ToString()); } return(Content("")); }
private bool IsLicensable(PluginDescriptor pluginDescriptor) { var result = false; try { result = LicenseChecker.IsLicensablePlugin(pluginDescriptor); } catch (Exception ex) { Logger.Error(ex); } return(result); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.IndeterminateProgress); SetContentView(Resource.Layout.Main); this.checkLicenseButton = FindViewById<Button>(Resource.Id.MyButton); this.checkLicenseButton.Click += delegate { this.DoCheck(); }; // Try to use more data here. ANDROID_ID is a single point of attack. string deviceId = Settings.Secure.GetString(ContentResolver, Settings.Secure.AndroidId); // Construct the LicenseChecker with a policy. var obfuscator = new AesObfuscator(Salt, this.PackageName, deviceId); var policy = new ServerManagedPolicy(this, obfuscator); this.checker = new LicenseChecker(this, policy, Base64PublicKey); this.DoCheck(); }
// protected Licenser(Storage storage, LicenseChecker checker) { this.storage = storage; this.checker = checker; }
public LocalChecker(LicenseChecker remote, Validator validator) { this.remote = remote; this.validator = validator; }
public TestLicenser(Storage storage, LicenseChecker checker) : base(storage, checker) { }