use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class MiddlewareSAL method dsiRead.
@Override
public DSIReadResponse dsiRead(DSIRead request) {
DSIReadResponse response = WSHelper.makeResponse(DSIReadResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
byte[] applicationID = cardStateEntry.getCurrentCardApplication().getApplicationIdentifier();
String dsiName = request.getDSIName();
byte[] slotHandle = connectionHandle.getSlotHandle();
Assert.assertIncorrectParameter(dsiName, "The parameter DSIName is empty.");
Assert.securityConditionDataSet(cardStateEntry, applicationID, dsiName, NamedDataServiceActionName.DSI_READ);
MwSession session = managedSessions.get(slotHandle);
for (MwCertificate cert : session.getCertificates()) {
try {
String label = cert.getLabel();
if (label.equals(dsiName)) {
// read certificate
byte[] certificate = cert.getValue();
response.setDSIContent(certificate);
return response;
}
} catch (CryptokiException ex) {
LOG.warn("Skipping certificate due to error.", ex);
}
}
String msg = "The given DSIName does not related to any know DSI or DataSet.";
throw new IncorrectParameterException(msg);
} 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 didUpdate.
@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
byte[] application = cardStateEntry.getImplicitlySelectedApplicationIdentifier();
DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
String didName = SALUtils.getDIDName(request);
DIDStructureType didStruct = cardStateEntry.getDIDStructure(didName, application);
if (didStruct == null) {
String msg = String.format("DID %s does not exist.", didName);
throw new NamedEntityNotFoundException(msg);
}
Result updateResult;
String protocolURI = didUpdateData.getProtocol();
if ("urn:oid:1.3.162.15480.3.0.9".equals(protocolURI)) {
updateResult = updatePin(didUpdateData, cardStateEntry, didStruct);
} else {
String msg = String.format("Protocol %s is not supported by this SAL.", protocolURI);
throw new UnknownProtocolException(msg);
}
// create did authenticate response
response.setResult(updateResult);
} 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 cardApplicationDisconnect.
@Override
public CardApplicationDisconnectResponse cardApplicationDisconnect(CardApplicationDisconnect request) {
CardApplicationDisconnectResponse response = WSHelper.makeResponse(CardApplicationDisconnectResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
byte[] slotHandle = connectionHandle.getSlotHandle();
// check existence of required parameters
if (slotHandle == null) {
return WSHelper.makeResponse(CardApplicationDisconnectResponse.class, WSHelper.makeResultError(ECardConstants.Minor.App.INCORRECT_PARM, "ConnectionHandle is null"));
}
managedSlots.remove(slotHandle);
MwSession session = managedSessions.remove(slotHandle);
if (session != null) {
session.closeSession();
}
// remove entries associated with this handle
states.removeSlotHandleEntry(slotHandle);
} 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 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.ConnectionHandleType in project open-ecard by ecsec.
the class MiddlewareSAL method getCardInfo.
@Override
public CardInfoType getCardInfo(@Nonnull ConnectionHandleType handle, @Nonnull String cardType) throws RuntimeException {
CardInfoType cif = mwSALConfig.getCardInfo(cardType);
CardSpecType cardSpec = mwSALConfig.getCardSpecType(cardType);
if (cif != null) {
cif = augmentCardInfo(handle, cif, cardSpec);
return cif;
} else {
LOG.error("No CIF available for card type '" + cardType + '"');
return null;
}
}
Aggregations