Search in sources :

Example 6 with EstablishChannel

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);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) PasswordField(org.openecard.gui.definition.PasswordField)

Example 7 with EstablishChannel

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;
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel)

Example 8 with 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);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) PasswordField(org.openecard.gui.definition.PasswordField)

Example 9 with EstablishChannel

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);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PasswordField(org.openecard.gui.definition.PasswordField)

Example 10 with EstablishChannel

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);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Aggregations

EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)16 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)15 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)11 AuthDataMap (org.openecard.common.anytype.AuthDataMap)8 AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)8 ExecutionResults (org.openecard.gui.executor.ExecutionResults)8 Connect (iso.std.iso_iec._24727.tech.schema.Connect)5 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)5 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)5 PasswordField (org.openecard.gui.definition.PasswordField)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)3 GetIFDCapabilitiesResponse (iso.std.iso_iec._24727.tech.schema.GetIFDCapabilitiesResponse)3 WSException (org.openecard.common.WSHelper.WSException)3 StepActionResult (org.openecard.gui.executor.StepActionResult)3 BeginTransaction (iso.std.iso_iec._24727.tech.schema.BeginTransaction)2 BeginTransactionResponse (iso.std.iso_iec._24727.tech.schema.BeginTransactionResponse)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)2 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)2 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)2