use of iso.std.iso_iec._24727.tech.schema.CardApplicationCreate in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationCreate.
/**
* Test of cardApplicationCreate method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationCreate() {
System.out.println("cardApplicationCreate");
Set<CardStateEntry> cHandles = states.getMatchingEntries(new ConnectionHandleType());
byte[] appName = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
CardApplicationCreate parameters = new CardApplicationCreate();
parameters.setConnectionHandle(cHandles.iterator().next().handleCopy());
parameters.setCardApplicationName(appName);
AccessControlListType cardApplicationACL = new AccessControlListType();
parameters.setCardApplicationACL(cardApplicationACL);
CardApplicationCreateResponse result = instance.cardApplicationCreate(parameters);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// get path to esign
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
// connect to esign
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse resultConnect = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, resultConnect.getResult().getResultMajor());
CardApplicationList cardApplicationList = new CardApplicationList();
cardApplicationList.setConnectionHandle(cHandles.iterator().next().handleCopy());
CardApplicationListResponse cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
Iterator<byte[]> it = cardApplicationListResponse.getCardApplicationNameList().getCardApplicationName().iterator();
boolean appFound = false;
try {
while (it.hasNext()) {
byte[] val = it.next();
if (Arrays.equals(val, appName)) {
appFound = true;
}
}
assertTrue(appFound);
} catch (Exception e) {
assertTrue(appFound);
System.out.println(e);
}
}
Aggregations