use of iso.std.iso_iec._24727.tech.schema.GetRandomResponse in project open-ecard by ecsec.
the class TinySAL method getRandom.
/**
* The GetRandom function returns a random number which is suitable for authentication with the DID addressed with
* DIDName.
* See BSI-TR-03112-4, version 1.1.2, section 3.5.3.
*
* @param request GetRandom
* @return GetRandomResponse
*/
@Publish
@Override
public GetRandomResponse getRandom(GetRandom request) {
GetRandomResponse response = WSHelper.makeResponse(GetRandomResponse.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);
DIDScopeType didScope = request.getDIDScope();
if (didScope == null) {
didScope = DIDScopeType.LOCAL;
}
if (didScope.equals(DIDScopeType.LOCAL)) {
byte[] necessaryApp = cardStateEntry.getInfo().getApplicationIdByDidName(didName, didScope);
if (!Arrays.equals(necessaryApp, applicationID)) {
throw new SecurityConditionNotSatisfiedException("The wrong application is selected for getRandom()");
}
}
DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, didScope);
Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
String protocolURI = didStructure.getDIDMarker().getProtocol();
SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
if (protocol.hasNextStep(FunctionType.GetRandom)) {
response = protocol.getRandom(request);
removeFinishedProtocol(connectionHandle, protocolURI, protocol);
} else {
throw new InappropriateProtocolForActionException("GetRandom", 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.GetRandomResponse in project open-ecard by ecsec.
the class GenericCryptographyProtocolTest method testGetRandom.
@Test(enabled = TESTS_ENABLED)
public void testGetRandom() {
// TODO write test as soon as implemented
GetRandomResponse resp = instance.getRandom(new GetRandom());
assertEquals(resp.getResult().getResultMajor(), ECardConstants.Major.ERROR);
}
use of iso.std.iso_iec._24727.tech.schema.GetRandomResponse in project open-ecard by ecsec.
the class TinySALTest method testGetRandom.
/**
* Test of getRandom method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testGetRandom() {
System.out.println("getRandom");
GetRandom parameters = new GetRandom();
GetRandomResponse result = instance.getRandom(parameters);
assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
}
Aggregations