mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-09 22:09:47 -04:00
Experiment with PGP signed messages
This commit is contained in:
parent
1a37442bf7
commit
c0544c101a
@ -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);
|
||||
|
@ -11,14 +11,16 @@ public enum LicenseModel {
|
||||
private final Resource<Boolean> 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<Boolean> 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;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user