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"));
136 CSVParser rangesParser = CSVFormat.RFC4180.builder().setHeader().setSkipHeaderRecord(
true).build().parse(in);
139 for (CSVRecord record : rangesParser) {
146 String start = StringUtils.rightPad(record.get(
"iin_start"), 8,
"0");
149 String end = StringUtils.defaultIfBlank(record.get(
"iin_end"), start);
150 end = StringUtils.rightPad(end, 8,
"99");
152 final String numberLength = record.get(
"number_length");
156 Integer.parseInt(end),
157 StringUtils.isBlank(numberLength) ? null : Integer.valueOf(numberLength),
158 record.get(
"scheme"),
161 record.get(
"country"),
162 record.get(
"bank_name"),
163 record.get(
"bank_url"),
164 record.get(
"bank_phone"),
165 record.get(
"bank_city"));
169 }
catch (NumberFormatException numberFormatException) {
170 logger.log(Level.WARNING,
"Failed to parse BIN range: " + record.toString(), numberFormatException);
174 }
catch (IOException ex) {
175 logger.log(Level.WARNING,
"Failed to load BIN ranges form ranges.csv", ex);
176 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)