diff --git a/app/build.gradle b/app/build.gradle index 16a79f31..9c623e9a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,10 +4,11 @@ android { compileSdkVersion 27 defaultConfig { applicationId "com.flutterwave.rave_android" - minSdkVersion 15 + minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" + multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/raveandroid/build.gradle b/raveandroid/build.gradle index b7f8c0cb..baaac823 100644 --- a/raveandroid/build.gradle +++ b/raveandroid/build.gradle @@ -6,13 +6,13 @@ android { compileSdkVersion 27 defaultConfig { - minSdkVersion 15 + minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0.43" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - + multiDexEnabled true } buildTypes { release { @@ -28,6 +28,7 @@ android { lintOptions { abortOnError false } + } dependencies { @@ -45,6 +46,7 @@ dependencies { implementation 'org.parceler:parceler-api:1.1.9' annotationProcessor 'org.parceler:parceler:1.1.9' implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' + implementation 'com.babylon.certificatetransparency:certificatetransparency-android:0.2.0' implementation 'com.scottyab:aescrypt:0.0.1' testImplementation 'junit:junit:4.12' // dagger 2 diff --git a/raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java b/raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java index 5fac6b8a..63fc98e3 100644 --- a/raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java +++ b/raveandroid/src/main/java/com/flutterwave/raveandroid/Utils.java @@ -14,13 +14,8 @@ import com.scottyab.aescrypt.AESCrypt; import java.lang.reflect.Type; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.MessageDigest; -import java.security.PublicKey; -import java.security.spec.X509EncodedKeySpec; import java.util.List; import javax.crypto.Cipher; @@ -34,10 +29,6 @@ public class Utils { private static final String ALGORITHM = "DESede"; private static final String TRANSFORMATION = "DESede/ECB/PKCS5Padding"; - private static final String TARGET = "FLWSECK-"; - private static final String MD5 = "MD5"; - private static final String CHARSET_NAME = "UTF-8"; - private static final String UTF_8 = "utf-8"; public static String getDeviceId(Context c) { return Settings.Secure.getString(c.getContentResolver(), Settings.Secure.ANDROID_ID); @@ -106,33 +97,6 @@ public static String stringifySubaccounts(List subAccounts) { return gson.toJson(subAccounts, type); } - public static byte[] RSAEncrypt(String plaintext) { - PublicKey key = getKey("baA/RgjURU3I0uqH3iRos3NbE8fT+lP8SDXKymsnfdPrMQAEoMBuXtoaQiJ1i5tuBG9EgSEOH1LAZEaAsvwClw=="); - byte[] ciphertext = null; - try { - Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPPadding"); - cipher.init(Cipher.ENCRYPT_MODE, key); - ciphertext = cipher.doFinal(plaintext.getBytes()); - } catch (Exception e) { - e.printStackTrace(); - } - return ciphertext; - } - - public static PublicKey getKey(String key) { - try { - byte[] byteKey = Base64.decode(key.getBytes(Charset.forName("UTF-16")), Base64.DEFAULT); - X509EncodedKeySpec X509publicKey = new X509EncodedKeySpec(byteKey); - KeyFactory kf = KeyFactory.getInstance("RSA"); - - return kf.generatePublic(X509publicKey); - } catch (Exception e) { - e.printStackTrace(); - } - - return null; - } - public static String getEncryptedData(String unEncryptedString, String encryptionKey) { if (unEncryptedString != null && encryptionKey != null) { @@ -178,16 +142,6 @@ private static String encrypt(String data, String key) throws Exception { } - private static String getMd5(String md5) throws Exception { - MessageDigest md = MessageDigest.getInstance(MD5); - byte[] array = md.digest(md5.getBytes(CHARSET_NAME)); - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < array.length; ++i) { - sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100), 1, 3); - } - return sb.toString(); - } - public static String obfuscateCardNumber(String first6, String last4) { int cardNoLength = first6.length() + last4.length(); diff --git a/raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java b/raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java index 77253248..0f25631f 100644 --- a/raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java +++ b/raveandroid/src/main/java/com/flutterwave/raveandroid/card/CardFragment.java @@ -291,13 +291,14 @@ public void showProgressIndicator(boolean active) { progessDialog = new ProgressDialog(getActivity()); progessDialog.setCanceledOnTouchOutside(false); progessDialog.setMessage(getResources().getString(R.string.wait)); + if (active && !progessDialog.isShowing()) { + progessDialog.show(); + } else { + progessDialog.dismiss(); + } } - if (active && !progessDialog.isShowing()) { - progessDialog.show(); - } else { - progessDialog.dismiss(); - } + } catch (NullPointerException e) { e.printStackTrace(); } diff --git a/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/EventLoggerModule.java b/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/EventLoggerModule.java index 73c205a2..56d62273 100644 --- a/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/EventLoggerModule.java +++ b/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/EventLoggerModule.java @@ -1,5 +1,7 @@ package com.flutterwave.raveandroid.di.modules; +import com.babylon.certificatetransparency.BasicAndroidCTLogger; +import com.babylon.certificatetransparency.CTInterceptorBuilder; import com.flutterwave.raveandroid.data.EventLoggerService; import java.util.concurrent.TimeUnit; @@ -40,7 +42,17 @@ public Retrofit providesRetrofit() { logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); - OkHttpClient okHttpClient = httpClient.addNetworkInterceptor(logging).connectTimeout(60, TimeUnit.SECONDS) + + CTInterceptorBuilder ctInterceptorBuilder = new CTInterceptorBuilder(); + BasicAndroidCTLogger basicAndroidCTLogger = new BasicAndroidCTLogger(true); + ctInterceptorBuilder.includeHost("ravesandboxapi.flutterwave.com") + .includeHost("ravesandboxapi.flutterwave.com") + .includeHost("rave-webhook.herokuapp.com/receivepayment") + .includeHost("kgelfdz7mf.execute-api.us-east-1.amazonaws.com/") + .includeHost("api.ravepay.co"); + ctInterceptorBuilder.setLogger(basicAndroidCTLogger); + + OkHttpClient okHttpClient = httpClient.addNetworkInterceptor(ctInterceptorBuilder.build()).addNetworkInterceptor(logging).connectTimeout(60, TimeUnit.SECONDS) .readTimeout(60, TimeUnit.SECONDS) .writeTimeout(60, TimeUnit.SECONDS).build(); diff --git a/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/NetworkModule.java b/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/NetworkModule.java index 67339125..987b3127 100644 --- a/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/NetworkModule.java +++ b/raveandroid/src/main/java/com/flutterwave/raveandroid/di/modules/NetworkModule.java @@ -1,5 +1,7 @@ package com.flutterwave.raveandroid.di.modules; +import com.babylon.certificatetransparency.BasicAndroidCTLogger; +import com.babylon.certificatetransparency.CTInterceptorBuilder; import com.flutterwave.raveandroid.data.ApiService; import com.google.gson.Gson; @@ -43,7 +45,16 @@ public Retrofit providesRetrofit() { logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); - OkHttpClient okHttpClient = httpClient.addNetworkInterceptor(logging).connectTimeout(60, TimeUnit.SECONDS) + + CTInterceptorBuilder ctInterceptorBuilder = new CTInterceptorBuilder(); + BasicAndroidCTLogger basicAndroidCTLogger = new BasicAndroidCTLogger(true); + ctInterceptorBuilder.includeHost("ravesandboxapi.flutterwave.com") + .includeHost("rave-webhook.herokuapp.com/receivepayment") + .includeHost("kgelfdz7mf.execute-api.us-east-1.amazonaws.com/") + .includeHost("api.ravepay.co"); + ctInterceptorBuilder.setLogger(basicAndroidCTLogger); + + OkHttpClient okHttpClient = httpClient.addNetworkInterceptor(ctInterceptorBuilder.build()).addNetworkInterceptor(logging).connectTimeout(60, TimeUnit.SECONDS) .readTimeout(60, TimeUnit.SECONDS) .writeTimeout(60, TimeUnit.SECONDS).build();