use of org.openecard.addons.cg.impl.ChipGatewayTask in project open-ecard by ecsec.
the class TCTokenHandler method processBinding.
/**
* Performs the actual ChipGateway procedure.
* Connects the given card, establishes the HTTP channel and talks to the server. Afterwards disconnects the card.
*
* @param token The TCToken containing the connection parameters.
* @return A TCTokenResponse indicating success or failure.
* @throws DispatcherException If there was a problem dispatching a request from the server.
* @throws ChipGatewayException If there was a transport error.
*/
private ChipGatewayResponse processBinding(@Nonnull TCToken token) throws InvalidTCTokenElement, RedirectionBaseError, InvalidRedirectUrlException {
ChipGatewayResponse response = new ChipGatewayResponse();
response.setToken(token);
String binding = token.getBinding();
switch(binding) {
case "http://ws.openecard.org/binding/chipgateway":
{
ChipGatewayTask task = new ChipGatewayTask(token, ctx);
FutureTask<TerminateType> cgTask = new FutureTask<>(task);
Thread cgThread = new Thread(cgTask, "ChipGateway-" + THREAD_NUM.getAndIncrement());
cgThread.start();
// wait for computation to finish
waitForTask(token, cgTask, cgThread);
break;
}
default:
// unknown binding
throw new InvalidTCTokenElement(ELEMENT_VALUE_INVALID, "Binding");
}
return response;
}
Aggregations