public final class ApduResponse
- Object
- 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).Methods
public static byte[] swSuccess() | SW = 90 00 – command succeeded. |
public static byte[] swFileNotFound() | SW = 6A 82 – file or AID not found. |
public static byte[] swInsNotSupported() | SW = 6D 00 – INS not supported. |
public static byte[] swClaNotSupported() | SW = 6E 00 – CLA not supported. |
public static byte[] swWrongLength() | SW = 67 00 – wrong length / Lc. |
public static byte[] swSecurityNotSatisfied() | SW = 69 82 – security condition not satisfied. |
public static byte[] swUnknownError() | SW = 6F 00 – unknown / generic failure. |
public static boolean isSuccess(byte[] apdu) | true when the trailing two bytes of apdu are 90 00. |
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. |
public static int statusWord(byte[] apdu) | 16-bit status word from the last two bytes of apdu. |
public static byte[] sw(int sw1, int sw2) | Returns a 2-byte status-word array for the given SW1/SW2 pair. |
public static byte[] withStatus(byte[] body, byte[] sw) | Appends sw to the end of body and returns the combined APDU response. |
Inherited methods
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’s SELECT when 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)true when the trailing two bytes of apdu are 90 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 of
apdu. Returns 0
for 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)Appends
sw to the end of body and returns the combined APDU
response. Helper for HostCardEmulationService implementations.