Skip to content

Commit 1421c48

Browse files
authored
Merge pull request #5 from getyoti/ED-714
[ED-714]Remove CustomCertificate class and functionality
2 parents 67eccf7 + e69bb61 commit 1421c48

File tree

7 files changed

+6
-169
lines changed

7 files changed

+6
-169
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ supportLibraryVersion=25.3.1
3232
libJunitVersion=4.12
3333
libMockitoVersion=1.10.19
3434

35-
currentVersion=0.0.6
36-
currentVersionCode=000006
35+
currentVersion=1.0.0
36+
currentVersionCode=000007
3737
currentAppName=Mobile Button SDK
3838
artefactName=yoti-button-sdk
3939

sample-app/src/main/java/com/yoti/mobile/android/sdk/sampleapp/SampleApp.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import com.yoti.mobile.android.sdk.YotiSDK;
77
import com.yoti.mobile.android.sdk.exceptions.YotiSDKNotValidScenarioException;
8-
import com.yoti.mobile.android.sdk.model.CustomCertificate;
98
import com.yoti.mobile.android.sdk.model.Scenario;
109

1110
import static android.content.ContentValues.TAG;
@@ -16,20 +15,13 @@ public class SampleApp extends Application {
1615
public void onCreate() {
1716
super.onCreate();
1817

19-
CustomCertificate customCertificate = new CustomCertificate();
20-
customCertificate.setCertificateResourceId(R.raw.certificate);
21-
customCertificate.setAlias("test");
22-
customCertificate.setPassword("test123");
23-
customCertificate.setStoreName("TEST");
24-
2518
try {
2619
Scenario scenario = new Scenario.Builder()
2720
.setUseCaseId("get_user_phone_1")
2821
.setClientSDKId("d10b19d3-fa50-48ab-bd8c-f5a099205e6c")
2922
.setScenarioId("17807359-a933-4b77-baa2-3c2fdb5608f2")
3023
.setCallbackAction("com.test.app.YOTI_CALLBACK")
3124
.setBackendCallbackAction("com.test.app.BACKEND_CALLBACK")
32-
.setCustomCertificate(customCertificate)
3325
.create();
3426

3527
YotiSDK.addScenario(scenario);

sample-app/src/main/res/raw/certificate.pem

Lines changed: 0 additions & 22 deletions
This file was deleted.

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/kernelSDK/KernelSDK.java

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,27 @@
11
package com.yoti.mobile.android.sdk.kernelSDK;
22

3-
import android.content.Context;
43
import android.support.annotation.NonNull;
54

65
import com.yoti.mobile.android.sdk.YotiSDKLogger;
7-
import com.yoti.mobile.android.sdk.model.CustomCertificate;
86
import com.yoti.mobile.android.sdk.model.Scenario;
97

108
import java.io.ByteArrayOutputStream;
119
import java.io.IOException;
1210
import java.io.InputStream;
1311
import java.net.URL;
14-
import java.security.KeyManagementException;
15-
import java.security.KeyStore;
16-
import java.security.KeyStoreException;
17-
import java.security.NoSuchAlgorithmException;
18-
import java.security.cert.CertificateException;
1912

2013
import javax.net.ssl.HttpsURLConnection;
21-
import javax.net.ssl.SSLContext;
22-
import javax.net.ssl.SSLSocketFactory;
23-
import javax.net.ssl.TrustManagerFactory;
2414

2515
public class KernelSDK {
2616

27-
private final Context mContext;
28-
private final CertificateManager mCertMgr;
29-
30-
public KernelSDK(Context context) {
31-
mContext = context;
32-
33-
mCertMgr = new CertificateManager(mContext);
34-
}
35-
3617
/**
3718
* Will make a call to the Yoti Connect API to retrieve the Uri for the provided Scenario
3819
*
3920
* @param currentScenario
4021
* @return the uri of the provided scenario to forward to the Yoti app
41-
* @throws CertificateException
42-
* @throws NoSuchAlgorithmException
43-
* @throws KeyStoreException
44-
* @throws KeyManagementException
4522
* @throws IOException
4623
*/
47-
public String retrieveScenarioUri(Scenario currentScenario) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
24+
public String retrieveScenarioUri(Scenario currentScenario) throws IOException {
4825

4926
URL url = new URL(String.format(EnvironmentConfiguration.GET_QR_CODE_URL, currentScenario.getClientSDKId(), currentScenario.getScenarioId()));
5027

@@ -66,21 +43,10 @@ public String retrieveScenarioUri(Scenario currentScenario) throws CertificateEx
6643
public void processShareResult(@NonNull Scenario currentScenario, @NonNull ICallbackBackendListener listener) {
6744

6845
try {
69-
7046
URL url = new URL(currentScenario.getCallbackBackendUrl());
7147

72-
CustomCertificate certificate = currentScenario.getCustomCertificate();
7348
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
7449

75-
if (certificate != null) {
76-
mCertMgr.storeCrt(certificate.getCertificateResourceId(),
77-
certificate.getStoreName(),
78-
certificate.getPassword(),
79-
certificate.getAlias());
80-
81-
urlConnection.setSSLSocketFactory(getSslSocketFactory(certificate.getStoreName(), certificate.getPassword()));
82-
}
83-
8450
int statusCode = urlConnection.getResponseCode();
8551

8652
byte[] response = getBytes(urlConnection);
@@ -95,7 +61,7 @@ public void processShareResult(@NonNull Scenario currentScenario, @NonNull ICall
9561
YotiSDKLogger.warning("ICallbackBackendListener is null");
9662
}
9763

98-
} catch (IOException | CertificateException | NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
64+
} catch (IOException e) {
9965
if (listener != null) {
10066
listener.onError(-1, e, null);
10167
} else {
@@ -104,36 +70,6 @@ public void processShareResult(@NonNull Scenario currentScenario, @NonNull ICall
10470
}
10571
}
10672

107-
/**
108-
* return a SSlSocketFactory for the provided store name
109-
*
110-
* @param storeName
111-
* @param storePassword
112-
* @return
113-
* @throws KeyStoreException
114-
* @throws IOException
115-
* @throws NoSuchAlgorithmException
116-
* @throws CertificateException
117-
* @throws KeyManagementException
118-
*/
119-
private SSLSocketFactory getSslSocketFactory(String storeName, String storePassword) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException {
120-
121-
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
122-
InputStream fos = mCertMgr.getKeyStoreAr(storeName);
123-
keyStore.load(fos, storePassword.toCharArray());
124-
125-
// Create a TrustManager that trusts the CAs in our KeyStore
126-
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
127-
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
128-
tmf.init(keyStore);
129-
130-
// Create an SSLContext that uses our TrustManager
131-
SSLContext sslContext = SSLContext.getInstance("TLS");
132-
sslContext.init(null, tmf.getTrustManagers(), null);
133-
134-
return sslContext.getSocketFactory();
135-
}
136-
13773
/**
13874
* read bytes from a UrlConnection
13975
*

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/kernelSDK/KernelSDKIntentService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public KernelSDKIntentService() {
4949
@Override
5050
public void onCreate() {
5151
super.onCreate();
52-
mKernelSDK = new KernelSDK(this);
52+
mKernelSDK = new KernelSDK();
5353
}
5454

5555
/**
@@ -102,7 +102,7 @@ private void handleActionStartScenario(String useCaseId, ResultReceiver resultRe
102102
String qrCodeUrl = null;
103103
try {
104104
qrCodeUrl = mKernelSDK.retrieveScenarioUri(currentScenario);
105-
} catch (CertificateException | NoSuchAlgorithmException | KeyManagementException | KeyStoreException | IOException e) {
105+
} catch (IOException e) {
106106
YotiSDKLogger.error("Error while reaching Connect API", e);
107107
}
108108

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/model/CustomCertificate.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

yoti-sdk/src/main/java/com/yoti/mobile/android/sdk/model/Scenario.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class Scenario {
1919
private String callbackAction;
2020
private String qrCodeUrl;
2121
private String callbackBackendAction;
22-
private CustomCertificate customCertificate;
2322
private String callbackBackendUrl;
2423

2524
public String getUseCaseId() {
@@ -70,14 +69,6 @@ public void setCallbackBackendAction(String callbackBackendAction) {
7069
this.callbackBackendAction = callbackBackendAction;
7170
}
7271

73-
public CustomCertificate getCustomCertificate() {
74-
return customCertificate;
75-
}
76-
77-
public void setCustomCertificate(CustomCertificate customCertificate) {
78-
this.customCertificate = customCertificate;
79-
}
80-
8172
public String getCallbackBackendUrl() {
8273
return callbackBackendUrl;
8374
}
@@ -131,13 +122,6 @@ public Builder setCallbackAction(String action) {
131122
return this;
132123
}
133124

134-
public Builder setCustomCertificate(CustomCertificate customCertificate) {
135-
if (customCertificate.isValid()) {
136-
mScenario.setCustomCertificate(customCertificate);
137-
}
138-
return this;
139-
}
140-
141125
public Scenario create() {
142126
return mScenario;
143127
}

0 commit comments

Comments
 (0)