Search in sources :

Example 1 with DIDUpdate

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

the class MiddlewareSAL method didUpdate.

@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
    DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        byte[] application = cardStateEntry.getImplicitlySelectedApplicationIdentifier();
        DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
        Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
        String didName = SALUtils.getDIDName(request);
        DIDStructureType didStruct = cardStateEntry.getDIDStructure(didName, application);
        if (didStruct == null) {
            String msg = String.format("DID %s does not exist.", didName);
            throw new NamedEntityNotFoundException(msg);
        }
        Result updateResult;
        String protocolURI = didUpdateData.getProtocol();
        if ("urn:oid:1.3.162.15480.3.0.9".equals(protocolURI)) {
            updateResult = updatePin(didUpdateData, cardStateEntry, didStruct);
        } else {
            String msg = String.format("Protocol %s is not supported by this SAL.", protocolURI);
            throw new UnknownProtocolException(msg);
        }
        // create did authenticate response
        response.setResult(updateResult);
    } 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) DIDUpdateResponse(iso.std.iso_iec._24727.tech.schema.DIDUpdateResponse) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) DIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.DIDUpdateDataType) ThreadTerminateException(org.openecard.common.ThreadTerminateException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) ECardException(org.openecard.common.ECardException) FinalizationException(org.openecard.mdlw.sal.exceptions.FinalizationException) PinBlockedException(org.openecard.mdlw.sal.exceptions.PinBlockedException) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) TokenException(org.openecard.mdlw.sal.exceptions.TokenException) WSMarshallerException(org.openecard.ws.marshal.WSMarshallerException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) UnsupportedAlgorithmException(org.openecard.crypto.common.UnsupportedAlgorithmException) PinIncorrectException(org.openecard.mdlw.sal.exceptions.PinIncorrectException) Result(oasis.names.tc.dss._1_0.core.schema.Result)

Example 2 with DIDUpdate

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

the class TinySAL method didUpdate.

/**
 * The DIDUpdate function creates a new key (marker) for the DID addressed with DIDName.
 * See BSI-TR-03112-4, version 1.1.2, section 3.6.4.
 *
 * @param request DIDUpdate
 * @return DIDUpdateResponse
 */
// TODO: discuss whether we should publish this @Publish
@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
    DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        String didName = request.getDIDName();
        Assert.assertIncorrectParameter(didName, "The parameter DIDName is empty.");
        DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
        Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        Assert.securityConditionDID(cardStateEntry, cardApplicationID, didName, DifferentialIdentityServiceActionName.DID_UPDATE);
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, null, protocolURI);
        if (protocol.hasNextStep(FunctionType.DIDUpdate)) {
            response = protocol.didUpdate(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("DIDUpdate", 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) DIDUpdateResponse(iso.std.iso_iec._24727.tech.schema.DIDUpdateResponse) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) SALProtocol(org.openecard.addon.sal.SALProtocol) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) DIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.DIDUpdateDataType) 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)

Example 3 with DIDUpdate

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

the class ChangePinInSALAction method execute.

@Override
public void execute() {
    List<ConnectionHandleType> connectedCards = null;
    try {
        connectedCards = connectCards();
        if (connectedCards.isEmpty()) {
        // TODO: show no card inserted dialog
        }
        for (ConnectionHandleType nextCard : connectedCards) {
            // pick first card, find pin DID and call didupdate
            String didName = null;
            try {
                didName = getPinDid(nextCard);
            } catch (WSException ex) {
                LOG.info("Skipping card, because it has no PIN DID.");
                continue;
            }
            DIDUpdate updateReq = new DIDUpdate();
            updateReq.setConnectionHandle(nextCard);
            updateReq.setDIDName(didName);
            DIDUpdateDataType updateData = new PinCompareDIDUpdateDataType();
            updateData.setProtocol("urn:oid:1.3.162.15480.3.0.9");
            updateReq.setDIDUpdateData(updateData);
            dispatcher.safeDeliver(updateReq);
        }
    } catch (WSException ex) {
    } finally {
        if (connectedCards != null) {
            for (ConnectionHandleType nextHandle : connectedCards) {
                CardApplicationDisconnect dr = new CardApplicationDisconnect();
                dr.setConnectionHandle(nextHandle);
                dr.setAction(ActionType.RESET);
                dispatcher.safeDeliver(dr);
            }
        }
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardApplicationDisconnect(iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect) DIDUpdate(iso.std.iso_iec._24727.tech.schema.DIDUpdate) WSException(org.openecard.common.WSHelper.WSException) PinCompareDIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.PinCompareDIDUpdateDataType) PinCompareDIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.PinCompareDIDUpdateDataType) DIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.DIDUpdateDataType)

Example 4 with DIDUpdate

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

the class TinySALTest method testDidUpdate.

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

Example 5 with DIDUpdate

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

the class GenericCryptographyProtocolTest method testDIDUpdate.

@Test(enabled = TESTS_ENABLED)
public void testDIDUpdate() {
    // TODO write test as soon as implemented
    DIDUpdateResponse resp = instance.didUpdate(new DIDUpdate());
    assertEquals(resp.getResult().getResultMajor(), ECardConstants.Major.ERROR);
}
Also used : DIDUpdateResponse(iso.std.iso_iec._24727.tech.schema.DIDUpdateResponse) DIDUpdate(iso.std.iso_iec._24727.tech.schema.DIDUpdate) Test(org.testng.annotations.Test)

Aggregations

DIDUpdateResponse (iso.std.iso_iec._24727.tech.schema.DIDUpdateResponse)4 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 DIDUpdate (iso.std.iso_iec._24727.tech.schema.DIDUpdate)3 DIDUpdateDataType (iso.std.iso_iec._24727.tech.schema.DIDUpdateDataType)3 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)2 ECardException (org.openecard.common.ECardException)2 ThreadTerminateException (org.openecard.common.ThreadTerminateException)2 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)2 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)2 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)2 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)2 Test (org.testng.annotations.Test)2 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)1 PinCompareDIDUpdateDataType (iso.std.iso_iec._24727.tech.schema.PinCompareDIDUpdateDataType)1 Result (oasis.names.tc.dss._1_0.core.schema.Result)1 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)1 SALProtocol (org.openecard.addon.sal.SALProtocol)1 WSException (org.openecard.common.WSHelper.WSException)1 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)1 NameExistsException (org.openecard.common.sal.exception.NameExistsException)1