diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-04 10:40:15 +0100 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-11-04 10:40:15 +0100 |
commit | 460549abaed6ecb07b95e0e47b0083a963aeceb9 (patch) | |
tree | a095a072c1ba4eb19c017778fc9bc8dc2a3d181c /pdf-over-gui | |
parent | fcf8d94de6171f9845126d4e971a2f161475f393 (diff) | |
download | pdf-over-460549abaed6ecb07b95e0e47b0083a963aeceb9.tar.gz pdf-over-460549abaed6ecb07b95e0e47b0083a963aeceb9.tar.bz2 pdf-over-460549abaed6ecb07b95e0e47b0083a963aeceb9.zip |
add cancel & sms buttons + signature data link for fido2
Diffstat (limited to 'pdf-over-gui')
2 files changed, 34 insertions, 10 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java index 764eb8bf..48dec801 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java @@ -1,5 +1,8 @@ package at.asit.pdfover.gui.composites.mobilebku; +import java.net.URI; + +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import org.eclipse.swt.SWT; @@ -10,6 +13,7 @@ import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +37,13 @@ public class MobileBKUFido2Composite extends StateComposite { private boolean userSms; private Button btn_authenticate; + private Button btn_cancel; + private Button btn_sms; + public void setSMSEnabled(boolean state) { this.btn_sms.setEnabled(state); } + + private @CheckForNull URI signatureDataURI; + private Link lnk_sigData; + public void setSignatureDataURI(URI uri) { this.signatureDataURI = uri; this.lnk_sigData.setVisible(uri != null); } public void initialize(@Nonnull String fido2Options) { this.fido2OptionsString = fido2Options; @@ -55,9 +66,7 @@ public class MobileBKUFido2Composite extends StateComposite { try { this.credential = PublicKeyCredentialRequestOptions.FromJSONString(this.fido2OptionsString).get("https://service.a-trust.at"); } catch (Throwable t) { - if (t instanceof WebAuthNUserCancelled) { - this.userCancel = true; - } else { + if (!(t instanceof WebAuthNUserCancelled)) { log.warn("webauthn operation failed", t); } } finally { @@ -78,26 +87,38 @@ public class MobileBKUFido2Composite extends StateComposite { e.gc.setForeground(Constants.MAINBAR_ACTIVE_BACK_DARK); e.gc.setLineWidth(3); e.gc.setLineStyle(SWT.LINE_SOLID); - e.gc.drawRoundRectangle(clientArea.x, clientArea.y, - clientArea.width - 2, clientArea.height - 2, 10, 10); + e.gc.drawRoundRectangle(clientArea.x, clientArea.y+25, + clientArea.width - 2, clientArea.height - 27, 10, 10); }); containerComposite.setLayout(new FormLayout()); - SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200); + SWTUtils.anchor(containerComposite).top(50, -145).bottom(50, 120).left(50, -200).right(50, 200); ImageData webauthnLogoImg = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_WEBAUTHN)); Label webauthnLogo = new Label(containerComposite, SWT.NATIVE); - SWTUtils.anchor(webauthnLogo).top(0, 10).right(100, -10).height(50).width(187); + SWTUtils.anchor(webauthnLogo).top(0,0).left(0, 10).height(50).width(187); webauthnLogo.setImage(new Image(getDisplay(), webauthnLogoImg.scaledTo(187, 50))); ImageData fidoLogoImg = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_FIDO2)); Label fidoLogo = new Label(containerComposite, SWT.NATIVE); - SWTUtils.anchor(fidoLogo).top(webauthnLogo, 10).right(100, -10).height(50).width(81); + SWTUtils.anchor(fidoLogo).left(0, 10).bottom(100, -10).height(50).width(81); fidoLogo.setImage(new Image(getDisplay(), fidoLogoImg.scaledTo(81, 50))); this.btn_authenticate = new Button(containerComposite, SWT.NATIVE); - SWTUtils.anchor(btn_authenticate).top(50, -10).left(0, 90).right(100, -90); + SWTUtils.anchor(btn_authenticate).top(50, -15).left(0, 90).right(100, -90); SWTUtils.addSelectionListener(btn_authenticate, this::beginAuthentication); + + this.btn_cancel = new Button(containerComposite, SWT.NATIVE); + SWTUtils.anchor(btn_cancel).bottom(100, -10).right(100, -10); + SWTUtils.addSelectionListener(btn_cancel, () -> { this.userCancel = true; }); + + this.btn_sms = new Button(containerComposite, SWT.NATIVE); + SWTUtils.anchor(btn_sms).bottom(100, -10).right(btn_cancel, -10); + SWTUtils.addSelectionListener(btn_sms, () -> { this.userSms = true; }); + + this.lnk_sigData = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE); + SWTUtils.anchor(lnk_sigData).top(0, 45).right(100, -20); + SWTUtils.addSelectionListener(lnk_sigData, (e) -> { SWTUtils.openURL(this.signatureDataURI); }); } @Override public void doLayout() { getShell().setDefaultButton(this.btn_authenticate); } @@ -105,5 +126,7 @@ public class MobileBKUFido2Composite extends StateComposite { @Override public void reloadResources() { SWTUtils.setLocalizedText(btn_authenticate, "mobileBKU.authorize"); + SWTUtils.setLocalizedText(btn_cancel, "common.Cancel"); + SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS"); } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index ab179cf2..92dca222 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -560,7 +560,8 @@ public class MobileBKUState extends State { return ISNOTNULL(Display.getDefault().syncCall(() -> {
MobileBKUFido2Composite fido2 = getMobileBKUFido2Composite();
fido2.initialize(fido2Options);
- // TODO signature data, sms tan support
+ fido2.setSMSEnabled(showSmsTan);
+ fido2.setSignatureDataURI(signatureDataURI);
getStateMachine().display(fido2);
|