Class ApduResponse
java.lang.Object
com.codename1.nfc.ApduResponse
Helpers for working with the ISO 7816 status word (SW1/SW2) trailer at
the end of every APDU response. Pair with
IsoDep (reader mode) and
HostCardEmulationService (card mode).-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]body(byte[] apdu) Slice helper -- returns the payload preceding the 2-byte SW trailer, or an empty array when the response is exactly 2 bytes.static booleanisSuccess(byte[] apdu) truewhen the trailing two bytes ofapduare90 00.static intstatusWord(byte[] apdu) 16-bit status word from the last two bytes ofapdu.static byte[]sw(int sw1, int sw2) Returns a 2-byte status-word array for the given SW1/SW2 pair.static byte[]SW =6E 00-- CLA not supported.static byte[]SW =6A 82-- file or AID not found.static byte[]SW =6D 00-- INS not supported.static byte[]SW =69 82-- security condition not satisfied.static byte[]SW =90 00-- command succeeded.static byte[]SW =6F 00-- unknown / generic failure.static byte[]SW =67 00-- wrong length / Lc.static byte[]withStatus(byte[] body, byte[] sw) Appendsswto the end ofbodyand returns the combined APDU response.
-
Method Details
-
swSuccess
public static byte[] swSuccess()SW =90 00-- command succeeded. -
swFileNotFound
public static byte[] swFileNotFound()SW =6A 82-- file or AID not found. Returned from an HCE service'sSELECTwhen the requested AID is not the one it registered. -
swInsNotSupported
public static byte[] swInsNotSupported()SW =6D 00-- INS not supported. Returned from an HCE service for any APDU whose instruction byte is not handled. -
swClaNotSupported
public static byte[] swClaNotSupported()SW =6E 00-- CLA not supported. -
swWrongLength
public static byte[] swWrongLength()SW =67 00-- wrong length / Lc. -
swSecurityNotSatisfied
public static byte[] swSecurityNotSatisfied()SW =69 82-- security condition not satisfied. -
swUnknownError
public static byte[] swUnknownError()SW =6F 00-- unknown / generic failure. -
isSuccess
public static boolean isSuccess(byte[] apdu) truewhen the trailing two bytes ofapduare90 00. -
body
public static byte[] body(byte[] apdu) Slice helper -- returns the payload preceding the 2-byte SW trailer, or an empty array when the response is exactly 2 bytes. -
statusWord
public static int statusWord(byte[] apdu) 16-bit status word from the last two bytes ofapdu. Returns0for inputs shorter than 2 bytes. -
sw
public static byte[] sw(int sw1, int sw2) Returns a 2-byte status-word array for the given SW1/SW2 pair. -
withStatus
public static byte[] withStatus(byte[] body, byte[] sw) Appendsswto the end ofbodyand returns the combined APDU response. Helper forHostCardEmulationServiceimplementations.
-