Search in sources :

Example 1 with VerifyCertificateResponse

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

the class TinySALTest method testVerifyCertificate.

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

Example 2 with VerifyCertificateResponse

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

the class TinySAL method verifyCertificate.

/**
 * The VerifyCertificate function validates a given certificate.
 * See BSI-TR-03112-4, version 1.1.2, section 3.5.7.
 *
 * @param request VerifyCertificate
 * @return VerifyCertificateResponse
 */
@Override
public VerifyCertificateResponse verifyCertificate(VerifyCertificate request) {
    VerifyCertificateResponse response = WSHelper.makeResponse(VerifyCertificateResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        byte[] applicationID = cardStateEntry.getCurrentCardApplication().getApplicationIdentifier();
        String didName = SALUtils.getDIDName(request);
        byte[] certificate = request.getCertificate();
        Assert.assertIncorrectParameter(certificate, "The parameter Certificate is empty.");
        String certificateType = request.getCertificateType();
        Assert.assertIncorrectParameter(certificateType, "The parameter CertificateType is empty.");
        String rootCert = request.getRootCert();
        Assert.assertIncorrectParameter(rootCert, "The parameter RootCert is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, applicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        DIDScopeType didScope = request.getDIDScope();
        if (didScope == null) {
            didScope = DIDScopeType.LOCAL;
        }
        if (didScope.equals(DIDScopeType.LOCAL)) {
            byte[] necessarySelectedApp = cardStateEntry.getInfo().getApplicationIdByDidName(didName, didScope);
            if (!Arrays.equals(necessarySelectedApp, applicationID)) {
                String msg = "Wrong application selected for the execution of VerifyCertificate with the DID " + didName + ".";
                throw new SecurityConditionNotSatisfiedException(msg);
            }
        }
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
        if (protocol.hasNextStep(FunctionType.VerifyCertificate)) {
            response = protocol.verifyCertificate(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("VerifyCertificate", 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) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) VerifyCertificateResponse(iso.std.iso_iec._24727.tech.schema.VerifyCertificateResponse) SALProtocol(org.openecard.addon.sal.SALProtocol) DIDScopeType(iso.std.iso_iec._24727.tech.schema.DIDScopeType) 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)

Example 3 with VerifyCertificateResponse

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

the class GenericCryptographyProtocolTest method testVerifyCertificate.

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

Aggregations

VerifyCertificateResponse (iso.std.iso_iec._24727.tech.schema.VerifyCertificateResponse)3 VerifyCertificate (iso.std.iso_iec._24727.tech.schema.VerifyCertificate)2 Test (org.testng.annotations.Test)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 DIDScopeType (iso.std.iso_iec._24727.tech.schema.DIDScopeType)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 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