Compare commits

..

No commits in common. "936444f162b101bc9c3df98e48d6eaf45112d123" and "a6e59c3d275a0fa4f956a98f68d03a529d0ee837" have entirely different histories.

4 changed files with 33 additions and 21 deletions

View file

@ -74,6 +74,7 @@ internal class DownloadProfileWorker(
)
authenticatingPhaseWorker.initiateAuthentication(
initialAuthenticationKeys,
matchingId,
imei
)
downloadAndInstallProfilePackage(

View file

@ -39,10 +39,6 @@ class ApduTransmitter(private val apduChannel: ApduChannel) {
)
}
if (apduResponse.length < 4) {
throw RuntimeException("APDU response should at least contain a status code")
}
// Last 2 bytes are the status code (should be 0x9000)
// TODO: Do this properly
return apduResponse.substring(0, apduResponse.length - 4)
@ -61,10 +57,6 @@ class ApduTransmitter(private val apduChannel: ApduChannel) {
)
}
if (apduResponse.length < 4) {
throw RuntimeException("APDU response should at least contain a status code")
}
// Last 2 bytes are the status code (should be 0x9000)
// TODO: Do this properly
return apduResponse.substring(0, apduResponse.length - 4)

View file

@ -125,7 +125,7 @@ public class AuthenticatingPhaseWorker {
}
}
public void initiateAuthentication(InitialAuthenticationKeys initialAuthenticationKeys, String imei) {
public void initiateAuthentication(InitialAuthenticationKeys initialAuthenticationKeys, String matchingId, String imei) {
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATE_AUTHENTICATION, "initiateAuthentication retrieving...");
@ -141,14 +141,14 @@ public class AuthenticatingPhaseWorker {
setServerCertificate(initialAuthenticationKeys, initiateAuthenticationResp);
setTransactionId(initialAuthenticationKeys, initiateAuthenticationResp);
setMatchingId(initialAuthenticationKeys);
setCtxParams1(initialAuthenticationKeys, imei);
setCtxParams1(initialAuthenticationKeys, matchingId, imei);
progress.stepExecuted(DOWNLOAD_PROFILE_INITIATED_AUTHENTICATION, "initiateAuthentication initiated...");
}
private void setCtxParams1(InitialAuthenticationKeys initialAuthenticationKeys, String imei) {
private void setCtxParams1(InitialAuthenticationKeys initialAuthenticationKeys, String matchingId, String imei) {
initialAuthenticationKeys.setCtxParams1(ApduUtils.generateCtxParams1(initialAuthenticationKeys.getMatchingId(), imei));
initialAuthenticationKeys.setCtxParams1(ApduUtils.generateCtxParams1(matchingId, imei));
if (LogStub.getInstance().isDebugEnabled()) {
LogStub.getInstance().logDebug(LOG, LogStub.getInstance().getTag() + " - ctxParams1: " + initialAuthenticationKeys.getCtxParams1());

View file

@ -98,8 +98,10 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (StringUtils.isNotBlank(profileInstallationResult) && profileInstallationResult.length() > 4) {
checkProfileInstallationResult(profileInstallationResult);
} else {
throw new RuntimeException("Unexpected response on loadBoundProfilePackage");
}
}
@ -110,8 +112,12 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
if (profileInstallationResult.compareTo("9000") != 0) {
if (StringUtils.isNotBlank(profileInstallationResult) && profileInstallationResult.length() > 4) {
checkProfileInstallationResult(profileInstallationResult);
} else {
throw new RuntimeException("Unexpected response on loadStoreMetadata");
}
}
}
@ -122,8 +128,12 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
if (profileInstallationResult.compareTo("9000") != 0) {
if (StringUtils.isNotBlank(profileInstallationResult) && profileInstallationResult.length() > 4) {
checkProfileInstallationResult(profileInstallationResult);
} else {
throw new RuntimeException("Unexpected response on loadConfigureIsdpa");
}
}
}
@ -134,8 +144,12 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
if (profileInstallationResult.compareTo("9000") != 0) {
if (StringUtils.isNotBlank(profileInstallationResult) && profileInstallationResult.length() > 4) {
checkProfileInstallationResult(profileInstallationResult);
} else {
throw new RuntimeException("Unexpected response on loadInitialiseSecureChannel");
}
}
}
@ -223,8 +237,13 @@ public class InstallationPhaseWorker {
"loadReplaceSessionsKeys...");
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
if (profileInstallationResult.compareTo("9000") != 0) {
if (StringUtils.isNotBlank(profileInstallationResult) && profileInstallationResult.length() > 4) {
checkProfileInstallationResult(profileInstallationResult);
} else {
throw new RuntimeException("Unexpected response on loadReplaceSessionsKeys");
}
}
}
}