mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
Experiment with PGP signed messages
This commit is contained in:
parent
b5d7f7c3bc
commit
a0d9ca6452
@ -124,7 +124,7 @@ public class License implements Serializable {
|
||||
return String.format("%s License %s (Valid-Until: %s)", product, id, expires == null ? null : expires.atZone(ZoneOffset.UTC).format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
}
|
||||
|
||||
public static final SystemProperty<File> FILE = SystemProperty.of("net.filebot.license", File::new, ApplicationFolder.AppData.resolve("license.txt"));
|
||||
public static final SystemProperty<File> FILE = SystemProperty.of("net.filebot.license", File::new, ApplicationFolder.AppData.resolve(".license"));
|
||||
public static final MemoizedResource<License> INSTANCE = Resource.lazy(() -> new License(FILE.get()));
|
||||
|
||||
public static License configure(File file) throws Exception {
|
||||
|
@ -8,26 +8,41 @@ public enum LicenseModel {
|
||||
|
||||
MicrosoftStore {
|
||||
|
||||
@Override
|
||||
public boolean isAppStore() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check() throws LicenseError {
|
||||
if (!getAppUserModelID().equals("PointPlanck.FileBot")) {
|
||||
throw new LicenseError("Invalid container state");
|
||||
throw new LicenseError("Microsoft Store: Desktop Bridge not found");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
MacAppStore {
|
||||
|
||||
@Override
|
||||
public boolean isAppStore() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check() throws LicenseError {
|
||||
if (File.listRoots()[0].canRead()) {
|
||||
throw new LicenseError("Invalid container state");
|
||||
throw new LicenseError("Mac App Store: App Sandbox not found");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
PGPSignedMessage {
|
||||
|
||||
@Override
|
||||
public boolean isAppStore() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void check() throws LicenseError {
|
||||
try {
|
||||
@ -38,6 +53,8 @@ public enum LicenseModel {
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean isAppStore();
|
||||
|
||||
public abstract void check() throws LicenseError;
|
||||
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ public class Main {
|
||||
// CLI mode => run command-line interface and then exit
|
||||
if (args.runCLI()) {
|
||||
// just import and print license when running with --license option
|
||||
if (configureLicense(args)) {
|
||||
if (args.getLicenseFile() != null && !LICENSE.isAppStore()) {
|
||||
configureLicense(args);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -161,21 +162,13 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean configureLicense(ArgumentBean args) {
|
||||
File file = args.getLicenseFile();
|
||||
|
||||
if (file == null || LICENSE != LicenseModel.PGPSignedMessage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void configureLicense(ArgumentBean args) {
|
||||
try {
|
||||
License license = License.configure(file);
|
||||
License license = License.configure(args.getLicenseFile());
|
||||
log.info(license + " has been activated.");
|
||||
} catch (Throwable e) {
|
||||
log.severe("License Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void onStart(ArgumentBean args) throws Exception {
|
||||
@ -186,13 +179,13 @@ public class Main {
|
||||
}
|
||||
|
||||
// import license if launched with license file
|
||||
configureLicense(args);
|
||||
if (args.getLicenseFile() != null && !LICENSE.isAppStore()) {
|
||||
configureLicense(args);
|
||||
|
||||
if (LICENSE == LicenseModel.PGPSignedMessage) {
|
||||
try {
|
||||
LICENSE.check();
|
||||
} catch (Throwable e) {
|
||||
debug.finest(e::toString);
|
||||
log.severe("License Error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user