use of org.openecard.common.tlv.TLVException in project open-ecard by ecsec.
the class CardUtils method writeFile.
public static void writeFile(Dispatcher dispatcher, byte[] slotHandle, byte[] fileID, byte[] data) throws APDUException {
CardResponseAPDU selectResponse = selectFile(dispatcher, slotHandle, fileID);
FCP fcp = null;
try {
fcp = new FCP(selectResponse.getData());
} catch (TLVException e) {
LOG.warn("Couldn't get File Control Parameters from Select response.", e);
}
writeFile(fcp, dispatcher, slotHandle, data);
}
use of org.openecard.common.tlv.TLVException in project open-ecard by ecsec.
the class TLVFunction method call.
@Override
@Nonnull
public String call(Object... params) throws APDUTemplateException {
if (params.length != 2) {
throw new APDUTemplateException("Invalid number of parameters given. Two are needed.");
}
byte[] tag = makeBytes(params[0]);
byte[] value = makeBytes(params[1]);
try {
TLV tlv = new TLV();
tlv.setTagNumWithClass(tag);
tlv.setValue(value);
byte[] result = tlv.toBER();
String resultStr = ByteUtils.toHexString(result);
return resultStr;
} catch (TLVException ex) {
throw new APDUTemplateException("Failed to create TLV structure based on given parameters.", ex);
}
}
use of org.openecard.common.tlv.TLVException in project open-ecard by ecsec.
the class TinySAL method createFakeFCP.
private byte[] createFakeFCP(byte[] fid) {
try {
TLV fcp = new TLV();
fcp.setTagNumWithClass((byte) 0x62);
TLV fileID = new TLV();
fileID.setTagNumWithClass((byte) 0x83);
fileID.setValue(fid);
fcp.setChild(fileID);
return fcp.toBER();
} catch (TLVException ex) {
LOG.error(null, ex);
return null;
}
}
Aggregations