package org.average.nfcauthcr;
+import java.lang.String;
import java.io.IOException;
import java.util.Arrays;
int length = resp.length;
if (resp[length - 2] != (byte)0x90 ||
resp[length - 1] != 0x00) {
- throw new CRException(
- "NFC Error code in the response to select");
+ throw new CRException(String.format(
+ "NFC select error code: %02x:%02x",
+ resp[length - 2], resp[length - 1]));
}
byte[] crApdu = new byte[69];
crApdu[0] = 0x00; // CLA
length = resp.length;
if (resp[length - 2] != (byte)0x90 ||
resp[length - 1] != 0x00) {
- throw new CRException(
- "NFC Error code in the response to CR");
+ throw new CRException(String.format(
+ "NFC CR error code: %02x:%02x",
+ resp[length - 2], resp[length - 1]));
}
if (length != 22) {
- throw new CRException(
- "NFC wrong response size: " + (length-2));
+ throw new CRException(String.format(
+ "NFC wrong response size: got %d, need 20",
+ length-2));
}
return Arrays.copyOf(resp, length-2);
} catch (TagLostException e) {
throw new CRException("NFC connection lost", e);
} catch (IOException e) {
- throw new CRException("NFC I/O error", e);
+ throw new CRException("NFC I/O: " + e.getMessage(), e);
}
}
}