use of iso.std.iso_iec._24727.tech.schema.Connect 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.Connect 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.Connect 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());
}
use of iso.std.iso_iec._24727.tech.schema.Connect in project open-ecard by ecsec.
the class TinySALTest method testDsiRead.
/**
* Test of dsiRead method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDsiRead() {
System.out.println("dsiRead");
// test normal case
// get esign path
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 result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
// read EF.C.CH.AUT
DSIRead dsiRead = new DSIRead();
dsiRead.setConnectionHandle(result.getConnectionHandle());
dsiRead.setDSIName("EF.C.CH.AUT");
DSIReadResponse dsiReadResponse = instance.dsiRead(dsiRead);
System.out.println(dsiReadResponse.getResult().getResultMinor());
assertEquals(ECardConstants.Major.OK, dsiReadResponse.getResult().getResultMajor());
System.out.println(dsiReadResponse.getResult().getResultMinor());
assertTrue(dsiReadResponse.getDSIContent().length > 0);
// test connectionhandle == null
dsiRead = new DSIRead();
dsiRead.setConnectionHandle(null);
dsiRead.setDSIName("EF.C.CH.AUT");
dsiReadResponse = instance.dsiRead(dsiRead);
assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
// test dsiName == null
dsiRead = new DSIRead();
dsiRead.setConnectionHandle(result.getConnectionHandle());
dsiRead.setDSIName(null);
dsiReadResponse = instance.dsiRead(dsiRead);
assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
// test dsiName invalid
dsiRead = new DSIRead();
dsiRead.setConnectionHandle(result.getConnectionHandle());
dsiRead.setDSIName("INVALID");
dsiReadResponse = instance.dsiRead(dsiRead);
assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND, dsiReadResponse.getResult().getResultMinor());
// test security condition not satisfied
dsiRead = new DSIRead();
dsiRead.setConnectionHandle(result.getConnectionHandle());
dsiRead.setDSIName("EF.C.CH.AUTN");
dsiReadResponse = instance.dsiRead(dsiRead);
assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.SAL.SECURITY_CONDITION_NOT_SATISFIED, dsiReadResponse.getResult().getResultMinor());
// test invalid connectionhandle
dsiRead = new DSIRead();
dsiRead.setConnectionHandle(result.getConnectionHandle());
dsiRead.getConnectionHandle().setIFDName("invalid");
dsiRead.setDSIName(null);
dsiReadResponse = instance.dsiRead(dsiRead);
assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
}
use of iso.std.iso_iec._24727.tech.schema.Connect in project open-ecard by ecsec.
the class TinySALTest method testDataSetCreate.
/**
* Test of dataSetCreate method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDataSetCreate() {
System.out.println("dataSetCreate");
DataSetCreate parameters = new DataSetCreate();
// 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 result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
AccessControlListType accessControlList = new AccessControlListType();
parameters.setConnectionHandle(result.getConnectionHandle());
String dataSetName = "DataSetTest";
parameters.setDataSetName(dataSetName);
parameters.setDataSetACL(accessControlList);
DataSetCreateResponse resultDataSetCreate = instance.dataSetCreate(parameters);
assertEquals(ECardConstants.Major.OK, resultDataSetCreate.getResult().getResultMajor());
// list datasets of esign
DataSetList dataSetList = new DataSetList();
dataSetList.setConnectionHandle(result.getConnectionHandle());
DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
Iterator<String> it = dataSetListResponse.getDataSetNameList().getDataSetName().iterator();
boolean appFound = false;
while (it.hasNext()) {
String val = it.next();
if (val.equals(dataSetName)) {
appFound = true;
}
}
assertTrue(appFound);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
}
Aggregations