Remove dependency on apache commons-lang3

This commit is contained in:
Peter Cai 2022-07-10 16:49:54 -04:00
parent a21f438ebd
commit 9ee8f8878b
9 changed files with 37 additions and 23 deletions

View File

@ -9,7 +9,6 @@ dependencies {
tool 'javax.xml.bind:jaxb-api:2.3.0'
tool 'com.beanit:asn1bean-compiler:1.13.0'
implementation 'com.beanit:asn1bean:1.13.0'
implementation 'org.apache.commons:commons-lang3:3.7'
implementation 'commons-codec:commons-codec:1.11'
implementation 'com.google.code.gson:gson:2.8.4'
testImplementation 'junit:junit:4.12'

View File

@ -3,8 +3,6 @@ package com.truphone.es9plus;
import com.truphone.util.LogStub;
import com.truphone.util.TextUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@ -57,7 +55,7 @@ public class HttpRSPClient {
StringBuilder endpoint = new StringBuilder(rspServerUrl);
HttpResponse httpResponse = new HttpResponse();
if (StringUtils.isNotBlank(url)) {
if (TextUtil.isNotBlank(url)) {
endpoint.append(url);
}

View File

@ -1,6 +1,6 @@
package com.truphone.lpa.apdu;
import org.apache.commons.lang3.StringUtils;
import com.truphone.util.TextUtil;
import com.truphone.util.ToTLV;
import com.truphone.util.Tools;
@ -135,7 +135,7 @@ public class ApduUtils {
public static String listNotificationApdu(String notificationType) {
String data;
if (StringUtils.isNotBlank(notificationType)) {
if (TextUtil.isNotBlank(notificationType)) {
data = ToTLV.toTLV("BF28", ToTLV.toTLV("81", "04" + notificationType));
} else {
data = ToTLV.toTLV("BF28", "");
@ -156,7 +156,7 @@ public class ApduUtils {
public static String getProfilesInfoApdu(String isdp1) {
String searchCriteria = "";
if (!StringUtils.isEmpty(isdp1)) {
if (TextUtil.isNotEmpty(isdp1)) {
searchCriteria = ToTLV.toTLV("A0", ToTLV.toTLV("4F", isdp1));
}
String data = ToTLV.toTLV("BF2D", searchCriteria);// + tagList);

View File

@ -15,8 +15,6 @@ import com.truphone.lpad.worker.LpadWorkerExchange;
import com.truphone.util.LogStub;
import com.truphone.util.TextUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;

View File

@ -7,9 +7,10 @@ import com.truphone.lpad.progress.ProgressStep;
import com.truphone.rsp.dto.asn1.rspdefinitions.ProfileInstallationResult;
import com.truphone.rsp.dto.asn1.rspdefinitions.ProfileInstallationResultData;
import com.truphone.util.LogStub;
import com.truphone.util.TextUtil;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -98,7 +99,7 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (TextUtil.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
}
}
@ -110,7 +111,7 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (TextUtil.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
}
}
@ -122,7 +123,7 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (TextUtil.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
}
}
@ -134,7 +135,7 @@ public class InstallationPhaseWorker {
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (TextUtil.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
}
}
@ -223,7 +224,7 @@ public class InstallationPhaseWorker {
"loadReplaceSessionsKeys...");
String profileInstallationResult = apduTransmitter.transmitApdus(sbpp);
if (StringUtils.isNotBlank(profileInstallationResult)) {
if (TextUtil.isNotBlank(profileInstallationResult)) {
checkProfileInstallationResult(profileInstallationResult);
}
}

View File

@ -3,14 +3,12 @@ package com.truphone.lpad.worker;
import com.truphone.es9plus.AllocateProfileResponse;
import com.truphone.es9plus.Es9PlusImpl;
import com.truphone.util.LogStub;
import org.apache.commons.lang3.StringUtils;
import com.truphone.lpad.LpadWorker;
import com.truphone.lpad.progress.Progress;
import com.truphone.lpad.progress.ProgressStep;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang3.NotImplementedException;
/**
* Worker containing all logic to allocate a profile for a MCC with a specific EID
@ -67,7 +65,7 @@ public class AllocateProfileWorker implements LpadWorker<LpadWorkerExchange<Allo
//
// throw new RuntimeException("Unable to allocate profile");
// }
throw new NotImplementedException("Not implemented");
throw new IllegalArgumentException("Not implemented");
}
private void logDebug(final String errorMessage) {

View File

@ -7,9 +7,10 @@ import com.truphone.lpad.progress.Progress;
import com.truphone.lpad.progress.ProgressStep;
import com.truphone.rsp.dto.asn1.rspdefinitions.DeleteProfileResponse;
import com.truphone.util.LogStub;
import com.truphone.util.TextUtil;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -47,7 +48,7 @@ public class DeleteProfileWorker implements LpadWorker<LpadWorkerExchange<Delete
inputValidation(lpadWorkerExchange == null, "Input params to invoke Delete Profile must not be null");
inputValidation(lpadWorkerExchange.getBody() == null, "Input params must have body defined");
inputValidation(StringUtils.isBlank(lpadWorkerExchange.getBody().getIccid()), "ICCID must not be null/empty");
inputValidation(TextUtil.isBlank(lpadWorkerExchange.getBody().getIccid()), "ICCID must not be null/empty");
String iccid = lpadWorkerExchange.getBody().getIccid(); // Get ICCID From Body
String eResponse = transmitDeleteProfile(iccid, progress);

View File

@ -7,9 +7,10 @@ import com.truphone.lpad.progress.Progress;
import com.truphone.lpad.progress.ProgressStep;
import com.truphone.rsp.dto.asn1.rspdefinitions.GetEuiccDataResponse;
import com.truphone.util.LogStub;
import com.truphone.util.TextUtil;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -45,7 +46,7 @@ public class GetEidLpadWorker implements LpadWorker<LpadWorkerExchange<String>,
progress.stepExecuted(ProgressStep.GET_EID_RETRIEVING, "getEID retrieving...");
inputValidation(lpadWorkerExchange == null, "Lpa dWorker Exchange must be provided");
inputValidation(StringUtils.isBlank(lpadWorkerExchange.getBody()), "EID APDU must be provided");
inputValidation(TextUtil.isBlank(lpadWorkerExchange.getBody()), "EID APDU must be provided");
logDebug("EID APDU: " + lpadWorkerExchange);
@ -62,7 +63,7 @@ public class GetEidLpadWorker implements LpadWorker<LpadWorkerExchange<String>,
progress.stepExecuted(ProgressStep.GET_EID_CONVERTING, "getEID converting...");
inputValidation(StringUtils.isBlank(eidapduResponseStr), "received an invalid eidapduResponseStr: " + eidapduResponseStr);
inputValidation(TextUtil.isBlank(eidapduResponseStr), "received an invalid eidapduResponseStr: " + eidapduResponseStr);
GetEuiccDataResponse eidResponse = new GetEuiccDataResponse();

View File

@ -86,4 +86,22 @@ object TextUtil {
*/
@JvmStatic
fun readInputStream(i: InputStream): ByteArray = i.readBytes()
/*
* TODO: Remove after Kotlin migration
*/
@JvmStatic
fun isNotBlank(str: String): Boolean = str.isNotBlank()
/*
* TODO: Remove after Kotlin migration
*/
@JvmStatic
fun isBlank(str: String): Boolean = str.isBlank()
/*
* TODO: Remove after Kotlin migration
*/
@JvmStatic
fun isNotEmpty(str: String): Boolean = str.isNotEmpty()
}