Skip to content

Commit 18f92f3

Browse files
committed
Fix an error that could be thrown if license string is empty in LoadFromString
1 parent 4af249d commit 18f92f3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/io/cryptolens/models/LicenseKey.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ public static LicenseKey LoadFromString(String RSAPubKey, String licenseString)
7676
*/
7777
public static LicenseKey LoadFromString(String RSAPubKey, String licenseString, int signatureExpirationInterval) {
7878

79-
ActivateResult result = new Gson().fromJson(licenseString, ActivateResult.class);
80-
81-
byte[] licenseKey = Shared.defaultBase64Decoder(result.licenseKey);
82-
byte[] signature = Shared.defaultBase64Decoder(result.signature);
79+
ActivateResult result = null;
80+
byte[] licenseKey;
81+
byte[] signature;
82+
try{
83+
result = new Gson().fromJson(licenseString, ActivateResult.class);
84+
licenseKey = Shared.defaultBase64Decoder(result.licenseKey);
85+
signature = Shared.defaultBase64Decoder(result.signature);
86+
} catch (Exception ex) {
87+
System.err.println(ex.getStackTrace()); return null;
88+
}
8389

8490
try {
8591

0 commit comments

Comments
 (0)