Search in sources :

Example 6 with TLVException

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);
}
Also used : FCP(org.openecard.common.tlv.iso7816.FCP) CardResponseAPDU(org.openecard.common.apdu.common.CardResponseAPDU) TLVException(org.openecard.common.tlv.TLVException)

Example 7 with TLVException

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);
    }
}
Also used : TLVException(org.openecard.common.tlv.TLVException) TLV(org.openecard.common.tlv.TLV) Nonnull(javax.annotation.Nonnull)

Example 8 with TLVException

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;
    }
}
Also used : TLVException(org.openecard.common.tlv.TLVException) TLV(org.openecard.common.tlv.TLV)

Aggregations

TLVException (org.openecard.common.tlv.TLVException)8 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)4 FCP (org.openecard.common.tlv.iso7816.FCP)4 TLV (org.openecard.common.tlv.TLV)3 ProtocolException (org.openecard.common.sal.protocol.exception.ProtocolException)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)1 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)1 DataSetSelectResponse (iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse)1 GeneralSecurityException (java.security.GeneralSecurityException)1 Nonnull (javax.annotation.Nonnull)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)1 DynamicContext (org.openecard.common.DynamicContext)1 ECardException (org.openecard.common.ECardException)1 ThreadTerminateException (org.openecard.common.ThreadTerminateException)1 APDUException (org.openecard.common.apdu.exception.APDUException)1 ObjectSchemaValidator (org.openecard.common.interfaces.ObjectSchemaValidator)1 ObjectValidatorException (org.openecard.common.interfaces.ObjectValidatorException)1 Publish (org.openecard.common.interfaces.Publish)1