Search in sources :

Example 1 with CardApplicationStartSessionResponse

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

the class TinySAL method cardApplicationStartSession.

/**
 * This CardApplicationStartSession function starts a session between the client application and the card application.
 * See BSI-TR-03112-4, version 1.1.2, section 3.2.3.
 *
 * @param request CardApplicationStartSession
 * @return CardApplicationStartSessionResponse
 */
@Publish
@Override
public CardApplicationStartSessionResponse cardApplicationStartSession(CardApplicationStartSession request) {
    CardApplicationStartSessionResponse response = WSHelper.makeResponse(CardApplicationStartSessionResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        String didName = SALUtils.getDIDName(request);
        Assert.assertIncorrectParameter(didName, "The parameter didName is empty.");
        DIDAuthenticationDataType didAuthenticationProtocolData = request.getAuthenticationProtocolData();
        Assert.assertIncorrectParameter(didAuthenticationProtocolData, "The parameter didAuthenticationProtocolData is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        Assert.securityConditionApplication(cardStateEntry, cardApplicationID, ConnectionServiceActionName.CARD_APPLICATION_START_SESSION);
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
        if (protocol.hasNextStep(FunctionType.CardApplicationStartSession)) {
            response = protocol.cardApplicationStartSession(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("CardApplicationStartSession", protocol.toString());
        }
    } 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) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) SALProtocol(org.openecard.addon.sal.SALProtocol) CardApplicationStartSessionResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationStartSessionResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) 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 CardApplicationStartSessionResponse

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

the class TinySALTest method testCardApplicationStartSession.

/**
 * Test of cardApplicationStartSession method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationStartSession() {
    System.out.println("cardApplicationStartSession");
    CardApplicationStartSession parameters = new CardApplicationStartSession();
    CardApplicationStartSessionResponse result = instance.cardApplicationStartSession(parameters);
    assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
}
Also used : CardApplicationStartSessionResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationStartSessionResponse) CardApplicationStartSession(iso.std.iso_iec._24727.tech.schema.CardApplicationStartSession) Test(org.testng.annotations.Test)

Aggregations

CardApplicationStartSessionResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationStartSessionResponse)2 CardApplicationStartSession (iso.std.iso_iec._24727.tech.schema.CardApplicationStartSession)1 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)1 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)1 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)1 SALProtocol (org.openecard.addon.sal.SALProtocol)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 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)1 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)1 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)1 TLVException (org.openecard.common.tlv.TLVException)1