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