TinySAL implements SAL { @Override public DSIDeleteResponse dsiDelete(DSIDelete request) { DSIDeleteResponse response = WSHelper.makeResponse(DSIDeleteResponse.class, WSHelper.makeResultOK()); try { ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request); CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle); CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo(); String dsiName = request.getDSIName(); Assert.assertIncorrectParameter(dsiName, "The parameter DSIName is empty."); if (cardStateEntry.getFCPOfSelectedEF() == null) { String msg = "No DataSet selected for deleting the DSI " + request.getDSIName(); throw new PrerequisitesNotSatisfiedException(msg); } DataSetInfoType dataSet = cardInfoWrapper.getDataSetByDsiName(request.getDSIName()); byte[] fidOrPath = dataSet.getDataSetPath().getEfIdOrPath(); byte[] dataSetFid = new byte[] {fidOrPath[fidOrPath.length - 2], fidOrPath[fidOrPath.length - 1]}; if (! Arrays.equals(dataSetFid, cardStateEntry.getFCPOfSelectedEF().getFileIdentifiers().get(0))) { String msg = "The wrong DataSet for the deletion of DSI " + request.getDSIName() + " is selected."; throw new PrerequisitesNotSatisfiedException(msg); } DataSetInfoType dSet = cardInfoWrapper.getDataSetByFid(cardStateEntry.getFCPOfSelectedEF().getFileIdentifiers().get(0)); Assert.securityConditionDataSet(cardStateEntry, connectionHandle.getCardApplication(), dSet.getDataSetName(), NamedDataServiceActionName.DSI_DELETE); DSIType dsi = cardInfoWrapper.getDSIbyName(dsiName); ArrayList<byte[]> responses = new ArrayList<byte[]>() { { add(new byte[] {(byte) 0x90, (byte) 0x00}); add(new byte[] {(byte) 0x63, (byte) 0xC1}); add(new byte[] {(byte) 0x63, (byte) 0xC2}); add(new byte[] {(byte) 0x63, (byte) 0xC3}); add(new byte[] {(byte) 0x63, (byte) 0xC4}); add(new byte[] {(byte) 0x63, (byte) 0xC5}); add(new byte[] {(byte) 0x63, (byte) 0xC6}); add(new byte[] {(byte) 0x63, (byte) 0xC7}); add(new byte[] {(byte) 0x63, (byte) 0xC8}); add(new byte[] {(byte) 0x63, (byte) 0xC9}); add(new byte[] {(byte) 0x63, (byte) 0xCA}); add(new byte[] {(byte) 0x63, (byte) 0xCB}); add(new byte[] {(byte) 0x63, (byte) 0xCC}); add(new byte[] {(byte) 0x63, (byte) 0xCD}); add(new byte[] {(byte) 0x63, (byte) 0xCE}); add(new byte[] {(byte) 0x63, (byte) 0xCF}); } }; if (cardStateEntry.getFCPOfSelectedEF().getDataElements().isLinear()) { EraseRecord rmRecord = new EraseRecord(dsi.getDSIPath().getIndex()[0], EraseRecord.ERASE_JUST_P1); rmRecord.transmit(env.getDispatcher(), connectionHandle.getSlotHandle(), responses); } else { EraseBinary rmBinary = new EraseBinary((byte) 0x00, (byte) 0x00, dsi.getDSIPath().getIndex()); rmBinary.transmit(env.getDispatcher(), connectionHandle.getSlotHandle(), responses); } } catch (ECardException e) { LOG.error(e.getMessage(), e); response.setResult(e.getResult()); } catch (Exception e) { LOG.error(e.getMessage(), e); throwThreadKillException(e); response.setResult(WSHelper.makeResult(e)); } return response; } TinySAL(Environment env, CardStateMap states); void setAddonManager(AddonManager manager); @Override InitializeResponse initialize(Initialize request); @Override TerminateResponse terminate(Terminate request); @Override CardApplicationPathResponse cardApplicationPath(CardApplicationPath request); @Override CardApplicationConnectResponse cardApplicationConnect(CardApplicationConnect request); @Override CardApplicationSelectResponse cardApplicationSelect(CardApplicationSelect request); @Override CardApplicationDisconnectResponse cardApplicationDisconnect(CardApplicationDisconnect request); @Publish @Override CardApplicationStartSessionResponse cardApplicationStartSession(CardApplicationStartSession request); @Publish @Override CardApplicationEndSessionResponse cardApplicationEndSession(CardApplicationEndSession request); @Publish @Override CardApplicationListResponse cardApplicationList(CardApplicationList request); @Override CardApplicationCreateResponse cardApplicationCreate(CardApplicationCreate request); @Override CardApplicationDeleteResponse cardApplicationDelete(CardApplicationDelete request); @Publish @Override CardApplicationServiceListResponse cardApplicationServiceList(CardApplicationServiceList request); @Override CardApplicationServiceCreateResponse cardApplicationServiceCreate(CardApplicationServiceCreate request); @Override CardApplicationServiceLoadResponse cardApplicationServiceLoad(CardApplicationServiceLoad request); @Override CardApplicationServiceDeleteResponse cardApplicationServiceDelete(CardApplicationServiceDelete request); @Publish @Override CardApplicationServiceDescribeResponse cardApplicationServiceDescribe(CardApplicationServiceDescribe request); @Override ExecuteActionResponse executeAction(ExecuteAction request); @Publish @Override DataSetListResponse dataSetList(DataSetList request); @Override DataSetCreateResponse dataSetCreate(DataSetCreate request); @Publish @Override DataSetSelectResponse dataSetSelect(DataSetSelect request); @Override DataSetDeleteResponse dataSetDelete(DataSetDelete request); @Publish @Override DSIListResponse dsiList(DSIList request); @Override DSICreateResponse dsiCreate(DSICreate request); @Override DSIDeleteResponse dsiDelete(DSIDelete request); @Publish @Override DSIWriteResponse dsiWrite(DSIWrite request); @Publish @Override DSIReadResponse dsiRead(DSIRead request); @Publish @Override EncipherResponse encipher(Encipher request); @Override DecipherResponse decipher(Decipher request); @Publish @Override GetRandomResponse getRandom(GetRandom request); @Publish @Override HashResponse hash(Hash request); @Override SignResponse sign(Sign request); @Override VerifySignatureResponse verifySignature(VerifySignature request); @Override VerifyCertificateResponse verifyCertificate(VerifyCertificate request); @Publish @Override DIDListResponse didList(DIDList request); @Override DIDCreateResponse didCreate(DIDCreate request); @Publish @Override DIDGetResponse didGet(DIDGet request); @Override DIDUpdateResponse didUpdate(DIDUpdate request); @Override DIDDeleteResponse didDelete(DIDDelete request); @Publish @Override DIDAuthenticateResponse didAuthenticate(DIDAuthenticate request); @Publish @Override ACLListResponse aclList(ACLList request); @Override ACLModifyResponse aclModify(ACLModify request); void setGUI(UserConsent uc);  }
@Test(enabled = TESTS_ENABLED) public void testDsiDelete() { System.out.println("dsiDelete"); CardApplicationPath cardApplicationPath = new CardApplicationPath(); CardApplicationPathType cardApplicationPathType = new CardApplicationPathType(); cardApplicationPathType.setCardApplication(appIdentifier_ESIGN); cardApplicationPath.setCardAppPathRequest(cardApplicationPathType); CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath); CardApplicationConnect cardApplicationConnect = new CardApplicationConnect(); cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult() .get(0)); CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect); assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor()); 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); String dsiName = "dsiTest"; DSIDelete parameters = new DSIDelete(); parameters.setConnectionHandle(result.getConnectionHandle()); parameters.setDSIName(dsiName); DSIDeleteResponse resultDSIDelete = instance.dsiDelete(parameters); assertEquals(ECardConstants.Major.OK, resultDSIDelete.getResult().getResultMajor()); DSIList parametersDSI = new DSIList(); parametersDSI.setConnectionHandle(result.getConnectionHandle()); DSIListResponse resultDSIList = instance.dsiList(parametersDSI); assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor()); Iterator<String> it = resultDSIList.getDSINameList().getDSIName().iterator(); boolean dsiFound = false; while (it.hasNext()) { String val = it.next(); if (val.equals(dsiName)) { dsiFound = true; } } assertTrue(!dsiFound); }