19 package org.sleuthkit.autopsy.datamodel;
21 import com.google.common.collect.Range;
22 import com.google.common.collect.RangeMap;
23 import com.google.common.collect.TreeRangeMap;
24 import java.io.IOException;
25 import java.io.InputStreamReader;
26 import java.util.Optional;
27 import java.util.logging.Level;
28 import javax.annotation.concurrent.GuardedBy;
29 import org.apache.commons.csv.CSVFormat;
30 import org.apache.commons.csv.CSVParser;
31 import org.apache.commons.csv.CSVRecord;
32 import org.apache.commons.lang3.StringUtils;
118 @GuardedBy(
"CreditCards.class")
134 InputStreamReader in =
new InputStreamReader(
CreditCards.class.getResourceAsStream(
"ranges.csv"));
135 CSVParser rangesParser = CSVFormat.RFC4180.withFirstRecordAsHeader().parse(in);
138 for (CSVRecord record : rangesParser) {
145 String start = StringUtils.rightPad(record.get(
"iin_start"), 8,
"0");
148 String end = StringUtils.defaultIfBlank(record.get(
"iin_end"), start);
149 end = StringUtils.rightPad(end, 8,
"99");
151 final String numberLength = record.get(
"number_length");
155 Integer.parseInt(end),
156 StringUtils.isBlank(numberLength) ? null : Integer.valueOf(numberLength),
157 record.get(
"scheme"),
160 record.get(
"country"),
161 record.get(
"bank_name"),
162 record.get(
"bank_url"),
163 record.get(
"bank_phone"),
164 record.get(
"bank_city"));
168 }
catch (NumberFormatException numberFormatException) {
169 logger.log(Level.WARNING,
"Failed to parse BIN range: " + record.toString(), numberFormatException);
173 }
catch (IOException ex) {
174 logger.log(Level.WARNING,
"Failed to load BIN ranges form ranges.csv", ex);
175 MessageNotifyUtil.
Notify.
warn(
"Credit Card Number Discovery",
"There was an error loading Bank Identification Number information. Accounts will not have their BINs identified.");
static boolean binsLoaded
synchronized static void loadBINRanges()
Optional< String > getScheme()
Optional< String > getCardType()
static synchronized BankIdentificationNumber getBINInfo(int bin)
Optional< String > getCountry()
static final Logger logger
static final RangeMap< Integer, BINRange > binRanges
Optional< String > getBankCity()
Optional< String > getBrand()
synchronized static Logger getLogger(String name)
Optional< String > getBankPhoneNumber()
Optional< String > getBankURL()
Optional< Integer > getNumberLength()
Optional< String > getBankName()
static void warn(String title, String message)