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);
|
System.arraycopy(this.apdu, 0, this.data, 0, length - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOK() {
|
public APDUResponse checkOK() throws APDUException {
|
||||||
return this.sw == SW_OK;
|
this.checkSW(SW_OK);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public APDUResponse checkOK(int... codes) throws APDUException {
|
public APDUResponse checkSW(int... codes) throws APDUException {
|
||||||
for (int code : codes) {
|
for (int code : codes) {
|
||||||
if (this.sw == code) {
|
if (this.sw == code) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOK()) {
|
|
||||||
switch (this.sw) {
|
switch (this.sw) {
|
||||||
case SW_SECURITY_CONDITION_NOT_SATISFIED:
|
case SW_SECURITY_CONDITION_NOT_SATISFIED:
|
||||||
throw new APDUException(this.sw, "security condition not satisfied");
|
throw new APDUException(this.sw, "security condition not satisfied");
|
||||||
|
@ -53,10 +53,6 @@ public class APDUResponse {
|
||||||
default:
|
default:
|
||||||
throw new APDUException(this.sw, "Unexpected error SW");
|
throw new APDUException(this.sw, "Unexpected error SW");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getData() {
|
public byte[] getData() {
|
||||||
|
|
Loading…
Reference in New Issue