Search in sources :

Example 1 with CardApplicationServiceDescribeResponse

use of iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse 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)

Example 2 with CardApplicationServiceDescribeResponse

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

the class TinySALTest method testCardApplicationServiceDescribe.

/**
 * Test of cardApplicationServiceDescribe method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationServiceDescribe() {
    System.out.println("cardApplicationServiceDescribe");
    CardApplicationServiceDescribe parameters = new CardApplicationServiceDescribe();
    // get path to esign
    CardApplicationPath cardApplicationPath = new CardApplicationPath();
    CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    assertTrue(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size() > 0);
    assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
    // 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());
    assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    parameters.setConnectionHandle(result.getConnectionHandle());
    parameters.setCardApplicationServiceName("testService");
    CardApplicationServiceDescribeResponse resultServiceDescribe = instance.cardApplicationServiceDescribe(parameters);
    assertEquals(ECardConstants.Major.OK, resultServiceDescribe.getResult().getResultMajor());
}
Also used : CardApplicationServiceDescribe(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribe) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationServiceDescribeResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Aggregations

CardApplicationServiceDescribeResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)1 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)1 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)1 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)1 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)1 CardApplicationServiceDescribe (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribe)1 CardApplicationServiceType (iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType)1 CardApplicationType (iso.std.iso_iec._24727.tech.schema.CardApplicationType)1 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)1 ECardException (org.openecard.common.ECardException)1 ThreadTerminateException (org.openecard.common.ThreadTerminateException)1 Publish (org.openecard.common.interfaces.Publish)1 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)1 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)1 NameExistsException (org.openecard.common.sal.exception.NameExistsException)1 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)1 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)1 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)1