use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class CardRecognitionImpl method getCardInfos.
@Override
public List<CardInfoType> getCardInfos() {
// TODO: add caching
GetCardInfoOrACD req = new GetCardInfoOrACD();
req.setAction(ECardConstants.CIF.GET_OTHER);
GetCardInfoOrACDResponse res = getCifRepo().getCardInfoOrACD(req);
// checkout response if it contains our cardinfo
List<Serializable> cifs = res.getCardInfoOrCapabilityInfo();
ArrayList<CardInfoType> result = new ArrayList<>();
for (Serializable next : cifs) {
if (next instanceof CardInfoType) {
result.add((CardInfoType) next);
}
}
return result;
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class LocalCifRepo method getCardInfoOrACD.
@Override
public GetCardInfoOrACDResponse getCardInfoOrACD(iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD parameters) {
List<String> cardTypes = parameters.getCardTypeIdentifier();
ArrayList<CardInfoType> cifsResult = new ArrayList<>(cardTypes.size());
Result result = WSHelper.makeResultOK();
try {
if (ECardConstants.CIF.GET_SPECIFIED.equals(parameters.getAction())) {
ArrayList<String> missingTypes = new ArrayList<>();
for (String cardType : cardTypes) {
Document cif = cifs.get(cardType);
if (cif == null) {
missingTypes.add(cardType);
} else {
// marshal here to receive a copy of the CIF
cifsResult.add((CardInfoType) m.unmarshal(cif));
}
}
if (!missingTypes.isEmpty()) {
StringBuilder error = new StringBuilder("The following card types could not be found:");
for (String type : missingTypes) {
error.append("\n ").append(type);
}
result = WSHelper.makeResultError(ECardConstants.Minor.SAL.UNKNOWN_CARDTYPE, error.toString());
}
} else if (ECardConstants.CIF.GET_OTHER.equals(parameters.getAction())) {
HashMap<String, Document> cifsTmp = new HashMap<>();
cifsTmp.putAll(cifs);
for (String cardType : cardTypes) {
cifsTmp.remove(cardType);
}
for (Map.Entry<String, Document> e : cifsTmp.entrySet()) {
Document next = e.getValue();
cifsResult.add((CardInfoType) m.unmarshal(next));
}
} else {
result = WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR, "Given action is unsupported.");
}
GetCardInfoOrACDResponse res = WSHelper.makeResponse(GetCardInfoOrACDResponse.class, result);
res.getCardInfoOrCapabilityInfo().addAll(cifsResult);
return res;
} catch (WSMarshallerException ex) {
String msg = "Failed to unmarshal a CIF document.";
logger.error(msg, ex);
result = WSHelper.makeResultError(ECardConstants.Minor.App.INT_ERROR, msg);
GetCardInfoOrACDResponse res = WSHelper.makeResponse(GetCardInfoOrACDResponse.class, result);
return res;
}
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class PINCompareProtocolTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher d = new MessageDispatcher(env);
env.setDispatcher(d);
IFD ifd = new IFD();
ifd.setGUI(uc);
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
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 cr.getCardImage(cardType);
}
};
env.setCIFProvider(cp);
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(ecr.getContextHandle(), listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
SALStateCallback salCallback = new SALStateCallback(env, states);
Connect c = new Connect();
c.setContextHandle(ecr.getContextHandle());
c.setIFDName(listIFDsResponse.getIFDName().get(0));
c.setSlot(BigInteger.ZERO);
ConnectResponse connectResponse = env.getIFD().connect(c);
ConnectionHandleType connectionHandleType = new ConnectionHandleType();
connectionHandleType.setContextHandle(ecr.getContextHandle());
connectionHandleType.setRecognitionInfo(recognitionInfo);
connectionHandleType.setIFDName(listIFDsResponse.getIFDName().get(0));
connectionHandleType.setSlotIndex(BigInteger.ZERO);
connectionHandleType.setSlotHandle(connectResponse.getSlotHandle());
salCallback.signalEvent(EventType.CARD_RECOGNIZED, new IfdEventObject(connectionHandleType));
instance = new TinySAL(env, states);
// init AddonManager
AddonManager manager = new AddonManager(env, uc, states, null);
instance.setAddonManager(manager);
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class StatusHandler method getSupportedCards.
@Nonnull
private static List<StatusType.SupportedCards> getSupportedCards(List<String> protocols, List<CardInfoType> cifs) {
List<StatusType.SupportedCards> result = new ArrayList<>();
for (CardInfoType cif : cifs) {
StatusType.SupportedCards supportedCard = new StatusType.SupportedCards();
result.add(supportedCard);
String name = cif.getCardType().getObjectIdentifier();
supportedCard.setCardType(name);
for (CardApplicationType app : cif.getApplicationCapabilities().getCardApplication()) {
for (DIDInfoType did : app.getDIDInfo()) {
String proto = did.getDifferentialIdentity().getDIDProtocol();
// add protocol to list only if it is supported by the application and not yet added
if (protocols.contains(proto) && !supportedCard.getDIDProtocols().contains(proto)) {
supportedCard.getDIDProtocols().add(proto);
}
}
}
}
return result;
}
use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.
the class GenericCryptographyProtocolTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher d = new MessageDispatcher(env);
env.setDispatcher(d);
ifd = new IFD();
ifd.setGUI(new SwingUserConsent(new SwingDialogWrapper()));
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
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 cr.getCardImage(cardType);
}
};
env.setCIFProvider(cp);
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(ecr.getContextHandle(), listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
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);
// init AddonManager
UserConsent uc = new SwingUserConsent(new SwingDialogWrapper());
AddonManager manager = new AddonManager(env, uc, states, null);
instance.setAddonManager(manager);
}
Aggregations