Search in sources :

Example 16 with CardInfo

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

the class CardInfoWrapperTest method test.

/**
 * Simple test for CardInfoWrapper-class. After getting the CardInfoWrapper for the npa we
 * check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    assertEquals(cardInfoWrapper.getCardType(), "http://bsi.bund.de/cif/npa.xml");
    assertEquals(cardInfoWrapper.getImplicitlySelectedApplication(), rootApplication);
    assertEquals(cardInfoWrapper.getCardApplications().size(), 3);
    assertEquals(cardInfoWrapper.getDataSetNameList(rootApplication).getDataSetName().size(), 5);
    assertEquals(cardInfoWrapper.getCardApplicationNameList().size(), 3);
// CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 17 with CardInfo

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

the class SALStateCallback method signalEvent.

@Override
public void signalEvent(EventType eventType, EventObject eventData) {
    if (eventData instanceof IfdEventObject) {
        IfdEventObject ifdEvtData = (IfdEventObject) eventData;
        ConnectionHandleType handle = ifdEvtData.getHandle();
        switch(eventType) {
            // only add cards with a cardinfo file
            case CARD_RECOGNIZED:
                LOG.info("Add ConnectionHandle to SAL:\n{}", HandlePrinter.printHandle(handle));
                String cardType = handle.getRecognitionInfo().getCardType();
                CardInfoType cif = env.getCIFProvider().getCardInfo(handle, cardType);
                if (cif != null) {
                    manager.addCredential(handle, ifdEvtData.getIfaceProtocol(), cif);
                } else {
                    LOG.info("Not adding card to SAL, because it has no CardInfo file.");
                }
                break;
            case CARD_REMOVED:
                LOG.info("Remove ConnectionHandle from SAL.\n{}", HandlePrinter.printHandle(handle));
                manager.removeCredential(handle);
                break;
            default:
                // not a relevant event
                break;
        }
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) IfdEventObject(org.openecard.common.event.IfdEventObject)

Aggregations

CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)11 Test (org.testng.annotations.Test)5 Expectations (mockit.Expectations)4 ClientEnv (org.openecard.common.ClientEnv)4 Environment (org.openecard.common.interfaces.Environment)4 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)4 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 CardApplicationType (iso.std.iso_iec._24727.tech.schema.CardApplicationType)2 CardInfo (iso.std.iso_iec._24727.tech.schema.CardInfo)2 CardTypeType (iso.std.iso_iec._24727.tech.schema.CardTypeType)2 DIDInfoType (iso.std.iso_iec._24727.tech.schema.DIDInfoType)2 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)2 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)2 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)2 GetCardInfoOrACD (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD)2 GetCardInfoOrACDResponse (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse)2 Serializable (java.io.Serializable)2 InternationalStringType (oasis.names.tc.dss._1_0.core.schema.InternationalStringType)2 WSMarshaller (org.openecard.ws.marshal.WSMarshaller)2 WSMarshallerException (org.openecard.ws.marshal.WSMarshallerException)2