示例#1
0
 void doVelocityChecking() {
   final String method = "doVelocityChecking()";
   try {
     int lowerLimit =
         BinaryNumber.toInt(transaction.getData(EMVTag.LOWER_CONSECUTIVE_OFFLINE_LIMIT));
     int upperLimit =
         BinaryNumber.toInt(transaction.getData(EMVTag.UPPER_CONSECUTIVE_OFFLINE_LIMIT));
     int lastOnlineATC = readLastOnlineATC();
     if (lastOnlineATC == 0) {
       indicateNewCard();
     }
     int atc = readATC();
     if (LOG.isInfoEnabled()) {
       LOG.info(method, "ATC: " + atc + ", Last Online ATC: " + lastOnlineATC);
     }
     int consecutiveOffline = atc - lastOnlineATC;
     TVR tvr = transaction.getTVR();
     if (consecutiveOffline > lowerLimit) {
       tvr.getByte4().lowerConsecutiveOfflineLimitExceeded();
     }
     if (consecutiveOffline > upperLimit) {
       tvr.getByte4().upperConsecutiveOfflineLimitExceeded();
     }
   } catch (IOException e) {
     if (LOG.isErrorEnabled()) {
       LOG.error(method, "Error reading data from ICC", e);
     }
   } catch (ProcessingStateException e) {
     if (LOG.isErrorEnabled()) {
       LOG.error(method, "Error reading data from ICC", e);
     }
     TVR tvr = transaction.getTVR();
     tvr.getByte4().lowerConsecutiveOfflineLimitExceeded();
     tvr.getByte4().upperConsecutiveOfflineLimitExceeded();
   } catch (DataNotFoundException e) {
     if (LOG.isDebugEnabled()) {
       LOG.debug(method, "Data not found: " + e.getEMVTag());
     }
   }
 }
 private void prerequisites() throws DataNotFoundException {
   final String method = "prerequisites()";
   amount = BinaryNumber.toBigInteger(transaction.getData(EMVTag.AMOUNT_AUTHORISED_BINARY));
   floorLimit = BinaryNumber.toBigInteger(transaction.getData(EMVTag.TERMINAL_FLOOR_LIMIT));
   RandomTransactionSelectionData selectionData =
       transaction.getApplication().getRandomTransactionSelectionData();
   targetPercentage = selectionData.getTargetPercentage();
   maxTargetPercentage = selectionData.getMaxTargetPercentage();
   thresholdValue = BinaryNumber.toBigInteger(selectionData.getThresholdValue());
   if (thresholdValue.compareTo(floorLimit) >= 0) {
     if (LOG.isWarnEnabled()) {
       LOG.warn(
           method,
           "Threshold Value ("
               + thresholdValue
               + ") is greater or equals to floor limit ("
               + floorLimit
               + ")");
     }
     thresholdValue = BigInteger.ZERO;
   }
   randomNumber = generateRandomNumber();
   if (LOG.isDebugEnabled()) {
     LOG.debug(
         method,
         "Amount: "
             + amount
             + ", Floor Limit: "
             + floorLimit
             + ", Target Percentage: "
             + targetPercentage
             + ", Max Target Percentage: "
             + maxTargetPercentage
             + ", Threshold Value: "
             + thresholdValue
             + ", Random Number: "
             + randomNumber);
   }
 }