use of iso.std.iso_iec._24727.tech.schema.EstablishChannel in project open-ecard by ecsec.
the class GenericPINAction method performPACEWithCAN.
private EstablishChannelResponse performPACEWithCAN(Map<String, ExecutionResults> oldResults) throws ParserConfigurationException {
DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
paceInput.setProtocol(ECardConstants.Protocol.PACE);
AuthDataMap tmp = new AuthDataMap(paceInput);
AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
if (capturePin) {
ExecutionResults executionResults = oldResults.get(getStepID());
PasswordField canField = (PasswordField) executionResults.getResult(GenericPINStep.CAN_FIELD);
String canValue = new String(canField.getValue());
if (canValue.length() != 6) {
// let the user enter the can again, when input verification failed
return null;
} else {
paceInputMap.addElement(PACEInputType.PIN, canValue);
}
}
paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_CAN);
// perform PACE by EstablishChannelCommand
EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
use of iso.std.iso_iec._24727.tech.schema.EstablishChannel in project open-ecard by ecsec.
the class GenericPINAction method createEstablishChannelStructure.
private EstablishChannel createEstablishChannelStructure(AuthDataResponse paceInputMap) {
// EstablishChannel
EstablishChannel establishChannel = new EstablishChannel();
establishChannel.setSlotHandle(slotHandle);
establishChannel.setAuthenticationProtocolData(paceInputMap.getResponse());
establishChannel.getAuthenticationProtocolData().setProtocol(ECardConstants.Protocol.PACE);
return establishChannel;
}
use of iso.std.iso_iec._24727.tech.schema.EstablishChannel in project open-ecard by ecsec.
the class GenericPINAction method performPACEWithPUK.
private EstablishChannelResponse performPACEWithPUK(Map<String, ExecutionResults> oldResults) throws ParserConfigurationException {
DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
paceInput.setProtocol(ECardConstants.Protocol.PACE);
AuthDataMap tmp = new AuthDataMap(paceInput);
AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
if (capturePin) {
ExecutionResults executionResults = oldResults.get(getStepID());
PasswordField pukField = (PasswordField) executionResults.getResult(GenericPINStep.PUK_FIELD);
String pukValue = new String(pukField.getValue());
if (pukValue.length() != 10) {
// TODO inform user that something with his input is wrong
return null;
} else {
paceInputMap.addElement(PACEInputType.PIN, pukValue);
}
}
paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PUK);
EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
use of iso.std.iso_iec._24727.tech.schema.EstablishChannel in project open-ecard by ecsec.
the class PINStepAction method performPACEWithPIN.
private EstablishChannelResponse performPACEWithPIN(Map<String, ExecutionResults> oldResults) {
DIDAuthenticationDataType protoData = eacData.didRequest.getAuthenticationProtocolData();
AuthDataMap paceAuthMap;
try {
paceAuthMap = new AuthDataMap(protoData);
} catch (ParserConfigurationException ex) {
LOG.error("Failed to read EAC Protocol data.", ex);
return null;
}
AuthDataResponse paceInputMap = paceAuthMap.createResponse(protoData);
if (capturePin) {
ExecutionResults executionResults = oldResults.get(getStepID());
PasswordField p = (PasswordField) executionResults.getResult(PINStep.PIN_FIELD);
char[] pinIn = p.getValue();
// TODO: check pin length and possibly allowed charset with CardInfo file
if (pinIn.length == 0) {
return null;
} else {
// NOTE: saving pin as string prevents later removal of the value from memory !!!
paceInputMap.addElement(PACEInputType.PIN, new String(pinIn));
}
}
// perform PACE
paceInputMap.addElement(PACEInputType.PIN_ID, PasswordID.parse(eacData.pinID).getByteAsString());
paceInputMap.addElement(PACEInputType.CHAT, eacData.selectedCHAT.toString());
String certDesc = ByteUtils.toHexString(eacData.rawCertificateDescription);
paceInputMap.addElement(PACEInputType.CERTIFICATE_DESCRIPTION, certDesc);
EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
use of iso.std.iso_iec._24727.tech.schema.EstablishChannel in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfEstablishChannel.
@Test
public void testConversionOfEstablishChannel() throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document d = builder.newDocument();
EstablishChannel establishChannel = new EstablishChannel();
establishChannel.setSlotHandle(new byte[] { 0x0, 0x1, 0x02 });
DIDAuthenticationDataType establishChannelInput = new DIDAuthenticationDataType();
establishChannelInput.setProtocol(ECardConstants.Protocol.PACE);
Element e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "PinID");
// Personalausweis-PIN
e.setTextContent("3");
establishChannelInput.getAny().add(e);
e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "PIN");
// Personalausweis-PIN
e.setTextContent("123456");
establishChannelInput.getAny().add(e);
establishChannel.setAuthenticationProtocolData(establishChannelInput);
marshalLog(establishChannel);
WSMarshaller m = new AndroidMarshaller();
Document doc = m.marshal(establishChannel);
String s = m.doc2str(doc);
LOG.debug(s);
}
Aggregations