Search in sources :

Example 21 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType 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 22 with CardInfoType

use of iso.std.iso_iec._24727.tech.schema.CardInfoType 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)

Example 23 with CardInfoType

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

the class StatusHandler method handleRequest.

/**
 * Handles a Status-Request by returning a status message describing the capabilities if the App.
 *
 * @param statusRequest Status Request possibly containing a session identifier for event registration.
 * @return Status message.
 */
public StatusResponse handleRequest(StatusRequest statusRequest) {
    Status status = new Status();
    // user agent
    StatusType.UserAgent ua = new StatusType.UserAgent();
    ua.setName(AppVersion.getName());
    ua.setVersionMajor(BigInteger.valueOf(AppVersion.getMajor()));
    ua.setVersionMinor(BigInteger.valueOf(AppVersion.getMinor()));
    ua.setVersionSubminor(BigInteger.valueOf(AppVersion.getPatch()));
    status.setUserAgent(ua);
    // API versions
    StatusType.SupportedAPIVersions apiVersion = new StatusType.SupportedAPIVersions();
    apiVersion.setName("http://www.bsi.bund.de/ecard/api");
    apiVersion.setVersionMajor(ECardConstants.ECARD_API_VERSION_MAJOR);
    apiVersion.setVersionMinor(ECardConstants.ECARD_API_VERSION_MINOR);
    apiVersion.setVersionSubminor(ECardConstants.ECARD_API_VERSION_SUBMINOR);
    status.getSupportedAPIVersions().add(apiVersion);
    // supported cards
    List<CardInfoType> cifs = rec.getCardInfos();
    List<StatusType.SupportedCards> supportedCards = getSupportedCards(protocols, cifs);
    status.getSupportedCards().addAll(supportedCards);
    // supported DID protocols
    status.getSupportedDIDProtocols().addAll(protocols);
    // TODO: additional features
    // add available cards
    status.getConnectionHandle().addAll(getCardHandles());
    // register session for wait for change
    if (statusRequest.hasSessionIdentifier()) {
        String sessionIdentifier = statusRequest.getSessionIdentifier();
        eventHandler.addQueue(sessionIdentifier);
    }
    return new StatusResponse(status);
}
Also used : Status(org.openecard.ws.schema.Status) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) StatusType(org.openecard.ws.schema.StatusType)

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