use of iso.std.iso_iec._24727.tech.schema.Disconnect in project open-ecard by ecsec.
the class CardSelectionAction method updateCards.
/**
* Update the list of available and fitting cards.
*/
private void updateCards() {
avCard.clear();
CardApplicationPath cap = new CardApplicationPath();
cap.setCardAppPathRequest(new CardApplicationPathType());
CardApplicationPathResponse resp = (CardApplicationPathResponse) ctx.getDispatcher().safeDeliver(cap);
List<CardApplicationPathType> cards = resp.getCardAppPathResultSet().getCardApplicationPathResult();
for (CardApplicationPathType path : cards) {
CardApplicationConnect connect = new CardApplicationConnect();
connect.setCardApplicationPath(path);
CardApplicationConnectResponse conResp = (CardApplicationConnectResponse) ctx.getDispatcher().safeDeliver(connect);
if (types.contains(conResp.getConnectionHandle().getRecognitionInfo().getCardType())) {
avCard.add(conResp.getConnectionHandle());
} else {
CardApplicationDisconnect disconnect = new CardApplicationDisconnect();
disconnect.setConnectionHandle(conResp.getConnectionHandle());
ctx.getDispatcher().safeDeliver(disconnect);
}
}
}
use of iso.std.iso_iec._24727.tech.schema.Disconnect in project open-ecard by ecsec.
the class GetCardsAndPINStatusAction method execute.
@Override
public void execute() {
// check if a german identity card is inserted, if not wait for it
ConnectionHandleType cHandle = waitForCardType(GERMAN_IDENTITY_CARD);
if (cHandle == null) {
LOG.debug("User cancelled card insertion.");
return;
}
cHandle = connectToRootApplication(cHandle);
RecognizedState pinState = recognizeState(cHandle);
boolean nativePace;
try {
nativePace = genericPACESupport(cHandle);
} catch (WSException e) {
LOG.error("Could not get capabilities from reader.");
return;
}
PINDialog uc = new PINDialog(gui, dispatcher, cHandle, pinState, !nativePace);
uc.show();
Disconnect d = new Disconnect();
d.setSlotHandle(cHandle.getSlotHandle());
dispatcher.safeDeliver(d);
}
use of iso.std.iso_iec._24727.tech.schema.Disconnect in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationDisconnect.
/**
* Test of cardApplicationDisconnect method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationDisconnect() {
System.out.println("cardApplicationDisconnect");
// test normal case
// get esign path
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
// connect to esign
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
CardApplicationDisconnect cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// test invalid connectionhandle
// connect to esign
cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
cardApplicationDisconnect.getConnectionHandle().setSlotHandle(new byte[] { 0x0, 0x0, 0x0 });
CardApplicationDisconnectResponse cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.getResult().getResultMinor());
// test nullpointer
// connect to esign
cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(null);
cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.getResult().getResultMinor());
}
use of iso.std.iso_iec._24727.tech.schema.Disconnect in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfDisconnect.
@Test
public void testConversionOfDisconnect() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Object o = m.unmarshal(m.str2doc(DISCONNECT));
if (!(o instanceof Disconnect)) {
throw new Exception("Object should be an instace of EstablishContext");
}
Disconnect d = (Disconnect) o;
assertEquals(d.getSlotHandle(), StringUtils.toByteArray("1D8EFC10F063FB6FE8A3BBF8D2E0CA5C"));
assertEquals(d.getAction(), ActionType.EJECT);
}
use of iso.std.iso_iec._24727.tech.schema.Disconnect in project open-ecard by ecsec.
the class CardRecognitionImpl method recognizeCard.
/**
* Recognizes the card in the defined reader.
*
* @param ctx Context handle of the IFD.
* @param ifdName Name of the card reader.
* @param slot Index of the slot in the reader.
* @return RecognitionInfo structure containing the card type of the detected card or {@code null} if no card could
* be detected.
* @throws RecognitionException Thrown in case there was an error in the recognition.
*/
@Nullable
@Override
public RecognitionInfo recognizeCard(byte[] ctx, String ifdName, BigInteger slot) throws RecognitionException {
// connect card
byte[] slotHandle = connect(ctx, ifdName, slot);
// recognise card
String type = treeCalls(slotHandle, getTree().getCardCall());
// disconnect and return
disconnect(slotHandle);
// build result or throw exception if it is null or unsupported
if (type == null || !isSupportedCard(type)) {
return null;
}
RecognitionInfo info = new RecognitionInfo();
info.setCardType(type);
return info;
}
Aggregations