use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class TinySALTest method testDataSetSelect.
/**
* Test of dataSetSelect method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDataSetSelect() {
System.out.println("dataSetSelect");
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
CardApplicationConnect parameters = new CardApplicationConnect();
parameters.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse result = instance.cardApplicationConnect(parameters);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// test good case
DataSetSelect dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName("EF.C.CH.AUT");
DataSetSelectResponse dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.OK, dataSetSelectResponse.getResult().getResultMajor());
// test connectionhanle == null
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(null);
dataSetSelect.setDataSetName("EF.C.CH.AUT");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
// test datasetname == null
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName(null);
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
// test datasetname not found
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName("INVALID");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND, dataSetSelectResponse.getResult().getResultMinor());
// test invalid connectionhandle
dataSetSelect = new DataSetSelect();
ConnectionHandleType invalidConnectionHandle = result.getConnectionHandle();
invalidConnectionHandle.setIFDName(("invalid"));
dataSetSelect.setConnectionHandle(invalidConnectionHandle);
dataSetSelect.setDataSetName("EF.C.CH.AUT");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class TinySALTest method testDataSetList.
/**
* Test of dataSetList method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDataSetList() {
System.out.println("dataSetList");
// 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());
// list datasets of esign
DataSetList dataSetList = new DataSetList();
dataSetList.setConnectionHandle(result.getConnectionHandle());
DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
System.out.println(ByteUtils.toHexString(result.getConnectionHandle().getSlotHandle()));
Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
// test invalid connectionhandle
dataSetList = new DataSetList();
ConnectionHandleType wrongConnectionHandle = result.getConnectionHandle();
wrongConnectionHandle.setCardApplication(new byte[] { 0x0, 0x0, 0x0 });
dataSetList.setConnectionHandle(wrongConnectionHandle);
dataSetListResponse = instance.dataSetList(dataSetList);
assertEquals(ECardConstants.Major.ERROR, dataSetListResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetListResponse.getResult().getResultMinor());
// test null connectionhandle
dataSetList = new DataSetList();
dataSetList.setConnectionHandle(null);
dataSetListResponse = instance.dataSetList(dataSetList);
assertEquals(ECardConstants.Major.ERROR, dataSetListResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetListResponse.getResult().getResultMinor());
// TODO test for unsatisfied security condition
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfStartPAOS.
@Test
public void testConversionOfStartPAOS() throws Exception {
WSMarshaller m = new AndroidMarshaller();
StartPAOS startP = new StartPAOS();
startP.setSessionIdentifier("5ec5ebb1dd254f392e6ca33cf5bf");
ConnectionHandleType connectionHandleType = new ConnectionHandleType();
connectionHandleType.setContextHandle(new BigInteger("94D7439CE657561E7AE3D491FD71AC21F8BCBB5608BA61F5A0EA52269BC01250", 16).toByteArray());
connectionHandleType.setSlotHandle(new BigInteger("EEB49368C1152BEC379DA59356D59039CA7757AC3EAF9430285F2CBB3DD6EDDD", 16).toByteArray());
connectionHandleType.setIFDName("Name of IFD");
connectionHandleType.setSlotIndex(new BigInteger("0"));
connectionHandleType.setCardApplication(new byte[] { 0x0, 0x0, 0x0 });
ChannelHandleType channelHandle = new ChannelHandleType();
channelHandle.setSessionIdentifier("sessionID");
connectionHandleType.setChannelHandle(channelHandle);
RecognitionInfo recognitionInfo = new RecognitionInfo();
recognitionInfo.setCardType("nPA_1-0-0.xml");
connectionHandleType.setRecognitionInfo(recognitionInfo);
startP.getConnectionHandle().add(connectionHandleType);
Document d = m.marshal(startP);
assertEquals(m.doc2str(d), START_PAOS);
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class InsertCardDialog method show.
/**
* Shows this InsertCardDialog dialog.
*
* @return The ConnectionHandle of the inserted card or null if no card was inserted.
*/
public List<ConnectionHandleType> show() {
List<ConnectionHandleType> availableCards = checkAlreadyAvailable();
if (!availableCards.isEmpty()) {
return availableCards;
} else {
InsertCardStepAction insertCardAction = new InsertCardStepAction(STEP_ID, cardStates, cardNameAndType.values());
evDispatcher.add(insertCardAction, EventType.CARD_RECOGNIZED);
UserConsentNavigator ucr = gui.obtainNavigator(createInsertCardUserConsent(insertCardAction));
ExecutionEngine exec = new ExecutionEngine(ucr);
// run gui
ResultStatus status = exec.process();
if (status == ResultStatus.CANCEL) {
return null;
}
evDispatcher.del(insertCardAction);
return insertCardAction.getResponse();
}
}
use of iso.std.iso_iec._24727.tech.schema.ConnectionHandleType in project open-ecard by ecsec.
the class InsertCardDialog method checkAlreadyAvailable.
/**
* Check whether there are already cards with the required type(s) are available.
*
* @return A list containing {@link ConnectionHandleType} objects referencing the cards which fit the requirements or
* an empty list if there are no cards which met the requirements are present.
*/
private List<ConnectionHandleType> checkAlreadyAvailable() {
List<ConnectionHandleType> handlesList = new ArrayList<>();
for (String type : cardNameAndType.values()) {
ConnectionHandleType conHandle = new ConnectionHandleType();
ConnectionHandleType.RecognitionInfo recInfo = new ConnectionHandleType.RecognitionInfo();
recInfo.setCardType(type);
conHandle.setRecognitionInfo(recInfo);
Set<CardStateEntry> entries = cardStates.getMatchingEntries(conHandle);
if (!entries.isEmpty()) {
handlesList.add(entries.iterator().next().handleCopy());
}
}
return handlesList;
}
Aggregations