Skip to content

Commit 4732a3e

Browse files
Security and Bugfixes (#99)
1 parent 741e292 commit 4732a3e

File tree

14 files changed

+21
-50
lines changed

14 files changed

+21
-50
lines changed

emv-anet-sdk.aar

3.88 KB
Binary file not shown.

sampleapp/app/build.gradle

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66

77
defaultConfig {
88
applicationId "authorize.net.inperson_sdk_android"
9-
minSdkVersion 30
9+
minSdkVersion 33
1010
targetSdkVersion 34
1111
versionCode 2
1212
versionName "1.1"

sampleapp/app/proguard-rules.pro

100644100755
File mode changed.

sampleapp/app/src/androidTest/java/authorize/net/inperson_sdk_android/ExampleInstrumentedTest.java

100644100755
File mode changed.

sampleapp/app/src/main/AndroidManifest.xml

100644100755
File mode changed.

sampleapp/app/src/main/java/authorize/net/inperson_sdk_android/LoginActivity.java

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.authorize.aim.emv.EMVTransactionManager;
2727
import net.authorize.auth.PasswordAuthentication;
2828
import net.authorize.auth.SessionTokenAuthentication;
29+
import net.authorize.auth.TransactionKeyAuthentication;
2930
import net.authorize.data.Order;
3031
import net.authorize.data.OrderItem;
3132
import net.authorize.data.creditcard.CreditCard;
@@ -39,7 +40,7 @@
3940
public class LoginActivity extends FragmentActivity {
4041
Button b;
4142
EditText login;
42-
EditText pwd;
43+
EditText transactionKey;
4344
Context context;
4445
Environment environment = Environment.SANDBOX;
4546
RadioGroup radioGroup;
@@ -55,7 +56,7 @@ protected void onCreate(Bundle savedInstanceState) {
5556
b.setOnClickListener(mListner);
5657

5758
login = (EditText)findViewById(R.id.editTextLoginLoginID);
58-
pwd = (EditText)findViewById(R.id.editTextLoginPassword);
59+
transactionKey = (EditText)findViewById(R.id.editTextLoginPassword);
5960

6061
radioGroup = (RadioGroup) findViewById(R.id.login_type_radio_group);
6162
testButton = (RadioButton) findViewById(R.id.test_radio_button);
@@ -111,52 +112,22 @@ public void onClick(View view){
111112
@Override
112113
public void run(){
113114

114-
// handler.sendEmptyMessage(0);
115-
net.authorize.mobile.Result result;
116-
String deviceID = "Test EMV Android";
117-
PasswordAuthentication passAuth = PasswordAuthentication
118-
.createMerchantAuthentication(login.getText().toString(), pwd.getText().toString(), deviceID);
119-
120-
AppManager.merchant = Merchant.createMerchant(environment, passAuth);
121-
122-
net.authorize.mobile.Transaction transaction = AppManager.merchant
123-
.createMobileTransaction(net.authorize.mobile.TransactionType.MOBILE_DEVICE_LOGIN);
124-
MobileDevice mobileDevice = MobileDevice.createMobileDevice(deviceID,
125-
"Device description", "425-555-0000", "Android");
126-
transaction.setMobileDevice(mobileDevice);
127-
128-
Gson gson = new GsonBuilder().setPrettyPrinting().create();
129-
String transactionJson = gson.toJson(transaction);
130-
Log.d("LoginRequest", "Sending request: " + transactionJson);
131-
132-
result = (net.authorize.mobile.Result) AppManager.merchant
133-
.postTransaction(transaction);
134-
135-
// Log incoming response
136-
Log.d("LoginResponse", "Received response: " + result.getXmlResponse());
137-
138-
if(result.isOk()){
139-
140-
try {
141-
SessionTokenAuthentication sessionTokenAuthentication = SessionTokenAuthentication
142-
.createMerchantAuthentication(AppManager.merchant
143-
.getMerchantAuthentication().getName(), result
144-
.getSessionToken(), "Test EMV Android");
145-
if ((result.getSessionToken() != null)
146-
&& (sessionTokenAuthentication != null)) {
147-
AppManager.merchant
148-
.setMerchantAuthentication(sessionTokenAuthentication);
149-
150-
handler.sendEmptyMessage(0);
151-
}
152-
} catch (Exception ex) {
153-
Log.e("loginException", "Exception: " + ex.getMessage());
154-
}
155-
}
156-
else{
115+
try {
116+
// Use TransactionKeyAuthentication (no session token needed)
117+
TransactionKeyAuthentication merchantAuth = TransactionKeyAuthentication
118+
.createMerchantAuthentication(login.getText().toString(), transactionKey.getText().toString());
119+
120+
AppManager.merchant = Merchant.createMerchant(environment, merchantAuth);
121+
122+
Log.d("LoginInfo", "Using Transaction Key Authentication");
123+
124+
// Transaction key authentication doesn't require a login transaction
125+
// Authentication is validated on the first actual transaction
126+
handler.sendEmptyMessage(0);
127+
128+
} catch (Exception ex) {
129+
Log.e("loginException", "Exception: " + ex.getMessage());
157130
handler.sendEmptyMessage(1);
158-
Log.e("EMVResponse",result.getXmlResponse());
159-
// Toast.makeText(context, result.getXmlResponse(),Toast.LENGTH_SHORT).show();
160131
}
161132

162133
}

sampleapp/app/src/main/res/layout/login.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
android:layout_height="wrap_content"
2525
android:ems="10"
2626
android:textSize="22sp"
27-
android:hint="Login Id"
27+
android:hint="Login ID"
2828
android:textColor="@android:color/black"
2929
android:inputType="text"
3030

@@ -39,7 +39,7 @@
3939
android:ems="10"
4040
android:textSize="22sp"
4141

42-
android:hint="Password"
42+
android:hint="Transaction Key"
4343
android:inputType="textPassword"
4444

4545

sampleapp/app/src/test/java/authorize/net/inperson_sdk_android/ExampleUnitTest.java

100644100755
File mode changed.

sampleapp/emv-anet-sdk/build.gradle

100644100755
File mode changed.
-22.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)