Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfehr committed Mar 28, 2023
1 parent 47f1d28 commit 2978938
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ public byte[] getDolValue(byte[] tagByte) {
return null; // default, entry not found
}

public String dump() {
StringBuilder sb = new StringBuilder();
sb.append("List of predefined tag and values for PDOL and CDOL").append("\n");
sb.append("Tag Name Value").append("\n");
sb.append("-------------------------------------------------").append("\n");
for (int i = 0; i < dolList.size(); i++) {
DolTag dol = dolList.get(i);
sb.append(trimStringRight(bytesToHexNpe(dol.getTag()), 5));
sb.append(trimStringRight(dol.getTagName(), 32));
sb.append(bytesToHexNpe(dol.getDefaultValue()));
sb.append("\n");
}
return sb.toString();
}

private DolTag setTag(byte[] tagByte, String tagName, byte[] tagValueByte) {
DolTag dolTag = new DolTag(tagByte, tagName, tagValueByte);
dolList.add(dolTag);
Expand All @@ -127,4 +142,40 @@ private static byte[] hexBlankToBytes(String str) {
}
return bytes;
}

/**
* add blanks to a string on right side up to a length of len
* if the data.length >= len one character is deleted to get minimum one blank
* @param data
* @param len
* @return
*/
private String trimStringRight(String data, int len) {
if (data.length() >= len) {
data = data.substring(0, (len - 1));
}
while (data.length() < len) {
data = data + " ";
}
return data;
}

/**
* converts a byte array to a hex encoded string
* This method is Null Pointer Exception (NPE) safe
*
* @param bytes
* @return hex encoded string
*/
public static String bytesToHexNpe(byte[] bytes) {
if (bytes != null) {
StringBuffer result = new StringBuffer();
for (byte b : bytes)
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
return result.toString();
} else {
return "";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ public void onTagDiscovered(Tag tag) {
BerTlv tag9f38 = tlvsAid.find(new BerTag(0x9F, 0x38));
writeToUiAppend(etData, "04 search for tag 0x9F38 in the selectAid response completed");
byte[] gpoRequestCommand;

// comment this out for regular workflow
DolValues dolValues = new DolValues();
writeToUiAppend("Available predefined values for PDOL and CDOL");
writeToUiAppend(dolValues.dump());

if (tag9f38 != null) {
/**
* the following code is for VisaCards and (German) GiroCards as we found a PDOL
Expand Down Expand Up @@ -695,11 +701,9 @@ private byte[] getGetProcessingOptionsFromPdol(final byte[] pPdol) throws Commun
* [1] = text table with requested tags from pdol with length and value
*/
private byte[][] getGpoFromPdolExtended(@NonNull byte[] pdol, int ttq) {

// todo implement alternative ttq

byte[][] result = new byte[2][];

// get the tags in a list
List<com.github.devnied.emvnfccard.iso7816emv.TagAndLength> tagAndLength = TlvUtil.parseTagAndLength(pdol);
int tagAndLengthSize = tagAndLength.size();
Expand Down
Loading

0 comments on commit 2978938

Please sign in to comment.