add checkSW method
This commit is contained in:
parent
918aec72ac
commit
5a2204bbcb
|
@ -33,18 +33,18 @@ public class APDUResponse {
|
|||
System.arraycopy(this.apdu, 0, this.data, 0, length - 2);
|
||||
}
|
||||
|
||||
public boolean isOK() {
|
||||
return this.sw == SW_OK;
|
||||
public APDUResponse checkOK() throws APDUException {
|
||||
this.checkSW(SW_OK);
|
||||
return this;
|
||||
}
|
||||
|
||||
public APDUResponse checkOK(int... codes) throws APDUException {
|
||||
public APDUResponse checkSW(int... codes) throws APDUException {
|
||||
for (int code : codes) {
|
||||
if (this.sw == code) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOK()) {
|
||||
switch (this.sw) {
|
||||
case SW_SECURITY_CONDITION_NOT_SATISFIED:
|
||||
throw new APDUException(this.sw, "security condition not satisfied");
|
||||
|
@ -53,10 +53,6 @@ public class APDUResponse {
|
|||
default:
|
||||
throw new APDUException(this.sw, "Unexpected error SW");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
|
|
Loading…
Reference in New Issue