Search in sources :

Example 21 with PasswordField

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

the class PINStepAction method verifyUserInput.

/**
 * Verify the input of the user (e.g. no empty mandatory fields, pin length, allowed charset).
 *
 * @param executionResults The results containing the OutputInfoUnits of interest.
 * @return True if the input of the user could be verified, else false.
 */
private boolean verifyUserInput(ExecutionResults executionResults) {
    // TODO: check pin length and possibly allowed charset with CardInfo file
    PasswordField fieldOldPIN = (PasswordField) executionResults.getResult(ChangePINStep.OLD_PIN_FIELD);
    PasswordField fieldNewPIN = (PasswordField) executionResults.getResult(ChangePINStep.NEW_PIN_FIELD);
    PasswordField fieldNewPINRepeat = (PasswordField) executionResults.getResult(ChangePINStep.NEW_PIN_REPEAT_FIELD);
    oldPIN = new String(fieldOldPIN.getValue());
    if (oldPIN.isEmpty()) {
        return false;
    }
    if (new String(fieldNewPIN.getValue()).isEmpty()) {
        return false;
    } else {
        try {
            newPIN = new String(fieldNewPIN.getValue()).getBytes(ISO_8859_1);
        } catch (UnsupportedEncodingException e) {
            return false;
        }
    }
    if (new String(fieldNewPINRepeat.getValue()).isEmpty()) {
        return false;
    } else {
        try {
            newPINRepeat = new String(fieldNewPINRepeat.getValue()).getBytes(ISO_8859_1);
        } catch (UnsupportedEncodingException e) {
            return false;
        }
    }
    return ByteUtils.compare(newPIN, newPINRepeat);
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) PasswordField(org.openecard.gui.definition.PasswordField)

Example 22 with PasswordField

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

the class PUKStepAction method verifyUserInput.

/**
 * Verify the input of the user (e.g. no empty mandatory fields, pin length, allowed charset).
 *
 * @param executionResults The results containing the OutputInfoUnits of interest.
 * @return True if the input of the user could be verified, else false
 */
private boolean verifyUserInput(ExecutionResults executionResults) {
    // TODO: check pin length and possibly allowed charset with CardInfo file
    PasswordField pukField = (PasswordField) executionResults.getResult(UnblockPINDialog.PUK_FIELD);
    puk = new String(pukField.getValue());
    return !puk.isEmpty();
}
Also used : 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