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);
}
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;
}
}
}
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);
}
Aggregations