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