use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathType in project open-ecard by ecsec.
the class TinySALTest method testCardApplicationDisconnect.
/**
* Test of cardApplicationDisconnect method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationDisconnect() {
System.out.println("cardApplicationDisconnect");
// 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(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
CardApplicationDisconnect cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// test invalid connectionhandle
// connect to esign
cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
cardApplicationDisconnect.getConnectionHandle().setSlotHandle(new byte[] { 0x0, 0x0, 0x0 });
CardApplicationDisconnectResponse cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.getResult().getResultMinor());
// test nullpointer
// connect to esign
cardApplicationConnect = new CardApplicationConnect();
cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
result = instance.cardApplicationConnect(cardApplicationConnect);
assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// disconnect
cardApplicationDisconnect = new CardApplicationDisconnect();
cardApplicationDisconnect.setConnectionHandle(null);
cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.getResult().getResultMinor());
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathType in project open-ecard by ecsec.
the class TinySALTest method testDataSetDelete.
/**
* Test of dataSetDelete method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDataSetDelete() {
System.out.println("dataSetDelete");
DataSetDelete parameters = new DataSetDelete();
// 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());
parameters.setConnectionHandle(result.getConnectionHandle());
String dataSetName = "DataSetTest";
parameters.setDataSetName(dataSetName);
DataSetDeleteResponse resultDataSetDelete = instance.dataSetDelete(parameters);
assertEquals(ECardConstants.Major.OK, resultDataSetDelete.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());
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathType 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.CardApplicationPathType in project open-ecard by ecsec.
the class TinySALTest method testDsiList.
/**
* Test of dsiList method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDsiList() {
System.out.println("dsiList");
// 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);
Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
String dataSetName = dataSetListResponse.getDataSetNameList().getDataSetName().get(0);
DSIList parameters = new DSIList();
parameters.setConnectionHandle(result.getConnectionHandle());
DSIListResponse resultDSIList = instance.dsiList(parameters);
assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor());
assertTrue(resultDSIList.getDSINameList().getDSIName().isEmpty());
}
use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathType in project open-ecard by ecsec.
the class AndroidMarshaller method marshalCardApplicationPathResult.
private Element marshalCardApplicationPathResult(CardApplicationPathType type, Document document, String name) {
Element em = createElementIso(document, name);
// ChannelHandle
ChannelHandleType h = type.getChannelHandle();
Element emChild = createElementIso(document, "ChannelHandle");
Element emChildOfCH;
if (h.getProtocolTerminationPoint() != null) {
emChildOfCH = createElementIso(document, "ProtocolTerminationPoint");
emChildOfCH.appendChild(document.createTextNode(h.getProtocolTerminationPoint()));
emChild.appendChild(emChildOfCH);
}
if (h.getSessionIdentifier() != null) {
emChildOfCH = createElementIso(document, "SessionIdentifier");
emChildOfCH.appendChild(document.createTextNode(h.getSessionIdentifier()));
emChild.appendChild(emChildOfCH);
}
if (h.getBinding() != null) {
emChildOfCH = createElementIso(document, "Binding");
emChildOfCH.appendChild(document.createTextNode(h.getBinding()));
emChild.appendChild(emChildOfCH);
}
PathSecurityType ps = h.getPathSecurity();
if (ps != null) {
emChildOfCH = createElementIso(document, "PathSecurity");
Element emChildOfPS = createElementIso(document, "Protocol");
emChildOfPS.appendChild(document.createTextNode(ps.getProtocol()));
emChildOfCH.appendChild(emChildOfPS);
// TODO here any type parsen
LOG.error("AnyType of CardApplicationPath: " + ps.getParameters().toString());
emChild.appendChild(emChildOfCH);
em.appendChild(emChild);
}
// context handle
emChild = createElementIso(document, "ContextHandle");
emChild.appendChild(document.createTextNode(ByteUtils.toHexString(type.getContextHandle())));
em.appendChild(emChild);
// IFDName
emChild = createElementIso(document, "IFDName");
emChild.appendChild(document.createTextNode(type.getIFDName()));
em.appendChild(emChild);
// SlotIndex
emChild = createElementIso(document, "SlotIndex");
emChild.appendChild(document.createTextNode(type.getSlotIndex().toString()));
em.appendChild(emChild);
// Card Application
emChild = createElementIso(document, "CardApplication");
emChild.appendChild(document.createTextNode(ByteUtils.toHexString(type.getCardApplication())));
em.appendChild(emChild);
return em;
}
Aggregations