Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dx 1018 #63

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Or,

To add the Contentstack Android SDK to your existing project manually, perform the steps given below:

1. [Download the Android SDK](https://docs.contentstack.com/platforms/android/android_sdk_latest)
1. [Download the Android SDK](https://github.com/contentstack/contentstack-android/archive/refs/heads/master.zip)
and extract the ZIP file to your local disk.
2. Add references/dependencies using Eclipse/Android Studio:

Expand Down
19 changes: 17 additions & 2 deletions contentstack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,25 @@ dependencies {
implementation 'com.github.rjeschke:txtmark:0.12'
// // Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson'
// // OkHttp
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
implementation 'com.squareup.okhttp3:okhttp'
// implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3'

constraints {
implementation('com.squareup.retrofit2:converter-gson:2.9.0') {
because 'gson 2.8.5 used by retrofit has a vulnerability'
}
implementation('com.google.code.gson:[email protected]') {
because 'gson 2.8.5 used by retrofit has a vulnerability'
}
implementation('com.squareup.okhttp3:okhttp:4.9.3') {
because 'kotlin stdlib 1.4.10 used by okhttp has a vulnerability'
}
implementation('org.jetbrains.kotlin:[email protected]') {
because 'kotlin stdlib 1.4.10 used by okhttp has a vulnerability'
}
}
}
tasks.register('clearJar', Delete) { delete 'build/libs/contentstack.jar' }
tasks.register('unzip', Copy) {
Expand Down
4 changes: 2 additions & 2 deletions contentstack/src/main/java/com/contentstack/sdk/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ public void fetch(FetchResultCallback callback) {
urlQueries.put("environment", headers.get("environment"));
}
String mainStringForMD5 = urlEndpoint + new JSONObject().toString() + headers.toString();
String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value);
String shaValue = new SDKUtil().getSHAFromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + shaValue);

switch (cachePolicyForCall) {
case IGNORE_CACHE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public void fetchAll(FetchAssetsCallback assetsCallback) {
urlQueries.put("environment", headers.get("environment"));
}
String mainStringForMD5 = URL + new JSONObject().toString() + headers.toString();
String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value);
String shaValue = new SDKUtil().getSHAFromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + shaValue);
switch (cachePolicyForCall) {
case IGNORE_CACHE:
fetchFromNetwork(URL, urlQueries, headers, cacheFile.getPath(), assetsCallback);
Expand Down
4 changes: 2 additions & 2 deletions contentstack/src/main/java/com/contentstack/sdk/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,9 @@ public void fetch(EntryResultCallBack callBack) {
}

String mainStringForMD5 = URL + new JSONObject().toString() + headerAll.toString();
String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim());
String shaValue = new SDKUtil().getSHAFromString(mainStringForMD5.trim());

File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value);
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + shaValue);


switch (cachePolicyForCall) {
Expand Down
4 changes: 2 additions & 2 deletions contentstack/src/main/java/com/contentstack/sdk/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,8 @@ protected void execQuery(SingleQueryResultCallback callBack, QueryResultsCallBac
mainJSON.put("query", urlQueries);
mainJSON.put("_method", SDKConstant.RequestMethod.GET.toString());
String mainStringForMD5 = URL + mainJSON.toString() + headers.toString();
String md5Value = new SDKUtil().getMD5FromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + md5Value);
String shaValue = new SDKUtil().getSHAFromString(mainStringForMD5.trim());
File cacheFile = new File(SDKConstant.cacheFolderName + File.separator + shaValue);
CachePolicy cachePolicy = CachePolicy.NETWORK_ONLY;//contentTypeInstance.stackInstance.globalCachePolicyForCall;
if (cachePolicyForCall != null) {
cachePolicy = cachePolicyForCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ public static JSONObject getJsonFromCacheFile(File file) {
* To encrypt given value.
*
* @param value string
* @return MD5 value
* @return SHA-256 value
*/
public String getMD5FromString(String value) {
public String getSHAFromString(String value) {
String output;
output = value.toString().trim();
if (value.length() > 0) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
MessageDigest digest = java.security.MessageDigest.getInstance("SHA-256");
digest.reset();
digest.update(output.getBytes());
byte messageDigest[] = digest.digest();
Expand Down
Loading