Search in sources :

Example 6 with CardApplicationList

use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.

the class SALFileUtils method selectAppByDataSet.

/**
 * The method connects the given card to the CardApplication containing the requested DataSet.
 *
 * @param dataSetName Name of the DataSet which should be contained in the application to connect.
 * @param handle ConnectionHandle which identifies the card and terminal.
 * @return The handle describing the new state of the card.
 * @throws WSException Thrown in case any of the requested eCard API methods returned an error, or no application of
 *   the specified card contains the requested data set.
 */
@Nonnull
public ConnectionHandleType selectAppByDataSet(@Nonnull String dataSetName, @Nonnull ConnectionHandleType handle) throws WSException {
    // copy handle so that the given handle is not damaged
    handle = HandlerUtils.copyHandle(handle);
    // get all card applications
    CardApplicationList cardApps = new CardApplicationList();
    cardApps.setConnectionHandle(handle);
    CardApplicationListResponse cardAppsResp = (CardApplicationListResponse) dispatcher.safeDeliver(cardApps);
    WSHelper.checkResult(cardAppsResp);
    List<byte[]> cardApplications = cardAppsResp.getCardApplicationNameList().getCardApplicationName();
    // check if our data set is in any of the applications
    for (byte[] app : cardApplications) {
        DataSetList dataSetListReq = new DataSetList();
        handle.setCardApplication(app);
        dataSetListReq.setConnectionHandle(handle);
        DataSetListResponse dataSetListResp = (DataSetListResponse) dispatcher.safeDeliver(dataSetListReq);
        WSHelper.checkResult(dataSetListResp);
        if (dataSetListResp.getDataSetNameList().getDataSetName().contains(dataSetName)) {
            handle = selectApplication(app, handle);
            return handle;
        }
    }
    // data set not found
    String msg = "Failed to find the requested data set (%s) in any of the applications of the specified card.";
    msg = String.format(msg, dataSetName);
    Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.FILE_NOT_FOUND, msg);
    throw WSHelper.createException(r);
}
Also used : CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Result(oasis.names.tc.dss._1_0.core.schema.Result) Nonnull(javax.annotation.Nonnull)

Example 7 with CardApplicationList

use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.

the class SALFileUtils method selectAppByDID.

/**
 * The method connects the given card to the CardApplication containing the requested DID Name.
 *
 * @param didName Name of the DID which is contained in the application to connect.
 * @param handle ConnectionHandle which identifies Card and Terminal.
 * @return The handle describing the new state of the card.
 * @throws WSException Thrown in case any of the requested eCard API methods returned an error, or no application of
 *   the specified card contains the requested DID name.
 */
@Nonnull
public ConnectionHandleType selectAppByDID(@Nonnull String didName, @Nonnull ConnectionHandleType handle) throws WSException {
    // copy handle so that the given handle is not damaged
    handle = HandlerUtils.copyHandle(handle);
    // get all card applications
    CardApplicationList cardApps = new CardApplicationList();
    cardApps.setConnectionHandle(handle);
    CardApplicationListResponse cardAppsResp = (CardApplicationListResponse) dispatcher.safeDeliver(cardApps);
    WSHelper.checkResult(cardAppsResp);
    List<byte[]> cardApplications = cardAppsResp.getCardApplicationNameList().getCardApplicationName();
    // check if our data set is in any of the applications
    for (byte[] app : cardApplications) {
        DIDList didListReq = new DIDList();
        handle.setCardApplication(app);
        didListReq.setConnectionHandle(handle);
        DIDListResponse didListResp = (DIDListResponse) dispatcher.safeDeliver(didListReq);
        WSHelper.checkResult(didListResp);
        if (didListResp.getDIDNameList().getDIDName().contains(didName)) {
            handle = selectApplication(app, handle);
            return handle;
        }
    }
    // data set not found
    String msg = "Failed to find the requested DID (%s) in any of the applications of the specified card.";
    msg = String.format(msg, didName);
    Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.FILE_NOT_FOUND, msg);
    throw WSHelper.createException(r);
}
Also used : CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) DIDList(iso.std.iso_iec._24727.tech.schema.DIDList) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) DIDListResponse(iso.std.iso_iec._24727.tech.schema.DIDListResponse) Result(oasis.names.tc.dss._1_0.core.schema.Result) Nonnull(javax.annotation.Nonnull)

Aggregations

CardApplicationListResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse)7 CardApplicationList (iso.std.iso_iec._24727.tech.schema.CardApplicationList)6 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)3 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)3 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)3 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)3 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)3 Test (org.testng.annotations.Test)3 Nonnull (javax.annotation.Nonnull)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Result (oasis.names.tc.dss._1_0.core.schema.Result)2 SkipException (org.testng.SkipException)2 AccessControlListType (iso.std.iso_iec._24727.tech.schema.AccessControlListType)1 CardApplicationCreate (iso.std.iso_iec._24727.tech.schema.CardApplicationCreate)1 CardApplicationCreateResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationCreateResponse)1 CardApplicationDelete (iso.std.iso_iec._24727.tech.schema.CardApplicationDelete)1 CardApplicationDeleteResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationDeleteResponse)1 CardApplicationNameList (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse.CardApplicationNameList)1