use of iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse in project open-ecard by ecsec.
the class MiddlewareSAL method cardApplicationSelect.
@Override
public CardApplicationSelectResponse cardApplicationSelect(CardApplicationSelect parameters) {
CardApplicationSelectResponse response = WSHelper.makeResponse(CardApplicationSelectResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType handle = SALUtils.createConnectionHandle(parameters.getSlotHandle());
CardStateEntry entry = states.getEntry(handle);
Assert.assertConnectionHandle(entry, handle);
// get fully filled handle
handle = entry.handleCopy();
response.setConnectionHandle(handle);
return response;
} catch (ECardException ex) {
response.setResult(ex.getResult());
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse in project open-ecard by ecsec.
the class TinySAL method cardApplicationSelect.
@Override
public CardApplicationSelectResponse cardApplicationSelect(CardApplicationSelect request) {
CardApplicationSelectResponse response = WSHelper.makeResponse(CardApplicationSelectResponse.class, WSHelper.makeResultOK());
try {
byte[] slotHandle = request.getSlotHandle();
ConnectionHandleType connectionHandle = SALUtils.createConnectionHandle(slotHandle);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
byte[] reqApplicationID = request.getCardApplication();
Assert.assertIncorrectParameter(reqApplicationID, "The parameter CardApplication is empty.");
CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
CardApplicationWrapper appInfo = cardInfoWrapper.getCardApplication(reqApplicationID);
Assert.assertNamedEntityNotFound(appInfo, "The given Application cannot be found.");
Assert.securityConditionApplication(cardStateEntry, reqApplicationID, ConnectionServiceActionName.CARD_APPLICATION_CONNECT);
// check if the currently selected application is already what the caller wants
byte[] curApplicationID = cardStateEntry.getCurrentCardApplication().getApplicationIdentifier();
if (!ByteUtils.compare(reqApplicationID, curApplicationID)) {
// Select the card application
CardCommandAPDU select;
// TODO: proper determination of path, file and app id
if (reqApplicationID.length == 2) {
select = new Select.File(reqApplicationID);
List<byte[]> responses = new ArrayList<>();
responses.add(TrailerConstants.Success.OK());
responses.add(TrailerConstants.Error.WRONG_P1_P2());
CardResponseAPDU resp = select.transmit(env.getDispatcher(), slotHandle, responses);
if (Arrays.equals(resp.getTrailer(), TrailerConstants.Error.WRONG_P1_P2())) {
select = new Select.AbsolutePath(reqApplicationID);
select.transmit(env.getDispatcher(), slotHandle);
}
} else {
select = new Select.Application(reqApplicationID);
select.transmit(env.getDispatcher(), slotHandle);
}
cardStateEntry.setCurrentCardApplication(reqApplicationID);
// reset the ef FCP
cardStateEntry.unsetFCPOfSelectedEF();
}
response.setConnectionHandle(cardStateEntry.handleCopy());
} catch (ECardException e) {
response.setResult(e.getResult());
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse in project open-ecard by ecsec.
the class DidInfos method connectApplication.
public void connectApplication(byte[] application) throws WSHelper.WSException {
CardApplicationSelect req = new CardApplicationSelect();
req.setCardApplication(application);
req.setSlotHandle(handle.getSlotHandle());
CardApplicationSelectResponse res = (CardApplicationSelectResponse) dispatcher.safeDeliver(req);
WSHelper.checkResult(res);
}
Aggregations