use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse in project open-ecard by ecsec.
the class AbstractPINAction method connectToRootApplication.
/**
* Connect to the root application of the card specified with a connection handle using a empty CardApplicationPath
* and afterwards a CardApplicationConnect.
*
* @param cHandle
* The connection handle for the card to connect to root application.
* @return The updated connection handle (now including a SlotHandle) or null if connecting went wrong.
*/
protected ConnectionHandleType connectToRootApplication(ConnectionHandleType cHandle) {
// Perform a CardApplicationPath and CardApplicationConnect to connect to the card application
CardApplicationPath cardApplicationPath = new CardApplicationPath();
cardApplicationPath.setCardAppPathRequest(cHandle);
CardApplicationPathResponse cardApplicationPathResponse = (CardApplicationPathResponse) dispatcher.safeDeliver(cardApplicationPath);
// Check CardApplicationPathResponse
try {
WSHelper.checkResult(cardApplicationPathResponse);
} catch (WSException ex) {
LOG.error("CardApplicationPath failed.", ex);
return null;
}
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse cardApplicationConnectResponse = (CardApplicationConnectResponse) dispatcher.safeDeliver(cardApplicationConnect);
// Check CardApplicationConnectResponse
try {
WSHelper.checkResult(cardApplicationConnectResponse);
} catch (WSException ex) {
LOG.error("CardApplicationConnect failed.", ex);
return null;
}
// Update ConnectionHandle. It now includes a SlotHandle.
cHandle = cardApplicationConnectResponse.getConnectionHandle();
return cHandle;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse in project open-ecard by ecsec.
the class ChangePinInSALAction method connectCards.
private List<ConnectionHandleType> connectCards() throws WSHelper.WSException {
// get all cards in the system
CardApplicationPath pathReq = new CardApplicationPath();
CardApplicationPathType pathType = new CardApplicationPathType();
pathReq.setCardAppPathRequest(pathType);
CardApplicationPathResponse pathRes = (CardApplicationPathResponse) dispatcher.safeDeliver(pathReq);
WSHelper.checkResult(pathRes);
// connect every card in the set
ArrayList<ConnectionHandleType> connectedCards = new ArrayList<>();
for (CardApplicationPathType path : pathRes.getCardAppPathResultSet().getCardApplicationPathResult()) {
try {
CardApplicationConnect conReq = new CardApplicationConnect();
conReq.setCardApplicationPath(path);
conReq.setExclusiveUse(false);
CardApplicationConnectResponse conRes = (CardApplicationConnectResponse) dispatcher.safeDeliver(conReq);
WSHelper.checkResult(conRes);
connectedCards.add(conRes.getConnectionHandle());
} catch (WSHelper.WSException ex) {
LOG.error("Failed to connect card, skipping this entry.", ex);
}
}
return connectedCards;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse in project open-ecard by ecsec.
the class TinySAL method cardApplicationPath.
/**
* The CardApplicationPath function determines a path between the client application and a card application.
* See BSI-TR-03112-4, version 1.1.2, section 3.1.3.
*
* @param request CardApplicationPath
* @return CardApplicationPathResponse
*/
@Override
public CardApplicationPathResponse cardApplicationPath(CardApplicationPath request) {
CardApplicationPathResponse response = WSHelper.makeResponse(CardApplicationPathResponse.class, WSHelper.makeResultOK());
try {
CardApplicationPathType cardAppPath = request.getCardAppPathRequest();
Assert.assertIncorrectParameter(cardAppPath, "The parameter CardAppPathRequest is empty.");
Set<CardStateEntry> entries = states.getMatchingEntries(cardAppPath);
// Copy entries to result set
CardAppPathResultSet resultSet = new CardAppPathResultSet();
List<CardApplicationPathType> resultPaths = resultSet.getCardApplicationPathResult();
for (CardStateEntry entry : entries) {
CardApplicationPathType pathCopy = entry.pathCopy();
if (cardAppPath.getCardApplication() != null) {
pathCopy.setCardApplication(cardAppPath.getCardApplication());
} else {
if (entry.getImplicitlySelectedApplicationIdentifier() != null) {
pathCopy.setCardApplication(entry.getImplicitlySelectedApplicationIdentifier());
} else {
LOG.warn("No CardApplication and ImplicitlySelectedApplication available using MF now.");
pathCopy.setCardApplication(MF);
}
}
resultPaths.add(pathCopy);
}
response.setCardAppPathResultSet(resultSet);
} catch (IncorrectParameterException e) {
response.setResult(e.getResult());
}
return response;
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationPath.
/**
* Test of cardApplicationPath method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationPath() {
System.out.println("cardApplicationPath");
// test normal case
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(this.appIdentifier_ESIGN);
cardApplicationPathType.setContextHandle(contextHandle);
cardApplicationPathType.setSlotIndex(new BigInteger("0"));
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
assertTrue(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size() > 0);
assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
// test return of alpha card application
cardApplicationPath = new CardApplicationPath();
cardApplicationPathType = new CardApplicationPathType();
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
assertTrue(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size() > 0);
assertNotNull(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0).getCardApplication());
assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
// test non existent card application identifier
cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(Hex.decode("C0CA"));
cardApplicationPathType.setContextHandle(contextHandle);
cardApplicationPathType.setSlotIndex(new BigInteger("0"));
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
assertEquals(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size(), 0);
assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
// test nullpointer
cardApplicationPath.setCardAppPathRequest(null);
cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.ERROR);
assertEquals(cardApplicationPathResponse.getResult().getResultMinor(), ECardConstants.Minor.App.INCORRECT_PARM);
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationServiceDescribe.
/**
* Test of cardApplicationServiceDescribe method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationServiceDescribe() {
System.out.println("cardApplicationServiceDescribe");
CardApplicationServiceDescribe parameters = new CardApplicationServiceDescribe();
// get path to esign
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
assertTrue(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size() > 0);
assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
// connect to esign
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
parameters.setConnectionHandle(result.getConnectionHandle());
parameters.setCardApplicationServiceName("testService");
CardApplicationServiceDescribeResponse resultServiceDescribe = instance.cardApplicationServiceDescribe(parameters);
assertEquals(ECardConstants.Major.OK, resultServiceDescribe.getResult().getResultMajor());
}
Aggregations