Skip to content

Commit 8d22070

Browse files
committed
Move to Code library for Android compatibility
1 parent 287f2bd commit 8d22070

File tree

7 files changed

+30
-17
lines changed

7 files changed

+30
-17
lines changed

.idea/artifacts/cryptolens_android_jar.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/cryptolens_jar.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@
2929
<artifactId>oshi-core</artifactId>
3030
<version>LATEST</version>
3131
</dependency>
32+
<dependency>
33+
<groupId>commons-codec</groupId>
34+
<artifactId>commons-codec</artifactId>
35+
<version>LATEST</version>
36+
</dependency>
3237
</dependencies>
3338
</project>

src/main/java/io/cryptolens/legacy/GsonResponseParser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ public Base64Response parseBase64Response(String response) {
8181

8282
if (resp.result != 0) { return new Base64Response(resp.message); }
8383

84-
Base64.Decoder decoder = Base64.getDecoder();
8584

86-
byte[] licenseKey = decoder.decode(resp.licenseKey);
87-
byte[] signature = decoder.decode(resp.signature);
85+
byte[] licenseKey = Shared.defaultBase64Decoder(resp.licenseKey);
86+
byte[] signature = Shared.defaultBase64Decoder(resp.signature);
8887

8988
return new Base64Response(licenseKey, signature);
9089
}

src/main/java/io/cryptolens/legacy/JavaSecuritySignatureVerifier.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import java.nio.*;
55
import java.nio.charset.*;
66
import java.net.*;
7-
import java.util.*;
87

9-
import javax.net.ssl.*;
108

119
import com.google.gson.*;
10+
import org.apache.commons.codec.binary.BaseNCodec;
1211

1312
import java.math.BigInteger;
1413
import java.security.*;
@@ -17,8 +16,8 @@
1716
import java.security.PrivateKey;
1817
import java.security.Signature;
1918
import java.security.spec.RSAPublicKeySpec;
20-
import java.util.Base64;
21-
import java.util.*;
19+
20+
2221
@Deprecated
2322
public class JavaSecuritySignatureVerifier {
2423
private BigInteger mod;
@@ -37,14 +36,11 @@ public boolean verify(byte[] message, byte[] signature) throws Exception {
3736
}
3837

3938
public void setExponentBase64(String exponent) {
40-
Base64.Decoder decoder = Base64.getDecoder();
41-
byte[] bytes = decoder.decode(exponent.getBytes());
42-
exp = new BigInteger(1, bytes);
39+
40+
exp = new BigInteger(1, Shared.defaultBase64Decoder(exponent));
4341
}
4442

4543
public void setModulusBase64(String modulus) {
46-
Base64.Decoder decoder = Base64.getDecoder();
47-
byte[] bytes = decoder.decode(modulus.getBytes());
48-
mod = new BigInteger(1, bytes);
44+
mod = new BigInteger(1, Shared.defaultBase64Decoder(modulus));
4945
}
5046
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.cryptolens.legacy;
2+
3+
import org.apache.commons.codec.binary.Base64;
4+
5+
public class Shared {
6+
7+
public static byte[] defaultBase64Decoder(String str) {
8+
9+
Base64 decoder = new Base64();
10+
return decoder.decode(str.getBytes());
11+
}
12+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import io.cryptolens.internal.ActivateResult;
55
import io.cryptolens.legacy.JavaSecuritySignatureVerifier;
6+
import io.cryptolens.legacy.Shared;
67
import io.cryptolens.methods.Helpers;
78

89
import java.nio.charset.StandardCharsets;
@@ -77,10 +78,8 @@ public static LicenseKey LoadFromString(String RSAPubKey, String licenseString,
7778

7879
ActivateResult result = new Gson().fromJson(licenseString, ActivateResult.class);
7980

80-
Base64.Decoder decoder = Base64.getDecoder();
81-
82-
byte[] licenseKey = decoder.decode(result.licenseKey);
83-
byte[] signature = decoder.decode(result.signature);
81+
byte[] licenseKey = Shared.defaultBase64Decoder(result.licenseKey);
82+
byte[] signature = Shared.defaultBase64Decoder(result.signature);
8483

8584
try {
8685

0 commit comments

Comments
 (0)