summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java131
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java404
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java287
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java480
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java371
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java483
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java59
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java71
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java132
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java709
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java77
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/Fido2ConfigurationComposite.java95
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java592
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java717
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java283
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java278
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java133
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java178
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java240
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java106
20 files changed, 0 insertions, 5826 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
deleted file mode 100644
index 9c73c2e5..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.BKUs;
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.controls.ClickableCanvas;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for BKU selection
- */
-public class BKUSelectionComposite extends StateComposite {
-
- static final Logger log = LoggerFactory.getLogger(BKUSelectionComposite.class);
-
- private BKUs selected = BKUs.NONE;
-
- private ClickableCanvas cc_mobile;
- private ClickableCanvas cc_karte;
- private Button btnMobile;
- private Button btnCard;
- private Button btnKS = null;
-
- public BKUs getSelected() { return this.selected; }
-
- public void setSelected(final BKUs selected) {
- this.selected = selected;
- this.state.updateStateMachine();
- }
-
- public void setLocalBKUEnabled(boolean state) {
- this.btnCard.setEnabled(state);
- this.cc_karte.setEnabled(false);
- }
-
- /**
- * Sets whether keystore option is enabled
- * @param enabled
- */
- public void setKeystoreEnabled(boolean enabled) {
- if (enabled) {
- this.btnKS = new Button(this, SWT.NONE);
- SWTUtils.anchor(this.btnKS).top(this.btnCard, 10).left(this.btnMobile, 0, SWT.LEFT).right(this.btnCard, 0, SWT.RIGHT);
- SWTUtils.addSelectionListener(btnKS, () -> { setSelected(BKUs.KS); });
-
- reloadResources();
- } else if (this.btnKS != null) {
- this.btnKS.dispose();
- this.btnKS = null;
- }
- }
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- * @param state
- */
- public BKUSelectionComposite(Composite parent, int style, State state) {
- super(parent, style, state);
-
- this.setLayout(new FormLayout());
-
- this.cc_mobile = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(cc_mobile).right(50, -5).top(40, -20);
- Image mobile = new Image(getDisplay(), new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE)));
- cc_mobile.setImage(mobile);
- SWTUtils.setFontHeight(cc_mobile, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addMouseDownListener(cc_mobile, () -> { setSelected(BKUs.MOBILE); });
-
- this.cc_karte = new ClickableCanvas(this, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(cc_karte).left(50, 5).top(40, -20);
- Image karte = new Image(getDisplay(), this.getClass().getResourceAsStream(Constants.RES_IMG_CARD));
- cc_karte.setImage(karte);
- SWTUtils.setFontHeight(cc_karte, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addMouseDownListener(cc_karte, () -> { setSelected(BKUs.LOCAL); });
-
-
- this.btnMobile = new Button(this, SWT.NONE);
- SWTUtils.anchor(btnMobile).top(cc_mobile, 10).right(50,-5);
- int mobilesize = cc_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- int btnmsize = this.btnMobile.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- SWTUtils.reanchor(btnMobile).width(Math.max(btnmsize, mobilesize));
- SWTUtils.addSelectionListener(btnMobile, () -> { setSelected(BKUs.MOBILE); });
-
- this.btnCard = new Button(this, SWT.NONE);
- SWTUtils.anchor(btnCard).top(cc_karte, 10).left(50,5);
- int cardsize = cc_karte.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- int btncsize = this.btnCard.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
- SWTUtils.reanchor(btnCard).width(Math.max(btncsize, cardsize));
- SWTUtils.addSelectionListener(btnCard, () -> { setSelected(BKUs.LOCAL); });
-
- reloadResources();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(btnMobile, "bku_selection.mobile");
- SWTUtils.setLocalizedText(btnCard, "bku_selection.card");
- if (this.btnKS != null)
- SWTUtils.setLocalizedText(btnKS, "bku_selection.ks");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
deleted file mode 100644
index aa757305..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.composites.configuration.AboutComposite;
-import at.asit.pdfover.gui.composites.configuration.AdvancedConfigurationComposite;
-import at.asit.pdfover.gui.composites.configuration.ConfigurationCompositeBase;
-import at.asit.pdfover.gui.composites.configuration.Fido2ConfigurationComposite;
-import at.asit.pdfover.gui.composites.configuration.KeystoreConfigurationComposite;
-import at.asit.pdfover.gui.composites.configuration.SimpleConfigurationComposite;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.exceptions.ResumableException;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for hosting configuration composites
- */
-public class ConfigurationComposite extends StateComposite {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(ConfigurationComposite.class);
-
- /**
- * configuration provider
- */
- ConfigurationManager configProvider = null;
-
- /**
- * simple configuration composite
- */
- ConfigurationCompositeBase simpleConfigComposite;
-
- /**
- * advanced configuration composite
- */
- ConfigurationCompositeBase advancedConfigComposite;
-
- /**
- * advanced configuration composite
- */
- ConfigurationCompositeBase keystoreConfigComposite = null;
-
- ConfigurationCompositeBase fido2ConfigComposite;
-
- /**
- * about page composite
- */
- ConfigurationCompositeBase aboutConfigComposite;
-
- private final Iterable<ConfigurationCompositeBase> _compositeIterable = new Iterable<>() {
- @Override
- public Iterator<ConfigurationCompositeBase> iterator() {
- return new Iterator<>() {
- int i = 0;
- @Override
- public boolean hasNext() {
- return i < 5;
- }
-
- @Override
- public ConfigurationCompositeBase next() {
- if ((i == 2) && (keystoreConfigComposite == null)) ++i;
- switch (++i) {
- case 1: return simpleConfigComposite;
- case 2: return advancedConfigComposite;
- case 3: return keystoreConfigComposite;
- case 4: return fido2ConfigComposite;
- case 5: return aboutConfigComposite;
- }
- throw new NoSuchElementException();
- }
- };
- }
- };
- private Iterable<ConfigurationCompositeBase> composites() { return _compositeIterable; }
-
- /**
- * The TabFolder
- */
- TabFolder tabFolder;
-
- /**
- * configuration container Keeps state for current configuration changes
- */
- ConfigurationDataInMemory configurationContainer = new ConfigurationDataInMemory();
-
- /**
- * The stack layout
- */
- StackLayout compositeStack = new StackLayout();
-
- /**
- * SWT style
- */
- int style;
-
- /**
- * base configuration container
- */
- Composite containerComposite;
-
- /**
- * checks whether the user is done
- */
- boolean userDone = false;
-
- private TabItem simpleTabItem;
-
- private TabItem advancedTabItem;
-
- private TabItem keystoreTabItem;
-
- private TabItem fido2TabItem;
-
- private TabItem aboutTabItem;
-
- private Button btnSpeichern;
-
- private Button btnAbbrechen;
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public ConfigurationComposite(Composite parent, int style, State state) {
- super(parent, SWT.FILL | style, state);
- this.style = SWT.FILL | style;
-
- this.setLayout(new FormLayout());
-
- this.containerComposite = new Composite(this, SWT.FILL | SWT.RESIZE);
-
- this.tabFolder = new TabFolder(this.containerComposite, SWT.NONE);
- SWTUtils.anchor(tabFolder).bottom(100, -5).right(100, -5).top(0, 5).left(0, 5);
- SWTUtils.setFontHeight(tabFolder, Constants.TEXT_SIZE_NORMAL);
-
- this.simpleTabItem = new TabItem(this.tabFolder, SWT.NONE);
- ScrolledComposite simpleCompositeScr = new ScrolledComposite(this.tabFolder, (SWT.H_SCROLL | SWT.V_SCROLL));
- this.simpleTabItem.setControl(simpleCompositeScr);
- this.simpleConfigComposite = new SimpleConfigurationComposite(simpleCompositeScr, SWT.NONE, state, configurationContainer);
- simpleCompositeScr.setContent(simpleConfigComposite);
- simpleCompositeScr.setExpandHorizontal(true);
- simpleCompositeScr.setExpandVertical(true);
- simpleCompositeScr.setMinSize(simpleConfigComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- this.advancedTabItem = new TabItem(this.tabFolder, SWT.NONE);
- ScrolledComposite advancedCompositeScr = new ScrolledComposite(this.tabFolder, (SWT.H_SCROLL | SWT.V_SCROLL));
- this.advancedTabItem.setControl(advancedCompositeScr);
- this.advancedConfigComposite = new AdvancedConfigurationComposite(advancedCompositeScr, SWT.NONE, state, configurationContainer, this);
- advancedCompositeScr.setContent(advancedConfigComposite);
- advancedCompositeScr.setExpandHorizontal(true);
- advancedCompositeScr.setExpandVertical(true);
- advancedCompositeScr.setMinSize(advancedConfigComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- this.fido2TabItem = new TabItem(this.tabFolder, SWT.NONE);
- ScrolledComposite fido2CompositeScr = new ScrolledComposite(this.tabFolder, (SWT.H_SCROLL | SWT.V_SCROLL));
- this.fido2TabItem.setControl(fido2CompositeScr);
- this.fido2ConfigComposite = new Fido2ConfigurationComposite(fido2CompositeScr, SWT.NONE, state, configurationContainer);
- fido2CompositeScr.setContent(fido2ConfigComposite);
- fido2CompositeScr.setExpandHorizontal(true);
- fido2CompositeScr.setExpandVertical(true);
- fido2CompositeScr.addListener(SWT.Resize, (e) -> {
- int widthHint = fido2CompositeScr.getClientArea().width - 50; /* offset for scroll bar */
- fido2CompositeScr.setMinSize(null);
- fido2CompositeScr.setMinSize(fido2CompositeScr.computeSize(widthHint, SWT.DEFAULT));
- });
-
- this.aboutTabItem = new TabItem(this.tabFolder, SWT.NONE);
- ScrolledComposite aboutCompositeScr = new ScrolledComposite(this.tabFolder, (SWT.H_SCROLL | SWT.V_SCROLL));
- this.aboutTabItem.setControl(aboutCompositeScr);
- this.aboutConfigComposite = new AboutComposite(aboutCompositeScr, SWT.NONE, state, configurationContainer);
- aboutCompositeScr.setContent(aboutConfigComposite);
- aboutCompositeScr.setExpandHorizontal(true);
- aboutCompositeScr.setExpandVertical(true);
- aboutCompositeScr.addListener(SWT.Resize, (event) -> {
- int widthHint = aboutCompositeScr.getClientArea().width - 50; /* offset for scroll bar */
- aboutCompositeScr.setMinSize(null);
- aboutCompositeScr.setMinSize(aboutCompositeScr.computeSize(widthHint, SWT.DEFAULT));
- });
-
- this.tabFolder.setSelection(this.simpleTabItem);
-
- this.btnSpeichern = new Button(this, SWT.NONE);
- SWTUtils.anchor(btnSpeichern).right(100, -5).bottom(100);
- SWTUtils.setFontHeight(btnSpeichern, Constants.TEXT_SIZE_BUTTON);
- this.btnSpeichern.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getShell().setText(Constants.APP_NAME);
- if (ConfigurationComposite.this.storeConfiguration()) {
- ConfigurationComposite.this.userDone = true;
- ConfigurationComposite.this.state.updateStateMachine();
- }
- }
- });
-
- this.btnAbbrechen = new Button(this, SWT.NONE);
- SWTUtils.anchor(btnAbbrechen).right(btnSpeichern, -10).bottom(btnSpeichern, 0, SWT.BOTTOM);
- SWTUtils.setFontHeight(btnAbbrechen, Constants.TEXT_SIZE_BUTTON);
- this.btnAbbrechen.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getShell().setText(Constants.APP_NAME);
- ConfigurationComposite.this.userDone = true;
- ConfigurationComposite.this.state.updateStateMachine();
- }
- });
-
- SWTUtils.anchor(containerComposite).top(0, 5).bottom(btnSpeichern, -10).left(0, 5).right(100, -5);
- this.containerComposite.setLayout(this.compositeStack);
- this.compositeStack.topControl = this.tabFolder;
-
- getShell().setText(Constants.APP_NAME_VERSION + " [" + System.getProperty("java.vendor") + " Java " + System.getProperty("java.version") + "]");
-
- reloadResources();
- this.doLayout();
- }
-
- private boolean keystoreInitialized = false;
-
- /**
- * Set whether keystore tab is enabled
- * @param enabled whether keystore tab is enabled
- */
- public void keystoreEnabled(boolean enabled) {
- if (enabled && this.keystoreConfigComposite == null) {
- this.keystoreTabItem = new TabItem(this.tabFolder, SWT.NONE, 2);
- SWTUtils.setLocalizedText(keystoreTabItem, "config.Keystore");
-
- ScrolledComposite keystoreCompositeScr = new ScrolledComposite(
- this.tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
- this.keystoreTabItem.setControl(keystoreCompositeScr);
- this.keystoreConfigComposite = new KeystoreConfigurationComposite(
- keystoreCompositeScr, SWT.NONE, this.state,
- this.configurationContainer);
- keystoreCompositeScr.setContent(this.keystoreConfigComposite);
- keystoreCompositeScr.setExpandHorizontal(true);
- keystoreCompositeScr.setExpandVertical(true);
- keystoreCompositeScr.setMinSize(this.keystoreConfigComposite
- .computeSize(SWT.DEFAULT, SWT.DEFAULT));
- if (!this.keystoreInitialized) {
- this.keystoreConfigComposite.initConfiguration(this.configProvider);
- this.keystoreInitialized = true;
- }
- this.keystoreConfigComposite.loadConfiguration();
-
- reloadResources();
- } else if (!enabled && this.keystoreConfigComposite != null){
- this.keystoreTabItem.dispose();
- this.keystoreConfigComposite = null;
- }
- }
-
- /**
- * Sets the configuration provider
- *
- * @param provider
- */
- public void setConfigProvider(ConfigurationManager provider) {
- if (provider.crashOnConfig) /* for testing initialization error handlers */
- throw new RuntimeException("A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n(CRASH=config is set.)");
-
- this.configProvider = provider;
- if (this.configProvider != null) {
- for (ConfigurationCompositeBase c : composites())
- c.initConfiguration(this.configProvider);
-
- for (ConfigurationCompositeBase c : composites())
- c.loadConfiguration();
- }
- }
-
- boolean storeConfiguration() {
- try {
- for (ConfigurationCompositeBase c : composites()) {
- int resumeIndex = 0;
- while (true) {
- try {
- c.validateSettings(resumeIndex);
- break;
- } catch (ResumableException e) {
- log.info("Settings validation failed!", e);
- ErrorDialog dialog = new ErrorDialog(getShell(),
- e.getMessage(), BUTTONS.ABORT_RETRY_IGNORE);
- int rc = dialog.open();
-
- if (rc == SWT.ABORT)
- return false;
- if (rc == SWT.IGNORE)
- resumeIndex = e.getResumeIndex();
- }
- }
- }
- } catch (Exception e) {
- log.error("Settings validation failed!", e);
- String message = e.getMessage();
- if (message == null)
- message = Messages.getString("error.Unexpected");
- ErrorDialog dialog = new ErrorDialog(getShell(), message,
- BUTTONS.OK);
- dialog.open();
- return false;
- }
-
- // Write current Configuration
- for (ConfigurationCompositeBase c : composites())
- c.storeConfiguration(this.configProvider);
-
- while (true) {
- // Save current config to file
- try {
- this.configProvider.saveToDisk();
- return true;
- } catch (IOException e) {
- log.error("Failed to save configuration to file!", e);
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.getString("error.FailedToSaveSettings"), BUTTONS.RETRY_CANCEL);
- int rc = dialog.open();
- if (rc == SWT.CANCEL)
- return false;
- }
- }
- }
-
- /**
- * Checks if the user has finished working with the configuration composite
- *
- * @return if the user is done
- */
- public boolean isUserDone() {
- return this.userDone;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
- */
- @Override
- public void onDisplay() {
- Control ctrl = this.compositeStack.topControl;
- this.containerComposite.layout(true, true);
- getShell().layout(true, true);
- // Note: SWT only layouts children! No grandchildren!
- if (ctrl instanceof StateComposite) {
- ((StateComposite) ctrl).doLayout();
- }
- setFocus();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(simpleTabItem, "config.Simple");
- SWTUtils.setLocalizedText(advancedTabItem, "config.Advanced");
- SWTUtils.setLocalizedText(fido2TabItem, "config.FIDO2");
- SWTUtils.setLocalizedText(aboutTabItem, "config.About", Constants.APP_NAME);
- if (this.keystoreConfigComposite != null)
- SWTUtils.setLocalizedText(keystoreTabItem, "config.Keystore");
-
- SWTUtils.setLocalizedText(btnSpeichern, "common.Save");
- SWTUtils.setLocalizedText(btnAbbrechen, "common.Cancel");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
deleted file mode 100644
index 852afecc..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.io.File;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for input document selection
- */
-public class DataSourceSelectComposite extends StateComposite {
-
- /**
- * Open the input document selection dialog
- */
- public void openFileDialog() {
- FileDialog dialog = new FileDialog(
- DataSourceSelectComposite.this.getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] { "*.pdf", "*" });
- dialog.setFilterNames(new String[] {
- Messages.getString("common.PDFExtension_Description"),
- Messages.getString("common.AllExtension_Description") });
- String fileName = dialog.open();
- File file = null;
- if (fileName != null) {
- file = new File(fileName);
- if (file.exists()) {
- DataSourceSelectComposite.this.setSelected(file);
- }
- }
- }
-
- /**
- * Selection adapter for file browsing
- */
- private final class FileBrowseDialogListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public FileBrowseDialogListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- openFileDialog();
- }
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(DataSourceSelectComposite.class);
-
- /**
- * Set this value through the setter method!!
- */
- private File selected = null;
-
- /**
- * Sets the selected file and calls update to the workflow
- *
- * @param selected
- */
- protected void setSelected(File selected) {
- this.selected = selected;
- this.state.updateStateMachine();
- }
-
- /**
- * Gets the selected file
- *
- * @return the selected file
- */
- public File getSelected() {
- return this.selected;
- }
-
- void MarkDragEnter() {
- this.backgroundColor = this.activeBackground;
- this.borderColor = this.activeBorder;
- this.redrawDrop();
- }
-
- void MarkDragLeave() {
- this.backgroundColor = this.inactiveBackground;
- this.borderColor = this.inactiveBorder;
- this.redrawDrop();
- }
-
- void redrawDrop() {
- this.lbl_drag.setBackground(this.backgroundColor);
- this.lbl_drag2.setBackground(this.backgroundColor);
- this.btn_open.setBackground(this.backgroundColor);
- this.drop_area.redraw();
- this.drop_area.layout(true, true);
- }
-
- Color activeBackground;
- Color inactiveBackground;
- Color inactiveBorder;
- Color activeBorder;
- Color borderColor;
- Color backgroundColor;
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public DataSourceSelectComposite(Composite parent, int style, State state) {
- super(parent, style, state);
-
- this.activeBackground = Constants.MAINBAR_ACTIVE_BACK_LIGHT;
- this.inactiveBackground = this.getBackground();//Constants.MAINBAR_INACTIVE_BACK;
- this.inactiveBorder = Constants.MAINBAR_ACTIVE_BACK_LIGHT;
- this.activeBorder = Constants.MAINBAR_ACTIVE_BACK_DARK;
- this.backgroundColor = this.inactiveBackground;
- this.borderColor = Constants.DROP_BORDER_COLOR;
-
- this.setLayout(new FormLayout());
-
- // Color back = new Color(Display.getCurrent(), 77, 190, 250);
-
- this.drop_area = new Composite(this, SWT.RESIZE);
- SWTUtils.anchor(drop_area).left(0, 30).right(100, -30).top(0, 30).bottom(100, -30);
- this.drop_area.setLayout(new FormLayout());
-
- this.drop_area.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = DataSourceSelectComposite.this
- .drop_area.getClientArea();
-
- //e.gc.setForeground(new Color(getDisplay(),0x6B, 0xA5, 0xD9));
- e.gc.setForeground(DataSourceSelectComposite.this.borderColor);
- e.gc.setLineWidth(3);
- e.gc.setLineStyle(SWT.LINE_DASH);
- e.gc.setBackground(DataSourceSelectComposite.this.backgroundColor);
- e.gc.fillRoundRectangle(clientArea.x,
- clientArea.y, clientArea.width - 2, clientArea.height - 2,
- 10, 10);
- e.gc.drawRoundRectangle(clientArea.x,
- clientArea.y, clientArea.width - 2, clientArea.height - 2,
- 10, 10);
- }
- });
-
- DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
- final FileTransfer fileTransfer = FileTransfer.getInstance();
- Transfer[] types = new Transfer[] { fileTransfer };
- dnd_target.setTransfer(types);
-
- dnd_target.addDropListener(new DropTargetAdapter() {
- @Override
- public void drop(DropTargetEvent event) {
- if (fileTransfer.isSupportedType(event.currentDataType)) {
- if (event.data == null) {
- log.error("Dropped file name was null");
- return;
- }
- String[] files = (String[]) event.data;
- if (files.length > 0) {
- // Only taking first file ...
- File file = new File(files[0]);
- if (!file.exists()) {
- log.error(Messages.formatString("error.FileNotExist", files[0]));
- return;
- }
- DataSourceSelectComposite.this.setSelected(file);
- }
- }
- }
-
- @Override
- public void dragOperationChanged(DropTargetEvent event) {
- event.detail = DND.DROP_COPY;
- }
-
- @Override
- public void dragEnter(DropTargetEvent event) {
- // only accept transferable files
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (fileTransfer.isSupportedType(event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- event.detail = DND.DROP_COPY;
- MarkDragEnter();
- return;
- }
- }
- event.detail = DND.DROP_NONE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.dnd.DropTargetAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent)
- */
- @Override
- public void dragLeave(DropTargetEvent event) {
- MarkDragLeave();
- super.dragLeave(event);
- }
- });
-
- this.lbl_drag = new Label(this.drop_area, SWT.NONE | SWT.RESIZE );
- this.lbl_drag2 = new Label(this.drop_area, SWT.NONE | SWT.RESIZE );
- SWTUtils.anchor(lbl_drag).left(0, 10).right(100, -10).bottom(lbl_drag2, -10);
- SWTUtils.anchor(lbl_drag2).left(0, 10).right(100, -10).top(50, -10);
- SWTUtils.setFontHeight(lbl_drag, Constants.TEXT_SIZE_BIG);
- SWTUtils.setFontHeight(lbl_drag2, Constants.TEXT_SIZE_NORMAL);
- this.lbl_drag.setAlignment(SWT.CENTER);
- this.lbl_drag2.setAlignment(SWT.CENTER);
-
- this.btn_open = new Button(this.drop_area, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(btn_open).left(lbl_drag2, 0, SWT.CENTER).top(lbl_drag2, 10);
- SWTUtils.setFontHeight(btn_open, Constants.TEXT_SIZE_BUTTON);
-
- reloadResources();
-
- this.btn_open.addSelectionListener(new FileBrowseDialogListener());
- this.drop_area.pack();
- this.redrawDrop();
- }
-
- Composite drop_area;
-
- private Label lbl_drag2;
-
- private Label lbl_drag;
-
- private Button btn_open;
-
- @Override
- public void onDisplay() {
- this.drop_area.layout(true, true);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_drag, "dataSourceSelection.DropLabel");
- SWTUtils.setLocalizedText(lbl_drag2, "dataSourceSelection.DropLabel2");
- SWTUtils.setLocalizedText(btn_open, "dataSourceSelection.browse");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
deleted file mode 100644
index 96dc3982..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/OutputComposite.java
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.Desktop;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.apache.commons.io.FilenameUtils;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.controls.Dialog;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.Dialog.ICON;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signer.DocumentSource;
-
-/**
- * GUI component for Output State
- */
-public class OutputComposite extends StateComposite {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(OutputComposite.class);
-
- private Link lnk_saved_file;
-
- private Button btn_save;
-
- private Label lbl_success_message;
-
- private DocumentSource signedDocument;
-
- private File inputFile;
-
- String outputDir = null;
-
- String tempDirectory = null;
-
- File outputFile = null;
-
- private boolean saveFailed = false;
-
- private String postFix = null;
-
- /**
- * Create the composite.
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style
- * @param state
- * The owning state
- */
- public OutputComposite(Composite parent, int style, State state) {
- super(parent, style, state);
-
- this.setLayout(new FormLayout());
-
- this.lbl_success_message = new Label(this, SWT.NATIVE | SWT.RESIZE);
- FormData fd_lbl_success_message = new FormData();
- fd_lbl_success_message.top = new FormAttachment(40, 0);
- fd_lbl_success_message.left = new FormAttachment(0);
- fd_lbl_success_message.right = new FormAttachment(100);
- this.lbl_success_message.setLayoutData(fd_lbl_success_message);
- this.lbl_success_message.setAlignment(SWT.CENTER);
-
- FontData[] fD1 = this.lbl_success_message.getFont().getFontData();
- fD1[0].setHeight(Constants.TEXT_SIZE_BIG);
- this.lbl_success_message.setFont(new Font(Display.getCurrent(), fD1[0]));
-
- this.lnk_saved_file = new Link(this, SWT.NATIVE | SWT.RESIZE);
- FormData fd_lnk_saved_file = new FormData();
- fd_lnk_saved_file.top = new FormAttachment(this.lbl_success_message, 10);
- fd_lnk_saved_file.left = new FormAttachment(this.lbl_success_message, 0,
- SWT.CENTER);
- // fd_lnk_saved_file.right = new FormAttachment(100);
- this.lnk_saved_file.setLayoutData(fd_lnk_saved_file);
-
- this.lnk_saved_file.addSelectionListener(new OpenSelectionListener());
-
- FontData[] fD2 = this.lnk_saved_file.getFont().getFontData();
- fD2[0].setHeight(Constants.TEXT_SIZE_NORMAL);
- this.lnk_saved_file.setFont(new Font(Display.getCurrent(), fD2[0]));
-
- this.btn_save = new Button(this, SWT.NATIVE | SWT.RESIZE);
-
- FontData[] fD_btn_save = this.btn_save.getFont().getFontData();
- fD_btn_save[0].setHeight(Constants.TEXT_SIZE_BUTTON);
- this.btn_save.setFont(new Font(Display.getCurrent(), fD_btn_save[0]));
-
- FormData fd_btn_save = new FormData();
- fd_btn_save.top = new FormAttachment(this.lnk_saved_file, 10);
- fd_btn_save.left = new FormAttachment(this.lnk_saved_file, 0,
- SWT.CENTER);
- this.btn_save.setLayoutData(fd_btn_save);
-
- this.btn_save.addSelectionListener(new SaveSelectionListener());
- enableSaveButton(false);
-
- reloadResources();
- }
-
- /**
- * @param outputDir
- * the outputDir to set
- */
- public void setOutputDir(String outputDir) {
- this.outputDir = outputDir;
- }
-
- /**
- * @return the outputDir
- */
- public String getOutputDir() {
- return this.outputDir;
- }
-
- /**
- * Sets the input file
- *
- * @param inputFile
- * the input file
- */
- public void setInputFile(File inputFile) {
- this.inputFile = inputFile;
- }
-
- /**
- * Gets the input file
- *
- * @return the input file
- */
- public File getInputFile() {
- return this.inputFile;
- }
-
- /**
- * @param tempDirectory
- */
- public void setTempDir(String tempDirectory) {
- this.tempDirectory = tempDirectory;
- }
-
- /**
- * Gets the signed document
- *
- * @return the signed document
- */
- public DocumentSource getSignedDocument() {
- return this.signedDocument;
- }
-
- /**
- * Sets the signed document
- *
- * @param signedDocument
- * the signed document
- */
- public void setSignedDocument(final DocumentSource signedDocument) {
- this.signedDocument = signedDocument;
- }
-
- /**
- * Return whether the last save was successful
- * @return whether the last save was successful
- */
- public boolean getSaveSuccessful() {
- return !this.saveFailed;
- }
-
- private void enableSaveButton(boolean doEnable)
- {
- this.btn_save.setEnabled(doEnable);
- this.btn_save.setVisible(doEnable);
- }
-
- public void setSaveFilePostFix(String postFix){
- this.postFix = postFix;
- }
-
- public String getSaveFilePostFix(){
- if (this.postFix == null){
- this.postFix = Constants.DEFAULT_POSTFIX;
- }
- return this.postFix;
- }
-
- /**
- * Saves the signed document.
- *
- * If user has a default output directory set, try to save there.
- * If not (or if directory unavailable), ask user for location.
- */
- public void saveDocument() {
- File inputFolder = getInputFile().getAbsoluteFile().getParentFile();
- String fileName = getInputFile().getName();
- String proposedName = getSignedFileName(fileName);
- String outputFileName;
-
- String outputFolder = getOutputDir();
- if (!this.saveFailed && outputFolder != null && !outputFolder.trim().isEmpty()) {
- // Output folder configured, try to save there
-
- File f = new File(outputFolder);
- if (f.isDirectory()) {
- if (!outputFolder.endsWith(File.separator)) {
- outputFolder += File.separator;
- }
- outputFileName = outputFolder + proposedName;
- } else {
- outputFileName = outputFolder;
- }
- } else {
- // Ask user where to save
-
- FileDialog save = new FileDialog(this.getShell(),
- SWT.SAVE | SWT.NATIVE);
- save.setFilterExtensions(new String[] { "*.pdf", "*" });
- save.setFilterNames(new String[] {
- Messages.getString("common.PDFExtension_Description"),
- Messages.getString("common.AllExtension_Description")});
- save.setFilterPath(inputFolder.getAbsolutePath());
- save.setFileName(proposedName);
-
- outputFileName = save.open();
- inputFolder = null;
- }
- log.debug("Trying to save to '" + outputFileName + "'");
-
- this.outputFile = saveResultAsFile(inputFolder, outputFileName);
- this.saveFailed = (this.outputFile == null);
-
- // If saving failed, enable save button
- enableSaveButton(this.saveFailed);
- reloadResources();
- layout(true);
- }
-
- /**
- * Save the signed document under the given filename
- * @param inputFolder the Folder the original document is located at
- * @param target the filename to save the document as
- *
- * @return saved File (or null if unsuccessful)
- * @throws FileNotFoundException
- * @throws IOException
- */
- private File saveResultAsFile(File inputFolder, String target) {
- if (target == null)
- return null;
-
- File targetFile = new File(target);
- if (!targetFile.isAbsolute())
- targetFile = new File(inputFolder, target);
-
- if (targetFile.exists()) {
- Dialog dialog = new Dialog(getShell(), Messages.getString("common.warning"),
- Messages.formatString("output.file_ask_overwrite", targetFile.getName()),
- BUTTONS.OK_CANCEL, ICON.QUESTION);
- if (dialog.open() == SWT.CANCEL)
- {
- return null;
- }
- }
-
- DocumentSource source = this.getSignedDocument();
- boolean retry;
-
- do {
- retry = false;
- try {
- FileOutputStream outstream = new FileOutputStream(targetFile);
- outstream.write(source.getByteArray(), 0,
- source.getByteArray().length);
- outstream.close();
- } catch (FileNotFoundException e) {
- log.warn("Failed to open output file", e);
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.formatString("output.save_failed",
- targetFile.getName(), e.getLocalizedMessage()),
- BUTTONS.RETRY_CANCEL);
- if (dialog.open() == SWT.CANCEL)
- return null;
- retry = true;
- } catch (IOException e) {
- log.error("I/O Error", e);
- ErrorDialog dialog = new ErrorDialog(getShell(),
- Messages.formatString("output.save_failed",
- targetFile.getName(), e.getLocalizedMessage()),
- BUTTONS.RETRY_CANCEL);
- if (dialog.open() == SWT.CANCEL)
- return null;
- retry = true;
- }
- } while (retry);
-
- if (!targetFile.exists())
- {
- log.error("Tried to save file " + targetFile.getName() +
- ", but it doesn't exist");
- return null;
- }
- return targetFile;
- }
-
- /**
- * Get the proposed filename of a signed document for a given input filename
- * @param name input filename
- * @return proposed output filename
- */
- private String getSignedFileName(String name) {
- name = FilenameUtils.getName(name);
- String extension = FilenameUtils.getExtension(name);
- name = FilenameUtils.removeExtension(name);
- return name + getSaveFilePostFix() + FilenameUtils.EXTENSION_SEPARATOR + extension;
- }
-
- /**
- * SelectionListener for save button
- */
- private final class SaveSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public SaveSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- OutputComposite.this.saveDocument();
- } catch (Exception ex) {
- log.error("SaveSelectionListener: ", ex);
- }
- }
- }
-
- /**
- * Selection Listener for open button
- */
- private final class OpenSelectionListener extends SelectionAdapter {
- /**
- * Empty constructor
- */
- public OpenSelectionListener() {
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- if (OutputComposite.this.outputFile == null)
- return;
-
- if (!OutputComposite.this.outputFile.exists())
- return;
-
- // Normalize filename
- File f = new File(FilenameUtils.normalize(
- OutputComposite.this.outputFile.getAbsolutePath()));
- log.debug("Trying to open " + f.toString());
- // work around for the case of Linux and Java version 8
- if (isSpecialCase()) {
- reReloadResources(f.toString());
- return;
- }
- else if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().open(f);
- } else {
- log.info("AWT Desktop is not supported on this platform");
- Program.launch(f.getAbsolutePath());
- }
- } catch (IOException ex) {
- log.error("OpenSelectionListener: ", ex);
- ErrorDialog error = new ErrorDialog(getShell(),
- Messages.formatString("error.FailedToOpenDocument",
- ex.getLocalizedMessage()), BUTTONS.RETRY_CANCEL);
- if (error.open() == SWT.RETRY)
- widgetSelected(e);
- }
- }
- }
-
- /**
- * @return true when linux and java version <= 8
- *
- */
- public boolean isSpecialCase() {
-
- boolean isSCase = false;
- try {
- String os = System.getProperty("os.name").toLowerCase();
- if (os.contains("linux")) {
- String version = System.getProperty("java.version");
- if (version.contains(".")) {
- String[] parts = version.split("\\.");
- isSCase = Integer.valueOf(parts[0]) <= 8 ? true : false;
- } else {
- isSCase = Integer.valueOf(version) <= 8 ? true : false;
- }
- }
- } catch (Exception e) {
- log.debug("Error: " + e.getMessage());
- isSCase = false;
- }
- return isSCase;
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_success_message, "output.success_message");
- if (this.outputFile == null) {
- SWTUtils.setLocalizedText(lnk_saved_file, "output.link_save_message");
- } else {
- SWTUtils.setLocalizedText(lnk_saved_file, "output.link_open_message");
- }
- SWTUtils.setLocalizedText(btn_save, "common.Save");
- }
-
- /**
- * @param str
- */
- public void reReloadResources(String str) {
- SWTUtils.setLocalizedText(lbl_success_message, "output.success_message");
- if (this.outputFile == null) {
- SWTUtils.setLocalizedText(lnk_saved_file, "output.link_save_message");
- } else {
- String str2 = "File location: " + str;
- this.lbl_success_message.setText(str2);
- this.lnk_saved_file.setText("");
- }
- SWTUtils.setLocalizedText(btn_save, "common.Save");
- }
-
-
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
deleted file mode 100644
index b4d06546..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/PositioningComposite.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.EventQueue;
-import java.awt.Frame;
-import java.awt.Image;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseWheelEvent;
-import java.awt.event.MouseWheelListener;
-import java.awt.geom.Point2D;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.awt.SWT_AWT;
-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.ScrollBar;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signer.SignaturePosition;
-
-/**
- * Composite which allows to position the signature on a preview of the document
- */
-public class PositioningComposite extends StateComposite {
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(PositioningComposite.class);
-
- SignaturePanel viewer = null;
- Frame frame = null;
- Composite mainArea = null;
- Composite bottomBar = null;
- Button btnNewPage = null;
- Label lblPage = null;
- ScrollBar scrollbar = null;
-
- private SignaturePosition position = null;
- int currentPage = 0;
- int numPages = 0;
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public PositioningComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- this.setLayout(new FormLayout());
-
- this.bottomBar = new Composite(this, SWT.NONE);
- SWTUtils.anchor(bottomBar).left(0).right(100).bottom(100);
- this.bottomBar.setLayout(new FormLayout());
-
- this.btnSign = new Button(this.bottomBar, SWT.PUSH);
- SWTUtils.anchor(btnSign).right(100).top(0);
- this.getShell().setDefaultButton(this.btnSign);
-
- this.btnNewPage = new Button(this.bottomBar, SWT.TOGGLE);
- SWTUtils.anchor(btnNewPage).right(btnSign).top(0);
-
- this.lblPage = new Label(this.bottomBar, SWT.CENTER);
- SWTUtils.anchor(lblPage).left(0).right(btnNewPage, 5).bottom(100);
-
- this.mainArea = new Composite(this, SWT.EMBEDDED | SWT.V_SCROLL);
- SWTUtils.anchor(mainArea).left(0).right(100).top(0).bottom(bottomBar, -5);
- this.scrollbar = this.mainArea.getVerticalBar();
-
- this.frame = SWT_AWT.new_Frame(this.mainArea);
- this.frame.addKeyListener(this.keyListener);
- this.frame.addMouseWheelListener(this.mouseListener);
-
- this.viewer = new SignaturePanel();
- this.viewer.setSignaturePlaceholderBorderColor(new Color(
- Constants.MAINBAR_ACTIVE_BACK_DARK.getRed(),
- Constants.MAINBAR_ACTIVE_BACK_DARK.getGreen(),
- Constants.MAINBAR_ACTIVE_BACK_DARK.getBlue()));
- this.frame.add(this.viewer, BorderLayout.CENTER);
-
- SWTUtils.addSelectionListener(btnNewPage, () -> {
- if (this.currentPage > this.numPages)
- showPage(this.numPages);
- else
- showPage(this.numPages + 1);
- requestFocus();
- });
-
- SWTUtils.addSelectionListener(btnSign, this::setFinalPosition);
-
- SWTUtils.addSelectionListener(scrollbar, () -> { this.showPage(this.scrollbar.getSelection()); });
-
- reloadResources();
- requestFocus();
- }
-
- @Override public void onDisplay() { if (this.viewer.getSigPagePos() == null) this.btnSign.setEnabled(false); }
-
- /**
- * Set the PDF Document to display
- *
- * @param document
- * document to display
- */
- public void displayDocument(final PDDocument document) {
- EventQueue.invokeLater(() -> {
- this.viewer.setDocument(document);
- getDisplay().asyncExec(() -> this.btnSign.setEnabled(true));
- });
-
- if (document != null)
- {
- this.numPages = document.getNumberOfPages();
- this.scrollbar.setValues(1, 1, this.numPages + 1, 1, 1, 1);
- showPage(this.numPages);
- }
- }
-
- @Override
- public void dispose() {
- this.viewer.setDocument(null);
- super.dispose();
- }
-
- /**
- * Request focus (to enable keyboard input)
- */
- public void requestFocus() {
- getDisplay().asyncExec(() -> {
- if (!this.isDisposed() && !this.mainArea.isDisposed()) {
- this.mainArea.setFocus();
- EventQueue.invokeLater(() -> {
- if (!this.isDisposed()) {
- if (!this.frame.hasFocus()) {
- this.frame.requestFocus();
- }
- }
- });
- }
- });
- }
-
- /**
- * Set the signature placeholder image Must be called _after_
- * displayDocument
- *
- * @param placeholder
- * signature placeholder
- * @param width
- * width of the placeholder in page space
- * @param height
- * height of the placeholder in page space
- */
- public void setPlaceholder(final Image placeholder) {
- EventQueue.invokeLater(() -> {
- if (this.viewer == null)
- return;
- this.viewer.setSignaturePlaceholder(placeholder);
- });
- }
-
- KeyListener keyListener = new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- int newPage = PositioningComposite.this.currentPage;
- int sigXOffset = 0;
- int sigYOffset = 0;
-
- switch (e.getKeyCode()) {
- case KeyEvent.VK_PAGE_DOWN:
- if (PositioningComposite.this.currentPage < PositioningComposite.this.numPages)
- ++newPage;
- break;
-
- case KeyEvent.VK_PAGE_UP:
- if (PositioningComposite.this.currentPage > 1)
- --newPage;
- break;
-
- case KeyEvent.VK_END:
- newPage = PositioningComposite.this.numPages;
- break;
-
- case KeyEvent.VK_HOME:
- newPage = 1;
- break;
-
- case KeyEvent.VK_ENTER:
- setFinalPosition();
- break;
-
- case KeyEvent.VK_LEFT:
- case KeyEvent.VK_KP_LEFT:
- sigXOffset -= Constants.SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
- break;
-
- case KeyEvent.VK_RIGHT:
- case KeyEvent.VK_KP_RIGHT:
- sigXOffset += Constants.SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
- break;
-
- case KeyEvent.VK_UP:
- case KeyEvent.VK_KP_UP:
- sigYOffset += Constants.SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
- break;
-
- case KeyEvent.VK_DOWN:
- case KeyEvent.VK_KP_DOWN:
- sigYOffset -= Constants.SIGNATURE_KEYBOARD_POSITIONING_OFFSET;
- break;
- }
-
- if (newPage != PositioningComposite.this.currentPage)
- showPage(newPage);
-
- if (sigXOffset != 0 || sigYOffset != 0)
- translateSignaturePosition(sigXOffset, sigYOffset);
- }
- };
-
- MouseWheelListener mouseListener = new MouseWheelListener() {
- private long lastEventTime = 0;
-
- @Override
- public void mouseWheelMoved(MouseWheelEvent e) {
- e.consume();
- // Workaround for Linux: Events fire twice
- if (e.getWhen() == this.lastEventTime)
- return;
- this.lastEventTime = e.getWhen();
-
- int change = e.isShiftDown() ? 5 : 1;
- int newPage = PositioningComposite.this.currentPage;
-
- if (e.getWheelRotation() < 0) {
- newPage = Math.max(1, newPage - change);
- } else if (e.getWheelRotation() > 0) {
- newPage = Math.min(newPage + change, PositioningComposite.this.numPages);
- }
-
- if (newPage != PositioningComposite.this.currentPage)
- showPage(newPage);
- }
- };
-
- private Button btnSign;
-
- void showPage(final int page) {
- final int previousPage = this.currentPage;
- this.currentPage = page;
- getDisplay().asyncExec(() -> {
- int currentPage = this.currentPage;
- int numPages = this.numPages;
- if ((previousPage > numPages) && (currentPage <= numPages)) {
- // Was on new page
- SWTUtils.setLocalizedText(btnNewPage, "positioning.newPage");
- this.btnNewPage.setSelection(false);
- this.bottomBar.layout();
- this.scrollbar.setMaximum(numPages + 1);
- } else if ((previousPage <= numPages) && (currentPage > numPages)) {
- // Go to new page
- SWTUtils.setLocalizedText(btnNewPage, "positioning.removeNewPage");
- this.btnNewPage.setSelection(true);
- this.bottomBar.layout();
- this.scrollbar.setMaximum(numPages + 2);
- }
- this.scrollbar.setSelection(currentPage);
- SWTUtils.setLocalizedText(lblPage, "positioning.page", currentPage, numPages);
- });
- EventQueue.invokeLater(() -> {
- PositioningComposite.this.viewer.showPage(page);
- });
- }
-
- /**
- * Translate the signature placeholder position
- *
- * @param sigXOffset
- * signature placeholder horizontal position offset
- * @param sigYOffset
- * signature placeholder vertical position offset (negative is down)
- */
- public void translateSignaturePosition(final int sigXOffset, final int sigYOffset) {
- EventQueue.invokeLater(() -> {
- this.viewer.translateSignaturePagePosition(sigXOffset, sigYOffset);
- });
- }
-
- /**
- * Set the signature position and continue to the next state
- *
- * @param position
- * the signature position
- */
- void setFinalPosition() {
- if (this.currentPage == 0) {
- this.position = new SignaturePosition();
- } else {
- Point2D pos = this.viewer.getSigPagePos();
- if (pos == null) return;
-
- this.position = new SignaturePosition(
- pos.getX(),
- pos.getY(),
- this.currentPage);
- }
- PositioningComposite.this.state.updateStateMachine();
- }
-
- /**
- * Set the signature position
- *
- * @param x
- * the horizontal signature position
- * @param y
- * the vertical signature position
- * @param page
- * the page the signature is on
- */
- public void setPosition(double x, double y, int page) {
- showPage(page);
- if (this.viewer != null)
- this.viewer.setSignaturePosition(x, y);
- }
-
- /**
- * Get the signature position
- *
- * @return the signature position
- */
- public SignaturePosition getPosition() {
- return this.position;
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(btnNewPage, (this.currentPage <= this.numPages) ? "positioning.newPage" : "positioning.removeNewPage");
- SWTUtils.setLocalizedText(btnSign, "positioning.sign");
- SWTUtils.setLocalizedText(lblPage, "positioning.page", this.currentPage, this.numPages);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
deleted file mode 100644
index df880459..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SignaturePanel.java
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-
-import javax.annotation.CheckForNull;
-import javax.swing.JPanel;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.rendering.PDFRenderer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class SignaturePanel extends JPanel {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(SignaturePanel.class);
-
- /** Default serial version ID */
- private static final long serialVersionUID = 1L;
-
- /** The PDF file being displayed */
- private PDDocument pdf = null;
- private PDFRenderer renderer = null;
-
- /** The image of the rendered PDF page being displayed */
- Image currentImage = null;
-
- /** The current scale for rendering pdf to image */
- private float pageToImageScale;
- /** The current scale for rendering image to screen */
- private double imageToScreenScale;
- /* scaling */
- private enum U {
- /* (0,0) is bottom-left of page */
- PAGE_ABS,
- /* (0,0) is top-left of page */
- PAGE_REL,
- /* pixels, (0,0) is top-left of image */
- IMAGE,
- /* pixels, (0,0) is top-left of image */
- SCREEN_REL,
- /* pixels, (0,0) is top-left of canvas */
- SCREEN_ABS };
- private enum Dim { X, Y };
- private double scale(double v, U from, U to, Dim d)
- {
- if (from == to) return v;
-
- if (from == U.PAGE_ABS) {
- return scale((d == Dim.X) ? v : (this.pageHeight - v), U.PAGE_REL, to, d);
- } else if (from == U.PAGE_REL) {
- if (to == U.PAGE_ABS)
- return ((d == Dim.X) ? v : (this.pageHeight - v));
- else
- return scale(v * this.pageToImageScale, U.IMAGE, to, d);
- } else if (from == U.IMAGE) {
- if ((to == U.PAGE_ABS) || (to == U.PAGE_REL))
- return scale(v / this.pageToImageScale, U.PAGE_REL, to, d);
- else
- return scale(v * this.imageToScreenScale, U.SCREEN_REL, to, d);
- } else if (from == U.SCREEN_REL) {
- if (to == U.SCREEN_ABS)
- return (v + ((d == Dim.X) ? this.offX : this.offY));
- else
- return scale(v / this.imageToScreenScale, U.IMAGE, to, d);
- } else if (from == U.SCREEN_ABS) {
- return scale(v - ((d == Dim.X) ? this.offX : this.offY), U.SCREEN_REL, to, d);
- } else throw new RuntimeException("unreachable");
- }
-
- private float pageWidth = 0;
- private float pageHeight = 0;
- /** The horizontal offset of the image from the left edge of the panel */
- private int offX = 0;
- /** The vertical offset of the image from the top of the panel */
- private int offY = 0;
- /** The position of the top-left corner of the signature, in absolute page space */
- private Point2D sigPagePos = null;
- public @CheckForNull Point2D getSigPagePos() { return this.sigPagePos; }
- /** The signature placeholder image */
- private Image sigPlaceholder = null;
- /** Width of the signature placeholder in page space */
- private int sigPageWidth = 0;
- /** Height of the signature placeholder in page space */
- private int sigPageHeight = 0;
- /** Color of the signature placeholder border */
- private Color sigPlaceholderBorderColor = Color.BLUE;
- /** Current page */
- private int currentPageNo = 0;
- /** Number of pages in the document */
- private int numPages = 0;
- /** Cursor types */
- private static enum Cursors {DEFAULT, HAND, MOVE};
- /** Default arrow cursor */
- private final Cursor defaultCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
- /** Hand cursor */
- private final Cursor handCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
- /** Move cursor */
- private final Cursor moveCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
- /** Current cursor */
- private Cursors currentCursor = Cursors.DEFAULT;
-
- /**
- * Create a new PagePanel.
- */
- public SignaturePanel() {
- super(new BorderLayout());
- setDocument(null);
- setFocusable(true);
- addMouseListener(this.mouseListener);
- addMouseMotionListener(this.mouseListener);
- }
-
- /**
- * Set a new document to be displayed
- * @param pdf the PDFFile to be displayed
- */
- public void setDocument(PDDocument pdf) {
- this.pdf = pdf;
- this.sigPagePos = null;
- if (pdf != null)
- {
- this.renderer = new PDFRenderer(pdf);
- this.numPages = pdf.getNumberOfPages();
- this.currentPageNo = -1;
- showPage(this.numPages);
- }
- else
- {
- this.renderer = null;
- this.currentPageNo = 0;
- this.numPages = 0;
- renderPageToImage();
- repaint();
- }
- }
-
- /**
- * Set the signature placeholder image
- * @param placeholder signature placeholder
- * @param width width of the placeholder in page space
- * @param height height of the placeholder in page space
- */
- public void setSignaturePlaceholder(Image placeholder) {
- this.sigPlaceholder = placeholder;
- // TODO figure out why this is divided by 4 (factor ported from old code)
- this.sigPageWidth = placeholder.getWidth(null) / 4;
- this.sigPageHeight = placeholder.getHeight(null) / 4;
- renderPageToImage();
- if (this.sigPagePos != null)
- setSignaturePosition(this.sigPagePos.getX(), this.sigPagePos.getY());
- repaint();
- }
-
- /**
- * Set the color of the signature placeholder border
- * @param color new signature placeholder border color
- */
- public void setSignaturePlaceholderBorderColor(Color color) {
- this.sigPlaceholderBorderColor = color;
- }
-
- /**
- * Change the currently displayed page
- * @param page the number of the page to display
- */
- public void showPage(int page) {
- if (this.currentPageNo == page) return;
- this.currentPageNo = page;
- renderPageToImage();
- repaint();
- }
-
- /**
- * Add and display a new page at the end of the document
- *
- * This page has the same dimensions as the old last page
- */
- public void addNewLastPage() {
- showPage(this.numPages + 1);
- }
-
- /**
- * Set the signature placeholder position
- * @param x the horizontal signature position
- * @param y the vertical signature position
- */
- public void setSignaturePosition(double x, double y)
- {
- this.sigPagePos = new Point2D.Double(
- clamp(x, 0, this.pageWidth - this.sigPageWidth),
- clamp(y, this.sigPageHeight, this.pageHeight)
- );
- repaint();
- }
-
- public void translateSignaturePagePosition(float dX, float dY) {
- setSignaturePosition(this.sigPagePos.getX() + dX, this.sigPagePos.getY() + dY);
- }
-
- /**
- * Stop the generation of any previous page, and draw the new one.
- *
- * @param page the PDFPage to draw.
- */
- private synchronized void renderPageToImage() {
- if (this.pdf == null)
- {
- this.currentImage = null;
- return;
- }
-
- boolean newPage = false;
- PDPage currentPage;
- // set up the new page
- if (this.currentPageNo > this.numPages)
- {
- // New last page - use old last page as template
- currentPage = this.pdf.getPage(this.numPages-1);
- newPage = true;
- }
- else
- currentPage = this.pdf.getPage(this.currentPageNo-1);
-
-
- if (currentPage == null) {
- // no page
- this.currentImage = null;
- return;
- }
-
- boolean isRotated = ((currentPage.getRotation()%180) == 90);
- PDRectangle actualPageSize = currentPage.getBBox();
- this.pageWidth = isRotated ? actualPageSize.getHeight() : actualPageSize.getWidth();
- this.pageHeight = isRotated ? actualPageSize.getWidth() : actualPageSize.getHeight();
- this.pageToImageScale = getToolkit().getScreenSize().height / this.pageHeight;
-
- // get the new image
- if (newPage)
- {
- int renderHeight = (int)(0.5 + this.scale(this.pageHeight, U.PAGE_REL, U.IMAGE, Dim.X));
- int renderWidth = (int)(0.5 + this.scale(this.pageWidth, U.PAGE_REL, U.IMAGE, Dim.Y));
- this.currentImage = new BufferedImage(renderWidth, renderHeight, BufferedImage.TYPE_INT_RGB);
- Graphics g = this.currentImage.getGraphics();
- g.setColor(Color.WHITE);
- g.fillRect(0, 0, renderWidth, renderHeight);
- }
- else
- {
- int whichPage = Math.min(this.currentPageNo, this.numPages);
-
- try {
- this.currentImage = renderer.renderImage(whichPage-1, this.pageToImageScale);
- } catch (IOException e) {
- log.error(String.format("Failed to render image for page %d of %d", whichPage, this.numPages), e);
- this.currentImage = null;
- }
- }
-
- if (this.sigPagePos == null)
- {
- setSignaturePosition(
- this.pageWidth * .5,
- this.pageHeight * .75
- );
- }
- }
-
- /**
- * Draw the image.
- */
- @Override
- public void paint(Graphics g) {
- Dimension renderPanelSize = getSize();
- g.setColor(getBackground());
- g.fillRect(0, 0, getWidth(), getHeight());
- if (this.currentImage == null) {
- g.setColor(Color.black);
- g.drawString(Messages.getString("common.working"), getWidth() / 2 - 30, getHeight() / 2);
- } else {
- this.imageToScreenScale = Math.min(
- renderPanelSize.getWidth() / this.currentImage.getWidth(null),
- renderPanelSize.getHeight() / this.currentImage.getHeight(null));
- // draw the image
- int actualRenderWidth = (int)(this.currentImage.getWidth(null) * this.imageToScreenScale);
- int actualRenderHeight = (int)(this.currentImage.getHeight(null) * this.imageToScreenScale);
-
- // draw it centered within the panel
- this.offX = (renderPanelSize.width - actualRenderWidth) / 2;
- this.offY = (renderPanelSize.height - actualRenderHeight) / 2;
-
- // draw document
- g.drawImage(this.currentImage, this.offX, this.offY, actualRenderWidth, actualRenderHeight, null);
-
-
- // draw signature
- int sigX = (int) this.scale(this.sigPagePos.getX(), U.PAGE_ABS, U.SCREEN_ABS, Dim.X);
- int sigY = (int) this.scale(this.sigPagePos.getY(), U.PAGE_ABS, U.SCREEN_ABS, Dim.Y);
- if (this.sigPlaceholder == null) {
- g.setColor(Color.red);
- g.drawRect(sigX, sigY, 100, 40);
- }
- else {
- int sigScreenWidth = (int)this.scale(this.sigPageWidth, U.PAGE_REL, U.SCREEN_REL, Dim.X);
- int sigScreenHeight = (int)this.scale(this.sigPageHeight, U.PAGE_REL, U.SCREEN_REL, Dim.Y);
- g.drawImage(this.sigPlaceholder, sigX, sigY, sigScreenWidth, sigScreenHeight, null);
- g.setColor(this.sigPlaceholderBorderColor);
- g.drawRect(sigX, sigY, sigScreenWidth-1, sigScreenHeight-1);
- }
- }
- }
-
- /**
- * Handles notification of the fact that some part of the image changed.
- * Repaints that portion.
- *
- * @return true if more updates are desired.
- */
- @Override
- public boolean imageUpdate(Image img, int infoflags, int x, int y,
- int width, int height) {
- if ((infoflags & (SOMEBITS | ALLBITS)) != 0) {
- repaint(x + this.offX, y + this.offY, width, height);
- }
- return ((infoflags & (ALLBITS | ERROR | ABORT)) == 0);
- }
-
- private MouseAdapter mouseListener = new MouseAdapter() {
-
- private boolean doDrag = false;
- private int dragXOffset = 0;
- private int dragYOffset = 0;
-
- private void updateSigPosDrag(MouseEvent evt) {
- SignaturePanel.this.setSignaturePosition(
- SignaturePanel.this.scale(evt.getX() - this.dragXOffset, U.SCREEN_ABS, U.PAGE_ABS, Dim.X),
- SignaturePanel.this.scale(evt.getY() - this.dragYOffset, U.SCREEN_ABS, U.PAGE_ABS, Dim.Y)
- );
- }
-
- /** Handles a mouseMoved event */
- @Override
- public void mouseMoved(MouseEvent evt) {
- try {
- boolean onSig = isOnSignature(evt);
- setCursor(onSig ? Cursors.HAND : Cursors.DEFAULT);
- } catch (NullPointerException e) {
- // do nothing
- }
- }
-
- /** Handles a mousePressed event */
- @Override
- public void mousePressed(MouseEvent evt) {
- if (evt.getButton() == MouseEvent.BUTTON1)
- {
- this.doDrag = true;
- if (isOnSignature(evt)) {
- /* offsets (in screen units) from top-left corner of signature to cursor on drag start */
- this.dragXOffset = (int)(evt.getX() - SignaturePanel.this.scale(SignaturePanel.this.sigPagePos.getX(), U.PAGE_ABS, U.SCREEN_ABS, Dim.X));
- this.dragYOffset = (int)(evt.getY() - SignaturePanel.this.scale(SignaturePanel.this.sigPagePos.getY(), U.PAGE_ABS, U.SCREEN_ABS, Dim.Y));
- } else {
- this.dragXOffset = 0;
- this.dragYOffset = 0;
- }
- updateSigPosDrag(evt);
- setCursor(Cursors.MOVE);
- }
- }
-
- /** Handles a mouseReleased event */
- @Override
- public void mouseReleased(MouseEvent evt) {
- this.doDrag = false;
- boolean onSig = isOnSignature(evt);
- setCursor(onSig ? Cursors.HAND : Cursors.DEFAULT);
- }
-
- /**
- * Handles a mouseDragged event.
- */
- @Override
- public void mouseDragged(MouseEvent evt) {
- if (this.doDrag)
- updateSigPosDrag(evt);
- }
- };
-
- /**
- * Sets the mouse cursor
- * @param cursor cursor to set
- */
- void setCursor(Cursors cursor)
- {
- if (this.currentCursor == cursor)
- return;
- this.currentCursor = cursor;
- Cursor cur = null;
- switch (cursor) {
- case DEFAULT:
- cur = this.defaultCursor;
- break;
- case HAND:
- cur = this.handCursor;
- break;
- case MOVE:
- cur = this.moveCursor;
- break;
- }
- this.getParent().setCursor(cur);
- }
-
- /**
- * Check whether given point is on signature placeholder
- * @param x x coordinate (screen)
- * @param y y coordinate (screen)
- * @return true if given point is on signature placeholder
- */
- private boolean isOnSignature(MouseEvent evt)
- {
- if (this.sigPagePos == null)
- return false;
-
- Rectangle2D sig = new Rectangle2D.Double(
- this.scale(this.sigPagePos.getX(), U.PAGE_ABS, U.SCREEN_ABS, Dim.X),
- this.scale(this.sigPagePos.getY(), U.PAGE_ABS, U.SCREEN_ABS, Dim.Y),
- this.scale(this.sigPageWidth, U.PAGE_REL, U.SCREEN_REL, Dim.X),
- this.scale(this.sigPageHeight, U.PAGE_REL, U.SCREEN_REL, Dim.Y)
- );
- return sig.contains(evt.getX(), evt.getY());
- }
-
- /**
- * Clamp x to be within [min-max]
- * @param x int to clamp
- * @param min minimum value
- * @param max maximum value
- * @return clamped x
- */
- private static double clamp(double x, double min, double max)
- {
- if (x < min)
- x = min;
- else if (x > max)
- x = max;
- return x;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
deleted file mode 100644
index 085f7b71..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/StateComposite.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import org.eclipse.swt.widgets.Composite;
-
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite interface for workflow state gui implementations
- */
-public abstract class StateComposite extends Composite {
-
- /**
- * Current State
- */
- protected State state;
-
- /**
- * The base class for state composites
- *
- * @param parent The parent Composite
- * @param style The Composite style
- * @param state The current State
- */
- public StateComposite(Composite parent, int style, State state) {
- super(parent, style);
- this.state = state;
- }
-
- public final void doLayout() { this.layout(true,true); this.onDisplay(); }
-
- /**
- * Reloads the localizeable resources
- */
- public abstract void reloadResources();
-
- /**
- * Called when the control is .display()ed
- */
- public void onDisplay() {}
-
- // allow subclassing of SWT components
- @Override protected final void checkSubclass() {}
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java
deleted file mode 100644
index dc18155a..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/WaitingComposite.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ProgressBar;
-
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- *
- */
-public class WaitingComposite extends StateComposite {
- private Label lbl_description;
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- * @param state
- */
- public WaitingComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- this.lbl_description = new Label(this, SWT.NATIVE);
- FormData fd_lbl_description = new FormData();
- fd_lbl_description.bottom = new FormAttachment(50, -10);
- fd_lbl_description.left = new FormAttachment(0, +10);
- fd_lbl_description.right = new FormAttachment(100, -10);
- this.lbl_description.setLayoutData(fd_lbl_description);
- this.lbl_description.setAlignment(SWT.CENTER);
- SWTUtils.setLocalizedText(lbl_description, "waiting.message");
-
- ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE);
- FormData fd_progressBar = new FormData();
- fd_progressBar.top = new FormAttachment(50, +10);
- fd_progressBar.bottom = new FormAttachment(50, +40);
- fd_progressBar.left = new FormAttachment(50, -100);
- fd_progressBar.right = new FormAttachment(50, +100);
- progressBar.setLayoutData(fd_progressBar);
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_description, "waiting.message");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
deleted file mode 100644
index 14f7a015..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AboutComposite.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package at.asit.pdfover.gui.composites.configuration;
-
-import java.awt.Desktop;
-import java.io.File;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.program.Program;
-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;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.utils.UpdateCheckManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.states.State;
-
-public class AboutComposite extends ConfigurationCompositeBase {
- static final Logger log = LoggerFactory.getLogger(AboutComposite.class);
- private Link lnkAbout;
- private Link lnkDataProtection;
- private Label lblDataProtection;
- private Link lnkUpdateCheckStatus;
- private Button btnUpdateCheck;
- private Button btnOpenLogDirectory;
- private UpdateCheckManager.Status latestUpdateStatus;
- /**
- * @param parent
- * @param style
- */
- public AboutComposite(Composite parent, int style, State state, ConfigurationDataInMemory container) {
- super(parent, style, state, container);
-
- setLayout(new FormLayout());
-
- this.lnkAbout = new Link(this, SWT.WRAP);
- SWTUtils.anchor(lnkAbout).top(0,5).right(100,-5).left(0,5);
- SWTUtils.setFontHeight(lnkAbout, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.addSelectionListener(lnkAbout, (e) -> { SWTUtils.openURL(Messages.getString("config.LicenseURL")); });
-
- this.lblDataProtection = new Label(this, SWT.WRAP);
- SWTUtils.anchor(lblDataProtection).top(lnkAbout, 15).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(lblDataProtection, Constants.TEXT_SIZE_BIG);
- SWTUtils.setFontStyle(lblDataProtection, SWT.BOLD);
-
- this.lnkDataProtection = new Link(this, SWT.WRAP);
- SWTUtils.anchor(lnkDataProtection).top(lblDataProtection,10).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(lnkDataProtection, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.addSelectionListener(lnkDataProtection, (e) -> { SWTUtils.openURL(Messages.getString("config.DataProtectionURL")); });
-
- this.lnkUpdateCheckStatus = new Link(this, SWT.NONE);
- SWTUtils.anchor(lnkUpdateCheckStatus).bottom(100, -5).left(0,5);
- SWTUtils.setFontHeight(lnkUpdateCheckStatus, Constants.TEXT_SIZE_BUTTON);
- UpdateCheckManager.registerStatusCallback((s) -> { if (isDisposed()) return; latestUpdateStatus = s; getDisplay().asyncExec(() -> { RefreshUpdateStatusText(); }); });
- SWTUtils.addSelectionListener(lnkUpdateCheckStatus, (e) -> {
- if (latestUpdateStatus == UpdateCheckManager.Status.OUTDATED)
- Program.launch(Constants.UPDATE_URL);
- else
- UpdateCheckManager.checkNow(getShell());
- });
-
- this.btnUpdateCheck = new Button(this, SWT.CHECK);
- SWTUtils.anchor(btnUpdateCheck).bottom(lnkUpdateCheckStatus,-5).left(0,5);
- SWTUtils.setFontHeight(btnUpdateCheck, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnUpdateCheck, (e) -> {
- boolean enabled = btnUpdateCheck.getSelection();
- this.configurationContainer.updateCheck = enabled;
- if (enabled)
- UpdateCheckManager.checkNow(getShell());
- });
-
- this.btnOpenLogDirectory = new Button(this, SWT.NONE);
- SWTUtils.anchor(btnOpenLogDirectory).bottom(100, -5).right(100, -5);
- SWTUtils.setFontHeight(btnOpenLogDirectory, Constants.TEXT_SIZE_BUTTON);
-
- SWTUtils.reanchor(lnkDataProtection).bottom(btnUpdateCheck,-5);
-
- SWTUtils.addSelectionListener(btnOpenLogDirectory, (e) -> {
- try {
- if (Desktop.isDesktopSupported())
- Desktop.getDesktop().open(new File(Constants.CONFIG_DIRECTORY + File.separator + "logs"));
- } catch (Exception ex) {
- log.warn("Failed to open log directory: ", ex);
- }
- });
-
- // Load localized strings
- reloadResources();
- }
-
- private void RefreshUpdateStatusText() {
- SWTUtils.setLocalizedText(lnkUpdateCheckStatus, "config.UpdateStatus." + latestUpdateStatus.name());
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lnkAbout, "config.AboutText");
- SWTUtils.setLocalizedText(lblDataProtection, "config.DataProtection");
- SWTUtils.setLocalizedText(lnkDataProtection, "config.DataProtectionStatement");
- SWTUtils.setLocalizedText(btnUpdateCheck, "advanced_config.UpdateCheck");
- SWTUtils.setLocalizedToolTipText(btnUpdateCheck, "advanced_config.UpdateCheck_ToolTip");
- SWTUtils.setLocalizedText(btnOpenLogDirectory, "config.ShowLogDirectory");
- RefreshUpdateStatusText();
- }
-
- @Override
- public void initConfiguration(ConfigurationManager provider) {
- this.configurationContainer.updateCheck = provider.getUpdateCheck();
- }
-
- @Override
- public void loadConfiguration() {
- btnUpdateCheck.setSelection(this.configurationContainer.updateCheck);
- }
-
- @Override
- public void storeConfiguration(ConfigurationManager store) {
- store.setUpdateCheckPersistent(this.configurationContainer.updateCheck);
- }
-
- @Override
- public void validateSettings(int resumeFrom) throws Exception {}
-} \ No newline at end of file
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
deleted file mode 100644
index df1a809b..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/AdvancedConfigurationComposite.java
+++ /dev/null
@@ -1,709 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.configuration;
-
-// Imports
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.stream.Collectors;
-
-import javax.annotation.Nonnull;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.BKUs;
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.commons.Profile;
-import at.asit.pdfover.gui.composites.ConfigurationComposite;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.ErrorMarker;
-import at.asit.pdfover.gui.exceptions.InvalidPortException;
-import at.asit.pdfover.gui.exceptions.OutputfolderDoesntExistException;
-import at.asit.pdfover.gui.exceptions.OutputfolderNotADirectoryException;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for advanced configuration
- *
- * Contains the simple configuration composite
- */
-public class AdvancedConfigurationComposite extends ConfigurationCompositeBase {
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(AdvancedConfigurationComposite.class);
-
- private ConfigurationComposite configurationComposite;
-
- private Group grpSignatur;
- private Group grpPlaceholder;
- Button btnAutomatischePositionierung;
- Button btnPdfACompat;
- Button btnPlatzhalterVerwenden;
- Button btnSignatureFieldsUsage;
- Button btnEnablePlaceholderUsage;
-
- private Group grpBkuAuswahl;
- Combo cmbBKUAuswahl;
- List<String> bkuStrings;
- Button btnKeystoreEnabled;
-
- private final Group grpSpeicherort;
- private final Label lblDefaultOutputFolder;
- Text txtOutputFolder;
- private final Button btnBrowse;
- private final Label lblSaveFilePostFix;
- private final Text txtSaveFilePostFix;
-
- private final Group grpLocaleAuswahl;
- Combo cmbLocaleAuswahl;
-
- private Group grpProxy;
- private Label lblProxyHost;
- private Text txtProxyHost;
- private ErrorMarker proxyHostErrorMarker;
- private Label lblProxyPort;
- private Text txtProxyPort;
- private ErrorMarker txtProxyPortErrorMarker;
- FormData fd_txtProxyPort;
- FormData fd_txtProxyPortErrorMarker;
-
- /**
- * @param parent
- * @param style
- * @param state
- * @param container
- * @param config
- */
- public AdvancedConfigurationComposite(Composite parent, int style, State state, ConfigurationDataInMemory container,
- ConfigurationComposite config) {
- super(parent, style, state, container);
- this.configurationComposite = config;
- setLayout(new FormLayout());
-
- FormLayout STANDARD_LAYOUT = new FormLayout();
- STANDARD_LAYOUT.marginHeight = 10;
- STANDARD_LAYOUT.marginWidth = 5;
-
- this.grpLocaleAuswahl = new Group(this, SWT.NONE);
- this.grpLocaleAuswahl.setLayout(STANDARD_LAYOUT);
- SWTUtils.anchor(grpLocaleAuswahl).top(0, 5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(grpLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);
-
- this.grpSignatur = new Group(this, SWT.NONE);
- this.grpSignatur.setLayout(STANDARD_LAYOUT);
- SWTUtils.anchor(grpSignatur).top(grpLocaleAuswahl,5).right(100,-5).left(0,5);
- SWTUtils.setFontHeight(grpSignatur, Constants.TEXT_SIZE_NORMAL);
-
- this.grpPlaceholder = new Group(this, SWT.NONE);
- this.grpPlaceholder.setLayout(STANDARD_LAYOUT);
- SWTUtils.anchor(grpPlaceholder).top(grpSignatur, 5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(grpPlaceholder, Constants.TEXT_SIZE_NORMAL);
-
- this.grpBkuAuswahl = new Group(this, SWT.NONE);
- this.grpBkuAuswahl.setLayout(STANDARD_LAYOUT);
- SWTUtils.anchor(grpBkuAuswahl).top(grpPlaceholder, 5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(grpBkuAuswahl, Constants.TEXT_SIZE_NORMAL);
-
- this.grpSpeicherort = new Group(this, SWT.NONE);
- grpSpeicherort.setLayout(new GridLayout(3, false));
- SWTUtils.anchor(grpSpeicherort).left(0,5).top(grpBkuAuswahl, 5).right(100,-5);
- SWTUtils.setFontHeight(grpSpeicherort, Constants.TEXT_SIZE_NORMAL);
-
- this.grpProxy = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpProxy).right(100,-5).top(grpSpeicherort, 5).left(0,5);
- this.grpProxy.setLayout(new GridLayout(2, false));
- SWTUtils.setFontHeight(grpProxy, Constants.TEXT_SIZE_NORMAL);
-
- this.btnAutomatischePositionierung = new Button(this.grpSignatur, SWT.CHECK);
- SWTUtils.anchor(btnAutomatischePositionierung).right(100,-5).top(0).left(0,5);
- SWTUtils.setFontHeight(btnAutomatischePositionierung, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnAutomatischePositionierung, e -> { performPositionSelection(btnAutomatischePositionierung.getSelection()); });
-
- this.btnPdfACompat = new Button(this.grpSignatur, SWT.CHECK);
- SWTUtils.anchor(btnPdfACompat).right(100,-5).top(btnAutomatischePositionierung, 5).left(0,5);
- SWTUtils.setFontHeight(btnPdfACompat, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnPdfACompat, e -> { performPdfACompatSelection(btnPdfACompat.getSelection()); });
-
- this.btnEnablePlaceholderUsage = new Button(this.grpPlaceholder, SWT.CHECK);
- SWTUtils.anchor(btnEnablePlaceholderUsage).top(0,5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(btnEnablePlaceholderUsage, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnEnablePlaceholderUsage, e -> { performEnableUsePlaceholder(btnEnablePlaceholderUsage.getSelection()); });
-
- this.btnPlatzhalterVerwenden = new Button(this.grpPlaceholder, SWT.RADIO);
- SWTUtils.anchor(btnPlatzhalterVerwenden).right(100,-5).top(btnEnablePlaceholderUsage,5).left(0,5);
- SWTUtils.setFontHeight(btnPlatzhalterVerwenden, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnPlatzhalterVerwenden, e -> { performUseMarkerSelection(btnPlatzhalterVerwenden.getSelection()); });
-
- this.btnSignatureFieldsUsage = new Button(this.grpPlaceholder, SWT.RADIO);
- SWTUtils.anchor(btnSignatureFieldsUsage).right(100,-5).top(btnPlatzhalterVerwenden, 5).left(0,5);
- SWTUtils.setFontHeight(btnSignatureFieldsUsage, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnSignatureFieldsUsage, e -> { performUseSignatureFieldsSelection(btnSignatureFieldsUsage.getSelection()); });
-
- this.cmbBKUAuswahl = new Combo(this.grpBkuAuswahl, SWT.READ_ONLY);
- SWTUtils.anchor(cmbBKUAuswahl).right(100,-5).top(0).left(0,5);
- SWTUtils.setFontHeight(cmbBKUAuswahl, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbBKUAuswahl);
-
- this.bkuStrings = Arrays.stream(BKUs.values()).map(s -> Messages.getString("BKU."+s)).collect(Collectors.toList());
- this.cmbBKUAuswahl.setItems(bkuStrings.toArray(new String[0]));
- SWTUtils.addSelectionListener(cmbBKUAuswahl, e -> {
- int selectionIndex = getBKUElementIndex(configurationContainer.defaultBKU);
- if (cmbBKUAuswahl.getSelectionIndex() != selectionIndex) {
- selectionIndex = cmbBKUAuswahl.getSelectionIndex();
- performBKUSelectionChanged(cmbBKUAuswahl.getItem(selectionIndex));
- }
- });
-
- this.btnKeystoreEnabled = new Button(this.grpBkuAuswahl, SWT.CHECK);
- SWTUtils.anchor(btnKeystoreEnabled).right(100,-5).top(cmbBKUAuswahl,5).left(0,5);
- SWTUtils.setFontHeight(btnKeystoreEnabled, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnKeystoreEnabled, e -> { performKeystoreEnabledSelection(btnKeystoreEnabled.getSelection()); });
-
- this.lblDefaultOutputFolder = new Label(this.grpSpeicherort, SWT.NONE);
- SWTUtils.setFontHeight(lblDefaultOutputFolder, Constants.TEXT_SIZE_NORMAL);
-
- this.txtOutputFolder = new Text(this.grpSpeicherort, SWT.BORDER);
- txtOutputFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- SWTUtils.setFontHeight(txtOutputFolder, Constants.TEXT_SIZE_NORMAL);
-
- this.txtOutputFolder.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- performOutputFolderChanged(txtOutputFolder.getText());
- }
- });
-
- this.btnBrowse = new Button(this.grpSpeicherort, SWT.NONE);
- btnBrowse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- SWTUtils.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
-
- SWTUtils.addSelectionListener(btnBrowse, e -> {
- DirectoryDialog dlg = new DirectoryDialog(AdvancedConfigurationComposite.this.getShell());
-
- // Set the initial filter path according
- // to anything they've selected or typed in
- dlg.setFilterPath(AdvancedConfigurationComposite.this.txtOutputFolder.getText());
-
- // Change the title bar text
- SWTUtils.setLocalizedText(dlg, "advanced_config.OutputFolder.Dialog_Title");
-
- // Customizable message displayed in the dialog
- dlg.setMessage(Messages.getString("advanced_config.OutputFolder.Dialog"));
-
- // Calling open() will open and run the dialog.
- // It will return the selected directory, or
- // null if user cancels
- String dir = dlg.open();
- if (dir != null) {
- // Set the text box to the new selection
- performOutputFolderChanged(dir);
- }
- });
-
- this.lblSaveFilePostFix = new Label(this.grpSpeicherort, SWT.NONE);
- SWTUtils.setLocalizedText(lblSaveFilePostFix, "AdvancedConfigurationComposite.lblSaveFilePostFix.text");
- SWTUtils.setFontHeight(lblSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
-
- this.txtSaveFilePostFix = new Text(this.grpSpeicherort, SWT.BORDER);
- txtSaveFilePostFix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- SWTUtils.setFontHeight(txtSaveFilePostFix, Constants.TEXT_SIZE_NORMAL);
-
- this.txtSaveFilePostFix.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- if (txtSaveFilePostFix.getText().trim().isEmpty())
- txtSaveFilePostFix.setText(Constants.DEFAULT_POSTFIX);
- performPostFixChanged(Constants.ISNOTNULL(txtSaveFilePostFix.getText()));
- }
- });
-
- this.cmbLocaleAuswahl = new Combo(this.grpLocaleAuswahl, SWT.READ_ONLY);
- SWTUtils.anchor(cmbLocaleAuswahl).right(100,-5).top(0).left(0,5);
- SWTUtils.setFontHeight(cmbLocaleAuswahl, Constants.TEXT_SIZE_NORMAL);;
- this.cmbLocaleAuswahl.setItems(Arrays.stream(Constants.SUPPORTED_LOCALES).map(l -> l.getDisplayLanguage()).toArray(String[]::new));
- SWTUtils.scrollPassthrough(cmbLocaleAuswahl);
-
- SWTUtils.addSelectionListener(cmbLocaleAuswahl, e -> {
- Locale currentLocale = configurationContainer.interfaceLocale;
- Locale selectedLocale = Constants.SUPPORTED_LOCALES[cmbLocaleAuswahl.getSelectionIndex()];
- if (!currentLocale.equals(selectedLocale)) {
- performLocaleSelectionChanged(selectedLocale);
- }
- });
-
- this.lblProxyHost = new Label(this.grpProxy, SWT.NONE);
- do { /* grid positioning */
- GridData gd_lblProxyHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
- gd_lblProxyHost.widthHint = 66;
- this.lblProxyHost.setLayoutData(gd_lblProxyHost);
- this.lblProxyHost.setBounds(0, 0, 57, 15);
- } while (false);
- SWTUtils.setFontHeight(lblProxyHost, Constants.TEXT_SIZE_NORMAL);
-
- Composite compProxyHostContainer = new Composite(this.grpProxy, SWT.NONE);
- compProxyHostContainer.setLayout(new FormLayout());
- compProxyHostContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
-
- this.txtProxyHost = new Text(compProxyHostContainer, SWT.BORDER);
- SWTUtils.anchor(txtProxyHost).right(100,-42).top(0).left(0,5);
- SWTUtils.setFontHeight(txtProxyHost, Constants.TEXT_SIZE_NORMAL);
-
- this.proxyHostErrorMarker = new ErrorMarker(compProxyHostContainer, SWT.NONE, "");
- SWTUtils.anchor(proxyHostErrorMarker).left(100,-32).right(100).top(0).bottom(0,32);
- this.proxyHostErrorMarker.setVisible(false);
-
- this.txtProxyHost.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- processProxyHostChanged();
- }
- });
-
- this.txtProxyHost.addTraverseListener(e -> {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processProxyHostChanged();
- }
- });
-
- this.lblProxyPort = new Label(this.grpProxy, SWT.NONE);
- this.lblProxyPort.setBounds(0, 0, 57, 15);
- SWTUtils.setFontHeight(lblProxyPort, Constants.TEXT_SIZE_NORMAL);
-
- Composite compProxyPortContainer = new Composite(this.grpProxy, SWT.NONE);
- compProxyPortContainer.setLayout(new FormLayout());
- compProxyPortContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
-
- this.txtProxyPort = new Text(compProxyPortContainer, SWT.BORDER);
- SWTUtils.anchor(txtProxyPort).top(0,0).left(0,5).right(100,-42);
- SWTUtils.setFontHeight(txtProxyPort, Constants.TEXT_SIZE_NORMAL);
-
- this.txtProxyPort.addTraverseListener(e -> {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processProxyPortChanged();
- }
- });
-
- this.txtProxyPortErrorMarker = new ErrorMarker(compProxyPortContainer, SWT.NONE, "");
- SWTUtils.anchor(txtProxyPortErrorMarker).left(100,-32).right(100).top(0).bottom(0,32);
- this.txtProxyPortErrorMarker.setVisible(false);
-
- this.txtProxyPort.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- processProxyPortChanged();
- }
- });
-
- reloadResources();
- }
-
- private void performPostFixChanged(@Nonnull String postfix) {
-
- log.debug("Save file postfix changed to : {}", postfix);
- this.configurationContainer.saveFilePostFix = postfix;
- AdvancedConfigurationComposite.this.txtSaveFilePostFix.setText(postfix);
- }
-
- void performOutputFolderChanged(String foldername) {
- log.debug("Selected Output folder: {}", foldername);
- this.configurationContainer.outputFolder = foldername;
- AdvancedConfigurationComposite.this.txtOutputFolder.setText(foldername);
- }
-
- int getBKUElementIndex(BKUs bku) {
- String lookup = "BKU." + bku.toString();
- String bkuName = Messages.getString(lookup);
-
- int i = this.bkuStrings.indexOf(bkuName);
- if (i == -1) {
- log.warn("NO BKU match for {}", bkuName);
- return 0;
- }
- return i;
- }
-
- void performBKUSelectionChanged(@Nonnull BKUs selected) {
- log.debug("Selected BKU: {}", selected);
- this.configurationContainer.defaultBKU = selected;
- this.cmbBKUAuswahl.select(this.getBKUElementIndex(selected));
- }
-
- void performBKUSelectionChanged(String selected) {
- try {
- BKUs bkuvalue = resolveBKU(selected);
- this.performBKUSelectionChanged(bkuvalue);
- } catch (Exception ex) {
- log.error("Failed to parse BKU value: {} {}", selected, ex);
- ErrorDialog dialog = new ErrorDialog(getShell(), Messages.getString("error.InvalidBKU"), BUTTONS.OK);
- dialog.open();
- }
- }
-
- @Nonnull BKUs resolveBKU(String localizedBKU) {
- int blen = BKUs.values().length;
-
- for (int i = 0; i < blen; i++) {
- String lookup = "BKU." + BKUs.values()[i].toString();
- if (Messages.getString(lookup).equals(localizedBKU)) {
- return Constants.ISNOTNULL(BKUs.values()[i]);
- }
- }
-
- return BKUs.NONE;
- }
-
- int getLocaleElementIndex(Locale locale) {
- for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; i++) {
- if (Constants.SUPPORTED_LOCALES[i].equals(locale)) {
- log.debug("Locale: {} IDX: {}", locale, i);
- return i;
- }
- }
-
- log.warn("NO Locale match for {}", locale);
- return 0;
- }
-
- void performLocaleSelectionChanged(Locale selected) {
- log.debug("Selected Locale: {}", selected);
- this.configurationContainer.interfaceLocale = selected;
- this.cmbLocaleAuswahl.select(this.getLocaleElementIndex(selected));
- }
-
- void performPositionSelection(boolean automatic) {
- log.debug("Selected Position: {}", automatic);
- this.configurationContainer.autoPositionSignature = automatic;
- this.btnAutomatischePositionierung.setSelection(automatic);
- }
-
- void performUseMarkerSelection(boolean useMarker) {
- this.configurationContainer.setUseMarker(useMarker);
- this.btnPlatzhalterVerwenden.setSelection(useMarker);
- }
-
- void performUseSignatureFieldsSelection(boolean useFields) {
- this.configurationContainer.setUseSignatureFields(useFields);
- this.btnSignatureFieldsUsage.setSelection(useFields);
- }
-
- void performEnableUsePlaceholder(boolean enable) {
- this.btnPlatzhalterVerwenden.setEnabled(enable);
- this.btnSignatureFieldsUsage.setEnabled(enable);
- this.configurationContainer.enabledPlaceholderUsage = enable;
- this.btnEnablePlaceholderUsage.setSelection(enable);
- }
-
- void performPdfACompatSelection(boolean compat) {
- this.configurationContainer.signaturePDFACompat = compat;
- this.btnPdfACompat.setSelection(compat);
- }
-
- void performKeystoreEnabledSelection(boolean enabled) {
- this.configurationContainer.keystoreEnabled = enabled;
- this.btnKeystoreEnabled.setSelection(enabled);
- this.configurationComposite.keystoreEnabled(enabled);
-
- int ksIndex = getBKUElementIndex(BKUs.KS);
- String ksText = this.bkuStrings.get(ksIndex);
- if (enabled) {
- if (!this.cmbBKUAuswahl.getItem(ksIndex).equals(ksText))
- this.cmbBKUAuswahl.add(ksText, ksIndex);
- } else {
- int i = this.cmbBKUAuswahl.indexOf(ksText);
- if (i != -1) {
- if (this.cmbBKUAuswahl.getSelectionIndex() == i)
- performBKUSelectionChanged(BKUs.NONE);
- this.cmbBKUAuswahl.remove(i);
- }
- }
- }
-
- void processProxyHostChanged() {
- try {
- this.proxyHostErrorMarker.setVisible(false);
- plainProxyHostSetter();
- } catch (Exception ex) {
- this.proxyHostErrorMarker.setVisible(true);
- this.proxyHostErrorMarker.setToolTipText(ex.getMessage());
- log.error("processProxyHost: ", ex);
- }
- }
-
- /**
- *
- */
- private void plainProxyHostSetter() {
- String host = this.txtProxyHost.getText();
- this.configurationContainer.proxyHost = host;
- }
-
- void processProxyPortChanged() {
- try {
- this.txtProxyPortErrorMarker.setVisible(false);
- plainProxyPortSetter();
- } catch (Exception ex) {
- this.txtProxyPortErrorMarker.setVisible(true);
- this.txtProxyPortErrorMarker.setToolTipText(ex.getMessage());
- log.error("processProxyPort: ", ex);
- }
- }
-
- /**
- * @throws InvalidPortException
- */
- private void plainProxyPortSetter() throws InvalidPortException {
- String portString = this.txtProxyPort.getText();
- int port = -1;
- if (portString == null || portString.trim().isEmpty()) {
- port = -1;
- } else {
- try {
- port = Integer.parseInt(portString);
- } catch (NumberFormatException e) {
- throw new InvalidPortException(portString, e);
- }
- }
- this.configurationContainer.setProxyPort(port);
- }
-
- @Override
- public void initConfiguration(ConfigurationManager provider) {
- this.configurationContainer.autoPositionSignature = provider.getAutoPositionSignaturePersistent();
- this.configurationContainer.setUseMarker(provider.getUseMarker());
- this.configurationContainer.setUseSignatureFields(provider.getUseSignatureFields());
- this.configurationContainer.enabledPlaceholderUsage = provider.getEnablePlaceholderUsage();
- this.configurationContainer.signaturePDFACompat = provider.getSignaturePdfACompat();
-
- this.configurationContainer.defaultBKU = provider.getDefaultBKUPersistent();
- this.configurationContainer.keystoreEnabled = provider.getKeyStoreEnabledPersistent();
-
- this.configurationContainer.outputFolder = provider.getDefaultOutputFolderPersistent();
- this.configurationContainer.saveFilePostFix = provider.getSaveFilePostFix();
-
- this.configurationContainer.interfaceLocale = provider.getInterfaceLocale();
-
- this.configurationContainer.proxyHost = provider.getProxyHostPersistent();
- try {
- this.configurationContainer.setProxyPort(provider.getProxyPortPersistent());
- } catch (InvalidPortException e) {
- log.error("Failed to set proxy port!", e);
- }
- this.configurationContainer.proxyUser = provider.getProxyUserPersistent();
- this.configurationContainer.proxyPass = provider.getProxyPassPersistent();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration()
- */
- @Override
- public void loadConfiguration() {
- // load advanced settings
- performBKUSelectionChanged(this.configurationContainer.defaultBKU);
- String outputFolder = this.configurationContainer.outputFolder;
- if (outputFolder != null) {
- performOutputFolderChanged(outputFolder);
- }
- performPostFixChanged(this.configurationContainer.saveFilePostFix);
- performPositionSelection(this.configurationContainer.autoPositionSignature);
- performUseMarkerSelection(this.configurationContainer.getUseMarker());
- performUseSignatureFieldsSelection(this.configurationContainer.getUseSignatureFields());
- performEnableUsePlaceholder(this.configurationContainer.enabledPlaceholderUsage);
- performLocaleSelectionChanged(this.configurationContainer.interfaceLocale);
- performPdfACompatSelection(this.configurationContainer.signaturePDFACompat);
- performKeystoreEnabledSelection(this.configurationContainer.keystoreEnabled);
-
- int port = this.configurationContainer.getProxyPort();
- if (port > 0) {
- this.txtProxyPort.setText(Integer.toString(port));
- }
-
- String host = this.configurationContainer.proxyHost;
- if (host != null) {
- this.txtProxyHost.setText(host);
- }
-
- }
-
- @Override
- public void storeConfiguration(ConfigurationManager store) {
- store.setAutoPositionSignaturePersistent(this.configurationContainer.autoPositionSignature);
- store.setUseMarkerPersistent(this.configurationContainer.getUseMarker());
- store.setUseSignatureFieldsPersistent(this.configurationContainer.getUseSignatureFields());
- store.setEnablePlaceholderUsagePersistent(this.configurationContainer.enabledPlaceholderUsage);
- store.setSignaturePdfACompatPersistent(this.configurationContainer.signaturePDFACompat);
-
- store.setDefaultBKUPersistent(this.configurationContainer.defaultBKU);
- store.setKeyStoreEnabledPersistent(this.configurationContainer.keystoreEnabled);
-
- store.setDefaultOutputFolderPersistent(this.configurationContainer.outputFolder);
- store.setSaveFilePostFixPersistent(this.configurationContainer.saveFilePostFix);
- store.setInterfaceLocalePersistent(this.configurationContainer.interfaceLocale);
-
- String hostOld = store.getProxyHostPersistent();
- String hostNew = this.configurationContainer.proxyHost;
- if (hostOld != null && !hostOld.isEmpty() && (hostNew == null || hostNew.isEmpty())) {
- // Proxy has been removed, let's clear the system properties
- // Otherwise, the proxy settings wouldn't get removed
- System.clearProperty("http.proxyHost");
- System.clearProperty("https.proxyHost");
- }
- store.setProxyHostPersistent(hostNew);
-
- int portOld = store.getProxyPortPersistent();
- int portNew = this.configurationContainer.getProxyPort();
- if (portOld != -1 && portNew == -1) {
- // cf. above
- System.clearProperty("http.proxyPort");
- System.clearProperty("https.proxyPort");
- }
- store.setProxyPortPersistent(portNew);
-
- String userOld = store.getProxyUserPersistent();
- String userNew = this.configurationContainer.proxyUser;
- if (userOld != null && !userOld.isEmpty() && (userNew == null || userNew.isEmpty())) {
- // cf. above
- System.clearProperty("http.proxyUser");
- System.clearProperty("https.proxyUser");
- }
- store.setProxyUserPersistent(userNew);
-
- String passOld = store.getProxyPassPersistent();
- String passNew = this.configurationContainer.proxyPass;
- if (passOld != null && passNew == null) {
- // cf. above
- System.clearProperty("http.proxyPassword");
- System.clearProperty("https.proxyPassword");
- }
- store.setProxyPassPersistent(passNew);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings()
- */
- @Override
- public void validateSettings(int resumeIndex) throws Exception {
-
- String foldername = this.configurationContainer.outputFolder;
-
- switch (resumeIndex) {
- case 0:
- if (foldername != null && !foldername.isEmpty()) {
- File outputFolder = new File(foldername);
- if (!outputFolder.exists()) {
- throw new OutputfolderDoesntExistException(outputFolder, 1);
- }
- if (!outputFolder.isDirectory()) {
- throw new OutputfolderNotADirectoryException(outputFolder);
- }
- }
- // Fall through
- case 1:
- this.plainProxyHostSetter();
- // Fall through
- case 2:
- this.plainProxyPortSetter();
- // Fall through
- // case 3:
- // this.plainProxyUserSetter();
- // // Fall through
- // case 4:
- // this.plainProxyPassSetter();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(grpSignatur, "advanced_config.Signature_Title");
- SWTUtils.setLocalizedText(btnAutomatischePositionierung, "advanced_config.AutoPosition");
- SWTUtils.setLocalizedToolTipText(btnAutomatischePositionierung, "advanced_config.AutoPosition_ToolTip");
- SWTUtils.setLocalizedText(grpPlaceholder, "advanced_config.Placeholder_Title");
- SWTUtils.setLocalizedText(btnPlatzhalterVerwenden, "advanced_config.UseMarker");
- SWTUtils.setLocalizedToolTipText(btnPlatzhalterVerwenden, "advanced_config.UseMarker_ToolTip");
- SWTUtils.setLocalizedText(btnSignatureFieldsUsage, "advanced_config.UseSignatureFields");
- SWTUtils.setLocalizedToolTipText(btnSignatureFieldsUsage, "advanced_config.UseSignatureFields_ToolTip");
- SWTUtils.setLocalizedText(btnEnablePlaceholderUsage, "advanced_config.Placeholder_Enabled");
- SWTUtils.setLocalizedText(btnPdfACompat, "advanced_config.PdfACompat");
- SWTUtils.setLocalizedToolTipText(btnPdfACompat, "advanced_config.PdfACompat_ToolTip");
-
- SWTUtils.setLocalizedText(grpBkuAuswahl, "advanced_config.BKUSelection_Title");
- SWTUtils.setLocalizedToolTipText(cmbBKUAuswahl, "advanced_config.BKUSelection_ToolTip");
- SWTUtils.setLocalizedText(btnKeystoreEnabled, "advanced_config.KeystoreEnabled");
- SWTUtils.setLocalizedToolTipText(btnKeystoreEnabled, "advanced_config.KeystoreEnabled_ToolTip");
-
- SWTUtils.setLocalizedText(grpSpeicherort, "advanced_config.OutputFolder_Title");
- SWTUtils.setLocalizedText(lblDefaultOutputFolder, "advanced_config.OutputFolder");
- SWTUtils.setLocalizedToolTipText(txtOutputFolder, "advanced_config.OutputFolder_ToolTip");
- SWTUtils.setLocalizedText(btnBrowse, "common.browse");
-
- SWTUtils.setLocalizedText(grpLocaleAuswahl, "advanced_config.LocaleSelection_Title");
- SWTUtils.setLocalizedToolTipText(cmbLocaleAuswahl, "advanced_config.LocaleSelection_ToolTip");
-
- SWTUtils.setLocalizedText(grpProxy, "advanced_config.Proxy_Title");
- SWTUtils.setLocalizedText(lblProxyHost, "advanced_config.ProxyHost");
- SWTUtils.setLocalizedToolTipText(txtProxyHost, "advanced_config.ProxyHost_ToolTip");
- this.txtProxyHost.setMessage(Messages.getString("advanced_config.ProxyHost_Template"));
- SWTUtils.setLocalizedText(lblProxyPort, "advanced_config.ProxyPort");
- SWTUtils.setLocalizedToolTipText(txtProxyPort, "advanced_config.ProxyPort_ToolTip");
- this.txtProxyPort.setMessage(Messages.getString("advanced_config.ProxyPort_Template"));
- // StateComposite.setLocalizedText(lblProxyUser, "advanced_config.ProxyUser");
-
- // this.txtProxyUser.setToolTipText(Messages
- // .getString("advanced_config.ProxyUser_ToolTip"));
- // this.txtProxyUser.setMessage(Messages
- // .getString("advanced_config.ProxyUser_Template"));
- // StateComposite.setLocalizedText(lblProxyPass, "advanced_config.ProxyPass");
-
- // this.txtProxyPass.setToolTipText(Messages
- // .getString("advanced_config.ProxyPass_ToolTip"));
- // this.txtProxyPass.setMessage(Messages
- // .getString("advanced_config.ProxyPass_Template"));
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java
deleted file mode 100644
index 54207292..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/ConfigurationCompositeBase.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.configuration;
-
-
-import org.eclipse.swt.widgets.Composite;
-
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Base class for configuration composites
- */
-public abstract class ConfigurationCompositeBase extends StateComposite {
-
- /**
- * the configuration container
- */
- protected ConfigurationDataInMemory configurationContainer;
-
- /**
- * @param parent
- * @param style
- * @param state
- * @param configuration
- */
- public ConfigurationCompositeBase(Composite parent, int style, State state, ConfigurationDataInMemory configuration) {
- super(parent, style, state);
- this.configurationContainer = configuration;
- }
-
- /**
- * Initialize ConfigurationContainer from ConfigProviderImpl
- * @param provider the ConfigProviderImpl to load config from
- */
- public abstract void initConfiguration(ConfigurationManager provider);
-
- /**
- * Load configuration from ConfigurationContainer
- */
- public abstract void loadConfiguration();
-
- /**
- * Store configuration from ConfigurationContainer to ConfigProvider
- * @param store the ConfigProviderImpl to store config to
- */
- public abstract void storeConfiguration(ConfigurationManager store);
-
- /**
- * Called before exit.
- * The method validates every setting in the configuration before exit
- *
- * There might be settings when the user can decide to ignore a validation exception
- * (for example the Outputfolder validation)
- * In this case, the validator throws a ResumableException, which includes the
- * validator index to resume from (should the user choose to ignore the error)
- *
- * @param resumeFrom Resume from this validator index (initially 0)
- * @throws Exception
- */
- public abstract void validateSettings(int resumeFrom) throws Exception;
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/Fido2ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/Fido2ConfigurationComposite.java
deleted file mode 100644
index 9b2d3ef1..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/Fido2ConfigurationComposite.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package at.asit.pdfover.gui.composites.configuration;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Link;
-
-import com.sun.jna.Platform;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.WebAuthN;
-
-public class Fido2ConfigurationComposite extends ConfigurationCompositeBase {
-
- private Link lnkInfoText;
- private Link unsupportedText;
-
- private Group grpFidoSettings;
- private Button btnFido2ByDefault;
-
- public Fido2ConfigurationComposite(Composite parent, int style, State state, ConfigurationDataInMemory container) {
- super(parent, style, state, container);
- setLayout(new FormLayout());
-
- this.lnkInfoText = new Link(this, SWT.WRAP);
- SWTUtils.anchor(lnkInfoText).top(0,5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(lnkInfoText, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.addSelectionListener(lnkInfoText, () -> { SWTUtils.openURL(Messages.getString("config.fido2.InfoURL")); });
-
- this.unsupportedText = new Link(this, SWT.WRAP);
- SWTUtils.anchor(unsupportedText).top(lnkInfoText,5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(unsupportedText, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.addSelectionListener(unsupportedText, () -> { SWTUtils.openURL("https://developers.yubico.com/libfido2/#_installation"); });
-
- FormLayout STANDARD_LAYOUT = new FormLayout();
- STANDARD_LAYOUT.marginHeight = 10;
- STANDARD_LAYOUT.marginWidth = 5;
-
- this.grpFidoSettings = new Group(this, SWT.NONE);
- this.grpFidoSettings.setLayout(STANDARD_LAYOUT);
- SWTUtils.anchor(grpFidoSettings).top(lnkInfoText,10).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(grpFidoSettings, Constants.TEXT_SIZE_NORMAL);
-
- this.btnFido2ByDefault = new Button(this.grpFidoSettings, SWT.CHECK);
- SWTUtils.anchor(btnFido2ByDefault).top(0).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(btnFido2ByDefault, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.addSelectionListener(btnFido2ByDefault, () -> { this.configurationContainer.fido2ByDefault = btnFido2ByDefault.getSelection(); });
-
- if (WebAuthN.isAvailable())
- this.unsupportedText.setVisible(false);
- else
- this.grpFidoSettings.setVisible(false);
-
- reloadResources();
- }
-
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lnkInfoText, "config.fido2.AboutFIDO");
- SWTUtils.setLocalizedText(grpFidoSettings, "config.fido2.Group");
- SWTUtils.setLocalizedText(btnFido2ByDefault, "config.fido2.ByDefault");
-
- if (Platform.isLinux() || Platform.isMac())
- SWTUtils.setLocalizedText(unsupportedText, "config.fido2.UnsupportedTryLibFido2");
- else {
- SWTUtils.setFontStyle(unsupportedText, SWT.BOLD);
- SWTUtils.setLocalizedText(unsupportedText, "config.fido2.UnsupportedPlatform");
- }
- }
-
- @Override
- public void initConfiguration(ConfigurationManager provider) {
- this.configurationContainer.fido2ByDefault = provider.getFido2ByDefault();
- }
-
- @Override
- public void loadConfiguration() {
- btnFido2ByDefault.setSelection(this.configurationContainer.fido2ByDefault);
- }
-
- @Override
- public void storeConfiguration(ConfigurationManager store) {
- store.setFido2ByDefaultPersistent(this.configurationContainer.fido2ByDefault);
- }
-
- @Override
- public void validateSettings(int resumeIndex) throws Exception {}
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java
deleted file mode 100644
index a477422e..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/KeystoreConfigurationComposite.java
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.configuration;
-
-// Imports
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.PasswordInputDialog;
-import at.asit.pdfover.gui.exceptions.CantLoadKeystoreException;
-import at.asit.pdfover.gui.exceptions.KeystoreAliasDoesntExistException;
-import at.asit.pdfover.gui.exceptions.KeystoreAliasNoKeyException;
-import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException;
-import at.asit.pdfover.gui.exceptions.KeystoreKeyPasswordException;
-import at.asit.pdfover.gui.keystore.KeystoreUtils;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- *
- */
-public class KeystoreConfigurationComposite extends ConfigurationCompositeBase {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(KeystoreConfigurationComposite.class);
-
- private Group grpKeystore;
- private Label lblKeystoreFile;
- Text txtKeystoreFile;
- private Button btnBrowse;
- private Label lblKeystoreType;
- Combo cmbKeystoreType;
- private Button btnLoad;
- private Label lblKeystoreAlias;
- Combo cmbKeystoreAlias;
- private Label lblKeystorePassStoreType;
- Combo cmbKeystorePassStoreType;
- private Label lblKeystoreStorePass;
- Text txtKeystoreStorePass;
- private Label lblKeystoreKeyPass;
- Text txtKeystoreKeyPass;
-
- private KeyStore ks;
-
- /**
- * @param parent
- * @param style
- * @param state
- * @param container
- */
- public KeystoreConfigurationComposite(
- org.eclipse.swt.widgets.Composite parent, int style, State state,
- ConfigurationDataInMemory container) {
- super(parent, style, state, container);
- setLayout(new FormLayout());
-
- this.grpKeystore = new Group(this, SWT.NONE | SWT.RESIZE);
- FormLayout layout = new FormLayout();
- layout.marginHeight = 10;
- layout.marginWidth = 5;
- this.grpKeystore.setLayout(layout);
-
- SWTUtils.anchor(grpKeystore).top(0,5).left(0,5).right(100,-5);
- SWTUtils.setFontHeight(this.grpKeystore, Constants.TEXT_SIZE_NORMAL);
-
- this.lblKeystoreFile = new Label(this.grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystoreFile).top(0).left(0,5);
- FormData fd_lblKeystoreFile = new FormData();
- fd_lblKeystoreFile.top = new FormAttachment(0);
- fd_lblKeystoreFile.left = new FormAttachment(0, 5);
- this.lblKeystoreFile.setLayoutData(fd_lblKeystoreFile);
- SWTUtils.setFontHeight(lblKeystoreFile, Constants.TEXT_SIZE_NORMAL);
-
- this.txtKeystoreFile = new Text(grpKeystore, SWT.BORDER);
- this.btnBrowse = new Button(grpKeystore, SWT.NONE);
- SWTUtils.setFontHeight(txtKeystoreFile, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.setFontHeight(btnBrowse, Constants.TEXT_SIZE_BUTTON);
- SWTUtils.anchor(txtKeystoreFile).top(lblKeystoreFile, 5).left(0,15).right(btnBrowse,-5);
- SWTUtils.anchor(btnBrowse).top(lblKeystoreFile, 5).right(100,-5);
-
- this.lblKeystoreType = new Label(grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystoreType).top(txtKeystoreFile, 5).left(0,5);
- SWTUtils.setFontHeight(lblKeystoreType, Constants.TEXT_SIZE_NORMAL);
-
- this.btnLoad = new Button(this.grpKeystore, SWT.NONE);
- SWTUtils.anchor(btnLoad).top(lblKeystoreType, 5).right(100,-5);
- SWTUtils.setFontHeight(btnLoad, Constants.TEXT_SIZE_BUTTON);
-
- this.cmbKeystoreType = new Combo(grpKeystore, SWT.READ_ONLY);
- SWTUtils.anchor(cmbKeystoreType).top(lblKeystoreType, 5).left(0,15).right(btnLoad, -5);
- SWTUtils.setFontHeight(cmbKeystoreType, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbKeystoreType);
-
- this.lblKeystoreAlias = new Label(grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystoreAlias).top(cmbKeystoreType, 5).left(0, 5);
- SWTUtils.setFontHeight(lblKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
-
- this.cmbKeystoreAlias = new Combo(grpKeystore, SWT.NONE);
- SWTUtils.anchor(cmbKeystoreAlias).top(lblKeystoreAlias, 5).left(0,15).right(100,-5);
- SWTUtils.setFontHeight(cmbKeystoreAlias, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbKeystoreAlias);
-
- this.lblKeystorePassStoreType = new Label(this.grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystorePassStoreType).top(cmbKeystoreAlias, 5).left(0,5);
- SWTUtils.setFontHeight(lblKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
-
- this.cmbKeystorePassStoreType = new Combo(grpKeystore, SWT.READ_ONLY);
- SWTUtils.anchor(cmbKeystorePassStoreType).top(lblKeystorePassStoreType, 5).left(0,15).right(100,-5);
- SWTUtils.setFontHeight(cmbKeystorePassStoreType, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbKeystorePassStoreType);
-
- this.lblKeystoreStorePass = new Label(grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystoreStorePass).top(cmbKeystorePassStoreType, 5).left(0,5);
- SWTUtils.setFontHeight(lblKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
-
- this.txtKeystoreStorePass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
- SWTUtils.anchor(txtKeystoreStorePass).right(100, -5).top(lblKeystoreStorePass, 5).left(0,15);
- SWTUtils.setFontHeight(txtKeystoreStorePass, Constants.TEXT_SIZE_NORMAL);
-
- this.lblKeystoreKeyPass = new Label(grpKeystore, SWT.NONE);
- SWTUtils.anchor(lblKeystoreKeyPass).top(txtKeystoreStorePass, 5).left(0,5);
- SWTUtils.setFontHeight(lblKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
-
- this.txtKeystoreKeyPass = new Text(grpKeystore, SWT.BORDER | SWT.PASSWORD);
- SWTUtils.anchor(txtKeystoreKeyPass).top(lblKeystoreKeyPass, 5).left(0,15).right(100,-5);
- SWTUtils.setFontHeight(txtKeystoreKeyPass, Constants.TEXT_SIZE_NORMAL);
-
- this.txtKeystoreFile.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- performKeystoreFileChanged(KeystoreConfigurationComposite.this.txtKeystoreFile.getText());
- }
- });
-
- this.btnBrowse.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(
- KeystoreConfigurationComposite.this.getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] {
- "*.p12;*.pkcs12;*.pfx;*.ks;*.jks", "*.p12;*.pkcs12;*.pfx;", "*.ks;*.jks*.", "*" });
- dialog.setFilterNames(new String[] {
- Messages.getString("common.KeystoreExtension_Description"),
- Messages.getString("common.PKCS12Extension_Description"),
- Messages.getString("common.KSExtension_Description"),
- Messages.getString("common.AllExtension_Description") });
- String fileName = dialog.open();
- File file = null;
- if (fileName != null) {
- file = new File(fileName);
- if (file.exists()) {
- performKeystoreFileChanged(fileName);
- }
- }
- }
- });
-
- this.cmbKeystoreType.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- performKeystoreTypeChanged(
- KeystoreConfigurationComposite.this.keystoreTypes.get(
- KeystoreConfigurationComposite.this.cmbKeystoreType.getItem(
- KeystoreConfigurationComposite.this.cmbKeystoreType.getSelectionIndex())));
- }
- });
-
- this.txtKeystoreStorePass.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- performKeystoreStorePassChanged(KeystoreConfigurationComposite.
- this.txtKeystoreStorePass.getText());
- }
-
- });
-
- this.btnLoad.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- File f = new File(KeystoreConfigurationComposite.this
- .configurationContainer.keystoreFile);
- try {
- loadKeystore();
- } catch (KeyStoreException ex) {
- log.error("Error loading keystore", ex);
- showErrorDialog(Messages.getString("error.KeyStore"));
- } catch (FileNotFoundException ex) {
- log.error("Error loading keystore", ex);
- showErrorDialog(Messages.formatString(
- "error.KeyStoreFileNotExist", f.getName()));
- } catch (NoSuchAlgorithmException ex) {
- log.error("Error loading keystore", ex);
- showErrorDialog(Messages.getString("error.KeyStore"));
- } catch (CertificateException ex) {
- log.error("Error loading keystore", ex);
- showErrorDialog(Messages.getString("error.KeyStore"));
- } catch (IOException ex) {
- log.error("Error loading keystore", ex);
- showErrorDialog(Messages.getString("error.KeyStore"));
- } catch (NullPointerException ex) {
- log.error("Error loading keystore - NPE?", ex);
- showErrorDialog(Messages.getString("error.KeyStore"));
- } catch (UnrecoverableKeyException ex) {
- log.warn("Error loading keystore, invalid password", ex);
- showErrorDialog(Messages.getString("error.KeyStoreStorePass"));
- }
- }
- });
-
- this.cmbKeystoreAlias.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- performKeystoreAliasChanged(
- KeystoreConfigurationComposite.this.cmbKeystoreAlias.getItem(
- KeystoreConfigurationComposite.this.cmbKeystoreAlias.getSelectionIndex()));
- }
- });
- this.cmbKeystoreAlias.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- performKeystoreAliasChanged(KeystoreConfigurationComposite.this.cmbKeystoreAlias.getText());
- }
- });
-
- this.cmbKeystorePassStoreType.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- performKeystorePassStorageTypeChanged(
- keystorePassStorageTypeOptions.get(
- KeystoreConfigurationComposite.this.cmbKeystorePassStoreType.getSelectionIndex()
- ).getLeft()
- );
- }
- });
-
- this.txtKeystoreKeyPass.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- performKeystoreKeyPassChanged(KeystoreConfigurationComposite.this.txtKeystoreKeyPass.getText());
- }
- });
-
- // Load localized strings
-
- reloadResources();
- }
-
- void showErrorDialog(String error) {
- ErrorDialog e = new ErrorDialog(getShell(), error, BUTTONS.OK);
- e.open();
- }
-
- void loadKeystore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
- this.cmbKeystoreAlias.remove(0, this.cmbKeystoreAlias.getItemCount()-1);
-
- ConfigurationDataInMemory config = this.configurationContainer;
- this.ks = null;
- String pass = config.keystoreStorePass;
-
- while (this.ks == null)
- {
- if (pass == null)
- {
- pass = new PasswordInputDialog(
- getShell(),
- Messages.getString("keystore_config.KeystoreStorePass"),
- Messages.getString("keystore.KeystoreStorePassEntry")).open();
- if (pass == null)
- throw new UnrecoverableKeyException("User cancelled password input");
- }
-
- try {
- this.ks = KeystoreUtils.tryLoadKeystore(new File(config.keystoreFile), config.keystoreType, pass);
- } catch (UnrecoverableKeyException ex) {
- new ErrorDialog(getShell(), Messages.getString("error.KeyStoreStorePass"), BUTTONS.OK).open();
- pass = null;
- }
- }
- config.keystoreStorePass = pass;
-
- Enumeration<String> aliases = this.ks.aliases();
- while (aliases.hasMoreElements())
- this.cmbKeystoreAlias.add(aliases.nextElement());
- }
-
- /**
- * @param fileName
- */
- protected void performKeystoreFileChanged(String fileName) {
- log.debug("Selected keystore file: " + fileName);
- this.configurationContainer.keystoreFile = fileName;
- KeystoreConfigurationComposite.this.txtKeystoreFile.setText(fileName);
- int i = fileName.lastIndexOf('.');
- if (i > 0) {
- String ext = fileName.substring(i+1);
- if (
- ext.equalsIgnoreCase("p12") ||
- ext.equalsIgnoreCase("pkcs12") ||
- ext.equalsIgnoreCase("pfx"))
- performKeystoreTypeChanged("PKCS12");
- else if (
- ext.equalsIgnoreCase("ks") ||
- ext.equalsIgnoreCase("jks"))
- performKeystoreTypeChanged("JCEKS");
- }
- }
-
- /**
- * @param type
- */
- protected void performKeystoreTypeChanged(String type) {
- log.debug("Selected keystore type: " + type);
- this.configurationContainer.keystoreType = type;
- for (int i = 0; i < this.cmbKeystoreType.getItemCount(); ++i) {
- if (this.keystoreTypes.get(this.cmbKeystoreType.getItem(i)).equals(type)) {
- this.cmbKeystoreType.select(i);
- break;
- }
- }
- }
-
- protected void performKeystorePassStorageTypeChanged(KeyStorePassStorageType p) {
- this.configurationContainer.keystorePassStorageType = p;
- for (int i=0; i<keystorePassStorageTypeOptions.size(); ++i)
- {
- if (keystorePassStorageTypeOptions.get(i).getLeft() == p)
- {
- this.cmbKeystorePassStoreType.select(i);
- break;
- }
- }
-
- boolean showPasswordFields = (p == KeyStorePassStorageType.DISK);
- this.lblKeystoreKeyPass.setVisible(showPasswordFields);
- this.txtKeystoreKeyPass.setVisible(showPasswordFields);
- this.lblKeystoreStorePass.setVisible(showPasswordFields);
- this.txtKeystoreStorePass.setVisible(showPasswordFields);
- if (showPasswordFields)
- { /* get rid of potential nulls */
- performKeystoreKeyPassChanged(this.txtKeystoreKeyPass.getText());
- performKeystoreStorePassChanged(this.txtKeystoreStorePass.getText());
- }
- }
-
- /**
- * @param storepass
- */
- protected void performKeystoreStorePassChanged(String storepass) {
- log.debug("Changed keystore store password");
- this.configurationContainer.keystoreStorePass = storepass;
- if (storepass == null)
- this.txtKeystoreStorePass.setText("");
- else
- this.txtKeystoreStorePass.setText(storepass);
- }
-
- /**
- * @param alias
- */
- protected void performKeystoreAliasChanged(String alias) {
- log.debug("Selected keystore alias: " + alias);
- this.configurationContainer.keystoreAlias = alias;
- this.cmbKeystoreAlias.setText(alias);
- }
-
- /**
- * @param keypass
- */
- protected void performKeystoreKeyPassChanged(String keypass) {
- log.debug("Changed keystore key password");
- this.configurationContainer.keystoreKeyPass = keypass;
- if (keypass == null)
- this.txtKeystoreKeyPass.setText("");
- else
- this.txtKeystoreKeyPass.setText(keypass);
- }
-
- @Override
- public void initConfiguration(ConfigurationManager provider) {
- ConfigurationDataInMemory config = this.configurationContainer;
- config.keystoreFile = provider.getKeyStoreFilePersistent();
- config.keystoreType = provider.getKeyStoreTypePersistent();
- config.keystoreAlias = provider.getKeyStoreAliasPersistent();
- config.keystorePassStorageType = provider.getKeyStorePassStorageType();
- if (config.keystorePassStorageType == KeyStorePassStorageType.DISK) {
- config.keystoreStorePass = provider.getKeyStoreStorePassPersistent();
- config.keystoreKeyPass = provider.getKeyStoreKeyPassPersistent();
- } else if (config.keystorePassStorageType == KeyStorePassStorageType.MEMORY) {
- config.keystoreStorePass = provider.getKeyStoreStorePass();
- config.keystoreKeyPass = provider.getKeyStoreKeyPass();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration
- * ()
- */
- @Override
- public void loadConfiguration() {
- // Initialize form fields from configuration Container
- ConfigurationDataInMemory config = this.configurationContainer;
-
- String ks = config.keystoreFile;
- performKeystoreFileChanged(ks);
- performKeystoreTypeChanged(config.keystoreType);
- performKeystorePassStorageTypeChanged(config.keystorePassStorageType);
- performKeystoreStorePassChanged(config.keystoreStorePass);
- try {
- File ksf = new File(ks);
- if (ksf.exists() && config.keystoreStorePass != null)
- loadKeystore();
- } catch (Exception e) {
- log.info("Failed to load keystore on init", e);
- }
- performKeystoreAliasChanged(config.keystoreAlias);
- performKeystoreKeyPassChanged(config.keystoreKeyPass);
- }
-
- @Override
- public void storeConfiguration(ConfigurationManager store) {
- ConfigurationDataInMemory config = this.configurationContainer;
- store.setKeyStoreFilePersistent(config.keystoreFile);
- store.setKeyStoreTypePersistent(config.keystoreType);
- store.setKeyStoreAliasPersistent(config.keystoreAlias);
- store.setKeyStorePassStorageTypePersistent(config.keystorePassStorageType);
- if (config.keystorePassStorageType == KeyStorePassStorageType.DISK)
- {
- store.setKeyStoreStorePassPersistent(config.keystoreStorePass);
- store.setKeyStoreKeyPassPersistent(config.keystoreKeyPass);
- }
- else if (config.keystorePassStorageType == KeyStorePassStorageType.MEMORY)
- {
- store.setKeyStoreStorePassOverlay(config.keystoreStorePass);
- store.setKeyStoreKeyPassOverlay(config.keystoreKeyPass);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings
- * ()
- */
- @Override
- public void validateSettings(int resumeFrom) throws Exception {
- ConfigurationDataInMemory config = this.configurationContainer;
- switch (resumeFrom) {
- case 0:
- String fname = config.keystoreFile;
-
- if (fname.isEmpty())
- break; //no checks required
-
- File f = new File(fname);
- if (!f.exists() || !f.isFile())
- throw new KeystoreDoesntExistException(f, 4); //skip next checks
- // Fall through
- case 1:
- try {
- if (config.keystoreStorePass != null) /* don't cause password prompts, just silently accept if there is no saved password */
- loadKeystore();
- } catch (Exception e) {
- throw new CantLoadKeystoreException(e, 4); //skip next checks
- }
- // Fall through
- case 2:
- {
- if (this.ks != null)
- {
- String alias = config.keystoreAlias;
- if (!this.ks.containsAlias(alias))
- throw new KeystoreAliasDoesntExistException(alias, 4); //skip next check
- if (!this.ks.isKeyEntry(alias))
- throw new KeystoreAliasNoKeyException(alias, 4); //skip next check
- }
- }
- // Fall through
- case 3:
- try {
- String alias = config.keystoreAlias;
- String keypass = config.keystoreKeyPass;
- if ((this.ks != null) && (keypass != null))
- { /* if no keypass is specified, this will happen at signature time */
- this.ks.getKey(alias, keypass.toCharArray());
- }
- } catch (Exception e) {
- throw new KeystoreKeyPasswordException(4);
- }
- }
- }
-
-
- Map<String, String> keystoreTypes;
- private void reloadKeystoreTypeStrings() {
- this.keystoreTypes = new HashMap<String, String>();
- this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_PKCS12"), "PKCS12");
- this.keystoreTypes.put(Messages.getString("keystore_config.KeystoreType_JKS"), "JCEKS");
- }
-
- Vector<Pair<KeyStorePassStorageType, String>> keystorePassStorageTypeOptions;
- private void reloadKeystorePassStorageTypeStrings() {
- keystorePassStorageTypeOptions = new Vector<Pair<KeyStorePassStorageType, String>>();
- java.util.function.BiConsumer<KeyStorePassStorageType, String> add = (k,v) -> {
- keystorePassStorageTypeOptions.add(new ImmutablePair<KeyStorePassStorageType,String>(k,Messages.getString(v)));
- };
- add.accept(null, "keystore_config.SaveToWhere.None");
- add.accept(KeyStorePassStorageType.MEMORY, "keystore_config.SaveToWhere.Memory");
- add.accept(KeyStorePassStorageType.DISK, "keystore_config.SaveToWhere.Disk");
-
- int n = keystorePassStorageTypeOptions.size();
- cmbKeystorePassStoreType.setVisibleItemCount(n);
- cmbKeystorePassStoreType.setItems();
- for (int i=0; i<n; ++i)
- cmbKeystorePassStoreType.add(keystorePassStorageTypeOptions.get(i).getRight());
- }
-
-
- @Override
-
- public void reloadResources() {
- SWTUtils.setLocalizedText(grpKeystore, "keystore_config.Keystore_Title");
- SWTUtils.setLocalizedText(lblKeystoreFile, "keystore_config.KeystoreFile");
- SWTUtils.setLocalizedText(btnBrowse, "common.browse");
- SWTUtils.setLocalizedToolTipText(txtKeystoreFile, "keystore_config.KeystoreFile_ToolTip");
- SWTUtils.setLocalizedText(lblKeystoreType, "keystore_config.KeystoreType");
- reloadKeystoreTypeStrings();
- SWTUtils.setLocalizedText(lblKeystorePassStoreType, "keystore_config.SaveToWhere.Header");
- reloadKeystorePassStorageTypeStrings();
- this.cmbKeystoreType.setItems(this.keystoreTypes.keySet().toArray(new String[0]));
- SWTUtils.setLocalizedText(lblKeystoreStorePass, "keystore_config.KeystoreStorePass");
- SWTUtils.setLocalizedToolTipText(txtKeystoreStorePass, "keystore_config.KeystoreStorePass_ToolTip");
- SWTUtils.setLocalizedText(btnLoad, "keystore_config.Load");
- SWTUtils.setLocalizedToolTipText(btnLoad, "keystore_config.Load_ToolTip");
- SWTUtils.setLocalizedText(lblKeystoreAlias, "keystore_config.KeystoreAlias");
- SWTUtils.setLocalizedText(lblKeystoreKeyPass, "keystore_config.KeystoreKeyPass");
- SWTUtils.setLocalizedToolTipText(txtKeystoreKeyPass, "keystore_config.KeystoreKeyPass_ToolTip");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
deleted file mode 100644
index cf24dca3..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.configuration;
-
-// Imports
-import java.io.File;
-import java.util.Arrays;
-import java.util.Locale;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Scale;
-import org.eclipse.swt.widgets.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.commons.Profile;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.ErrorMarker;
-import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signer.Emblem;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignaturePlaceholder;
-
-/**
- *
- */
-public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(SimpleConfigurationComposite.class);
-
- private Group grpHandySignatur;
- private Label lblMobileNumber;
- protected Text txtMobileNumber;
- protected ErrorMarker txtMobileNumberErrorMarker;
-
- private Group grpPreview;
- protected Canvas cSigPreview;
- protected Button btnClearImage;
- private Button btnBrowseLogo;
-
- private Group grpSignatureNote;
- private Label lblSignatureNote;
- protected Text txtSignatureNote;
- private Button btnSignatureNoteDefault;
-
- protected final Group grpSignatureLang;
- protected final Combo cmbSignatureLang;
-
- final Group grpLogoOnlyTargetSize;
- final Label lblLogoOnlyTargetSizeCurrentValue;
- /** in millimeters */
- final Scale sclLogoOnlyTargetSize;
- private void updateLogoOnlyTargetSizeCurrentValueLabel() {
- lblLogoOnlyTargetSizeCurrentValue.setText(String.format("%4.1fcm", configurationContainer.logoOnlyTargetSize / 10.0));
- }
-
- protected String logoFile = null;
-
- protected final Group grpSignatureProfile;
- protected final Combo cmbSignatureProfiles;
-
-
-
-
- /**
- * @param parent
- * @param style
- * @param state
- * @param container
- */
- public SimpleConfigurationComposite(
- org.eclipse.swt.widgets.Composite parent, int style, State state,
- ConfigurationDataInMemory container) {
- super(parent, style, state, container);
- setLayout(new FormLayout());
-
- this.grpHandySignatur = new Group(this, SWT.NONE | SWT.RESIZE);
- SWTUtils.anchor(grpHandySignatur).right(100,-5).left(0,5).top(0,5);
- grpHandySignatur.setLayout(new GridLayout(2, false));
- SWTUtils.setFontHeight(grpHandySignatur, Constants.TEXT_SIZE_NORMAL);
-
- this.lblMobileNumber = new Label(grpHandySignatur, SWT.NONE | SWT.RESIZE);
- this.lblMobileNumber.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
- SWTUtils.setFontHeight(lblMobileNumber, Constants.TEXT_SIZE_NORMAL);
-
- Composite compMobileNumerContainer = new Composite(this.grpHandySignatur, SWT.NONE);
- compMobileNumerContainer.setLayout(new FormLayout());
- compMobileNumerContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
-
- this.txtMobileNumber = new Text(compMobileNumerContainer, SWT.BORDER | SWT.RESIZE);
- SWTUtils.anchor(txtMobileNumber).left(0,5).right(100,-42).top(0);
- SWTUtils.setFontHeight(txtMobileNumber, Constants.TEXT_SIZE_NORMAL);
-
- this.txtMobileNumberErrorMarker = new ErrorMarker(compMobileNumerContainer, SWT.NONE, "");
- this.txtMobileNumberErrorMarker.setVisible(false);
- SWTUtils.anchor(txtMobileNumberErrorMarker).left(100,-32).right(100).top(0).bottom(0,32);
-
- this.txtMobileNumber.addTraverseListener(e -> {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processNumberChanged();
- }
- });
-
- this.txtMobileNumber.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- processNumberChanged();
- }
- });
-
- this.grpSignatureProfile = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpSignatureProfile).right(100,-5).left(0,5).top(grpHandySignatur, 5);
- this.grpSignatureProfile.setLayout(new FormLayout());
- SWTUtils.setFontHeight(grpSignatureProfile, Constants.TEXT_SIZE_NORMAL);
-
- this.cmbSignatureProfiles = new Combo(this.grpSignatureProfile, SWT.READ_ONLY);
- SWTUtils.anchor(cmbSignatureProfiles).left(0,10).right(100,-10).top(0,10).bottom(100,-10);
- SWTUtils.setFontHeight(cmbSignatureProfiles, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbSignatureProfiles);
- this.cmbSignatureProfiles.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Profile current = SimpleConfigurationComposite.this.configurationContainer.getSignatureProfile();
- int index = SimpleConfigurationComposite.this.cmbSignatureProfiles.getSelectionIndex();
- Profile selected = Profile.values()[index];
- if (!current.equals(selected)) {
- performProfileSelectionChanged(selected);
- }
- }
- });
-
- this.grpSignatureLang = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpSignatureLang).right(100,-5).top(grpSignatureProfile, 5).left(0,5);
- this.grpSignatureLang.setLayout(new FormLayout());
- SWTUtils.setFontHeight(grpSignatureLang, Constants.TEXT_SIZE_NORMAL);
-
- this.cmbSignatureLang = new Combo(this.grpSignatureLang, SWT.READ_ONLY);
- SWTUtils.anchor(cmbSignatureLang).left(0,10).right(100,-10).top(0,10).bottom(100,-10);
- SWTUtils.setFontHeight(cmbSignatureLang, Constants.TEXT_SIZE_NORMAL);
- SWTUtils.scrollPassthrough(cmbSignatureLang);
- this.cmbSignatureLang.setItems(Arrays.stream(Constants.SUPPORTED_LOCALES).map(l -> l.getDisplayLanguage()).toArray(String[]::new));
-
- this.cmbSignatureLang.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Locale currentLocale = SimpleConfigurationComposite.this.configurationContainer.signatureLocale;
- Locale selectedLocale = Constants.SUPPORTED_LOCALES[SimpleConfigurationComposite.this.cmbSignatureLang.getSelectionIndex()];
- if (!currentLocale.equals(selectedLocale)) {
- performSignatureLangSelectionChanged(selectedLocale, currentLocale);
- }
- }
- });
-
- this.grpSignatureNote = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpSignatureNote).right(100,-5).top(grpSignatureLang,5).left(0,5);
- this.grpSignatureNote.setLayout(new GridLayout(2, false));
- SWTUtils.setFontHeight(grpSignatureNote, Constants.TEXT_SIZE_NORMAL);
-
- this.lblSignatureNote = new Label(this.grpSignatureNote, SWT.NONE);
- do { /* grid positioning */
- GridData gd_lblSignatureNote = new GridData(SWT.LEFT, SWT.CENTER,
- false, false, 1, 1);
- gd_lblSignatureNote.widthHint = 66;
- this.lblSignatureNote.setLayoutData(gd_lblSignatureNote);
- this.lblSignatureNote.setBounds(0, 0, 57, 15);
- } while (false);
- SWTUtils.setFontHeight(lblSignatureNote, Constants.TEXT_SIZE_NORMAL);
-
- Composite compSignatureNoteContainer = new Composite(this.grpSignatureNote, SWT.NONE);
- compSignatureNoteContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
- compSignatureNoteContainer.setLayout(new FormLayout());
-
- this.txtSignatureNote = new Text(compSignatureNoteContainer, SWT.BORDER);
- SWTUtils.anchor(txtSignatureNote).top(0,0).left(0,5).right(100,-42);
- SWTUtils.setFontHeight(txtSignatureNote, Constants.TEXT_SIZE_NORMAL);
-
- this.txtSignatureNote.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- processSignatureNoteChanged();
- }
- });
-
- this.txtSignatureNote.addTraverseListener(e -> {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- processSignatureNoteChanged();
- }
- });
-
- Composite compSignatureNoteButtonContainer = new Composite(this.grpSignatureNote, SWT.NONE);
- compSignatureNoteButtonContainer.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
- compSignatureNoteButtonContainer.setLayout(new FormLayout());
-
- this.btnSignatureNoteDefault = new Button(compSignatureNoteButtonContainer, SWT.NONE);
- SWTUtils.anchor(btnSignatureNoteDefault).top(0,0).right(100,-42);
- SWTUtils.setFontHeight(btnSignatureNoteDefault, Constants.TEXT_SIZE_BUTTON);
- this.btnSignatureNoteDefault.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- SimpleConfigurationComposite.this.txtSignatureNote.setText(getDefaultSignatureBlockNoteTextFor(null, null));
- }
- });
-
- this.grpLogoOnlyTargetSize = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpLogoOnlyTargetSize).left(0,5).right(100,-5).top(grpSignatureProfile,5);
- this.grpLogoOnlyTargetSize.setLayout(new FormLayout());
- SWTUtils.setFontHeight(grpLogoOnlyTargetSize, Constants.TEXT_SIZE_NORMAL);
-
- Label lblLOTSLeft = new Label(this.grpLogoOnlyTargetSize, SWT.HORIZONTAL);
- SWTUtils.anchor(lblLOTSLeft).top(0, 5).left(0, 15);
- lblLOTSLeft.setText("1cm");
- SWTUtils.setFontHeight(lblLOTSLeft, Constants.TEXT_SIZE_NORMAL);
-
- Label lblLOTSRight = new Label(this.grpLogoOnlyTargetSize, SWT.HORIZONTAL);
- SWTUtils.anchor(lblLOTSRight).top(0,5).right(100, -5);
- lblLOTSRight.setText("20cm");
- SWTUtils.setFontHeight(lblLOTSRight, Constants.TEXT_SIZE_NORMAL);
-
- this.sclLogoOnlyTargetSize = new Scale(this.grpLogoOnlyTargetSize, SWT.HORIZONTAL);
- SWTUtils.anchor(sclLogoOnlyTargetSize).top(0,5).left(lblLOTSLeft,5).right(lblLOTSRight,-5);
- sclLogoOnlyTargetSize.setMinimum(10);
- sclLogoOnlyTargetSize.setMaximum(200);
- sclLogoOnlyTargetSize.setIncrement(1);
- sclLogoOnlyTargetSize.setPageIncrement(1);
- SWTUtils.scrollPassthrough(sclLogoOnlyTargetSize);
- SWTUtils.addSelectionListener(sclLogoOnlyTargetSize, e ->
- {
- configurationContainer.logoOnlyTargetSize = sclLogoOnlyTargetSize.getSelection();
- this.updateLogoOnlyTargetSizeCurrentValueLabel();
- });
- sclLogoOnlyTargetSize.addFocusListener(new FocusAdapter() {
- public void focusLost(FocusEvent e) { signatureBlockPreviewChanged(); };
- });
-
- this.lblLogoOnlyTargetSizeCurrentValue = new Label(this.grpLogoOnlyTargetSize, SWT.HORIZONTAL);
- SWTUtils.anchor(lblLogoOnlyTargetSizeCurrentValue).top(sclLogoOnlyTargetSize, 5).left(0,5).right(100,-5);
- lblLogoOnlyTargetSizeCurrentValue.setAlignment(SWT.CENTER);
- SWTUtils.setFontHeight(lblLogoOnlyTargetSizeCurrentValue, Constants.TEXT_SIZE_NORMAL);
-
- this.grpPreview = new Group(this, SWT.NONE);
- SWTUtils.anchor(grpPreview).left(0,5).right(100,-5).top(grpSignatureNote, 5).height(250);
- this.grpPreview.setLayout(new FormLayout());
- SWTUtils.setFontHeight(grpPreview, Constants.TEXT_SIZE_NORMAL);
-
- Composite containerComposite = new Composite(this.grpPreview, SWT.NONE);
- SWTUtils.anchor(containerComposite).left(0).right(100).top(0).bottom(100);
- containerComposite.setLayout(new FormLayout());
-
- this.btnBrowseLogo = new Button(containerComposite, SWT.NONE);
- SWTUtils.anchor(btnBrowseLogo).top(0,5).right(50,-5);
- SWTUtils.setFontHeight(btnBrowseLogo, Constants.TEXT_SIZE_BUTTON);
-
- this.btnClearImage = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btnClearImage).top(0,5).left(50, 5);
- SWTUtils.setFontHeight(btnClearImage, Constants.TEXT_SIZE_BUTTON);
- this.btnClearImage.setEnabled(false);
-
- this.cSigPreview = new Canvas(containerComposite, SWT.RESIZE);
- SWTUtils.anchor(cSigPreview).left(0, 5).right(100,-5).top(btnBrowseLogo,5).bottom(100,-5);
- SWTUtils.setFontHeight(cSigPreview, Constants.TEXT_SIZE_NORMAL);
- this.cSigPreview.addPaintListener(e -> SimpleConfigurationComposite.this.paintSignaturePreview(e));
-
- DropTarget dnd_target = new DropTarget(containerComposite, DND.DROP_DEFAULT | DND.DROP_COPY);
- final FileTransfer fileTransfer = FileTransfer.getInstance();
- Transfer[] types = new Transfer[] { fileTransfer };
- dnd_target.setTransfer(types);
-
- dnd_target.addDropListener(new DropTargetAdapter() {
- @Override
- public void drop(DropTargetEvent event) {
- if (fileTransfer.isSupportedType(event.currentDataType)) {
- String[] files = (String[]) event.data;
- if (files.length > 0) {
- // Only taking first file ...
- File file = new File(files[0]);
- if (!file.exists()) {
- log.error("File: {} does not exist!", files[0]); ////
- return;
- }
- performProfileSelectionChanged(Profile.BASE_LOGO);
- processEmblemChanged(file.getAbsolutePath());
- }
- }
- }
-
- @Override
- public void dragOperationChanged(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) {
- if ((event.operations & DND.DROP_COPY) != 0) {
- event.detail = DND.DROP_COPY;
- } else {
- event.detail = DND.DROP_NONE;
- }
- }
- }
-
- @Override
- public void dragEnter(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) {
- if ((event.operations & DND.DROP_COPY) != 0) {
- event.detail = DND.DROP_COPY;
- } else {
- event.detail = DND.DROP_NONE;
- }
- }
- // Only drop one item!
- if (event.dataTypes.length > 1) {
- event.detail = DND.DROP_NONE;
- return;
- }
- // will accept text but prefer to have files dropped
- for (int i = 0; i < event.dataTypes.length; i++) {
- if (fileTransfer.isSupportedType(event.dataTypes[i])) {
- event.currentDataType = event.dataTypes[i];
- // files should only be copied
- if (event.detail != DND.DROP_COPY) {
- event.detail = DND.DROP_NONE;
- }
- break;
- }
- }
- }
- });
-
- this.btnClearImage.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- SimpleConfigurationComposite.this.processEmblemChanged(null);
- }
- });
- this.btnBrowseLogo.addSelectionListener(new ImageFileBrowser());
-
- this.cSigPreview.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- SimpleConfigurationComposite.this.forceFocus();
- }
- });
-
- // Load localized strings
- reloadResources();
- }
-
- private PdfAs4SignatureParameter sigPreviewParam = null;
- private Image sigPreview = null;
- void paintSignaturePreview(PaintEvent evt) {
- if (this.sigPreview == null)
- return;
- Rectangle r = this.sigPreview.getBounds();
- int srcW = r.width;
- int srcH = r.height;
- Point p = ((Canvas)evt.widget).getSize();
- float dstW = p.x;
- float dstH = p.y;
-
- float scale = dstW / srcW;
- if (srcH * scale > dstH)
- scale = dstH / srcH;
-
- float w = srcW * scale;
- float h = srcH * scale;
-
- int x = (int) ((dstW / 2) - (w / 2));
- int y = (int) ((dstH / 2) - (h / 2));
- evt.gc.drawImage(this.sigPreview, 0, 0, srcW, srcH, x, y, (int) w, (int) h);
- }
-
- /**
- *
- */
- private final class ImageFileBrowser extends SelectionAdapter {
- /**
- *
- */
- public ImageFileBrowser() {
- // Nothing to do
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog dialog = new FileDialog(
- SimpleConfigurationComposite.this.getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] {
- "*.jpg;*.png;*.gif", "*.jpg", "*.png", "*.gif", "*" });
- dialog.setFilterNames(new String[] {
- Messages.getString("common.ImageExtension_Description"),
- Messages.getString("common.JPGExtension_Description"),
- Messages.getString("common.PNGExtension_Description"),
- Messages.getString("common.GIFExtension_Description"),
- Messages.getString("common.AllExtension_Description") });
- String fileName = dialog.open();
- File file = null;
- if (fileName != null) {
- file = new File(fileName);
- if (file.exists()) {
- processEmblemChanged(fileName);
- }
- }
- }
- }
-
- private void setEmblemFileInternal(final String filename, boolean force)
- throws Exception {
- if (!force && this.configurationContainer.getEmblemPath() != null) {
- if (this.configurationContainer.getEmblemPath().equals(filename)) {
- return; // Ignore ...
- }
- }
-
- this.configurationContainer.setEmblem(filename);
- this.btnClearImage.setEnabled(filename != null);
- this.signatureBlockPreviewChanged();
- this.doLayout();
- }
-
- void signatureBlockPreviewChanged() {
- try {
- PdfAs4SignatureParameter param = new PdfAs4SignatureParameter();
- param.signatureProfile = this.configurationContainer.getSignatureProfile();
- if(this.configurationContainer.signatureNote != null && !this.configurationContainer.signatureNote.isEmpty()) {
- param.signatureNote = this.configurationContainer.signatureNote;
- }
-
- param.signatureLanguage = this.configurationContainer.signatureLocale.getLanguage();
- param.enablePDFACompat = this.configurationContainer.signaturePDFACompat;
- param.targetLogoSize = Math.min(120.0, this.configurationContainer.logoOnlyTargetSize); // TODO WORKAROUND FOR #117
- String image = this.configurationContainer.getEmblemPath();
- if (image != null && !image.trim().isEmpty()) {
- param.emblem = new Emblem(image);
- }
-
- this.sigPreviewParam = param;
- PdfAs4SignaturePlaceholder.For(param, (p) -> {
- if (this.isDisposed())
- return;
-
- this.getDisplay().syncExec(() -> {
- if (this.isDisposed())
- return;
- if (this.sigPreviewParam != param)
- return;
- if (this.sigPreview != null)
- this.sigPreview.dispose();
- if (p.hasImage())
- this.sigPreview = new Image(this.getDisplay(), p.getSWTImage());
- this.cSigPreview.redraw();
- });
- });
- } catch (Exception e) {
- log.error("Failed to load image for display...", e);
- }
- }
-
- void processEmblemChanged(String filename) {
- try {
- setEmblemFileInternal(filename, false);
- } catch (Exception ex) {
- log.error("processEmblemChanged: ", ex);
- ErrorDialog dialog = new ErrorDialog(
- getShell(),
- Messages.getString("error.FailedToLoadEmblem"), BUTTONS.OK);
- dialog.open();
- }
- }
-
- void processNumberChanged() {
- try {
- this.txtMobileNumberErrorMarker.setVisible(false);
- plainMobileNumberSetter();
- } catch (Exception ex) {
- this.txtMobileNumberErrorMarker.setVisible(true);
- this.txtMobileNumberErrorMarker.setToolTipText(Messages
- .getString("error.InvalidPhoneNumber"));
- log.error("processNumberChanged: ", ex);
- this.redraw();
- this.doLayout();
- }
- }
-
- int getLocaleElementIndex(Locale locale) {
- for (int i = 0; i < Constants.SUPPORTED_LOCALES.length; i++) {
- if (Constants.SUPPORTED_LOCALES[i].equals(locale)) {
- log.debug("Locale: {} IDX: {}",locale, i);
- return i;
- }
- }
-
- log.warn("NO Locale match for {}", locale);
- return 0;
- }
-
- void performSignatureLangSelectionChanged(Locale selected, Locale previous) {
- log.debug("Selected Sign Locale: {}", selected);
- this.configurationContainer.signatureLocale = selected;
- this.cmbSignatureLang.select(this.getLocaleElementIndex(selected));
-
- if ((previous != null) && (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(null, previous))))
- txtSignatureNote.setText(getDefaultSignatureBlockNoteTextFor(null, selected));
-
- signatureBlockPreviewChanged();
- }
-
-
-
- void performProfileSelectionChanged(Profile newProfile) {
- log.debug("Signature Profile {} was selected", newProfile.name());
- Profile oldProfile = this.configurationContainer.getSignatureProfile();
- this.configurationContainer.setSignatureProfile(newProfile);
- this.cmbSignatureProfiles.select(newProfile.ordinal());
-
- if (txtSignatureNote.getText().equals(getDefaultSignatureBlockNoteTextFor(oldProfile, null)))
- txtSignatureNote.setText(getDefaultSignatureBlockNoteTextFor(newProfile, null));
-
- this.grpSignatureLang.setVisible(newProfile.hasText());
- this.grpSignatureNote.setVisible(newProfile.hasText());
- this.grpLogoOnlyTargetSize.setVisible(newProfile.equals(Profile.BASE_LOGO));
-
- SWTUtils.reanchor(grpPreview).top(newProfile.hasText() ? grpSignatureNote : grpLogoOnlyTargetSize, 5);
- this.grpPreview.setVisible(newProfile.isVisibleSignature());
- this.grpPreview.requestLayout();
- signatureBlockPreviewChanged();
- }
-
- String getDefaultSignatureBlockNoteTextFor(Profile profile, Locale locale){
- if (profile == null)
- profile = configurationContainer.getSignatureProfile();
- if (locale == null)
- locale = configurationContainer.signatureLocale;
- return profile.getDefaultSignatureBlockNote(locale);
- }
-
- private void plainMobileNumberSetter() {
- String number = this.txtMobileNumber.getText();
- this.configurationContainer.setMobileNumber(number);
- number = this.configurationContainer.getMobileNumber();
- if (number == null) {
- this.txtMobileNumber.setText("");
- return;
- }
- this.txtMobileNumber.setText(number);
- }
-
- void processSignatureNoteChanged() {
- String note = this.txtSignatureNote.getText();
- this.configurationContainer.signatureNote = note;
- signatureBlockPreviewChanged();
- }
-
- @Override
- public void initConfiguration(ConfigurationManager provider) {
- this.configurationContainer.setMobileNumber(provider.getDefaultMobileNumberPersistent());
-
- try {
- this.configurationContainer.setEmblem(provider.getDefaultEmblemPersistent());
- } catch (InvalidEmblemFile e) {
- log.error("Failed to set emblem!", e);
- }
-
- this.configurationContainer.signatureLocale = provider.getSignatureLocale();
- this.configurationContainer.signatureNote = provider.getSignatureNote();
- this.configurationContainer.logoOnlyTargetSize = provider.getLogoOnlyTargetSize();
- }
-
- /*
- * (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.BaseConfigurationComposite#loadConfiguration
- * ()
- */
- @Override
- public void loadConfiguration() {
- // Initialize form fields from configuration Container
- String number = this.configurationContainer.getMobileNumber();
- if (number != null) {
- this.txtMobileNumber.setText(number);
- }
-
- String emblemFile = this.configurationContainer.getEmblemPath();
- if (emblemFile != null && !emblemFile.trim().isEmpty()) {
- this.logoFile = emblemFile;
- try {
- setEmblemFileInternal(emblemFile, true);
- this.btnClearImage.setSelection(true);
- } catch (Exception e1) {
- log.error("Failed to load emblem: ", e1);
- ErrorDialog dialog = new ErrorDialog(
- getShell(),
- Messages.getString("error.FailedToLoadEmblem"), BUTTONS.OK);
- dialog.open();
- }
- }
-
- String note = this.configurationContainer.signatureNote;
-
- if (note != null) {
- this.txtSignatureNote.setText(note);
- }
-
- this.sclLogoOnlyTargetSize.setSelection((int)this.configurationContainer.logoOnlyTargetSize);
- this.updateLogoOnlyTargetSizeCurrentValueLabel();
-
- this.signatureBlockPreviewChanged();
-
- this.performSignatureLangSelectionChanged(this.configurationContainer.signatureLocale, null);
-
- this.performProfileSelectionChanged(this.configurationContainer.getSignatureProfile());
-
- }
-
- @Override
- public void storeConfiguration(ConfigurationManager store) {
- store.setDefaultMobileNumberPersistent(this.configurationContainer.getMobileNumber());
- store.setDefaultEmblemPersistent(this.configurationContainer.getEmblemPath());
- store.setSignatureLocalePersistent(this.configurationContainer.signatureLocale);
- store.setSignatureNotePersistent(this.configurationContainer.signatureNote);
- store.setSignatureProfilePersistent(this.configurationContainer.getSignatureProfile());
- store.setLogoOnlyTargetSizePersistent(this.configurationContainer.logoOnlyTargetSize);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.composites.BaseConfigurationComposite#validateSettings
- * ()
- */
- @Override
- public void validateSettings(int resumeFrom) throws Exception {
- switch (resumeFrom) {
- case 0:
- this.plainMobileNumberSetter();
- // Fall through
- case 1:
- this.processSignatureNoteChanged();
- break;
- default:
- break;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(grpHandySignatur, "simple_config.MobileBKU_Title");
- SWTUtils.setLocalizedText(lblMobileNumber, "simple_config.PhoneNumber");
- SWTUtils.setLocalizedToolTipText(txtMobileNumber, "simple_config.ExampleNumber_ToolTip");
- this.txtMobileNumber.setMessage(Messages.getString("simple_config.ExampleNumber"));
-
- SWTUtils.setLocalizedText(grpPreview, "simple_config.Preview_Title");
- SWTUtils.setLocalizedText(btnClearImage, "simple_config.ClearEmblem");
- SWTUtils.setLocalizedText(btnBrowseLogo, "simple_config.ReplaceEmblem");
- SWTUtils.setLocalizedText(grpSignatureNote, "simple_config.Note_Title");
- SWTUtils.setLocalizedText(lblSignatureNote, "simple_config.Note");
- SWTUtils.setLocalizedToolTipText(txtSignatureNote, "simple_config.Note_Tooltip");
- SWTUtils.setLocalizedText(btnSignatureNoteDefault, "simple_config.Note_SetDefault");
-
- SWTUtils.setLocalizedText(grpSignatureLang, "simple_config.SigBlockLang_Title");
- SWTUtils.setLocalizedToolTipText(cmbSignatureLang, "simple_config.SigBlockLang_ToolTip");
-
- SWTUtils.setLocalizedText(grpSignatureProfile, "simple_config.SigProfile_Title");
- this.cmbSignatureProfiles.setItems(Arrays.stream(Profile.values()).map(v -> Messages.getString("simple_config."+v.name())).toArray(String[]::new));
-
- SWTUtils.setLocalizedText(grpLogoOnlyTargetSize, "simple_config.LogoOnlyTargetSize_Title");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java
deleted file mode 100644
index 7c02eda0..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterNumberComposite.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.mobilebku;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-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.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.bku.mobile.MobileBKUValidator;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Composite for entering the phone number for the mobile BKU
- */
-public class MobileBKUEnterNumberComposite extends StateComposite {
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MobileBKUEnterNumberComposite.class);
-
- /**
- *
- */
- private final SelectionListener okListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (!MobileBKUEnterNumberComposite.this.btn_ok.isEnabled()) {
- return;
- }
-
- try {
- String number = MobileBKUEnterNumberComposite.this.txt_number.getText();
-
- MobileBKUEnterNumberComposite.this.setMobileNumber(number);
-
- String password = MobileBKUEnterNumberComposite.this.txt_password.getText();
-
- MobileBKUValidator.validatePassword(password);
-
- MobileBKUEnterNumberComposite.this.mobilePassword = password;
- MobileBKUEnterNumberComposite.this.userAck = true;
-
- MobileBKUEnterNumberComposite.this.btn_ok.setEnabled(false);
-
- } catch(InvalidPasswordException ex) {
- log.info("Validating input for Mobile BKU failed!", ex);
- MobileBKUEnterNumberComposite.this.setErrorMessage(ex.getMessage());
- MobileBKUEnterNumberComposite.this.txt_password.setFocus();
- } catch (Exception ex) {
- log.info("Validating input for Mobile BKU failed!", ex);
- MobileBKUEnterNumberComposite.this.setErrorMessage(Messages.getString("error.InvalidPhoneNumber"));
- MobileBKUEnterNumberComposite.this.txt_number.setFocus();
- return;
- }
- }
- };
-
- /**
- *
- */
- private final SelectionListener cancelListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- MobileBKUEnterNumberComposite.this.userCancel = true;
- }
- };
-
-
- String mobileNumber;
-
- String mobilePassword;
-
- Text txt_number;
-
- Text txt_password;
-
- String errorMessage = null;
-
- public boolean userAck = false;
- public boolean userCancel = false;
-
-
- private Label lbl_error;
- private Label lbl_password;
- private Label lbl_number;
-
- Button btn_ok;
- Button btn_cancel;
- Button btn_remember;
-
- /**
- * @return the errorMessage
- */
- public String getErrorMessage() {
- return this.errorMessage;
- }
-
- /**
- * @param errorMessage
- * the errorMessage to set
- */
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
-
- if (this.errorMessage != null) {
- this.lbl_error.setText(this.errorMessage);
- } else {
- this.lbl_error.setText("");
- }
- }
-
- public boolean isRememberPassword() { return this.btn_remember.getSelection(); }
- public void setRememberPassword(boolean state) { this.btn_remember.setSelection(state); }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUEnterNumberComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(e -> {
- Rectangle clientArea = containerComposite.getClientArea();
-
- //e.gc.setForeground();
- 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);
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
-
- this.txt_number = new Text(containerComposite, SWT.SINGLE | SWT.NATIVE | SWT.BORDER);
- SWTUtils.anchor(txt_number).bottom(50, -10).left(50, 10).right(100, -20);
- this.txt_number.setEditable(true);
-
- this.lbl_number = new Label(containerComposite, SWT.NATIVE);
- this.lbl_number.setAlignment(SWT.RIGHT);
- SWTUtils.anchor(lbl_number).bottom(50, -10).right(50, -10);
-
- ImageData mobileIconData = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Image mobileIcon = new Image(getDisplay(), mobileIconData);
-
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(20, -1 * (mobileIconData.width / 2)).bottom(20, mobileIconData.width / 2).left(0, 10).width(mobileIconData.width);
- lbl_image.setImage(mobileIcon);
-
- this.txt_password = new Text(containerComposite, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER | SWT.NATIVE);
- SWTUtils.anchor(txt_password).top(50, 10).left(50, 10).right(100, -20);
- this.txt_password.setEditable(true);
-
- this.lbl_password = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_password).top(50, 10).right(50, -10);
- this.lbl_password.setAlignment(SWT.RIGHT);
-
- this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_ok).bottom(100, -20).right(100, -20);
- this.btn_ok.addSelectionListener(this.okListener);
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).bottom(100, -20).right(btn_ok, -10);
- this.btn_cancel.addSelectionListener(this.cancelListener);
-
- this.lbl_error = new Label(containerComposite, SWT.WRAP | SWT.NATIVE );
- SWTUtils.anchor(lbl_error).bottom(103, -20).left(5, 0).right(btn_cancel, -10);
-
- this.btn_remember = new Button(containerComposite, SWT.CHECK);
- SWTUtils.anchor(btn_remember).right(100, -10).top(0, 5);
- }
-
- @Override public void onDisplay() {
- getShell().setDefaultButton(this.btn_ok);
- if (this.txt_number.getText().isEmpty()) {
- this.txt_number.setFocus();
- } else {
- this.txt_password.setFocus();
- }
- }
-
- /**
- * enables submit button
- */
- public void enableButton() {
- this.btn_ok.setEnabled(true);
- }
-
- /**
- * @return the mobileNumber
- */
- public String getMobileNumber() {
- return this.mobileNumber;
- }
-
- /**
- * @param mobileNumber
- * the mobileNumber to set
- */
- public void setMobileNumber(String mobileNumber) {
- this.mobileNumber = mobileNumber;
-
- if (this.mobileNumber != null && !this.mobileNumber.isEmpty()) {
- this.txt_number.setText(this.mobileNumber);
- } else {
- this.txt_number.setText("");
- }
- }
-
- /**
- * @return the mobilePassword
- */
- public String getMobilePassword() {
- return this.mobilePassword;
- }
-
-
-
- /**
- * @param mobilePassword
- * the mobilePassword to set
- */
- public void setMobilePassword(String mobilePassword) {
- this.mobilePassword = mobilePassword;
-
- if (this.mobilePassword != null) {
- this.txt_password.setText(this.mobilePassword);
- } else {
- this.txt_password.setText("");
- }
- }
-
- /** (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_number, "mobileBKU.number");
- SWTUtils.setLocalizedText(lbl_password, "mobileBKU.password");
- SWTUtils.setLocalizedText(btn_remember, "mobileBKU.rememberPassword");
- SWTUtils.setLocalizedText(btn_ok, "common.Ok");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
-
- SWTUtils.setLocalizedToolTipText(btn_remember, "mobileBKU.rememberPasswordNote");
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java
deleted file mode 100644
index a1e90f51..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUEnterTANComposite.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.mobilebku;
-
-// Imports
-import java.net.URI;
-import java.util.Objects;
-
-import javax.annotation.CheckForNull;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-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.eclipse.swt.widgets.Text;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.beust.jcommander.internal.Nullable;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.WebAuthN;
-
-/**
- * Composite for entering the TAN for the mobile BKU
- */
-public class MobileBKUEnterTANComposite extends StateComposite {
-
- private void validateAndConfirmTAN() {
- String tan = this.txt_tan.getText();
-
- tan = tan.trim();
-
- if (tan.isEmpty()) {
- this.setMessage(Messages.getString("error.NoTan"));
- return;
- }
-
- if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
- this.setMessage(Messages.getString("error.EnteredReferenceValue"));
- return;
- }
-
- if (tan.length() > 6) {
- this.setMessage(Messages.getString("error.TanTooLong"));
- return;
- }
-
- this.tan = tan;
- this.userAck = true;
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MobileBKUEnterTANComposite.class);
-
- private Text txt_tan;
-
- private boolean userAck = false;
- private boolean userCancel = false;
- private boolean userFido2 = false;
-
- private Label lblRefVal;
-
- private String refVal;
-
- private URI signatureDataURI;
-
- /**
- * @param signatureData
- * the signatureData to set
- */
- public void setSignatureDataURI(@Nullable URI uri) {
- this.signatureDataURI = uri;
- this.lnk_sig_data.setVisible(uri != null);
- }
-
- private String tan;
-
- private Link lnk_sig_data;
-
- private Label lblMessage;
- private Label lblRefValLabel;
- private Label lblTan;
-
- private Button btn_ok;
- private Button btn_cancel;
- private Button btn_fido2;
-
- public boolean isDone() { return (this.userAck || this.userCancel || this.userFido2); }
- public boolean isUserAck() { return this.userAck; }
- public boolean isUserCancel() { return this.userCancel; }
- public boolean isUserFido2() { return this.userFido2; }
-
- public void reset() { this.userAck = this.userCancel = this.userFido2 = false; }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblMessage.setText("");
- else
- this.lblMessage.setText(
- Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- /**
- * Sets the message
- *
- * @param msg
- */
- public void setMessage(String msg) {
- this.lblMessage.setText(msg);
- this.lblMessage.redraw();
- this.lblMessage.getParent().layout(true, true);
- }
-
- public String getRefVal() { return this.refVal; }
- public void setRefVal(@CheckForNull String refVal) {
- this.refVal = (refVal != null) ? refVal.trim() : null;
- this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
- }
-
- /**
- * @return the tan
- */
- public String getTan() {
- return this.tan;
- }
-
- /**
- * @param tan
- * the tan to set
- */
- public void setTan(String tan) {
- this.tan = tan;
-
- if (this.tan == null) {
- this.txt_tan.setText("");
- } else {
- this.txt_tan.setText(this.tan);
- }
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUEnterTANComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- 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);
- }
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -120).bottom(50, 120).left(50, -200).right(50, 200);
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).bottom(50,-10);
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50,10).right(100,-20).bottom(50,-10);
- this.lblRefVal.setText("");
-
- this.lblTan = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblTan).right(50,-10).top(50,10);
- SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
- this.lblTan.setAlignment(SWT.RIGHT);
-
- this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
- SWTUtils.anchor(txt_tan).left(50,10).right(100,-20).top(50,10);
- this.txt_tan.setEditable(true);
-
- this.txt_tan.addTraverseListener((e) -> {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- validateAndConfirmTAN();
- }
- });
-
- this.txt_tan.addModifyListener((e) -> {
- String text = this.txt_tan.getText();
- if (text.length() > 3 && this.getRefVal().startsWith(text.trim()))
- this.setMessage(Messages.getString("error.EnteredReferenceValue"));
- });
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100,-20).top(0,20);
- lnk_sig_data.setEnabled(true);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
-
- this.btn_ok = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_ok).right(100,-20).bottom(100,-20);
- SWTUtils.addSelectionListener(btn_ok, (e) -> { validateAndConfirmTAN(); });
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(btn_ok, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancel = true; });
-
- this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_fido2).right(btn_cancel, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFido2 = true; });
- this.btn_fido2.setVisible(WebAuthN.isAvailable());
-
- this.lblMessage = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblMessage).right(btn_fido2, -10).bottom(100, -20);
- }
-
- @Override public void onDisplay() { getShell().setDefaultButton(btn_ok); txt_tan.setFocus(); }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblTan, "tanEnter.TAN");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_ok, "common.Ok");
- SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
- }
-}
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
deleted file mode 100644
index b0506596..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFido2Composite.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package at.asit.pdfover.gui.composites.mobilebku;
-
-import java.net.URI;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-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;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.PublicKeyCredential;
-import at.asit.webauthn.WebAuthN;
-import at.asit.webauthn.exceptions.WebAuthNUserCancelled;
-import at.asit.webauthn.responsefields.AuthenticatorAssertionResponse;
-
-public class MobileBKUFido2Composite extends StateComposite {
- private static final Logger log = LoggerFactory.getLogger(MobileBKUFido2Composite.class);
-
- private @Nonnull String fido2OptionsString = "";
-
- private PublicKeyCredential<AuthenticatorAssertionResponse> credential;
- private boolean userCancel;
- 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;
- this.credential = null;
- this.userCancel = this.userSms = false;
- }
-
- public boolean isDone() { return ((this.credential != null) || this.userCancel || this.userSms); }
- public PublicKeyCredential<AuthenticatorAssertionResponse> getResultingCredential() { return this.credential; }
- public boolean wasUserCancelClicked() { return userCancel; }
- public boolean wasUserSMSClicked() { return userSms; }
-
- public void beginAuthentication() {
- if (!btn_authenticate.isEnabled()) return;
-
- SWTUtils.setLocalizedText(btn_authenticate, "common.working");
- btn_authenticate.setEnabled(false);
- new Thread(() -> {
- try {
- this.credential = WebAuthN.buildGetFromJSON(this.fido2OptionsString).get("https://service.a-trust.at");
- } catch (Throwable t) {
- if (!(t instanceof WebAuthNUserCancelled)) {
- log.warn("webauthn operation failed", t);
- }
- } finally {
- this.getDisplay().syncExec(() -> { btn_authenticate.setEnabled(true); this.reloadResources(); });
- this.getDisplay().wake();
- }
- }).start();
- }
-
- public MobileBKUFido2Composite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener((e) -> {
- Rectangle clientArea = containerComposite.getClientArea();
- 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+25,
- clientArea.width - 2, clientArea.height - 27, 10, 10);
-
- });
- containerComposite.setLayout(new FormLayout());
- 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,0).left(0, 10).height(50).width(187);
- webauthnLogo.setBackground(getBackground());
- 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).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, -15).left(0, 90).right(100, -90);
- SWTUtils.addSelectionListener(btn_authenticate, this::beginAuthentication);
- btn_authenticate.setEnabled(WebAuthN.isAvailable());
-
- 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 onDisplay() { getShell().setDefaultButton(this.btn_authenticate); beginAuthentication(); }
-
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(btn_authenticate, WebAuthN.isAvailable() ? "mobileBKU.authorize" : "common.unavailable");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(lnk_sigData, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sigData, "mobileBKU.show_tooltip");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java
deleted file mode 100644
index ee9d9a0c..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUFingerprintComposite.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.mobilebku;
-
-import java.net.URI;
-import java.util.Objects;
-
-import javax.annotation.CheckForNull;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-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 at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.WebAuthN;
-
-/**
- * Composite for displaying the QR code for the mobile BKU
- */
-public class MobileBKUFingerprintComposite extends StateComposite {
- private Label lblError;
- private Label lblRefValLabel;
- private Label lblFPLabel;
- private Label lblRefVal;
- private Button btn_sms;
- private Button btn_fido2;
- private Button btn_cancel;
- private Link lnk_sig_data;
- public URI signatureDataURI;
- private String refVal;
-
- private boolean userCancelClicked = false;
- private boolean userSMSClicked = false;
- private boolean userFido2Clicked = false;
- private boolean pollingDone = false;
-
- public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
- public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFido2Clicked || this.pollingDone); }
- public boolean wasCancelClicked() { return this.userCancelClicked; }
- public boolean wasSMSClicked() { return this.userSMSClicked; }
- public boolean wasFIDO2Clicked() { return this.userFido2Clicked; }
- public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFido2Clicked = this.pollingDone = false; }
-
- public void setSMSEnabled(boolean state) {
- this.btn_sms.setEnabled(state);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblError.setText("");
- else
- this.lblError.setText(Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- public String getRefVal() { return this.refVal; }
- public void setRefVal(@CheckForNull String refVal) {
- this.refVal = (refVal != null) ? refVal.trim() : null;
- this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUFingerprintComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- 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);
- }
- });
- containerComposite.setLayout(new FormLayout());
- SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
-
- this.lblFPLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblFPLabel).left(25, 10).top(lblRefValLabel, 10);
- this.lblFPLabel.setAlignment(SWT.LEFT);
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
- this.lnk_sig_data.setEnabled(true);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_cancel, () -> { this.userCancelClicked = true; });
-
- this.btn_sms = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_sms, () -> { this.userSMSClicked = true; });
-
- this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_fido2).right(btn_sms, -20).bottom(100, -20);
- SWTUtils.addSelectionListener(btn_fido2, () -> { this.userFido2Clicked = true; });
- this.btn_fido2.setVisible(WebAuthN.isAvailable());
-
- this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
-
- reloadResources();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblFPLabel, "tanEnter.FP");
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java
deleted file mode 100644
index 135bb775..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/MobileBKUQRComposite.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.mobilebku;
-
-// Imports
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.util.Objects;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-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;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.WebAuthN;
-
-/**
- * Composite for displaying the QR code for the mobile BKU
- */
-public class MobileBKUQRComposite extends StateComposite {
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(MobileBKUQRComposite.class);
-
- private Label lblQR;
-
- private boolean userCancelClicked = false;
- private boolean userSMSClicked = false;
- private boolean userFIDO2Clicked = false;
- private boolean pollingDone = false;
-
- private Label lblRefVal;
-
- private String refVal;
-
- private ImageData currentQRImage;
-
- private URI signatureDataURI;
-
- private Label lblError;
- private Label lblRefValLabel;
- private Label lblQRLabel;
-
- private Button btn_fido2;
- private Button btn_sms;
- private Button btn_cancel;
-
- private Link lnk_sig_data;
-
- public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
- public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
- public boolean wasCancelClicked() { return this.userCancelClicked; }
- public boolean wasSMSClicked() { return this.userSMSClicked; }
- public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
- public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
-
- /**
- * Set an error message
- * @param errorMessage the error message
- */
- public void setErrorMessage(String errorMessage) {
- if (errorMessage == null)
- this.lblError.setText("");
- else
- this.lblError.setText(
- Messages.getString("error.Title") + ": " + errorMessage);
- }
-
- public String getRefVal() { return this.refVal; }
- public void setRefVal(@CheckForNull String refVal) {
- this.refVal = (refVal != null) ? refVal.trim() : null;
- this.lblRefVal.setText(Objects.requireNonNullElse(this.refVal, ""));
- }
-
- private void updateQRImage() {
- if (this.currentQRImage == null)
- return;
-
- Point availableSize = this.lblQR.getSize();
- int targetSize = Math.min(availableSize.x, availableSize.y);
- if (targetSize <= 0)
- return;
-
- this.lblQR.setImage(new Image(this.lblQR.getDisplay(), this.currentQRImage.scaledTo(targetSize, targetSize)));
- }
-
- /**
- * @param qrcode
- * the qrcode to set
- */
- public void setQR(byte[] qrcode) {
- if (qrcode == null) {
- setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
- return;
- }
- try {
- this.currentQRImage = new ImageData(new ByteArrayInputStream(qrcode));
- } catch (SWTException e) {
- log.warn("Failed to load QR code", e);
- setErrorMessage(Messages.getString("error.FailedToLoadQRCode"));
- return;
- }
- updateQRImage();
- }
-
- public void setSMSEnabled(boolean state) {
- this.btn_sms.setEnabled(state);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- public void setSignatureDataURI(@Nullable URI uri) {
- this.signatureDataURI = uri;
- this.lnk_sig_data.setVisible(uri != null);
- }
-
- /**
- * Create the composite.
- *
- * @param parent
- * @param style
- * @param state
- */
- public MobileBKUQRComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- final Composite containerComposite = new Composite(this, SWT.NATIVE);
- SWTUtils.anchor(containerComposite).top(50, -140).bottom(50, 140).left(50, -200).right(50, 200);
- containerComposite.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle clientArea = containerComposite.getClientArea();
-
- // e.gc.setForeground();
- 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);
- }
- });
- containerComposite.setLayout(new FormLayout());
-
- this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefValLabel).right(50, -10).top(30, -10);
- this.lblRefValLabel.setAlignment(SWT.RIGHT);
-
- ImageData mobileIcon = new ImageData(this.getClass().getResourceAsStream(Constants.RES_IMG_MOBILE));
- Label lbl_image = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lbl_image).top(50, -1 * (mobileIcon.width / 2)).bottom(50, mobileIcon.width / 2).left(0, 10).width(mobileIcon.width);
- lbl_image.setImage(new Image(getDisplay(), mobileIcon));
-
- this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblRefVal).left(50, 10).right(100, -20).top(30, -10);
-
- this.lblQRLabel = new Label(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(lblQRLabel).right(50, -10).top(lblRefValLabel, 10);
- this.lblQRLabel.setAlignment(SWT.RIGHT);
-
- this.lblQR = new Label(containerComposite, SWT.NATIVE);
- this.lblQR.addListener(SWT.Resize, (e) -> { updateQRImage(); });
-
- this.lnk_sig_data = new Link(containerComposite, SWT.NATIVE | SWT.RESIZE);
- SWTUtils.anchor(lnk_sig_data).right(100, -20).top(0, 20);
- SWTUtils.addSelectionListener(lnk_sig_data, (e) -> { SWTUtils.openURL(this.signatureDataURI); });
-
- this.btn_cancel = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_cancel).right(100, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
-
- this.btn_sms = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_sms).right(btn_cancel, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
-
- this.btn_fido2 = new Button(containerComposite, SWT.NATIVE);
- SWTUtils.anchor(btn_fido2).right(btn_sms, -20).bottom(100, -5);
- SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFIDO2Clicked = true; });
- this.btn_fido2.setVisible(WebAuthN.isAvailable());
-
- SWTUtils.anchor(lblQR).left(50, 10).right(100, -20).top(lblRefVal, 10).bottom(btn_sms, -10);
-
- this.lblError = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
- SWTUtils.anchor(lblError).right(btn_sms, -10).bottom(100, -20);
-
- reloadResources();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lblRefValLabel, "tanEnter.ReferenceValue");
- SWTUtils.setLocalizedText(lblQRLabel, "tanEnter.QR");
- SWTUtils.setLocalizedText(lnk_sig_data, "mobileBKU.show");
- SWTUtils.setLocalizedToolTipText(lnk_sig_data, "mobileBKU.show_tooltip");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java
deleted file mode 100644
index 24529452..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/mobilebku/WaitingForAppComposite.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://joinup.ec.europa.eu/software/page/eupl
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- */
-package at.asit.pdfover.gui.composites.mobilebku;
-
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ProgressBar;
-
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.webauthn.WebAuthN;
-
-import org.eclipse.swt.widgets.Button;
-
-/**
- *
- */
-public class WaitingForAppComposite extends StateComposite {
- private Label lbl_description;
- private Button btn_sms;
- private Button btn_cancel;
- private Button btn_fido2;
- private boolean userSMSClicked = false;
- private boolean userCancelClicked = false;
- private boolean userFIDO2Clicked = false;
- private boolean pollingDone = false;
-
- public void signalPollingDone() { this.pollingDone = true; getDisplay().wake(); }
- public boolean isDone() { return (this.userCancelClicked || this.userSMSClicked || this.userFIDO2Clicked || this.pollingDone); }
- public boolean wasCancelClicked() { return this.userCancelClicked; }
- public boolean wasSMSClicked() { return this.userSMSClicked; }
- public boolean wasFIDO2Clicked() { return this.userFIDO2Clicked; }
- public void reset() { this.userCancelClicked = this.userSMSClicked = this.userFIDO2Clicked = this.pollingDone = false; }
-
- public void setSMSEnabled(boolean state) {
- this.btn_sms.setEnabled(state);
- }
-
- public void setFIDO2Enabled(boolean state) {
- this.btn_fido2.setEnabled(state);
- }
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- * @param state
- */
- public WaitingForAppComposite(Composite parent, int style, State state) {
- super(parent, style, state);
- setLayout(new FormLayout());
-
- this.lbl_description = new Label(this, SWT.NATIVE);
- SWTUtils.anchor(lbl_description).bottom(50, -1).left(0, 10).right(100, -10);
- this.lbl_description.setAlignment(SWT.CENTER);
- SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
-
- ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE);
- SWTUtils.anchor(progressBar).top(50, 10).bottom(50, 40).left(50,-100).right(50,100);
-
- this.btn_sms = new Button(this, SWT.NONE);
- SWTUtils.anchor(btn_sms).top(progressBar, 24).right(progressBar, 0, SWT.RIGHT);
- SWTUtils.addSelectionListener(btn_sms, (e) -> { this.userSMSClicked = true; });
-
- this.btn_cancel = new Button(this, SWT.NONE);
- SWTUtils.anchor(btn_cancel).top(btn_sms, 0, SWT.TOP).right(btn_sms, -6);
- SWTUtils.addSelectionListener(btn_cancel, (e) -> { this.userCancelClicked = true; });
-
- this.btn_fido2 = new Button(this, SWT.NONE);
- SWTUtils.anchor(btn_fido2).top(btn_cancel, 0, SWT.TOP).right(btn_cancel, -6);
- SWTUtils.addSelectionListener(btn_fido2, (e) -> { this.userFIDO2Clicked = true; });
- this.btn_fido2.setVisible(WebAuthN.isAvailable());
-
- reloadResources();
-
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
- */
- @Override
- public void reloadResources() {
- SWTUtils.setLocalizedText(lbl_description, "waiting_for_app.message");
- SWTUtils.setLocalizedText(btn_sms, "tanEnter.SMS");
- SWTUtils.setLocalizedText(btn_fido2, "tanEnter.FIDO2");
- SWTUtils.setLocalizedText(btn_cancel, "common.Cancel");
- }
-}