From 4e01a42e6943e1a290eb84a88f8a2dab74442a75 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 9 Jun 2018 23:46:14 +0700 Subject: [PATCH] Experiment with PGP signed messages --- installer/appx/filebot.l4j.ini | 3 --- installer/appx/filebot.launcher.l4j.ini | 3 --- source/net/filebot/License.java | 28 +++++++++++++++++++++++-- source/net/filebot/Settings.java | 6 +----- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/installer/appx/filebot.l4j.ini b/installer/appx/filebot.l4j.ini index 7d41ec2c..122404cc 100644 --- a/installer/appx/filebot.l4j.ini +++ b/installer/appx/filebot.l4j.ini @@ -27,9 +27,6 @@ # reduce default logging -Djava.util.logging.config.file="%EXEDIR%\logging.properties" -# force Application User Model ID for Windows Store --Dnet.filebot.AppUserModelID=@{microsoft.application.name} - # support JAVA_OPTS environment variable %JAVA_OPTS% diff --git a/installer/appx/filebot.launcher.l4j.ini b/installer/appx/filebot.launcher.l4j.ini index d5855c23..54e27a47 100644 --- a/installer/appx/filebot.launcher.l4j.ini +++ b/installer/appx/filebot.launcher.l4j.ini @@ -27,9 +27,6 @@ # reduce default logging -Djava.util.logging.config.file="%EXEDIR%\logging.properties" -# force Application User Model ID for Windows Store --Dnet.filebot.AppUserModelID=@{microsoft.application.name} - # support JAVA_OPTS environment variable %JAVA_OPTS% diff --git a/source/net/filebot/License.java b/source/net/filebot/License.java index 353afe3f..080893f5 100644 --- a/source/net/filebot/License.java +++ b/source/net/filebot/License.java @@ -3,6 +3,8 @@ package net.filebot; import static java.nio.charset.StandardCharsets.*; import static java.util.stream.Collectors.*; import static net.filebot.CachedResource.*; +import static net.filebot.Settings.*; +import static net.filebot.platform.windows.WinAppUtilities.*; import static net.filebot.util.FileUtilities.*; import static net.filebot.util.RegularExpressions.*; @@ -27,12 +29,34 @@ import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; import net.filebot.util.ByteBufferOutputStream; +import net.filebot.util.SystemProperty; import net.filebot.web.WebRequest; public class License implements Serializable { - public static final File LICENSE_FILE = ApplicationFolder.AppData.resolve("license.txt"); - public static final Resource INSTANCE = Resource.lazy(() -> new License(readFile(LICENSE_FILE))); + public static final SystemProperty LICENSE_FILE = SystemProperty.of("net.filebot.license", File::new, ApplicationFolder.AppData.resolve("license.txt")); + + public static final Resource INSTANCE = Resource.lazy(() -> { + return new License(readFile(LICENSE_FILE.get())); + }); + + public static final void check() throws Exception { + if (isAppStore()) { + if (isWindowsApp() && "PointPlanck.FileBot".equals(getAppUserModelID())) { + return; + } else if (isMacSandbox() && !File.listRoots()[0].canRead()) { + return; + } + throw new Exception("BAD LICENSE: " + getAppStoreName() + " sandbox not found"); + } + + // check license file + License license = INSTANCE.get(); + + if (!license.isValid()) { + throw new Exception("BAD LICENSE: " + license); + } + }; private byte[] bytes; diff --git a/source/net/filebot/Settings.java b/source/net/filebot/Settings.java index 9f736f7c..93879154 100644 --- a/source/net/filebot/Settings.java +++ b/source/net/filebot/Settings.java @@ -114,10 +114,6 @@ public final class Settings { return false; } - public static String getApplicationUserModelID() { - return System.getProperty("net.filebot.AppUserModelID", getApplicationName()); - } - public static FileChooser getPreferredFileChooser() { return FileChooser.valueOf(System.getProperty("net.filebot.UserFiles.fileChooser", "Swing")); } @@ -139,7 +135,7 @@ public final class Settings { if (isMacApp()) return "Mac App Store"; if (isWindowsApp()) - return "Windows Store"; + return "Microsoft Store"; if (isUbuntuApp()) return "Ubuntu Software Center";