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);
}
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.");
}
}
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);
}
}
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);
}
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);
}
Aggregations