TinySAL implements SAL { @Publish @Override public DIDListResponse didList(DIDList request) { DIDListResponse response = WSHelper.makeResponse(DIDListResponse.class, WSHelper.makeResultOK()); try { ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request); byte[] appId = connectionHandle.getCardApplication(); CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false); Assert.securityConditionApplication(cardStateEntry, appId, DifferentialIdentityServiceActionName.DID_LIST); byte[] applicationIDFilter = null; String objectIDFilter = null; String applicationFunctionFilter = null; DIDQualifierType didQualifier = request.getFilter(); if (didQualifier != null) { applicationIDFilter = didQualifier.getApplicationIdentifier(); objectIDFilter = didQualifier.getObjectIdentifier(); applicationFunctionFilter = didQualifier.getApplicationFunction(); } CardApplicationWrapper cardApplication; if (applicationIDFilter != null) { cardApplication = cardStateEntry.getInfo().getCardApplication(applicationIDFilter); Assert.assertIncorrectParameter(cardApplication, "The given CardApplication cannot be found."); } else { cardApplication = cardStateEntry.getCurrentCardApplication(); } List<DIDInfoType> didInfos = new ArrayList<>(cardApplication.getDIDInfoList()); if (objectIDFilter != null) { Iterator<DIDInfoType> it = didInfos.iterator(); while (it.hasNext()) { DIDInfoType next = it.next(); if (!next.getDifferentialIdentity().getDIDProtocol().equals(objectIDFilter)) { it.remove(); } } } if (applicationFunctionFilter != null) { Iterator<DIDInfoType> it = didInfos.iterator(); while (it.hasNext()) { DIDInfoType next = it.next(); if (next.getDifferentialIdentity().getDIDMarker().getCryptoMarker() == null) { it.remove(); } else { iso.std.iso_iec._24727.tech.schema.CryptoMarkerType rawMarker; rawMarker = next.getDifferentialIdentity().getDIDMarker().getCryptoMarker(); CryptoMarkerType cryptoMarker = new CryptoMarkerType(rawMarker); AlgorithmInfoType algInfo = cryptoMarker.getAlgorithmInfo(); if (! algInfo.getSupportedOperations().contains(applicationFunctionFilter)) { it.remove(); } } } } DIDNameListType didNameList = new DIDNameListType(); for (DIDInfoType didInfo : didInfos) { didNameList.getDIDName().add(didInfo.getDifferentialIdentity().getDIDName()); } response.setDIDNameList(didNameList); } catch (ECardException 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 testDidList() { System.out.println("didList"); 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()); DIDList didList = new DIDList(); didList.setConnectionHandle(result.getConnectionHandle()); DIDQualifierType didQualifier = new DIDQualifierType(); didQualifier.setApplicationIdentifier(appIdentifier_ESIGN); didQualifier.setObjectIdentifier("urn:oid:1.3.162.15480.3.0.25"); didQualifier.setApplicationFunction("Compute-signature"); didList.setFilter(didQualifier); DIDListResponse didListResponse = instance.didList(didList); Assert.assertTrue(didListResponse.getDIDNameList().getDIDName().size() > 0); assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor()); cardApplicationPath = new CardApplicationPath(); cardApplicationPathType = new CardApplicationPathType(); cardApplicationPathType.setCardApplication(appIdentifier_ROOT); cardApplicationPath.setCardAppPathRequest(cardApplicationPathType); cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath); cardApplicationConnect = new CardApplicationConnect(); cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult() .get(0)); cardApplicationConnect.getCardApplicationPath().setCardApplication(appIdentifier_ROOT); result = instance.cardApplicationConnect(cardApplicationConnect); assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor()); didList = new DIDList(); didList.setConnectionHandle(result.getConnectionHandle()); didQualifier = new DIDQualifierType(); didQualifier.setApplicationIdentifier(appIdentifier_ROOT); didQualifier.setObjectIdentifier("urn:oid:1.3.162.15480.3.0.25"); didQualifier.setApplicationFunction("Compute-signature"); didList.setFilter(didQualifier); didListResponse = instance.didList(didList); Assert.assertEquals(didListResponse.getDIDNameList().getDIDName().size(), 0); assertEquals(ECardConstants.Major.OK, didListResponse.getResult().getResultMajor()); didList = new DIDList(); didList.setConnectionHandle(null); didListResponse = instance.didList(didList); assertEquals(ECardConstants.Major.ERROR, didListResponse.getResult().getResultMajor()); assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, didListResponse.getResult().getResultMinor()); didList = new DIDList(); didList.setConnectionHandle(result.getConnectionHandle()); didList.getConnectionHandle().setIFDName("invalid"); didListResponse = instance.didList(didList); assertEquals(ECardConstants.Major.ERROR, didListResponse.getResult().getResultMajor()); assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, didListResponse.getResult().getResultMinor()); }