Search in sources :

Example 1 with QRCode

use of fi.jasoft.qrcode.QRCode in project cia by Hack23.

the class SetGoogleAuthenticatorCredentialClickListener method buttonClick.

@Override
public void buttonClick(final ClickEvent event) {
    final SetGoogleAuthenticatorCredentialResponse response = (SetGoogleAuthenticatorCredentialResponse) ApplicationMangerAccess.getApplicationManager().service(googleAuthRequest);
    if (ServiceResult.SUCCESS == response.getResult()) {
        try {
            final URI keyUri = new URI(response.getOtpAuthTotpURL());
            final QRCode qrCode = new QRCode(QR_CODE, keyUri.toASCIIString());
            qrCode.setHeight(QR_CODE_IMAGE_SIZE);
            qrCode.setWidth(QR_CODE_IMAGE_SIZE);
            final Window mywindow = new Window(GOOGLE_AUTHENTICATOR_QR_CODE);
            mywindow.setHeight(MODAL_WINDOW_SIZE);
            mywindow.setWidth(MODAL_WINDOW_SIZE);
            mywindow.setPositionX(WINDOW_POSITION);
            mywindow.setPositionY(WINDOW_POSITION);
            final VerticalLayout panelContent = new VerticalLayout();
            mywindow.setContent(panelContent);
            panelContent.addComponent(qrCode);
            mywindow.setModal(true);
            UI.getCurrent().addWindow(mywindow);
        } catch (final URISyntaxException e) {
            LOGGER.warn(PROBLEM_DISPLAYING_QR_CODE, e);
            Notification.show(PROBLEM_DISPLAYING_QR_CODE, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
        }
    } else {
        Notification.show(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
        LOGGER.info(PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR_SESSIONID, googleAuthRequest.getSessionId());
    }
}
Also used : Window(com.vaadin.ui.Window) QRCode(fi.jasoft.qrcode.QRCode) SetGoogleAuthenticatorCredentialResponse(com.hack23.cia.service.api.action.user.SetGoogleAuthenticatorCredentialResponse) VerticalLayout(com.vaadin.ui.VerticalLayout) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

SetGoogleAuthenticatorCredentialResponse (com.hack23.cia.service.api.action.user.SetGoogleAuthenticatorCredentialResponse)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 QRCode (fi.jasoft.qrcode.QRCode)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1