Search in sources :

Example 1 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType 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;
    }
}
Also used : CardSpecType(org.openecard.mdlw.sal.config.CardSpecType) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType)

Example 2 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.

the class MwStateCallback method addEntry.

public boolean addEntry(MwEventObject o) {
    try {
        ConnectionHandleType handle = o.getHandle();
        MwSlot slot = o.getMwSlot();
        MwToken token = slot.getTokenInfo();
        String cardType = null;
        String type = String.format("%s_%s", token.getManufacturerID(), token.getModel());
        for (MiddlewareConfig mwConfig : mwConfigs) {
            cardType = mwConfig.mapMiddlewareType(type);
            if (cardType != null) {
                break;
            }
        }
        CardInfoType cif = null;
        if (cardType != null) {
            cif = env.getCIFProvider().getCardInfo(handle, cardType);
        }
        if (cif == null) {
            LOG.warn("Unknown card recognized by Middleware.");
            return false;
        }
        // create new entry in card states
        CardStateEntry entry = new CardStateEntry(handle, cif, null);
        states.addEntry(entry);
        return true;
    } catch (CryptokiException ex) {
        LOG.info("Cryptoki Token invalid.", ex);
    } catch (RuntimeException ex) {
        LOG.error("Error in CIF augmentation process.", ex);
    }
    return false;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) MwSlot(org.openecard.mdlw.sal.MwSlot) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) MiddlewareConfig(org.openecard.mdlw.sal.config.MiddlewareConfig) MwToken(org.openecard.mdlw.sal.MwToken)

Example 3 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.

the class CIFCreator method addTokenInfo.

public CardInfoType addTokenInfo() throws WSMarshallerException, CryptokiException {
    LOG.debug("Adding information to CardInfo file for card type {}.", cif.getCardType().getObjectIdentifier());
    PIN_NAME = "USER_PIN";
    DIDInfoType pinDid = createPinDID();
    List<DIDInfoType> cryptoDids = getSignatureCryptoDIDs();
    List<DataSetInfoType> datasets = getCertificateDatasets();
    CardApplicationType app = cif.getApplicationCapabilities().getCardApplication().get(0);
    app.getDIDInfo().add(pinDid);
    app.getDIDInfo().addAll(cryptoDids);
    app.getDataSetInfo().addAll(datasets);
    return cif;
}
Also used : CardApplicationType(iso.std.iso_iec._24727.tech.schema.CardApplicationType) DIDInfoType(iso.std.iso_iec._24727.tech.schema.DIDInfoType) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType)

Example 4 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.

the class CardRecognitionImpl method getTranslatedCardName.

/**
 * Gets the translated card name for a card type.
 *
 * @param cardType The card type to get the card name for.
 * @return A card name matching the users locale or the English name as default. If the card is not supported, the
 *   string {@code Unknown card type} is returned.
 */
@Override
public String getTranslatedCardName(String cardType) {
    CardInfoType info = getCardInfo(cardType);
    Locale userLocale = Locale.getDefault();
    String langCode = userLocale.getLanguage();
    String enFallback = "Unknown card type.";
    if (info == null) {
        // we can identify the card but do not have a card info file for it
        return enFallback;
    }
    for (InternationalStringType typ : info.getCardType().getCardTypeName()) {
        if (typ.getLang().equalsIgnoreCase("en")) {
            enFallback = typ.getValue();
        }
        if (typ.getLang().equalsIgnoreCase(langCode)) {
            return typ.getValue();
        }
    }
    return enFallback;
}
Also used : Locale(java.util.Locale) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) InternationalStringType(oasis.names.tc.dss._1_0.core.schema.InternationalStringType)

Example 5 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType in project open-ecard by ecsec.

the class CardRecognitionImpl method getCardInfoFromRepo.

@Override
public CardInfoType getCardInfoFromRepo(String type) {
    CardInfoType cif = null;
    // only do something when a repo is specified
    if (cif == null && cifRepo != null) {
        GetCardInfoOrACD req = new GetCardInfoOrACD();
        req.setAction(ECardConstants.CIF.GET_SPECIFIED);
        req.getCardTypeIdentifier().add(type);
        GetCardInfoOrACDResponse res = getCifRepo().getCardInfoOrACD(req);
        // checkout response if it contains our cardinfo
        List<Serializable> cifs = res.getCardInfoOrCapabilityInfo();
        for (Serializable next : cifs) {
            if (next instanceof CardInfoType) {
                return (CardInfoType) next;
            }
        }
    }
    return cif;
}
Also used : Serializable(java.io.Serializable) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) GetCardInfoOrACD(iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD) GetCardInfoOrACDResponse(iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse)

Aggregations

CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)19 ClientEnv (org.openecard.common.ClientEnv)8 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)8 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)6 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)4 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)4 GetCardInfoOrACDResponse (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse)4 ArrayList (java.util.ArrayList)4 Expectations (mockit.Expectations)4 IfdEventObject (org.openecard.common.event.IfdEventObject)4 CIFProvider (org.openecard.common.interfaces.CIFProvider)4 Environment (org.openecard.common.interfaces.Environment)4 CardStateMap (org.openecard.common.sal.state.CardStateMap)4 SALStateCallback (org.openecard.common.sal.state.SALStateCallback)4 IFD (org.openecard.ifd.scio.IFD)4 MessageDispatcher (org.openecard.transport.dispatcher.MessageDispatcher)4 Test (org.testng.annotations.Test)4 RecognitionInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo)3 GetCardInfoOrACD (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD)3 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)3