use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType 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 iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.
the class PINTest method testHalfNibble.
@Test
public void testHalfNibble() throws UtilException {
PasswordAttributesType pwdAttr = create(false, HALF_NIBBLE_BCD, 6, 6);
byte[] pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
assertEquals(new byte[] { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6 }, pinResult);
pwdAttr = create(true, HALF_NIBBLE_BCD, 6, 7);
pwdAttr.setPadChar(new byte[] { (byte) 0xFF });
pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
assertEquals(new byte[] { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6, (byte) 0xFF }, pinResult);
}
use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.
the class PINTest method create.
private static PasswordAttributesType create(boolean needsPadding, PasswordTypeType pwdType, int minLen, int storedLen) {
PasswordAttributesType r = new PasswordAttributesType();
r.setMinLength(BigInteger.valueOf(minLen));
r.setStoredLength(BigInteger.valueOf(storedLen));
r.setPwdType(pwdType);
if (needsPadding) {
r.getPwdFlags().add("needs-padding");
}
return r;
}
use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.
the class PINTest method testASCII.
@Test
public void testASCII() throws UtilException {
PasswordAttributesType pwdAttr = create(false, ASCII_NUMERIC, 6, 6);
byte[] pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
assertEquals(new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 }, pinResult);
try {
pwdAttr = create(true, ASCII_NUMERIC, 6, 6);
PINUtils.encodePin("123456".toCharArray(), pwdAttr);
// padding needed, but no char given
fail();
} catch (UtilException ex) {
}
// try {
// pwdAttr = create(false, ASCII_NUMERIC, 6, 7);
// PINUtils.encodePin("123456", pwdAttr);
// fail(); // padding inferred, but no char given
// } catch (UtilException ex) {
// }
}
use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.
the class PINTest method verifyISO.
@Test
public void verifyISO() throws IFDException {
PasswordAttributesType pwdAttr = create(true, ISO_9564_1, 4, 8);
PCSCPinVerify ctrlStruct = new PCSCPinVerify(pwdAttr, StringUtils.toByteArray("00200001"));
ctrlStruct.setLang(Locale.GERMANY);
byte[] structData = ctrlStruct.toBytes();
// length=13
String pinStr = "00 20 00 01 08 20 FF FF FF FF FF FF FF";
String ctrlStr = "3C 00 89 47 04 0E04 02 01 0704 00 000000 0D000000";
byte[] referenceData = StringUtils.toByteArray(ctrlStr + pinStr, true);
assertEquals(referenceData, structData);
}
Aggregations