Amadis

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Purpose

This page aims at helping L3 applications developers to use the OLA Java API.

The code snippets below are just an example of how things can be done, absolutely not the only way to go!

Basic transaction

A basic OLA transaction includes the following steps:

  • OLA classes instanciation

private final Ola ola;                                                                                                  
private final OlaEmv emv;                                                                                               
private final OlaContactless contactless;
private final Dev dev;

this.ola = Ola.AccessLowLevel();
this.emv = OlaEmv.AccessLowLevel();
this.contactless = OlaContactless.AccessLowLevel();
this.dev = new Dev(this, this, this, false, "/data/data/<application_name>/"); /* internal storage path example */

(new Thread(this.dev)).start();

  • OLA component initialization (Ola.ola_initialize)

private void txnInit() {
    final String path = "/data/data/com.amadis.agnoid_tester/";
    final String CAKeys = path + "CAKeys";
    final String CRL = path + "CRL";
    final String EFL = path + "EFL";
    final String langIni = path + "lang.ini";
    final byte[] params = {0x00, 0x00, 0x00, 0x10, 0x05, 0x00};
    final byte paramsLen = (byte)params.length;
    final byte traceLevel = (byte)5;

    ola.ola_initialize(new OlaInit(path, CAKeys, CRL, EFL, langIni, params, paramsLen, traceLevel));
}

  • Preprocessing (OlaContactless.ola_contactless_preprocess)

private OlaContactlessResult txnPreProcess() {
    OlaContactlessResult ret = contactless.ola_contactless_preprocess(
            new byte[]{0x00, 0x00, 0x00, 0x0A},
            new BCD.BCD_YYMMDD(20, 12, 31),
            new BCD.BCD_YYMMDD(12, 59, 59),
            new BCD(0, 0, 0, 1)
    );

    if (ret != OlaContactlessResult.OK) {
        Log.e("OLA-TESTER", "contactless pre-process failed");
    }

    return ret;
}

  • Card detection

private short txnGetCard() {
    Log.d("OLA-TESTER", "PRESENT CARD");

    int foundTechnos = dev.technoPolling(60000);
    l("Result of foundTechnos: "+ foundTechnos);

    if (foundTechnos==4) {
        return clcEMV_CARD; //TODO remove hard-coding
    } else {
        return 0;
    }
}

  • Build candidate list (OlaContactless.ola_contactless_build_candidate_list)

private OlaContactlessResult txnBuildCandidateList() {
    SingleObjectHolder<Integer> nbCandidatesHolder = new SingleObjectHolder<Integer>();
    OlaContactlessResult ret = contactless.ola_contactless_build_candidate_list(nbCandidatesHolder);

    if (ret != OlaContactlessResult.OK) {
        showOutcome(ret);
    }
    
    return ret;
}

  • Select application (OlaContactless.ola_contactless_final_select_candidate)

private OlaContactlessResult txnFinalSelectCandidate() {
    kernel_id_holder = new SingleObjectHolder<Byte>();
    OlaContactlessResult ret = contactless.ola_contactless_final_select_candidate(1, kernel_id_holder);

    if (ret != OlaContactlessResult.OK) {
        showOutcome(ret);
    }

    return ret;
}

  • Start transaction (OlaContactless.ola_contactless_do_transaction)

private void txnDoTransaction() {
    SingleObjectHolder<OlaEntryMode> entryMode_holder = new SingleObjectHolder<OlaEntryMode>();
    OlaContactlessResult ret = contactless.ola_contactless_do_transaction(entryMode_holder);
    showOutcome(ret);
}

  • No labels