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
1a37442bf7
commit
c0544c101a
@ -44,7 +44,7 @@ public class License implements Serializable {
|
|||||||
try {
|
try {
|
||||||
// read and verify license file
|
// read and verify license file
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new FileNotFoundException("License not found");
|
throw new FileNotFoundException("UNREGISTERED");
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Files.readAllBytes(file.toPath());
|
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) {
|
if (error != null) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Instant.now().isAfter(expires)) {
|
if (Instant.now().isAfter(expires)) {
|
||||||
throw new IllegalStateException("Expired: " + toString());
|
throw new IllegalStateException("EXPIRED: " + toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -131,8 +133,7 @@ public class License implements Serializable {
|
|||||||
// lock memoized resource while validating and setting a new license
|
// lock memoized resource while validating and setting a new license
|
||||||
synchronized (INSTANCE) {
|
synchronized (INSTANCE) {
|
||||||
// check if license file is valid and not expired
|
// check if license file is valid and not expired
|
||||||
License license = new License(file);
|
License license = new License(file).check();
|
||||||
license.check();
|
|
||||||
|
|
||||||
// write to default license file path
|
// write to default license file path
|
||||||
Files.copy(file.toPath(), FILE.get().toPath(), StandardCopyOption.REPLACE_EXISTING);
|
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"));
|
private final Resource<Boolean> CHECK = Resource.lazy(() -> !getAppUserModelID().equals("PointPlanck.FileBot"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void check() throws LicenseError {
|
public Object check() throws LicenseError {
|
||||||
try {
|
try {
|
||||||
if (CHECK.get()) {
|
if (CHECK.get()) {
|
||||||
throw new LicenseError("Microsoft Store: Desktop Bridge not found");
|
throw new LicenseError("Desktop Bridge not found");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(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());
|
private final Resource<Boolean> CHECK = Resource.lazy(() -> !File.listRoots()[0].canRead());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void check() throws LicenseError {
|
public Object check() throws LicenseError {
|
||||||
try {
|
try {
|
||||||
if (CHECK.get()) {
|
if (CHECK.get()) {
|
||||||
throw new LicenseError("Microsoft Store: Desktop Bridge not found");
|
throw new LicenseError("Mac App Sandbox not found");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "Mac App Store License";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
PGPSignedMessage {
|
PGPSignedMessage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void check() throws LicenseError {
|
public License check() throws LicenseError {
|
||||||
try {
|
try {
|
||||||
License.INSTANCE.get().check();
|
return License.INSTANCE.get().check();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new LicenseError(e.getMessage());
|
throw new LicenseError(e.getMessage());
|
||||||
}
|
}
|
||||||
@ -54,6 +58,6 @@ public enum LicenseModel {
|
|||||||
return this == PGPSignedMessage;
|
return this == PGPSignedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void check() throws LicenseError;
|
public abstract Object check() throws LicenseError;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user