diff --git a/source/net/filebot/License.java b/source/net/filebot/License.java index 92184cce..9737b761 100644 --- a/source/net/filebot/License.java +++ b/source/net/filebot/License.java @@ -44,7 +44,7 @@ public class License implements Serializable { try { // read and verify license file if (!file.exists()) { - throw new FileNotFoundException("License not found"); + throw new FileNotFoundException("UNREGISTERED"); } byte[] bytes = Files.readAllBytes(file.toPath()); @@ -109,14 +109,16 @@ public class License implements Serializable { } } - public void check() throws Exception { + public License check() throws Exception { if (error != null) { throw error; } if (Instant.now().isAfter(expires)) { - throw new IllegalStateException("Expired: " + toString()); + throw new IllegalStateException("EXPIRED: " + toString()); } + + return this; } @Override @@ -131,8 +133,7 @@ public class License implements Serializable { // lock memoized resource while validating and setting a new license synchronized (INSTANCE) { // check if license file is valid and not expired - License license = new License(file); - license.check(); + License license = new License(file).check(); // write to default license file path Files.copy(file.toPath(), FILE.get().toPath(), StandardCopyOption.REPLACE_EXISTING); diff --git a/source/net/filebot/LicenseModel.java b/source/net/filebot/LicenseModel.java index 4ba6cd4f..4fde1124 100644 --- a/source/net/filebot/LicenseModel.java +++ b/source/net/filebot/LicenseModel.java @@ -11,14 +11,16 @@ public enum LicenseModel { private final Resource CHECK = Resource.lazy(() -> !getAppUserModelID().equals("PointPlanck.FileBot")); @Override - public void check() throws LicenseError { + public Object check() throws LicenseError { try { if (CHECK.get()) { - throw new LicenseError("Microsoft Store: Desktop Bridge not found"); + throw new LicenseError("Desktop Bridge not found"); } } catch (Exception e) { throw new IllegalStateException(e); } + + return "Microsoft Store License"; } }, @@ -27,23 +29,25 @@ public enum LicenseModel { private final Resource CHECK = Resource.lazy(() -> !File.listRoots()[0].canRead()); @Override - public void check() throws LicenseError { + public Object check() throws LicenseError { try { if (CHECK.get()) { - throw new LicenseError("Microsoft Store: Desktop Bridge not found"); + throw new LicenseError("Mac App Sandbox not found"); } } catch (Exception e) { throw new IllegalStateException(e); } + + return "Mac App Store License"; } }, PGPSignedMessage { @Override - public void check() throws LicenseError { + public License check() throws LicenseError { try { - License.INSTANCE.get().check(); + return License.INSTANCE.get().check(); } catch (Exception e) { throw new LicenseError(e.getMessage()); } @@ -54,6 +58,6 @@ public enum LicenseModel { return this == PGPSignedMessage; } - public abstract void check() throws LicenseError; + public abstract Object check() throws LicenseError; }