use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class TinySALTest method setUp.
@BeforeMethod()
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher dispatcher = new MessageDispatcher(env);
env.setDispatcher(dispatcher);
IFD ifd = new IFD();
ifd.setEnvironment(env);
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
contextHandle = ecr.getContextHandle();
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(contextHandle, listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
CIFProvider cp = new CIFProvider() {
@Override
public CardInfoType getCardInfo(ConnectionHandleType type, String cardType) {
return cr.getCardInfo(cardType);
}
@Override
public boolean needsRecognition(byte[] atr) {
return true;
}
@Override
public CardInfoType getCardInfo(String cardType) throws RuntimeException {
return cr.getCardInfo(cardType);
}
@Override
public InputStream getCardImage(String cardType) {
return null;
}
};
env.setCIFProvider(cp);
SALStateCallback salCallback = new SALStateCallback(env, states);
ConnectionHandleType connectionHandleType = new ConnectionHandleType();
connectionHandleType.setContextHandle(ecr.getContextHandle());
connectionHandleType.setRecognitionInfo(recognitionInfo);
connectionHandleType.setIFDName(listIFDsResponse.getIFDName().get(0));
connectionHandleType.setSlotIndex(new BigInteger("0"));
salCallback.signalEvent(EventType.CARD_RECOGNIZED, new IfdEventObject(connectionHandleType));
instance = new TinySAL(env, states);
env.setSAL(instance);
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class MiddlewareConfig method getCardInfoByCardSpec.
/**
* Stores the CardType-Spec in a freshly allocated CardInfo Template.
* The filled CardInfo Template will be returned.
*
* @param cardSpec specification of the card.
* @return {@code CardInfoType} or {@code null} if there is no available CardInfo Template.
*/
public CardInfoType getCardInfoByCardSpec(CardSpecType cardSpec) {
CardInfoType cardInfo = getCardInfoTemplate();
cardInfo.setCardType(mapCardSpecToCardType(cardSpec));
return cardInfo;
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class MiddlewareConfig method getCardInfoTemplate.
/**
* Returns the CardInfo-Template as CardInfoType.
*
* @return CardInfo-Template or {@code null} if template can not be parsed.
*/
@Nonnull
private synchronized CardInfoType getCardInfoTemplate() {
CardInfoType cardInfo;
try {
WSMarshaller m = MARSHALLER.deref();
assert (m != null);
Document doc = CIF_DOC.deref();
cardInfo = m.unmarshal(doc, CardInfoType.class).getValue();
return cardInfo;
} catch (WSMarshallerException ex) {
String msg = "Can not parse CardInfo-Document.";
LOG.error(msg, ex);
throw new RuntimeException(CARD_IMAGE_PATH, ex);
} catch (InterruptedException ex) {
String msg = "Shutdown requested while retrieving CIF template.";
LOG.debug(msg);
throw new RuntimeException(msg);
} catch (NullPointerException ex) {
String msg = "Marshaller and/ or CIF Template could not be loaded correctly.";
LOG.error(msg, ex);
throw new RuntimeException(msg);
}
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class MiddlewareSAL method augmentCardInfo.
private CardInfoType augmentCardInfo(@Nonnull ConnectionHandleType handle, @Nonnull CardInfoType template, @Nonnull CardSpecType cardSpec) {
boolean needsConnect = handle.getSlotHandle() == null;
try {
// connect card, so that we have a session
MwSession session;
if (needsConnect) {
MwSlot slot = getMatchingSlot(handle.getIFDName(), handle.getSlotIndex());
if (slot != null) {
session = slot.openSession();
} else {
throw new TokenException("No card available in this slot.", CryptokiLibrary.CKR_TOKEN_NOT_PRESENT);
}
} else {
session = managedSessions.get(handle.getSlotHandle());
}
if (session != null) {
CIFCreator cc = new CIFCreator(session, template, cardSpec);
CardInfoType cif = cc.addTokenInfo();
LOG.info("Finished augmenting CardInfo file.");
return cif;
} else {
LOG.warn("Card not available for object info retrieval anymore.");
return null;
}
} catch (WSMarshallerException ex) {
throw new RuntimeException("Failed to marshal CIF file.", ex);
} catch (CryptokiException ex) {
throw new RuntimeException("Error in PKCS#11 module while requesting CIF data.", ex);
}
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class CardRecognitionImpl method getAllTypesFromRepo.
private List<String> getAllTypesFromRepo(org.openecard.ws.GetCardInfoOrACD repo) throws WSHelper.WSException {
// read list of all cifs from the repo
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_OTHER);
GetCardInfoOrACDResponse res = repo.getCardInfoOrACD(req);
WSHelper.checkResult(res);
ArrayList<String> oids = new ArrayList<>();
for (Object cif : res.getCardInfoOrCapabilityInfo()) {
if (cif instanceof CardInfoType) {
String type = ((CardInfoType) cif).getCardType().getObjectIdentifier();
oids.add(type);
}
}
return oids;
}
Aggregations