Search in sources :

Example 1 with CardApplicationServiceType

use of iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType in project open-ecard by ecsec.

the class TinySAL method cardApplicationServiceList.

/**
 * The CardApplicationServiceList function returns a list of all available services of a card application.
 * See BSI-TR-03112-4, version 1.1.2, section 3.3.4.
 *
 * @param request CardApplicationServiceList
 * @return CardApplicationServiceListResponse
 */
@Publish
@Override
public CardApplicationServiceListResponse cardApplicationServiceList(CardApplicationServiceList request) {
    CardApplicationServiceListResponse response = WSHelper.makeResponse(CardApplicationServiceListResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        // Assert.securityConditionApplication(cardStateEntry, cardApplicationID,
        // CardApplicationServiceActionName.CARD_APPLICATION_SERVICE_LIST);
        CardApplicationServiceNameList cardApplicationServiceNameList = new CardApplicationServiceNameList();
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        Iterator<CardApplicationType> it = cardInfoWrapper.getApplicationCapabilities().getCardApplication().iterator();
        while (it.hasNext()) {
            CardApplicationType next = it.next();
            byte[] appName = next.getApplicationIdentifier();
            if (Arrays.equals(appName, cardApplicationID)) {
                Iterator<CardApplicationServiceType> itt = next.getCardApplicationServiceInfo().iterator();
                while (itt.hasNext()) {
                    CardApplicationServiceType nextt = itt.next();
                    cardApplicationServiceNameList.getCardApplicationServiceName().add(nextt.getCardApplicationServiceName());
                }
            }
        }
        response.setCardApplicationServiceNameList(cardApplicationServiceNameList);
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throwThreadKillException(e);
        response.setResult(WSHelper.makeResult(e));
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationType(iso.std.iso_iec._24727.tech.schema.CardApplicationType) CardApplicationServiceListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse) CardApplicationServiceType(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) CardApplicationServiceNameList(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse.CardApplicationServiceNameList) Publish(org.openecard.common.interfaces.Publish)

Example 2 with CardApplicationServiceType

use of iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType in project open-ecard by ecsec.

the class TinySAL method cardApplicationServiceDescribe.

/**
 * The CardApplicationServiceDescribe function can be used to request an URI, an URL or a detailed description
 * of the selected card application service.
 * See BSI-TR-03112-4, version 1.1.2, section 3.3.8.
 *
 * @param request CardApplicationServiceDescribe
 * @return CardApplicationServiceDescribeResponse
 */
@Publish
@Override
public CardApplicationServiceDescribeResponse cardApplicationServiceDescribe(CardApplicationServiceDescribe request) {
    CardApplicationServiceDescribeResponse response = WSHelper.makeResponse(CardApplicationServiceDescribeResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        String cardApplicationServiceName = request.getCardApplicationServiceName();
        Assert.assertIncorrectParameter(cardApplicationServiceName, "The parameter CardApplicationServiceName is empty.");
        // Assert.securityConditionApplication(cardStateEntry, cardApplicationID,
        // CardApplicationServiceActionName.CARD_APPLICATION_SERVICE_DESCRIBE);
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        Iterator<CardApplicationType> it = cardInfoWrapper.getApplicationCapabilities().getCardApplication().iterator();
        while (it.hasNext()) {
            CardApplicationType next = it.next();
            byte[] appName = next.getApplicationIdentifier();
            if (Arrays.equals(appName, cardApplicationID)) {
                Iterator<CardApplicationServiceType> itt = next.getCardApplicationServiceInfo().iterator();
                while (itt.hasNext()) {
                    CardApplicationServiceType nextt = itt.next();
                    if (nextt.getCardApplicationServiceName().equals(cardApplicationServiceName)) {
                        response.setServiceDescription(nextt.getCardApplicationServiceDescription());
                        return response;
                    }
                }
            }
        }
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throwThreadKillException(e);
        response.setResult(WSHelper.makeResult(e));
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationType(iso.std.iso_iec._24727.tech.schema.CardApplicationType) CardApplicationServiceDescribeResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse) CardApplicationServiceType(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) Publish(org.openecard.common.interfaces.Publish)

Aggregations

CardApplicationServiceType (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType)2 CardApplicationType (iso.std.iso_iec._24727.tech.schema.CardApplicationType)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)2 ECardException (org.openecard.common.ECardException)2 ThreadTerminateException (org.openecard.common.ThreadTerminateException)2 Publish (org.openecard.common.interfaces.Publish)2 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)2 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)2 NameExistsException (org.openecard.common.sal.exception.NameExistsException)2 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)2 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)2 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)2 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)2 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)2 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)2 CardInfoWrapper (org.openecard.common.sal.state.cif.CardInfoWrapper)2 TLVException (org.openecard.common.tlv.TLVException)2 CardApplicationServiceDescribeResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse)1 CardApplicationServiceListResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse)1