Search in sources :

Example 11 with PasswordField

use of org.openecard.gui.definition.PasswordField 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 12 with PasswordField

use of org.openecard.gui.definition.PasswordField in project open-ecard by ecsec.

the class EacGuiImpl method getPinResult.

public List<OutputInfoUnit> getPinResult(Step step) throws InterruptedException {
    if (step instanceof PINStep) {
        PINStep pinStep = (PINStep) step;
        switch(pinStep.getStatus()) {
            case RC3:
                this.pinStatus.deliver(PinStatus.RC3);
                break;
            case RC2:
                this.pinStatus.deliver(PinStatus.RC2);
                break;
            case RC1:
                this.pinStatus.deliver(PinStatus.CAN);
                break;
        }
        // read values
        String pinValue = this.userPin.deref();
        String canValue = this.userCan.deref();
        ArrayList<OutputInfoUnit> result = new ArrayList<>();
        for (InputInfoUnit nextIn : pinStep.getInputInfoUnits()) {
            if (pinValue != null && nextIn instanceof PasswordField && nextIn.getID().equals("PACE_PIN_FIELD")) {
                PasswordField pw = new PasswordField(nextIn.getID());
                pw.copyContentFrom(nextIn);
                pw.setValue(pinValue.toCharArray());
                result.add(pw);
            } else if (canValue != null && nextIn instanceof PasswordField && nextIn.getID().equals("PACE_CAN_FIELD")) {
                PasswordField pw = new PasswordField(nextIn.getID());
                pw.copyContentFrom(nextIn);
                pw.setValue(canValue.toCharArray());
                result.add(pw);
            }
        }
        return result;
    } else {
        throw new InterruptedException("The given step is not a PinStep.");
    }
}
Also used : InputInfoUnit(org.openecard.gui.definition.InputInfoUnit) PINStep(org.openecard.sal.protocol.eac.gui.PINStep) ArrayList(java.util.ArrayList) OutputInfoUnit(org.openecard.gui.definition.OutputInfoUnit) PasswordField(org.openecard.gui.definition.PasswordField)

Example 13 with PasswordField

use of org.openecard.gui.definition.PasswordField in project open-ecard by ecsec.

the class PinEntryStep method createPinEntryGui.

private void createPinEntryGui() {
    setInstantReturn(false);
    if (lastTryFailed) {
        addVerifyFailed();
    } else {
        String desc = LANG.translationForKey("action.pinentry.userconsent.pinstep.enter_pin");
        Text descText = new Text(desc);
        getInputInfoUnits().add(descText);
    }
    PasswordField pass = new PasswordField(PIN_FIELD);
    pass.setDescription("PIN");
    // set length restrictions based on DID description. No info means no value set
    PasswordAttributesType pwAttr = pinMarker.getPasswordAttributes();
    if (pwAttr != null) {
        if (pwAttr.getMinLength() != null) {
            pass.setMinLength(pwAttr.getMinLength().intValue());
        }
        if (pwAttr.getMaxLength() != null) {
            pass.setMaxLength(pwAttr.getMaxLength().intValue());
        }
    }
    getInputInfoUnits().add(pass);
    if (pinState == PinState.PIN_FINAL_TRY) {
        String noteStr = LANG.translationForKey("action.pinentry.userconsent.pinstep.final_try_note");
        Text noteText = new Text(noteStr);
        getInputInfoUnits().add(noteText);
    }
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) Text(org.openecard.gui.definition.Text) PasswordField(org.openecard.gui.definition.PasswordField)

Example 14 with PasswordField

use of org.openecard.gui.definition.PasswordField in project open-ecard by ecsec.

the class PINStep method initialize.

private void initialize() {
    step.setDescription(lang.translationForKey(STEP_DESCRIPTION));
    String decriptionText = lang.translationForKey(DESCRIPTION, passwordType);
    Text description = new Text();
    description.setText(decriptionText);
    step.getInputInfoUnits().add(description);
    PasswordField pinInputField = new PasswordField(passwordType);
    pinInputField.setDescription(lang.translationForKey(passwordType));
    step.getInputInfoUnits().add(pinInputField);
}
Also used : Text(org.openecard.gui.definition.Text) PasswordField(org.openecard.gui.definition.PasswordField)

Example 15 with PasswordField

use of org.openecard.gui.definition.PasswordField in project open-ecard by ecsec.

the class PINStep method addCANEntry.

protected void addCANEntry() {
    PasswordField canField = new PasswordField(CAN_FIELD);
    canField.setDescription(LANG_PACE.translationForKey("can"));
    canField.setMaxLength(6);
    canField.setMinLength(6);
    getInputInfoUnits().add(canField);
    Text canNotice = new Text();
    canNotice.setText(LANG_EAC.translationForKey("eac_can_notice"));
    canNotice.setID(CAN_NOTICE_ID);
    getInputInfoUnits().add(canNotice);
}
Also used : Text(org.openecard.gui.definition.Text) PasswordField(org.openecard.gui.definition.PasswordField)

Aggregations

PasswordField (org.openecard.gui.definition.PasswordField)22 Text (org.openecard.gui.definition.Text)10 ExecutionResults (org.openecard.gui.executor.ExecutionResults)7 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)6 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)5 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)5 AuthDataMap (org.openecard.common.anytype.AuthDataMap)5 AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 Step (org.openecard.gui.definition.Step)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InputInfoUnit (org.openecard.gui.definition.InputInfoUnit)2 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)1 ControlIFDResponse (iso.std.iso_iec._24727.tech.schema.ControlIFDResponse)1 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)1 Disconnect (iso.std.iso_iec._24727.tech.schema.Disconnect)1 PasswordAttributesType (iso.std.iso_iec._24727.tech.schema.PasswordAttributesType)1 ArrayList (java.util.ArrayList)1 WSHelper (org.openecard.common.WSHelper)1 APDUException (org.openecard.common.apdu.exception.APDUException)1