From 6799fa1e2922aab7802a09c2f147eca419e9947e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 18 May 2017 15:14:56 +0200 Subject: java : vaadin : upgrade to 8.0.5 --- java/vaadin/ivy.xml | 2 +- .../vaadin/src/main/java/ch/asynk/ui/ViewMain.java | 59 ++++++++++++++-------- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/java/vaadin/ivy.xml b/java/vaadin/ivy.xml index eef7a32..8de4615 100644 --- a/java/vaadin/ivy.xml +++ b/java/vaadin/ivy.xml @@ -1,6 +1,6 @@ + ]> binder = new Binder<>(); + binder.addValueChangeListener(evt -> bt.setEnabled(binder.isValid()) ); + binder.forField(tf) + .asRequired("Login required") + .withValidator(s -> s.length() >= 6, "at least 6 characters") + .withValidator(s -> s.length() <= 20, "at most 20 characters") + .withValidator(new RegexpValidator("invalid username", "^(?=.{6,20}$)[a-zA-Z][a-zA-Z0-9#@.]+[a-zA-Z]$")) + .bind(Login::getLogin, Login::setLogin); + + bt.setEnabled(false); + bt.addClickListener(e -> { + if (binder.writeBeanIfValid(login)) { + tf.setValue(""); + tryAction(action, login); } }); @@ -101,6 +102,20 @@ public class ViewMain extends TabSheet implements View, U2fConnector.U2fListener return vl; } + private void tryAction(Action action, Login login) + { + final String userId = login.getLogin(); + login.setLogin(null); + try { + if (action == Action.U2F_REGISTER) + u2fConnector.sendRegisterRequest(userId, this); + else if (action == Action.U2F_AUTHENTICATE) + u2fConnector.startAuthentication(userId, this); + } catch (com.yubico.u2f.exceptions.U2fBadConfigurationException ex) { + Notification.show(U2F_TITLE, ex.getMessage(), Notification.Type.ERROR_MESSAGE); + } + } + public void u2fCallback(U2fConnector.U2fAction action, String msg) { Notification n = null; -- cgit v1.1-2-g2b99