use of iso.std.iso_iec._24727.tech.schema.Connect 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);
}
use of iso.std.iso_iec._24727.tech.schema.Connect 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);
}
Aggregations