use of iso.std.iso_iec._24727.tech.schema.VerifyCertificate 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());
}
use of iso.std.iso_iec._24727.tech.schema.VerifyCertificate in project open-ecard by ecsec.
the class PINCompareProtocolTest method testUnsupportedFunctions.
/*
* [TR-03112-7] The following functions are not supported with this protocol
* and, when called up, relay an error message to this effect
* /resultminor/sal#inappropriateProtocolForAction:
* CardApplicationStartSession, Encipher, Decipher, GetRandom, Hash, Sign,
* VerifySignature, VerifyCertificate
*/
/**
* This Test ensures that all functions unsupported by this protocol relay the correct error message when
* called.
*/
@Test(enabled = TESTS_ENABLED)
public void testUnsupportedFunctions() {
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(this.appIdentifier_ROOT);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
cardApplicationPathType = cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0);
cardApplicationConnect.setCardApplicationPath(cardApplicationPathType);
CardApplicationConnectResponse result1 = instance.cardApplicationConnect(cardApplicationConnect);
Encipher encipher = new Encipher();
encipher.setDIDName("PIN.home");
encipher.setPlainText(new byte[] { 0x0, 0x0, 0x0 });
encipher.setConnectionHandle(result1.getConnectionHandle());
EncipherResponse encipherResponse = instance.encipher(encipher);
assertEquals(encipherResponse.getResult().getResultMajor(), ECardConstants.Major.ERROR);
assertEquals(encipherResponse.getResult().getResultMinor(), ECardConstants.Minor.SAL.INAPPROPRIATE_PROTOCOL_FOR_ACTION);
// TODO remaining unsupported functions
}
use of iso.std.iso_iec._24727.tech.schema.VerifyCertificate 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;
}
use of iso.std.iso_iec._24727.tech.schema.VerifyCertificate 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);
}
Aggregations