Skip to content

Commit

Permalink
Digicert fix (#95)
Browse files Browse the repository at this point in the history
Updated legacy authentication methods that do not comply with modern security standards.
  • Loading branch information
kpanugan-anet authored Dec 16, 2024
1 parent f66bfd3 commit cfd8de0
Show file tree
Hide file tree
Showing 34 changed files with 436 additions and 259 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To determine which processor you use, you can submit an API call to [getMerchant

# Setting Up Your Project

1. Confirm that you are using Android Studio 2.3+ with min Android SDK version 21 and Gradle 2.14.1.
1. Confirm that you are using Android Studio Koala with min Android SDK version 34 and Gradle 8.7.
2. Select *File > Open > sampleapp* to open the project.
3. Run Sync in Gradle to bring all the dependencies up to date.
4. Plug in the test reader and run the sample application.
Expand Down
Binary file modified emv-anet-sdk.aar
Binary file not shown.
Empty file modified sampleapp/app/.gitignore
100755 → 100644
Empty file.
46 changes: 29 additions & 17 deletions sampleapp/app/build.gradle
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
namespace "authorize.net.inperson_sdk_android"
compileSdk 34

defaultConfig {
applicationId "authorize.net.inperson_sdk_android"
minSdkVersion 21
targetSdkVersion 27
minSdkVersion 29
targetSdkVersion 34
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -21,21 +21,33 @@ android {
packagingOptions{
exclude 'META-INF/DEPENDENCIES'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':emv-anet-sdk')
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.madgag.spongycastle:prov:1.53.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('../emv-anet-sdk/emv-anet-sdk.aar')
// Remove old support library dependencies
// implementation 'com.android.support:cardview-v7:27.1.1'
// implementation 'com.android.support:appcompat-v7:27.1.1'
// implementation 'com.android.support:design:27.1.1'

// Add AndroidX equivalents
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.fragment:fragment:1.3.6'

implementation 'com.madgag.spongycastle:prov:1.53.0.0'
implementation 'org.apache.httpcomponents:httpcore:4.4.1'
implementation 'org.apache.httpcomponents:httpclient:4.5'
implementation 'com.google.code.gson:gson:2.8.8'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'junit:junit:4.12'
}
Empty file modified sampleapp/app/proguard-rules.pro
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package authorize.net.inperson_sdk_android;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.test.ApplicationTestCase;
import android.bluetooth.BluetoothDevice;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.util.Log;

import junit.framework.Assert;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import net.authorize.Environment;
import net.authorize.Merchant;
Expand All @@ -24,16 +22,17 @@
import net.authorize.mobile.Result;
import net.authorize.util.StringUtils;

import org.junit.Before;
import org.junit.runner.RunWith;

import java.math.BigDecimal;
import java.util.List;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}

@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
static final String TestLogTab = "INTestLogs";

EMVTransactionManager.QuickChipTransactionSessionListener iemvTransaction = new EMVTransactionManager.QuickChipTransactionSessionListener() {
Expand Down Expand Up @@ -66,13 +65,28 @@ public void onEMVReadError(EMVErrorCode emvError) {
public void onEMVTransactionError(net.authorize.aim.emv.Result result, EMVErrorCode emvError) {
assertTrue("this error case should be handled by client application", false);
}
};

@Override
protected void setUp() throws Exception {
super.setUp();
@Override
public void onReturnBluetoothDevices(List<BluetoothDevice> list) {
// Log the list of Bluetooth devices
for (BluetoothDevice device : list) {
Log.d(TestLogTab, "Bluetooth Device: " + device.getName() + " - " + device.getAddress());
}
}

@Override
public void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice) {
Log.d(TestLogTab, "Bluetooth Device Connected: " + bluetoothDevice.getName() + " - " + bluetoothDevice.getAddress());
}

@Override
public void onBluetoothDeviceDisConnected() {
Log.d(TestLogTab, "Bluetooth Device Disconnected");
}
};

@Before
protected void setUp() throws Exception {
//setup crendentials
PasswordAuthentication passAuth = PasswordAuthentication
.createMerchantAuthentication("MobileCNP1", "mPOSAnet2", "Android-Integration-tests");
Expand Down Expand Up @@ -133,16 +147,4 @@ EMVTransaction sampleEMVTransaction() {
return emvTransaction;

}







@Override
protected void tearDown() throws Exception {
super.tearDown();
terminateApplication();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package authorize.net.inperson_sdk_android;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;


import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -19,8 +21,7 @@ public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("authorize.net.inperson_sdk_android", appContext.getPackageName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.authorize.data.swiperdata.SwiperEncryptionAlgorithmType;
import net.authorize.data.swiperdata.SwiperModeType;
import net.authorize.util.StringUtils;
import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.authorize.data.Order;
import net.authorize.data.OrderItem;
import net.authorize.data.creditcard.CreditCard;
import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package authorize.net.inperson_sdk_android;

import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import net.authorize.aim.emv.EMVTransactionManager;

/**
* Created by yiwang on 1/12/17.
*/
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class QuickChipAuthOnlyTest extends QuickChipBaseTest {
public void testQuickChipAuthOnlyTest() throws InterruptedException{
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
EMVTransactionManager.startQuickChipTransaction(sampleEMVTransaction("7.1"), iemvTransaction, getActivity(), false, true);
}

@Rule
public ActivityScenarioRule<MainActivity> activityScenarioRule = new ActivityScenarioRule<>(MainActivity.class);

@Test
public void testQuickChipAuthOnly() throws InterruptedException {
activityScenarioRule.getScenario().onActivity(activity -> {
activity.runOnUiThread(() -> {
EMVTransactionManager.startQuickChipTransaction(sampleEMVTransaction("7.1"), iemvTransaction, activity, false, true);
});
});
semaphore.acquire();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package authorize.net.inperson_sdk_android;

import android.test.ActivityInstrumentationTestCase2;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.util.Log;

import net.authorize.Environment;
Expand All @@ -18,20 +19,29 @@
import net.authorize.data.mobile.MobileDevice;
import net.authorize.mobile.Result;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;

import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.Semaphore;

/**
* Created by yinghaowang on 12/29/16.
*/
@RunWith(AndroidJUnit4.class)
public class QuickChipBaseTest {

@Rule
public ActivityTestRule<MainActivity> activityTestRule = new ActivityTestRule<>(MainActivity.class);

public class QuickChipBaseTest extends ActivityInstrumentationTestCase2 {
public QuickChipBaseTest() {
super(MainActivity.class);
}
static final String TestLogTab = "INTestLogs";

Semaphore semaphore = new Semaphore(0);

EMVTransactionManager.QuickChipTransactionSessionListener iemvTransaction = new EMVTransactionManager.QuickChipTransactionSessionListener() {
@Override
public void onTransactionStatusUpdate(String transactionStatus) {
Expand All @@ -50,6 +60,27 @@ public void onPrepareQuickChipDataError(EMVErrorCode error, String cause) {
semaphore.release();
}

@Override
public void onReturnBluetoothDevices(List<BluetoothDevice> list) {
// Log the list of Bluetooth devices
for (BluetoothDevice device : list) {
Log.d(TestLogTab, "Bluetooth Device: " + device.getName() + " - " + device.getAddress());
}
semaphore.release();
}

@Override
public void onBluetoothDeviceConnected(BluetoothDevice bluetoothDevice) {
Log.d(TestLogTab, "Bluetooth Device Connected: " + bluetoothDevice.getName() + " - " + bluetoothDevice.getAddress());
semaphore.release();
}

@Override
public void onBluetoothDeviceDisConnected() {
Log.d(TestLogTab, "Bluetooth Device Disconnected");
semaphore.release();
}

@Override
public void onEMVTransactionSuccessful(net.authorize.aim.emv.Result result) {
updateSessionToken(result.getSessionToken());
Expand All @@ -68,35 +99,30 @@ public void onEMVTransactionError(net.authorize.aim.emv.Result result, EMVErrorC
assertTrue("this error case should be handled by client application", false);
semaphore.release();
}
};

};


@Override
protected void setUp() throws Exception {
super.setUp();

@Before
public void setUp() throws Exception {
EMVTransactionManager.playSoundAndShowBanner = false;
QuickChipSignatureReviewActivity2.isTestMode = true;
//setup crendentials
PasswordAuthentication passAuth = PasswordAuthentication
.createMerchantAuthentication("login", "password", "Android-Integration-tests");

PasswordAuthentication passAuth = PasswordAuthentication.createMerchantAuthentication(
"login", "password", "Android-Integration-tests");
AppManager.merchant = Merchant.createMerchant(Environment.SANDBOX, passAuth);

net.authorize.mobile.Transaction transaction = AppManager.merchant
.createMobileTransaction(net.authorize.mobile.TransactionType.MOBILE_DEVICE_LOGIN);
MobileDevice mobileDevice = MobileDevice.createMobileDevice("Android-Integration-tests",
"Device description", "425-555-0000", "Android");
MobileDevice mobileDevice = MobileDevice.createMobileDevice(
"Android-Integration-tests", "Device description", "425-555-0000", "Android");
transaction.setMobileDevice(mobileDevice);
Result result = (net.authorize.mobile.Result) AppManager.merchant
.postTransaction(transaction);
Result result = (net.authorize.mobile.Result) AppManager.merchant.postTransaction(transaction);

assertTrue("login should work", result.isOk());

SessionTokenAuthentication sessionTokenAuthentication = SessionTokenAuthentication
.createMerchantAuthentication(AppManager.merchant
.getMerchantAuthentication().getName(), result
.getSessionToken(), "Android-Integration-tests");
.getMerchantAuthentication().getName(), result.getSessionToken(), "Android-Integration-tests");
if ((result.getSessionToken() != null) && (sessionTokenAuthentication != null)) {
AppManager.merchant.setMerchantAuthentication(sessionTokenAuthentication);
}
Expand All @@ -111,11 +137,12 @@ void updateSessionToken(String newToken) {
}
}

@Test
public void testBase() {
assertTrue("merchant should have valid authentication field populated", AppManager.merchant.getMerchantAuthentication() != null);
assertTrue("merchant should have valid authentication field populated",
AppManager.merchant.getMerchantAuthentication() != null);
}


EMVTransaction sampleEMVTransaction(String value) {
Order order = Order.createOrder();
OrderItem oi = OrderItem.createOrderItem();
Expand All @@ -137,6 +164,5 @@ EMVTransaction sampleEMVTransaction(String value) {
emvTransaction.setSolutionID("SOLUTION ID");

return emvTransaction;

}
}
}
Loading

0 comments on commit cfd8de0

Please sign in to comment.