Search in sources :

Example 11 with CardInfoType

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

the class CardApplicationWrapperTest method test.

/**
 * Simple test for CardApplicationWrapper-class. After getting the CardApplicationWrapper for the root application
 * 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);
    CardApplicationWrapper cardAppWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    assertEquals(cardAppWrapper.getApplicationIdentifier(), rootApplication);
    assertEquals(cardAppWrapper.getDataSetNameList().getDataSetName().size(), 5);
    assertEquals(cardAppWrapper.getDIDInfoList().size(), 9);
    assertEquals(cardAppWrapper.getCardApplicationACL().getAccessRule().size(), 40);
    assertNotNull(cardAppWrapper.getSecurityCondition(CardApplicationServiceActionName.CARD_APPLICATION_LIST));
}
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 12 with CardInfoType

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

the class DIDInfoWrapperTest method test.

/**
 * Simple test for DIDInfoWrapper-class. After getting the DIDInfoWrapper for the CAN DID in the
 * root applicaton of 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);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DIDInfoWrapper didInfoWrapper = cardApplicationWrapper.getDIDInfo("CAN");
    assertSame(didInfoWrapper, cardApplicationWrapper.getDIDInfo("CAN"));
    assertNotNull(didInfoWrapper.getDIDInfo());
    assertNotNull(didInfoWrapper.getSecurityCondition(DifferentialIdentityServiceActionName.DID_GET));
}
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 13 with CardInfoType

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

the class DataSetInfoWrapperTest method test.

/**
 * Simple test for DataSetInfoWrapper-class. After getting the DataSetInfoWrapper for the EF.DIR data set in the
 * root applicaton of 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);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DataSetInfoWrapper dataSetInfoWrapper = cardApplicationWrapper.getDataSetInfo("EF.DIR");
    assertSame(dataSetInfoWrapper, cardApplicationWrapper.getDataSetInfo("EF.DIR"));
    assertNotNull(dataSetInfoWrapper.getDataSetInfo());
    assertNotNull(dataSetInfoWrapper.getSecurityCondition(NamedDataServiceActionName.DSI_READ));
}
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 14 with CardInfoType

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

the class TestClient method setup.

private void setup() throws Exception {
    // Set up client environment
    ClientEnv env = new ClientEnv();
    // Set up the IFD
    IFD ifd = new IFD();
    env.setIFD(ifd);
    // Set up Management
    TinyManagement management = new TinyManagement(env);
    env.setManagement(management);
    // Set up the Dispatcher
    MessageDispatcher dispatcher = new MessageDispatcher(env);
    env.setDispatcher(dispatcher);
    // Perform an EstablishContext to get a ContextHandle
    EstablishContext establishContext = new EstablishContext();
    EstablishContextResponse establishContextResponse = ifd.establishContext(establishContext);
    byte[] contextHandle = ifd.establishContext(establishContext).getContextHandle();
    final CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    env.setRecognition(recognition);
    env.setCIFProvider(new CIFProvider() {

        @Override
        public CardInfoType getCardInfo(ConnectionHandleType type, String cardType) {
            return recognition.getCardInfo(cardType);
        }

        @Override
        public boolean needsRecognition(byte[] atr) {
            return true;
        }

        @Override
        public CardInfoType getCardInfo(String cardType) throws RuntimeException {
            return recognition.getCardInfo(cardType);
        }

        @Override
        public InputStream getCardImage(String cardType) {
            return recognition.getCardImage(cardType);
        }
    });
    // Set up EventManager
    EventDispatcher ed = new EventDispatcherImpl();
    env.setEventDispatcher(ed);
    // Set up SALStateCallback
    cardStates = new CardStateMap();
    SALStateCallback salCallback = new SALStateCallback(env, cardStates);
    ed.add(salCallback);
    // Set up SAL
    sal = new TinySAL(env, cardStates);
    env.setSAL(sal);
    // Set up GUI
    SwingUserConsent gui = new SwingUserConsent(new SwingDialogWrapper());
    sal.setGUI(gui);
    ifd.setGUI(gui);
    // Initialize the EventManager
    ed.start();
    AddonManager manager = new AddonManager(env, gui, cardStates, null);
    sal.setAddonManager(manager);
    HttpBinding binding = new HttpBinding(24727);
    binding.setAddonManager(manager);
    binding.start();
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SALStateCallback(org.openecard.common.sal.state.SALStateCallback) TinySAL(org.openecard.sal.TinySAL) EventDispatcherImpl(org.openecard.common.event.EventDispatcherImpl) IFD(org.openecard.ifd.scio.IFD) InputStream(java.io.InputStream) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) CIFProvider(org.openecard.common.interfaces.CIFProvider) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) TinyManagement(org.openecard.management.TinyManagement) CardStateMap(org.openecard.common.sal.state.CardStateMap) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) AddonManager(org.openecard.addon.AddonManager)

Example 15 with CardInfoType

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

the class Status method resolveCardType.

private String resolveCardType(String cardType) {
    if (cardType.equals("http://bsi.bund.de/cif/unknown")) {
        return lang.translationForKey("status.unknowncard");
    } else {
        // read CardTypeName from CardInfo file
        String cardTypeName = cardType;
        CardInfoType cif = env.getCIFProvider().getCardInfo(cardType);
        if (cif != null) {
            CardTypeType type = cif.getCardType();
            if (type != null) {
                boolean found = false;
                String[] languages = new String[] { Locale.getDefault().getLanguage(), "en" };
                // check native lang, then english
                for (String language : languages) {
                    if (found) {
                        // stop when the inner loop terminated
                        break;
                    }
                    List<InternationalStringType> cardTypeNames = type.getCardTypeName();
                    for (InternationalStringType ist : cardTypeNames) {
                        if (ist.getLang().equalsIgnoreCase(language)) {
                            cardTypeName = ist.getValue();
                            found = true;
                            break;
                        }
                    }
                }
            }
        }
        return cardTypeName;
    }
}
Also used : CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) CardTypeType(iso.std.iso_iec._24727.tech.schema.CardTypeType) InternationalStringType(oasis.names.tc.dss._1_0.core.schema.InternationalStringType)

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