Beispiel #1
0
  private byte[] sendRequest(byte command, byte p1, byte p2, byte lc, byte[] parameters)
      throws CEPASException, IOException {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    byte[] recvBuffer = mTagTech.transceive(wrapMessage(command, p1, p2, lc, parameters));

    if (recvBuffer[recvBuffer.length - 2] != (byte) 0x90) {
      if (recvBuffer[recvBuffer.length - 2] == 0x6b) {
        throw new CEPASException("File " + p1 + " was an invalid file.");

      } else if (recvBuffer[recvBuffer.length - 2] == 0x67) {
        throw new CEPASException("Got invalid file size response.");
      }

      throw new CEPASException(
          "Got generic invalid response: "
              + Integer.toHexString(((int) recvBuffer[recvBuffer.length - 2]) & 0xff));
    }

    output.write(recvBuffer, 0, recvBuffer.length - 2);

    byte status = recvBuffer[recvBuffer.length - 1];
    if (status == OPERATION_OK) {
      return output.toByteArray();
    } else if (status == PERMISSION_DENIED) {
      throw new CEPASException("Permission denied");
    } else {
      throw new CEPASException("Unknown status code: " + Integer.toHexString(status & 0xFF));
    }
  }
 public byte[] getChallenge() {
   byte[] challengeRequest = {(byte) 0x00, (byte) 0x84, (byte) 0x00, (byte) 0x00, (byte) 0x08};
   byte[] challengeResponse = null;
   try {
     challengeResponse = isoDep.transceive(challengeRequest);
     Log.d("challengeResponse", Util.hexString(challengeResponse));
   } catch (IOException e) {
   }
   return challengeResponse;
 }
 public String getPurseData(String purseRequest) {
   byte[] purseByte = Util.hexStringToByteArray(purseRequest.toString());
   String purseData = null;
   try {
     byte[] purseResponse = isoDep.transceive(purseByte);
     purseData = Util.hexString(purseResponse);
     Log.d("PurseData Response", purseData);
   } catch (IOException e) {
   }
   return purseData;
 }
 public byte[] init() {
   byte[] initByte = new byte[8];
   initByte[1] = -92;
   initByte[4] = 2;
   initByte[5] = 64;
   byte[] initRespose = null;
   try {
     initRespose = isoDep.transceive(initByte);
   } catch (IOException e) {
   }
   return initRespose;
 }
 public String getReceipt(String debitCommand, WebserviceConnection wsConnection) {
   String receiptData = null;
   try {
     debitCommand = "90340000" + debitCommand + "00";
     byte[] debitCommandByte = Util.hexStringToByteArray(debitCommand);
     byte[] receiptResponse = isoDep.transceive(debitCommandByte);
     receiptData = Util.hexString(receiptResponse);
   } catch (IOException e) {
     // wsConnection.uploadReceiptData("", new
     // RecieptReqError(StringConstants.ErrorCode.ERROR_CODE_01,
     // StringConstants.ErrorDecription.DEBIT_COMMAND_SUCCESSFUL_BUT_NO_RESPONSE_FROM_CARD));
   }
   return receiptData;
 }
 public String getPurseData() {
   String purseData = null;
   try {
     //		String terminalRN = Util.getRandomHexString(16);
     terminalRN = "CF549C2B7520389C";
     Log.d("terminalRN", terminalRN);
     purseRequest = "903203000A1403" + terminalRN + "00";
     Log.d("Purse Request", purseRequest);
     byte[] purseByte = Util.hexStringToByteArray(purseRequest.toString());
     byte[] purseResponse = isoDep.transceive(purseByte);
     purseData = Util.hexString(purseResponse);
     Log.d("PurseData Response", purseData);
   } catch (IOException e) {
   }
   return purseData;
 }