use of iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType in project open-ecard by ecsec.
the class PUKStepAction method perform.
@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
if (result.isBack()) {
return new StepActionResult(StepActionResultStatus.BACK);
}
DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
paceInput.setProtocol(ECardConstants.Protocol.PACE);
AuthDataMap tmp;
try {
tmp = new AuthDataMap(paceInput);
} catch (ParserConfigurationException ex) {
LOG.error("Failed to read empty Protocol data.", ex);
return new StepActionResult(StepActionResultStatus.CANCEL);
}
AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
if (capturePin) {
ExecutionResults executionResults = oldResults.get(getStepID());
if (!verifyUserInput(executionResults)) {
// TODO inform user that something with his input is wrong
return new StepActionResult(StepActionResultStatus.REPEAT);
} else {
paceInputMap.addElement(PACEInputType.PIN, puk);
}
}
paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PUK);
// perform PACE by sending an EstablishChannel
EstablishChannel establishChannel = new EstablishChannel();
establishChannel.setSlotHandle(slotHandle);
establishChannel.setAuthenticationProtocolData(paceInputMap.getResponse());
establishChannel.getAuthenticationProtocolData().setProtocol(ECardConstants.Protocol.PACE);
try {
EstablishChannelResponse establishChannelResponse = (EstablishChannelResponse) dispatcher.safeDeliver(establishChannel);
WSHelper.checkResult(establishChannelResponse);
// pace was successfully performed, so get to the next step
return new StepActionResult(StepActionResultStatus.NEXT);
} catch (WSException ex) {
LOG.info("Wrong PUK entered, trying again");
// TODO update the step to inform the user that he entered the puk wrong
return new StepActionResult(StepActionResultStatus.REPEAT);
} finally {
DestroyChannel destroyChannel = new DestroyChannel();
destroyChannel.setSlotHandle(slotHandle);
dispatcher.safeDeliver(destroyChannel);
}
}
use of iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType in project open-ecard by ecsec.
the class SchemaValidationTest method testDIDAuth.
@Test
public void testDIDAuth() throws JAXBException, SAXException, IOException, ObjectValidatorException, ParserConfigurationException {
JAXBSchemaValidator validator;
JAXBContext jc = JAXBContext.newInstance(DIDAuthenticate.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
InputStream dataStream = FileUtils.resolveResourceAsStream(SchemaValidationTest.class, "DIDAuthenticate.xml");
DIDAuthenticate didAuth = (DIDAuthenticate) unmarshaller.unmarshal(dataStream);
validator = JAXBSchemaValidator.load(didAuth.getClass(), "ISO24727-Protocols.xsd");
Assert.assertEquals(validator.validateObject(didAuth), true);
dataStream = FileUtils.resolveResourceAsStream(SchemaValidationTest.class, "DIDAuthenticate.xml");
DIDAuthenticate didAuth2 = (DIDAuthenticate) unmarshaller.unmarshal(dataStream);
DIDAuthenticationDataType authData = didAuth2.getAuthenticationProtocolData();
DocumentBuilderFactory docFac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFac.newDocumentBuilder();
Document d = docBuilder.newDocument();
Element sigElem = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "Signature");
sigElem.setTextContent("1254786930AAD4A8");
authData.getAny().add(sigElem);
didAuth2.setAuthenticationProtocolData(authData);
validator = JAXBSchemaValidator.load(didAuth2.getClass(), "ISO24727-Protocols.xsd");
Assert.assertEquals(validator.validateObject(didAuth2), false);
}
Aggregations