use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.
the class TinySAL method cardApplicationList.
/**
* The CardApplicationList function returns a list of the available card applications on an eCard.
* See BSI-TR-03112-4, version 1.1.2, section 3.3.1.
*
* @param request CardApplicationList
* @return CardApplicationListResponse
*/
@Publish
@Override
public CardApplicationListResponse cardApplicationList(CardApplicationList request) {
CardApplicationListResponse response = WSHelper.makeResponse(CardApplicationListResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
/*
TR-03112-4 section 3.3.2 states that the alpha application have to be connected with
CardApplicationConnect.
In case of using CardInfo file descriptions this is not necessary because we just work on a file.
*/
// byte[] cardApplicationID = connectionHandle.getCardApplication();
// Assert.securityConditionApplication(cardStateEntry, cardApplicationID,
// CardApplicationServiceActionName.CARD_APPLICATION_LIST);
CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
CardApplicationNameList cardApplicationNameList = new CardApplicationNameList();
cardApplicationNameList.getCardApplicationName().addAll(cardInfoWrapper.getCardApplicationNameList());
response.setCardApplicationNameList(cardApplicationNameList);
} catch (ECardException e) {
response.setResult(e.getResult());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throwThreadKillException(e);
response.setResult(WSHelper.makeResult(e));
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationList 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);
}
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationList.
/**
* Test of cardApplicationList method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationList() {
System.out.println("cardApplicationList");
// get path to root
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ROOT);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
// connect to root
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
CardApplicationList cardApplicationList = new CardApplicationList();
cardApplicationList.setConnectionHandle(result.getConnectionHandle());
CardApplicationListResponse cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
System.out.println(cardApplicationListResponse.getResult().getResultMinor());
assertEquals(ECardConstants.Major.OK, cardApplicationListResponse.getResult().getResultMajor());
assertTrue(cardApplicationListResponse.getCardApplicationNameList().getCardApplicationName().size() > 0);
// test non existent connectionhandle
cardApplicationList = new CardApplicationList();
cardApplicationList.setConnectionHandle(result.getConnectionHandle());
cardApplicationList.getConnectionHandle().setIFDName("invalid");
cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
assertEquals(ECardConstants.Major.ERROR, cardApplicationListResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationListResponse.getResult().getResultMinor());
// test nullpointer
cardApplicationList = new CardApplicationList();
cardApplicationList.setConnectionHandle(null);
cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
assertEquals(ECardConstants.Major.ERROR, cardApplicationListResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationListResponse.getResult().getResultMinor());
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationDelete.
/**
* Test of cardApplicationDelete method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationDelete() {
System.out.println("cardApplicationDelete");
Set<CardStateEntry> cHandles = states.getMatchingEntries(new ConnectionHandleType());
byte[] appName = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
CardApplicationDelete parameters = new CardApplicationDelete();
parameters.setConnectionHandle(cHandles.iterator().next().handleCopy());
parameters.setCardApplicationName(appName);
CardApplicationDeleteResponse result = instance.cardApplicationDelete(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);
}
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationList in project open-ecard by ecsec.
the class DidInfos method getApplicationsInt.
synchronized List<byte[]> getApplicationsInt() throws WSHelper.WSException {
if (applications == null) {
CardApplicationList req = new CardApplicationList();
req.setConnectionHandle(getHandle());
CardApplicationListResponse res = (CardApplicationListResponse) dispatcher.safeDeliver(req);
WSHelper.checkResult(res);
CardApplicationListResponse.CardApplicationNameList nameList = res.getCardApplicationNameList();
if (nameList != null) {
applications = Collections.unmodifiableList(nameList.getCardApplicationName());
}
}
return applications;
}
Aggregations