Some improvements and better IBAN/BIC support
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
Index: emv/IBAN.java
===================================================================
--- emv/IBAN.java (Arbeitskopie)
+++ emv/IBAN.java (Arbeitskopie)
@@ -15,26 +15,53 @@
*/
package sasc.emv;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import sasc.util.Util;
+
/**
- * International Bank Account Number (IBAN)
- * Uniquely identifies the account of a customer at a financial institution as
defined in ISO 13616
- *
+ * International Bank Account Number (IBAN) Uniquely identifies the account of
a
+ * customer at a financial institution as defined in ISO 13616
+ *
* Length 0-34 bytes
- *
+ *
* TODO
- *
+ *
* @author sasc
*/
public class IBAN {
-//IBAN - International Bank Account Number. Often (incorrectly) referred to as
IBAN Number.
-//An unique account identifier for every bank account in Europe, supervised by
SWIFT.
-//The IBAN system was originally intended for use within Europe, and its use
is
-//largely confined thereto: most notably, the USA does not participate.
-//Among British dependencies, only Gibraltar assigns IBANs.
-//All of Europe does however participate with the exception of the CIS
countries:
-//urkey uses IBANS and so do some African countries. The number consists first
of a
-//two-digit country identifier, followed by two check digits, then up to 30
characters representing the local account.
-//The number of characters varies from country to country, but is fixed for
each country.
-//When used electronically there are no spaces in IBANs, but the convention on
paper
-//is to separate into groups of four with any odd digits in the last group.
+ public String iban;
+
+ public String accountNumber;
+
+ public String bankNumber;
+
+ public String countryCode;
+
+ public IBAN(byte[] iban) {
+ this.iban = new String(iban);
+ countryCode = this.iban.substring(0, 2);
+ if (countryCode.equalsIgnoreCase("de")) {
+ bankNumber = this.iban.substring(2, 10);
+ accountNumber = this.iban.substring(10);
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringWriter sw = new StringWriter();
+ dump(new PrintWriter(sw), 0);
+ return sw.toString();
+ }
+
+ public void dump(PrintWriter pw, int indent) {
+ pw.println(Util.getSpaces(indent) + "International Bank Account
Number (IBAN) - " + iban);
+ pw.println(Util.getSpaces(indent + 3) + "Country - " +
countryCode);
+ if (bankNumber != null) {
+ pw.println(Util.getSpaces(indent + 3) + "Bank - " +
bankNumber);
+ pw.println(Util.getSpaces(indent + 3) + "Account - " +
accountNumber);
+ }
+ }
+
}
Index: emv/EMVUtil.java
===================================================================
--- emv/EMVUtil.java (Revision 15)
+++ emv/EMVUtil.java (Arbeitskopie)
@@ -523,6 +523,10 @@
} else if (tlv.getTag().equals(EMVTags.DDOL)) {
DOL ddol = new DOL(DOL.Type.DDOL, tlv.getValueBytes());
app.setDDOL(ddol);
+ } else if (tlv.getTag().equals(EMVTags.IBAN)) {
+ app.setIBAN(new IBAN(tlv.getValueBytes()));
+ } else if
(tlv.getTag().equals(EMVTags.BANK_IDENTIFIER_CODE)) {
+ app.setBIC(new String(tlv.getValueBytes()));
} else {
app.addUnhandledRecord(tlv);
}
Index: emv/EMVTerminalProfile.java
===================================================================
--- emv/EMVTerminalProfile.java (Revision 15)
+++ emv/EMVTerminalProfile.java (Arbeitskopie)
@@ -84,6 +84,12 @@
//TODO not supported at the moment
//http://www.codeproject.com/Articles/100084/Introduction-to-ISO-8583
return new byte[tal.getLength()];
+ } else if (tal.getTag().equals(EMVTags.TERMINAL_TYPE) &&
tal.getLength() == 1) {
+ return Util.fromHexString("14");
+ } else if (tal.getTag().equals(EMVTags.TERMINAL_CAPABILITIES)
&& tal.getLength() == 2) {
+ return Util.fromHexString("60 c0");
+ } else if
(tal.getTag().equals(EMVTags.ADDITIONAL_TERMINAL_CAPABILITIES) &&
tal.getLength() == 1) {
+ return Util.fromHexString("00");
} else {
Log.debug("Terminal Resident Data not found for " + tal);
}
Index: emv/EMVApplication.java
===================================================================
--- emv/EMVApplication.java (Revision 15)
+++ emv/EMVApplication.java (Arbeitskopie)
@@ -89,7 +89,9 @@
//Transaction related data elements
private TransactionStatusInformation transactionStatusInformation = new TransactionStatusInformation();
private List<BERTLV> unhandledRecords = new ArrayList<BERTLV>();
-
+ private IBAN iban;
+ private String bic;
+
public EMVApplication() {
}
@@ -262,6 +264,14 @@
this.ddol = ddol;
}
+ public IBAN getIBAN() {
+ return iban;
+ }
+
+ public void setIBAN(IBAN iban) {
+ this.iban = iban;
+ }
+
public void setCardholderName(String name) {
this.cardholderName = name;
}
@@ -324,6 +334,8 @@
}
public Date getExpirationDate() {
+ if (applicationExpirationDate==null)
+ return null;
return (Date) applicationExpirationDate.clone();
}
@@ -715,4 +727,12 @@
}
pw.println("");
}
+
+ public String getBIC() {
+ return bic;
+ }
+
+ public void setBIC(String bic) {
+ this.bic = bic;
+ }
}
Original issue reported on code.google.com by folkyvolk@googlemail.com
on 21 Feb 2013 at 9:51
Google Code Exporter commented
Thanks for the patch. Will add it to the next release
Original comment by sasc...@gmail.com
on 23 Feb 2013 at 10:16
- Changed state: Started
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
Google Code Exporter commented
Original comment by sasc...@gmail.com
on 2 Jan 2014 at 1:59
- Changed state: Verified
Google Code Exporter commented
Original comment by sasc...@gmail.com
on 17 Apr 2014 at 1:42
- Changed state: Fixed