use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MiddlewareSAL method dataSetSelect.
@Override
public DataSetSelectResponse dataSetSelect(DataSetSelect request) {
DataSetSelectResponse response = WSHelper.makeResponse(DataSetSelectResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
byte[] applicationID = connectionHandle.getCardApplication();
String dataSetName = request.getDataSetName();
Assert.assertIncorrectParameter(dataSetName, "The parameter DataSetName is empty.");
CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
DataSetInfoType dataSetInfo = cardInfoWrapper.getDataSet(dataSetName, applicationID);
Assert.assertNamedEntityNotFound(dataSetInfo, "The given DataSet cannot be found.");
Assert.securityConditionDataSet(cardStateEntry, applicationID, dataSetName, NamedDataServiceActionName.DATA_SET_SELECT);
// nothing else to do, DSI Read works for itself
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MiddlewareSAL method cardApplicationConnect.
@Override
public CardApplicationConnectResponse cardApplicationConnect(CardApplicationConnect request) {
CardApplicationConnectResponse response = WSHelper.makeResponse(CardApplicationConnectResponse.class, WSHelper.makeResultOK());
try {
CardApplicationPathType cardAppPath = request.getCardApplicationPath();
Assert.assertIncorrectParameter(cardAppPath, "The parameter CardAppPathRequest is empty.");
Set<CardStateEntry> cardStateEntrySet = states.getMatchingEntries(cardAppPath, false);
Assert.assertIncorrectParameter(cardStateEntrySet, "The given ConnectionHandle is invalid.");
/*
* [TR-03112-4] If the provided path fragments are valid for more than one card application
* the eCard-API-Framework SHALL return any of the possible choices.
*/
CardStateEntry cardStateEntry = cardStateEntrySet.iterator().next();
ConnectionHandleType handle = cardStateEntry.handleCopy();
cardStateEntry = cardStateEntry.derive(handle);
byte[] applicationID = cardStateEntry.getImplicitlySelectedApplicationIdentifier();
Assert.securityConditionApplication(cardStateEntry, applicationID, ConnectionServiceActionName.CARD_APPLICATION_CONNECT);
// find matching slot and associate it with the slotHandle
MwSlot slot = getMatchingSlot(handle.getIFDName(), handle.getSlotIndex());
if (slot != null) {
// open session
MwSession session = slot.openSession();
// save values in maps
byte[] slotHandle = ValueGenerators.generateRandom(64);
handle.setSlotHandle(slotHandle);
managedSlots.put(slotHandle, slot);
managedSessions.put(slotHandle, session);
} else {
throw new IncorrectParameterException("No slot found for requestet handle.");
}
cardStateEntry.setSlotHandle(handle.getSlotHandle());
// reset the ef FCP
cardStateEntry.unsetFCPOfSelectedEF();
states.addEntry(cardStateEntry);
response.setConnectionHandle(cardStateEntry.handleCopy());
response.getConnectionHandle().setCardApplication(applicationID);
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (CryptokiException ex) {
String msg = "Error in Middleware.";
LOG.error(msg, ex);
response.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MwEventObject method toString.
@Override
public String toString() {
ConnectionHandleType handle = getHandle();
String ifdName = handle.getIFDName();
String slotHandle = ByteUtils.toHexString(handle.getSlotHandle());
ConnectionHandleType.RecognitionInfo recInfo = handle.getRecognitionInfo();
String cardType = recInfo != null ? recInfo.getCardType() : null;
return String.format("MwEventObject={ifdName=%s, slot=%s, cardType=%s}", ifdName, slotHandle, cardType);
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MwEventRunner method sendCardInserted.
private void sendCardInserted(MwSlot slot) {
// Add new Terminal to cache if needed
this.sendTerminalAdded(slot);
if (slots.get(slot.getSlotInfo().getSlotID()).isCardPresent) {
// Event already sended
return;
}
CkSlot ckSlot = slot.getSlotInfo();
// send card inserted
ConnectionHandleType insertHandle = makeUnknownCardHandle(ckSlot.getSlotDescription(), ckSlot.getSlotID());
MwEventObject insertEvent = new MwEventObject(insertHandle, slot);
notify(EventType.CARD_INSERTED, insertEvent);
// For Cache
slots.get(slot.getSlotInfo().getSlotID()).isCardPresent = true;
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MwEventRunner method makeKnownCardHandle.
private ConnectionHandleType makeKnownCardHandle(String ifdName, long slotIdx, String cardType, boolean isProtectedAuthPath) {
ConnectionHandleType.RecognitionInfo rInfo = new ConnectionHandleType.RecognitionInfo();
rInfo.setCardType(cardType);
rInfo.setCaptureTime(dataFactory.newXMLGregorianCalendar(new GregorianCalendar()));
ConnectionHandleType h = builder.setIfdName(ifdName).setSlotIdx(BigInteger.valueOf(slotIdx)).setRecognitionInfo(rInfo).setProtectedAuthPath(isProtectedAuthPath).buildConnectionHandle();
return h;
}
Aggregations