summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java85
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java408
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java116
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/PlaceholderSelectionGui.java155
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java105
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java122
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java439
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java379
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUValidator.java93
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java127
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java127
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java47
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java64
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java76
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/HelpArgument.java95
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java76
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java70
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreAliasArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreFileArgument.java75
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreKeyPassArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreStorePassArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreTypeArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java74
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java70
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java73
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPassArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java74
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyUserArgument.java67
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/SkipFinishArgument.java46
-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
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java119
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java123
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java79
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java160
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java370
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java97
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java93
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java174
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java154
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ATrustConnectionException.java40
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InitializationException.java35
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidEmblemFile.java48
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPasswordException.java35
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPortException.java46
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasDoesntExistException.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasNoKeyException.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java38
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreKeyPasswordException.java35
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderDoesntExistException.java39
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderNotADirectoryException.java39
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PDFOverGUIException.java58
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooLongException.java38
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooShortException.java38
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ResumableException.java59
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/keystore/KeystoreUtils.java28
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/osx/CocoaUIEnhancer.java370
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/FileUploadSource.java57
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java59
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java235
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/UpdateCheckManager.java110
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/VersionComparator.java101
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Zipper.java128
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java278
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java77
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java196
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java919
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java131
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java128
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java225
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java215
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java668
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java275
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java138
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java228
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java348
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java263
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java158
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java93
102 files changed, 0 insertions, 16883 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
deleted file mode 100644
index 77e71581..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
+++ /dev/null
@@ -1,85 +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;
-
-//Imports
-import java.io.File;
-import java.io.IOException;
-
-import javax.swing.JOptionPane;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.workflow.StateMachine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import iaik.security.provider.IAIK;
-
-/**
- * Main entry point for production
- */
-public class Main {
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(Main.class);
-// private static URL url=null;
-
- /**
- * @param args
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- try {
- log.info("This is " + Constants.APP_NAME_VERSION + ", " +
- "running on " + System.getProperty("os.arch") + " " + System.getProperty("os.name") + ", " +
- "powered by "+ System.getProperty("java.vendor") + " Java " + System.getProperty("java.version") + ".");
- File configDir = new File(Constants.CONFIG_DIRECTORY);
-
- if (!configDir.exists()) {
- configDir.mkdir();
- }
-
- // force loading the IAIK JCE (cf. #95)
- IAIK.addAsProvider();
-
- // force keystore type (Adoptium JRE 17 still ships with JKS, cf. #95)
- System.setProperty("javax.net.ssl.trustStoreType", "jks");
-
- // disable display scaling for AWT components embedded in SWT (cf. #106)
- System.setProperty("sun.java2d.uiScale", "1");
-
- log.debug("Starting stateMachine ...");
- (new StateMachine(args)).start();
- log.debug("Ended stateMachine ...");
- }
- catch (Throwable e) {
-
- log.error("Unhandled error", e);
-
- JOptionPane.showMessageDialog(null,
- "Error occured " + e.getMessage(),
- null, JOptionPane.ERROR_MESSAGE);
- }
-
- // Workaround for remaining AWT-Shutdown thread on OSX
- System.exit(0);
- }
-
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
deleted file mode 100644
index a382bf4d..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
+++ /dev/null
@@ -1,408 +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;
-
-// Imports
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.EnumMap;
-import java.util.Map;
-
-import at.asit.pdfover.commons.Constants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Rectangle;
-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.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Monitor;
-import org.eclipse.swt.widgets.Shell;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.composites.StateComposite;
-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.MainBarButton;
-import at.asit.pdfover.gui.controls.MainBarEndButton;
-import at.asit.pdfover.gui.controls.MainBarMiddleButton;
-import at.asit.pdfover.gui.controls.MainBarRectangleButton;
-import at.asit.pdfover.gui.controls.MainBarStartButton;
-import at.asit.pdfover.gui.osx.CocoaUIEnhancer;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.states.BKUSelectionState;
-import at.asit.pdfover.gui.workflow.states.ConfigurationUIState;
-import at.asit.pdfover.gui.workflow.states.OpenState;
-import at.asit.pdfover.gui.workflow.states.PositioningState;
-
-/**
- * The Main Window of PDF-Over 4
- */
-public class MainWindow {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(MainWindow.class);
-
- private Shell shell;
- private Composite mainbar;
- private FormData mainBarFormData;
- private Composite container;
- private FormData containerFormData;
- private StackLayout stack;
- StateMachine stateMachine;
- private MainBarButton btn_sign;
- private MainBarButton btn_position;
- private MainBarButton btn_open;
- private MainBarButton btn_config;
-
- /**
- * Main bar Buttons
- */
- public enum Buttons {
- /** the configuration button */
- CONFIG,
-
- /** the open button */
- OPEN,
-
- /** the position button */
- POSITION,
-
- /** the signature button */
- SIGN,
-
- /** the final button */
- FINAL
- }
-
- private Map<Buttons, MainBarButton> buttonMap;
-
- private MainBarEndButton btn_end;
-
- /**
- * Default constructor
- *
- * @param stateMachine
- * The main workflow
- */
- public MainWindow(StateMachine stateMachine) {
- super();
-
- this.stateMachine = stateMachine;
-
- this.buttonMap = new EnumMap<MainWindow.Buttons, MainBarButton>(
- Buttons.class);
- }
-
- /**
- * Sets top level composite for stack layout
- *
- * @param ctrl
- */
- public void setTopControl(Control ctrl) {
- if(ctrl != null)
- log.debug("Top control: " + ctrl.toString());
- this.stack.topControl = ctrl;
- this.doLayout();
- }
-
- /**
- * Layout the Main Window
- */
- public void doLayout() {
- Control ctrl = this.stack.topControl;
- if (this.container.isDisposed()) {
- //Note: if the conainter is disposed, we are finished here
- return;
- }
- this.container.layout(true, true);
- getShell().layout(true, true);
- // Note: SWT only layouts children! No grandchildren!
- if (ctrl instanceof StateComposite) {
- if (!ctrl.isDisposed()) {
- ((StateComposite) ctrl).reloadResources();
- ((StateComposite) ctrl).doLayout();
- }
- }
- }
-
- /**
- * Gets the container composite
- *
- * @return the container composite
- */
- public Composite getContainer() {
- return this.container;
- }
-
- /**
- * Open the window.
- *
- */
- public void open() {
- createContents();
- }
-
- /**
- * Reload the localization
- */
- public void reloadLocalization() {
- SWTUtils.setLocalizedText(btn_config, "main.configuration");
- SWTUtils.setLocalizedToolTipText(btn_config, "main.configuration");
- SWTUtils.setLocalizedText(btn_open, "common.open");
- SWTUtils.setLocalizedToolTipText(btn_open, "common.open");
-
- SWTUtils.setLocalizedText(btn_position, "main.position");
- SWTUtils.setLocalizedToolTipText(btn_position, "main.position");
-
- SWTUtils.setLocalizedText(btn_sign, "main.signature");
- SWTUtils.setLocalizedToolTipText(btn_sign, "main.signature");
-
- SWTUtils.setLocalizedText(btn_end, "main.done");
- SWTUtils.setLocalizedToolTipText(btn_end, "main.done");
-
- Control ctrl = this.stack.topControl;
- if (ctrl instanceof StateComposite) {
- if (!ctrl.isDisposed()) {
- ((StateComposite) ctrl).reloadResources();
- ((StateComposite) ctrl).doLayout();
- }
- }
- }
-
- /**
- * Create contents of the window.
- */
- protected void createContents() {
- this.shell = new Shell();
- getShell().setSize(this.stateMachine.configProvider.getMainWindowSize());
- if (System.getProperty("os.name").toLowerCase().contains("mac")) {
- if (System.getProperty("os.name").contains("OS X")) {
- hookupOSXMenu();
- }
- }
- try {
- Display display = Display.getCurrent();
- Monitor primary = display.getPrimaryMonitor();
- Rectangle bounds = primary.getBounds();
- Rectangle main = getShell().getBounds();
- getShell().setLocation(
- bounds.x + (bounds.width - main.width) / 2,
- bounds.y + (bounds.height - main.height) / 2);
- }
- catch (SWTError e) {
- log.debug("Cannot get display", e);
- }
- Display.setAppVersion(Constants.APP_VERSION);
- getShell().setText(Constants.APP_NAME);
-
- getShell().addShellListener(new ShellAdapter() {
- @Override
- public void shellClosed(ShellEvent e) {
- log.debug("Closing main window");
- MainWindow.this.stateMachine.configProvider.setMainWindowSizePersistent(Constants.ISNOTNULL(getShell().getSize()));
- try {
- MainWindow.this.stateMachine.configProvider.saveToDisk();
- } catch (IOException e1) {
- log.error("Error saving configuration", e);
- }
- getShell().dispose();
- }
- });
-
- ImageData data = new ImageData(this.getClass().getResourceAsStream(Constants.RES_ICON));
- Image shellicon = new Image(getShell().getDisplay(), data);
-
- getShell().setImage(shellicon);
-
- getShell().setLayout(new FormLayout());
-
- this.mainbar = new Composite(getShell(), SWT.NONE);
- this.mainbar.setLayout(new FormLayout());
- this.mainBarFormData = new FormData();
- this.mainBarFormData.left = new FormAttachment(0, 10);
- this.mainBarFormData.right = new FormAttachment(100, -10);
- this.mainBarFormData.top = new FormAttachment(0, 10);
- this.mainBarFormData.bottom = new FormAttachment(0, Constants.MAINBAR_HEIGHT);
- this.mainbar.setLayoutData(this.mainBarFormData);
-
- this.btn_config = new MainBarRectangleButton(this.mainbar, SWT.NONE);
- SWTUtils.anchor(btn_config).bottom(100).right(0,50).top(0).left(0);
- SWTUtils.setLocalizedText(btn_config, "main.configuration");
- SWTUtils.setLocalizedToolTipText(btn_config, "main.configuration");
- this.btn_config.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- MainWindow.this.stateMachine
- .jumpToState(new ConfigurationUIState(
- MainWindow.this.stateMachine));
- }
- });
- this.buttonMap.put(Buttons.CONFIG, this.btn_config);
-
- InputStream is = this.getClass().getResourceAsStream(Constants.RES_IMG_CONFIG);
- ((MainBarRectangleButton) this.btn_config).setEnabledImage(
- new Image(Display.getDefault(), new ImageData(is)));
- is = this.getClass().getResourceAsStream(Constants.RES_IMG_CONFIG_DISABLED);
- ((MainBarRectangleButton) this.btn_config).setDisabledImage(
- new Image(Display.getDefault(), new ImageData(is)));
-
- Composite mainbarContainer = new Composite(this.mainbar, SWT.NONE);
- mainbarContainer.setLayout(new FormLayout());
- SWTUtils.anchor(mainbarContainer).left(btn_config).right(100).top(0).bottom(100);
-
- this.btn_open = new MainBarStartButton(mainbarContainer, SWT.NONE);
- SWTUtils.anchor(btn_open).left(0).right(27, (MainBarButton.SplitFactor / 2)).top(0).bottom(100);
- SWTUtils.setLocalizedText(btn_open, "common.open");
- SWTUtils.setLocalizedToolTipText(btn_open, "common.open");
- this.btn_open.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- if (MainWindow.this.stateMachine.status.getCurrentState() instanceof OpenState) {
- ((OpenState) MainWindow.this.stateMachine.status.getCurrentState()).openFileDialog();
- } else {
- MainWindow.this.stateMachine.jumpToState(new OpenState(
- MainWindow.this.stateMachine));
- }
- }
- });
- this.buttonMap.put(Buttons.OPEN, this.btn_open);
-
- this.btn_position = new MainBarMiddleButton(mainbarContainer, SWT.NONE);
- SWTUtils.anchor(btn_position).left(27, -1 * (MainBarButton.SplitFactor / 2)).right(54, (MainBarButton.SplitFactor / 2)).top(0).bottom(100);
- SWTUtils.setLocalizedText(btn_position, "main.position");
- SWTUtils.setLocalizedToolTipText(btn_position, "main.position");
- this.btn_position.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- MainWindow.this.stateMachine.jumpToState(new PositioningState(
- MainWindow.this.stateMachine));
- }
- });
- this.buttonMap.put(Buttons.POSITION, this.btn_position);
-
- this.btn_sign = new MainBarMiddleButton(mainbarContainer, SWT.NONE);
- SWTUtils.anchor(btn_sign).left(54, -1 * (MainBarButton.SplitFactor / 2)).right(81, (MainBarButton.SplitFactor / 2)).top(0).bottom(100);
- SWTUtils.setLocalizedText(btn_sign, "main.signature");
- SWTUtils.setLocalizedToolTipText(btn_sign, "main.signature");
- this.btn_sign.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- MainWindow.this.stateMachine.jumpToState(new BKUSelectionState(
- MainWindow.this.stateMachine));
- }
- });
- this.buttonMap.put(Buttons.SIGN, this.btn_sign);
-
- this.btn_end = new MainBarEndButton(mainbarContainer, SWT.NONE);
- SWTUtils.anchor(btn_end).left(81, -1 * (MainBarButton.SplitFactor / 2)).right(100).top(0).bottom(100);
- SWTUtils.setLocalizedText(btn_end, "main.done");
- SWTUtils.setLocalizedToolTipText(btn_end, "main.done");
- this.buttonMap.put(Buttons.FINAL, this.btn_end);
-
- this.container = new Composite(getShell(), SWT.RESIZE);
- this.containerFormData = new FormData();
- this.containerFormData.bottom = new FormAttachment(100, -10);
- this.containerFormData.right = new FormAttachment(100, -10);
- this.containerFormData.top = new FormAttachment(0, Constants.MAINBAR_HEIGHT + 10);
- this.containerFormData.left = new FormAttachment(0, 10);
- this.container.setLayoutData(this.containerFormData);
- this.stack = new StackLayout();
- this.container.setLayout(this.stack);
- }
-
- /**
- * Hook up SWT menu under OS X
- */
- private void hookupOSXMenu() {
- log.debug("Hooking up OS X menu");
- CocoaUIEnhancer.hookApplicationMenu(
- getShell().getDisplay(),
- /* quitListener */
- (Event arg0) -> {
- MainWindow.this.stateMachine.exit();
- },
- /* aboutListener */
- (Event arg0) -> {
- Dialog dialog = new Dialog(getShell(),
- Messages.formatString("main.about", Constants.APP_NAME),
- Constants.APP_NAME_VERSION, BUTTONS.OK, ICON.INFORMATION);
- dialog.open();
- },
- /* preferencesListener */
- (Event arg0) -> {
- if (MainWindow.this.stateMachine.status.behavior.getEnabled(Buttons.CONFIG))
- MainWindow.this.stateMachine.jumpToState(new ConfigurationUIState(MainWindow.this.stateMachine));
- }
- );
- }
-
- /**
- * Update MainWindow to fit new status
- */
- public void applyBehavior() {
- MainWindowBehavior behavior = this.stateMachine.status.behavior;
-
- log.debug("Updating MainWindow state for : "
- + this.stateMachine.status.getCurrentState().toString());
-
- for (Buttons button : Buttons.values()) {
- boolean active = behavior.getActive(button);
- boolean enabled = behavior.getEnabled(button);
-
- MainBarButton theButton = this.buttonMap.get(button);
- if (theButton != null) {
- theButton.setEnabled(enabled);
- theButton.setActive(active);
- }
- }
-
- if (behavior.getMainBarVisible()) {
- this.mainBarFormData.bottom = new FormAttachment(0, Constants.MAINBAR_HEIGHT);
- this.containerFormData.top = new FormAttachment(0, Constants.MAINBAR_HEIGHT + 10);
- } else {
- this.mainBarFormData.bottom = new FormAttachment(0, 0);
- this.containerFormData.top = new FormAttachment(0, 10);
- }
-
- getShell().getDisplay().update();
- this.mainbar.layout(true, true);
- this.mainbar.redraw();
- }
-
- /**
- * @return the shell
- */
- public Shell getShell() {
- return this.shell;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
deleted file mode 100644
index ee78b628..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java
+++ /dev/null
@@ -1,116 +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;
-
-import java.util.EnumMap;
-import java.util.Map;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-
-/**
- * Behavior manipulation for Main Window
- */
-public class MainWindowBehavior {
- /**
- * Enabled buttons map
- */
- protected Map<Buttons, Boolean> buttonsEnabled;
-
- /**
- * active buttons map
- */
- protected Map<Buttons, Boolean> buttonsActive;
-
- /**
- * Main bar visible
- */
- protected boolean mainBarVisible;
-
- /**
- *
- */
- public MainWindowBehavior() {
- this.buttonsActive = new EnumMap<MainWindow.Buttons, Boolean>(MainWindow.Buttons.class);
- this.buttonsEnabled = new EnumMap<MainWindow.Buttons, Boolean>(MainWindow.Buttons.class);
- reset();
- }
-
- /**
- * set active buttons
- * @param button
- * @param active
- */
- public void setActive(Buttons button, boolean active) {
- this.buttonsActive.put(button, active);
- }
-
- /**
- * Gets the active state of a button from main bar
- * @param button the button
- * @return the active state
- */
- public boolean getActive(Buttons button) {
- return this.buttonsActive.get(button);
- }
-
- /**
- * Sets the enabled buttons in the main bar
- * @param button
- * @param enabled
- */
- public void setEnabled(Buttons button, boolean enabled) {
- this.buttonsEnabled.put(button, enabled);
- }
-
- /**
- * Get the enabled state of a button in main bar
- * @param button the button
- * @return the enabled state
- */
- public boolean getEnabled(Buttons button) {
- return this.buttonsEnabled.get(button);
- }
-
- /**
- * Resets all behavior to a default state
- * All buttons are inactive
- * All buttons are disabled
- * Main bar is visible
- */
- public void reset() {
- for (Buttons button : Buttons.values()) {
- setActive(button, false);
- setEnabled(button, false);
- }
- setMainBarVisible(true);
- }
-
- /**
- * Sets the main bar visible
- * @param visible
- */
- public void setMainBarVisible(boolean visible) {
- this.mainBarVisible = visible;
- }
-
- /**
- * Gets wether the main bar is visible
- * @return the visibility of the main bar
- */
- public boolean getMainBarVisible() {
- return this.mainBarVisible;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/PlaceholderSelectionGui.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/PlaceholderSelectionGui.java
deleted file mode 100644
index f06e9f92..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/PlaceholderSelectionGui.java
+++ /dev/null
@@ -1,155 +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;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import at.asit.pdfover.gui.utils.SWTUtils;
-
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Dialog;
-
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Label;
-
-
-/**
- *
- */
-public class PlaceholderSelectionGui extends Dialog {
- /**
- * SLF4J Logger instance
- **/
- protected Object result;
- protected Shell shlInfo;
- protected Combo placeholderNameDropDown;
- protected String lblString;
- protected List<String> placeholderList;
- private Button btnCancel;
- private Button btnOk;
- protected int returnValue;
-
-
- /**
- * Create the dialog.
- * @param parent
- * @param style
- * @param text
- * @param lblString
- * @param placeholderList
- */
- public PlaceholderSelectionGui(Shell parent, int style, String text, String lblString, List<String> placeholderList) {
- super(parent, style);
- setText(text);
- this.lblString = lblString;
- this.placeholderList = placeholderList;
- }
-
- /**
- * Open the dialog.
- * @return the result
- */
-
- public int open() {
- createContents();
- this.shlInfo.open();
- this.shlInfo.layout();
- Display display = getParent().getDisplay();
- while (!this.shlInfo.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- return this.returnValue;
- }
-
- /**
- * @return
- */
- public int getUserSelection() {
- return this.returnValue;
- }
-
- /**
- * Create contents of the dialog.
- */
- private void createContents() {
- this.shlInfo = new Shell(getParent(), getStyle());
- this.shlInfo.setSize(290, 195);
- this.shlInfo.setText("Info");
- this.shlInfo.setLayout(null);
-
- this.placeholderNameDropDown = new Combo(this.shlInfo, SWT.NONE);
- this.placeholderNameDropDown.setBounds(27, 77, 223, 23);
- addDropDownEntries(this.placeholderList);
- this.placeholderNameDropDown.select(0);
-
- this.btnCancel = new Button(this.shlInfo, SWT.NONE);
- this.btnCancel.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- PlaceholderSelectionGui.this.returnValue = -1;
- PlaceholderSelectionGui.this.shlInfo.dispose();
- }
- });
- this.btnCancel.setBounds(175, 118, 75, 25);
- this.btnCancel.setText("Cancel");
-
- this.btnOk = new Button(this.shlInfo, SWT.NONE);
- this.btnOk.setBounds(94, 118, 75, 25);
- this.btnOk.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- PlaceholderSelectionGui.this.returnValue = PlaceholderSelectionGui.this.placeholderNameDropDown.getSelectionIndex();
- PlaceholderSelectionGui.this.shlInfo.dispose();
- }
- });
- this.btnOk.setText("Ok");
-
- Label lbLabel = new Label(this.shlInfo, SWT.WRAP);
- lbLabel.setBounds(27, 10, 223, 41);
- SWTUtils.setLocalizedText(lbLabel, "positioning.placeholder");
-
- }
-
- /**
- * @param list
- * @param Filling up the placeholder drop down list
- */
- public void addDropDownEntries(List<String> list) {
- for (String name : list) {
- this.placeholderNameDropDown.add(name);
- }
- }
-
- /**
- *
- */
- protected void close() {
- this.close();
- }
-
- @Override
- protected void checkSubclass() {
- // allow subclass
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
deleted file mode 100644
index 382a3d24..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/BKUHelper.java
+++ /dev/null
@@ -1,105 +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.bku;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-// Imports
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.http.client.config.CookieSpecs;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-
-/**
- *
- */
-public class BKUHelper {
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(BKUHelper.class);
-
- /* public static HttpClient getHttpClient(boolean useProxy) {
- HttpClient client = new HttpClient();
- client.getParams().setParameter("http.useragent",
- Constants.APP_NAME_VERSION);
-
- if (useProxy) {
- String host = System.getProperty("http.proxyHost");
- String port = System.getProperty("http.proxyPort");
- if (host != null && !host.isEmpty() &&
- port != null && !port.isEmpty()) {
- int p = Integer.parseInt(port);
- client.getHostConfiguration().setProxy(host, p);
- String user = System.getProperty("http.proxyUser");
- String pass = System.getProperty("http.proxyPassword");
- if (user != null && !user.isEmpty() && pass != null) {
- client.getState().setProxyCredentials(new AuthScope(host, p),
- new UsernamePasswordCredentials(user, pass));
- }
- }
- }
-
- return client;
- }*/
-
- /**
- * Get a HTTP Client instance
- *
- * @param useProxy
- * whether to use a potentially set proxy
- * @return the HttpClient
- */
- @SuppressWarnings("deprecation")
- public static HttpClient getHttpClient(boolean useProxy) {
- HttpClient client = new HttpClient();
- client.getParams().setParameter("http.useragent",
- Constants.APP_NAME_VERSION);
-
-
- client.getParams().setParameter("http.protocol.cookie-policy", CookieSpecs.BROWSER_COMPATIBILITY);
-
- if (useProxy) {
- String host = System.getProperty("http.proxyHost");//
- String port = System.getProperty("http.proxyPort");//
- if (host != null && !host.isEmpty() && port != null && !port.isEmpty()) {
- int p = Integer.parseInt(port);
- client.getHostConfiguration().setProxy(host, p);
- String user = System.getProperty("http.proxyUser");//
- String pass = System.getProperty("http.proxyPassword");//
- if (user != null && !user.isEmpty() && pass != null) {
- client.getState().setProxyCredentials(new AuthScope(host, p),
- new UsernamePasswordCredentials(user, pass));
- }
- }
- }
-
- return client;
-
- }
-
- /**
- * Get a HTTP Client instance
- *
- * @return the HttpClient
- */
- public static HttpClient getHttpClient() {
- return getHttpClient(false);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
deleted file mode 100644
index 1f68a020..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
+++ /dev/null
@@ -1,122 +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.bku;
-
-// Imports
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.utils.FileUploadSource;
-import at.asit.pdfover.signer.BkuSlConnector;
-import at.asit.pdfover.signer.SignatureException;
-import at.asit.pdfover.signer.pdfas.PdfAs4SLRequest;
-
-/**
- *
- */
-public class LocalBKUConnector implements BkuSlConnector {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(LocalBKUConnector.class);
-
- private static boolean isAvailable = false;
- public static boolean IsAvailable() { return isAvailable; }
- private static Thread pollingThread = new Thread(() -> {
- while (true) {
- try { Thread.sleep(isAvailable ? 30000 : 5000); } catch (InterruptedException e) {}
- try (Socket socket = new Socket("127.0.0.1", 3495)) {
- isAvailable = true;
- } catch (IOException e) {
- isAvailable = false;
- }
- }
- }, "LocalBKUProbeThread");
- static {
- pollingThread.setDaemon(true);
- pollingThread.start();
- }
-
-
- /**
- * HTTP Response server HEADER
- */
- public final static String BKU_RESPONSE_HEADER_SERVER = "server";
-
- /**
- * HTTP Response user-agent HEADER
- */
- public final static String BKU_RESPONSE_HEADER_USERAGENT = "user-agent";
-
- /**
- * HTTP Response SignatureLayout HEADER
- */
- public final static String BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout";
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.BkuSlConnector#handleSLRequest(java.lang.String)
- */
- @Override
- public String handleSLRequest(PdfAs4SLRequest request) throws SignatureException {
- try {
- HttpClient client = BKUHelper.getHttpClient();
- PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
-
- String sl_request = request.xmlRequest;
- if (request.signatureData == null) {
- method.addParameter("XMLRequest", sl_request);
- } else {
- StringPart xmlpart = new StringPart(
- "XMLRequest", sl_request, "UTF-8");
-
- FilePart filepart = new FilePart("fileupload", new FileUploadSource(request.signatureData));
-
- Part[] parts = { xmlpart, filepart };
-
- method.setRequestEntity(new MultipartRequestEntity(parts, method
- .getParams()));
- }
- log.trace("SL REQUEST: " + sl_request);
-
- int returnCode = client.executeMethod(method);
-
- if (returnCode != HttpStatus.SC_OK) {
- throw new HttpException(
- method.getResponseBodyAsString());
- }
-
- return method.getResponseBodyAsString();
- } catch (HttpException e) {
- log.error("LocalBKUConnector: ", e);
- throw new SignatureException(e);
- } catch (IOException e) {
- log.error("LocalBKUConnector: ", e);
- throw new SignatureException(e);
- }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
deleted file mode 100644
index 779e24c6..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
+++ /dev/null
@@ -1,439 +0,0 @@
-package at.asit.pdfover.gui.bku;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Base64;
-import java.util.List;
-import java.util.Optional;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.classic.methods.HttpPost;
-import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
-import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
-import org.apache.hc.core5.http.ClassicHttpRequest;
-import org.apache.hc.core5.http.ContentType;
-import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.http.NoHttpResponseException;
-import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.ProtocolException;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.apache.hc.core5.http.message.BasicNameValuePair;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-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.bku.mobile.ATrustParser;
-import at.asit.pdfover.gui.workflow.states.MobileBKUState;
-import at.asit.pdfover.gui.workflow.states.MobileBKUState.UsernameAndPassword;
-import at.asit.pdfover.signer.BkuSlConnector;
-import at.asit.pdfover.signer.SignatureException;
-import at.asit.pdfover.signer.UserCancelledException;
-import at.asit.pdfover.signer.pdfas.PdfAs4SLRequest;
-import at.asit.webauthn.WebAuthN;
-
-import static at.asit.pdfover.commons.Constants.ISNOTNULL;
-
-public class MobileBKUConnector implements BkuSlConnector {
- private static final Logger log = LoggerFactory.getLogger(MobileBKUConnector.class);
-
- private final @Nonnull MobileBKUState state;
- public MobileBKUConnector(@Nonnull MobileBKUState state) {
- this.state = state;
- this.wantsFido2Default = WebAuthN.isAvailable() && state.getConfig().getFido2ByDefault();
- state.storeRememberedCredentialsTo(this.credentials);
- }
-
- private class UserDisplayedError extends Exception {
- private final @Nonnull String msg;
- @Override public @Nonnull String getMessage() { return this.msg; }
- private UserDisplayedError(@Nonnull String s) { this.msg = s; }
- }
-
- public @Nonnull UsernameAndPassword credentials = new UsernameAndPassword();
-
- /**
- * This method takes the SLRequest from PDF-AS, and blocks until it has obtained a response
- */
- @Override
- public String handleSLRequest(PdfAs4SLRequest slRequest) throws SignatureException, UserCancelledException {
- log.debug("Got security layer request: (has file part: {})\n{}", (slRequest.signatureData != null), slRequest.xmlRequest);
- try (final CloseableHttpClient httpClient = HttpClients.custom().disableRedirectHandling().build()) {
- ClassicHttpRequest currentRequest = buildInitialRequest(slRequest);
- ATrustParser.Result response;
- while ((response = sendHTTPRequest(httpClient, currentRequest)).slResponse == null)
- currentRequest = presentResponseToUserAndReturnNextRequest(ISNOTNULL(response.html));
- log.debug("Returning security layer response:\n{}", response.slResponse);
- return response.slResponse;
- } catch (UserDisplayedError e) {
- state.showUnrecoverableError(e.getMessage());
- throw new IllegalStateException("unreachable", e); /* showUnrecoverableError always throws */
- } catch (UserCancelledException e) {
- throw e;
- } catch (Exception e) {
- throw new SignatureException(e);
- }
- }
-
- /* some anti-infinite-loop safeguards so we don't murder the atrust servers by accident */
- private int loopHTTPRequestCounter = 0;
- private Long lastHTTPRequestTime = null;
- /**
- * Sends the specified request, following redirects (including meta-tag redirects) recursively
- * @return The JSOUP document retrieved
- * @throws IOException on HTTP error codes
- * @throws ProtocolException
- * @throws URISyntaxException
- * @throws InterruptedException
- */
- private @Nonnull ATrustParser.Result sendHTTPRequest(CloseableHttpClient httpClient, ClassicHttpRequest request) throws IOException, ProtocolException, URISyntaxException, UserDisplayedError {
- long now = System.nanoTime();
- if ((lastHTTPRequestTime != null) && ((now - lastHTTPRequestTime) < 2e+9)) { /* less than 2s since last request */
- ++loopHTTPRequestCounter;
- if (loopHTTPRequestCounter > 250)
- throw new IOException("Infinite loop protection triggered");
- } else {
- loopHTTPRequestCounter = 0;
- }
- lastHTTPRequestTime = now;
-
- log.debug("Sending {} request to '{}'...", request.getMethod(), request.getUri().toString());
- try (final CloseableHttpResponse response = httpClient.execute(request)) {
- int httpStatus = response.getCode();
- if ((httpStatus == HttpStatus.SC_MOVED_PERMANENTLY) || (httpStatus == HttpStatus.SC_MOVED_TEMPORARILY)) {
- Header redirectPath = response.getHeader("location");
- if (redirectPath == null)
- throw new IOException("Received HTTP redirect, but no Location header.");
- return sendHTTPRequest(httpClient, buildRedirectedRequest(request.getUri(), redirectPath.getValue()));
- }
-
- if (httpStatus != HttpStatus.SC_OK) {
- switch (httpStatus) {
- case HttpStatus.SC_REQUEST_TOO_LONG: throw new UserDisplayedError(Messages.getString("atrusterror.http_413"));
- default: throw new UserDisplayedError(Messages.formatString("atrusterror.http_generic", httpStatus, Optional.ofNullable(response.getReasonPhrase()).orElse("(null)")));
- }
- }
-
- Header refreshHeader = response.getHeader("refresh");
- if (refreshHeader != null)
- return sendHTTPRequest(httpClient, buildRefreshHeaderRequest(request.getUri(), refreshHeader.getValue()));
-
- HttpEntity responseEntity = response.getEntity();
- if (responseEntity == null)
- throw new IOException("Did not get a HTTP body (entity == null)");
-
- ContentType contentType = ContentType.parse(responseEntity.getContentType());
- String entityBody = EntityUtils.toString(response.getEntity(),contentType.getCharset());
- if (entityBody == null)
- throw new IOException("Did not get a HTTP body (entity content == null)");
-
- if ("text/html".equals(contentType.getMimeType())) {
- Document resultDocument = Jsoup.parse(entityBody, request.getUri().toASCIIString());
- if (resultDocument == null)
- {
- log.error("Failed to parse A-Trust server response as HTML:\n{}", entityBody);
- throw new IOException("Failed to parse HTML");
- }
-
- Element metaRefresh = resultDocument.selectFirst("meta[http-equiv=\"refresh\"i]");
- if (metaRefresh != null) {
- String refreshContent = metaRefresh.attr("content");
- if (!refreshContent.isEmpty())
- return sendHTTPRequest(httpClient, buildRefreshHeaderRequest(request.getUri(), refreshContent));
- }
- return ATrustParser.Parse(resultDocument);
- } else {
- return ATrustParser.Parse(request.getUri(), contentType.getMimeType(), entityBody);
- }
- }
- }
-
- /**
- * Builds a HttpRequest for the given base URI and (potentially relative) redirect path
- */
- private static @Nonnull ClassicHttpRequest buildRedirectedRequest(URI baseURI, String redirectLocation) {
- log.debug("following redirect: {}", redirectLocation);
- return new HttpGet(baseURI.resolve(redirectLocation));
- }
-
- /**
- * Builds a HttpRequest for redirection to a given Refresh header value
- */
- private static @Nonnull ClassicHttpRequest buildRefreshHeaderRequest(URI baseURI, String refreshHeader) throws IOException {
- // refresh value is delay in seconds, semicolon, URL=, url
- Pattern pattern = Pattern.compile("^\\s*[0-9\\.]+\\s*;\\s*(?:[uU][rR][lL]\s*=\s*)(.+)$");
- Matcher matcher = pattern.matcher(refreshHeader);
- if (!matcher.matches())
- throw new IOException("Got invalid Refresh header with value \"" + refreshHeader + "\".");
- String redirectURL = matcher.group(1);
- return buildRedirectedRequest(baseURI, redirectURL);
- }
-
- /**
- * Builds the initial request to A-Trust based on the specified SL request
- */
- private static @Nonnull ClassicHttpRequest buildInitialRequest(PdfAs4SLRequest slRequest) {
- HttpPost post = new HttpPost(Constants.MOBILE_BKU_URL);
- if (slRequest.signatureData != null) {
- post.setEntity(MultipartEntityBuilder.create()
- .addBinaryBody("fileupload", slRequest.signatureData.getByteArray(), ContentType.APPLICATION_PDF, "sign.pdf")
- .addTextBody("XMLRequest", slRequest.xmlRequest)
- .build());
- } else {
- post.setEntity(UrlEncodedFormEntityBuilder.create()
- .add("XMLRequest", slRequest.xmlRequest)
- .build());
- }
- return post;
- }
-
- private static @Nonnull ClassicHttpRequest buildFormSubmit(@Nonnull ATrustParser.HTMLResult html, @CheckForNull String submitButton) {
- HttpPost post = new HttpPost(html.formTarget);
-
- var builder = MultipartEntityBuilder.create();
- for (var pair : html.iterateFormOptions())
- builder.addTextBody(pair.getKey(), pair.getValue());
-
- if (submitButton != null) {
- var submitButtonElm = html.htmlDocument.selectFirst(submitButton);
- if (submitButtonElm != null) {
- if ("input".equalsIgnoreCase(submitButtonElm.tagName())) {
- if ("submit".equalsIgnoreCase(submitButtonElm.attr("type"))) {
- String name = submitButtonElm.attr("name");
- if (!name.isEmpty())
- builder.addTextBody(name, submitButtonElm.attr("value"));
- } else {
- log.warn("Skipped specified submitButton {}, type is {} (not submit)", submitButton, submitButtonElm.attr("type"));
- }
- } else {
- log.warn("Skipped specified submitButton {}, tag name is {} (not input)", submitButton, submitButtonElm.tagName());
- }
- } else {
- log.warn("Skipped specified submitButton {}, element not found", submitButton);
- }
- }
-
- post.setEntity(builder.build());
- return post;
- }
-
- private static class LongPollThread extends Thread implements AutoCloseable {
-
- private final CloseableHttpClient httpClient = HttpClients.createDefault();
- private final HttpGet request;
- private final Runnable signal;
- private boolean done = false;
-
- @Override
- public void run() {
- long timeout = System.nanoTime() + (300l * 1000l * 1000l * 1000l); /* a-trust timeout is 5 minutes */
- log.debug("longPollThread hello");
- while (!done) {
- try (final CloseableHttpResponse response = httpClient.execute(request)) {
- JSONObject jsonResponse = new JSONObject(EntityUtils.toString(response.getEntity()));
- if (jsonResponse.getBoolean("Fin"))
- signal.run();
- else if (jsonResponse.getBoolean("Wait"))
- {
- log.debug("longPollThread continue...");
- continue;
- }
- else if (jsonResponse.getBoolean("Error"))
- signal.run(); /* will trigger reload and find error; this is the same thing a-trust does */
- else {
- log.warn("Unknown long poll response:\n{}", jsonResponse.toString(2));
- break;
- }
- } catch (NoHttpResponseException e) {
- if (timeout <= System.nanoTime())
- signal.run(); /* reload to find the timeout error */
- continue; /* httpclient timeout */
- } catch (IOException | ParseException | IllegalStateException e) {
- if (done) break;
- log.warn("QR code long polling exception", e);
- /* sleep so we don't hammer a-trust too hard in case this goes wrong */
- try { Thread.sleep(5000); } catch (InterruptedException e2) {}
- }
- }
- log.debug("longPollThread goodbye");
- }
-
- public LongPollThread(URI uri, Runnable signal) {
- this.request = new HttpGet(uri);
- this.signal = signal;
- }
-
- @Override
- public void close() {
- done = true;
- if (this.request != null)
- this.request.abort();
-
- if (this.isAlive())
- try { this.join(1000); } catch (InterruptedException e) {}
-
- if (this.httpClient != null)
- try { this.httpClient.close(); } catch (IOException e) { log.warn("Auto-close of long-poll HTTP client threw exception", e); }
- }
-
- }
-
- private boolean wantsFido2Default;
- /**
- * Main lifting function for MobileBKU UX
- * @return the next request to make
- */
- private @Nonnull ClassicHttpRequest presentResponseToUserAndReturnNextRequest(@Nonnull ATrustParser.HTMLResult html) throws UserCancelledException {
- if ((html.errorBlock == null) && (html.usernamePasswordBlock == null)) { /* successful username/password auth */
- if ((this.credentials.username != null) && (this.credentials.password != null))
- state.rememberCredentialsIfNecessary(this.credentials);
- }
-
- if (wantsFido2Default && (html.fido2Link != null)) {
- wantsFido2Default = false;
- return new HttpGet(html.fido2Link);
- }
-
- if (html.autoSkipBlock != null) {
- return buildFormSubmit(html, html.autoSkipBlock.submitButton);
- }
- if (html.interstitialBlock != null) {
- this.state.showInformationMessage(html.interstitialBlock.interstitialMessage);
- return buildFormSubmit(html, html.interstitialBlock.submitButton);
- }
- if (html.errorBlock != null) {
- try {
- this.credentials.password = null;
- this.state.clearRememberedPassword();
-
- if (html.errorBlock.isRecoverable)
- this.state.showRecoverableError(html.errorBlock.errorText);
- else
- this.state.showUnrecoverableError(html.errorBlock.errorText);
- return buildFormSubmit(html, "#Button_Back");
- } catch (UserCancelledException e) {
- return buildFormSubmit(html, "#Button_Cancel");
- }
- }
- if (html.usernamePasswordBlock != null) {
- try {
- while ((this.credentials.username == null) || (this.credentials.password == null)) {
- this.state.getCredentialsFromUserTo(this.credentials, html.usernamePasswordBlock.errorMessage);
- }
- html.usernamePasswordBlock.setUsernamePassword(this.credentials.username, this.credentials.password);
- return buildFormSubmit(html, "#Button_Identification");
- } catch (UserCancelledException e) {
- return buildFormSubmit(html, "#Button_Cancel");
- }
- }
- if (html.smsTanBlock != null) {
- MobileBKUState.SMSTanResult result = this.state.getSMSTanFromUser(
- html.smsTanBlock.referenceValue, html.signatureDataLink,
- html.fido2Link != null, html.smsTanBlock.errorMessage);
-
- switch (result.type) {
- case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link);
- case SMSTAN: html.smsTanBlock.setTAN(result.smsTan); return buildFormSubmit(html, "#SignButton");
- }
- return new HttpGet(html.htmlDocument.baseUri());
- }
- if (html.qrCodeBlock != null) {
- try (LongPollThread longPollThread = new LongPollThread(html.qrCodeBlock.pollingURI, () -> { this.state.signalQRScanned(); })) {
- this.state.showQRCode(html.qrCodeBlock.referenceValue, html.qrCodeBlock.qrCodeURI, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null, html.qrCodeBlock.errorMessage);
- longPollThread.start();
- var result = this.state.waitForQRCodeResult();
- switch (result) {
- case UPDATE: break;
- case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
- case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
- }
- return new HttpGet(html.htmlDocument.baseUri());
- }
- }
- if (html.waitingForAppBlock != null) {
- try (LongPollThread longPollThread = new LongPollThread(html.waitingForAppBlock.pollingURI, () -> { this.state.signalAppOpened(); })) {
- this.state.showWaitingForAppOpen(html.waitingForAppBlock.referenceValue, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null);
- longPollThread.start();
- var result = this.state.waitForAppOpen();
- switch (result) {
- case UPDATE: break;
- case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
- case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
- }
- return new HttpGet(html.htmlDocument.baseUri());
- }
- }
- if (html.waitingForBiometryBlock != null) {
- try (LongPollThread longPollThread = new LongPollThread(html.waitingForBiometryBlock.pollingURI, () -> { this.state.signalAppBiometryDone(); })) {
- this.state.showWaitingForAppBiometry(html.waitingForBiometryBlock.referenceValue, html.signatureDataLink, html.smsTanLink != null, html.fido2Link != null);
- longPollThread.start();
- var result = this.state.waitForAppBiometry();
- switch (result) {
- case UPDATE: break;
- case TO_FIDO2: if (html.fido2Link != null) return new HttpGet(html.fido2Link); break;
- case TO_SMS: if (html.smsTanLink != null) return new HttpGet(html.smsTanLink); break;
- }
- return new HttpGet(html.htmlDocument.baseUri());
- }
- }
- if (html.fido2Block != null) {
-
- var fido2Result = this.state.promptUserForFIDO2Auth(html.fido2Block.fidoOptions, html.signatureDataLink, html.smsTanLink != null);
-
- switch (fido2Result.type) {
- case TO_SMS: return new HttpGet(html.smsTanLink);
- case CREDENTIAL: break;
- }
-
- var fido2Assertion = ISNOTNULL(fido2Result.credential);
-
- Base64.Encoder base64 = Base64.getEncoder();
-
- JSONObject aTrustAssertion = new JSONObject();
- aTrustAssertion.put("id", fido2Assertion.id);
- aTrustAssertion.put("rawId", base64.encodeToString(fido2Assertion.rawId));
- aTrustAssertion.put("type", fido2Assertion.type);
- aTrustAssertion.put("extensions", new JSONObject()); // TODO fix extensions in library
-
- JSONObject aTrustAssertionResponse = new JSONObject();
- aTrustAssertion.put("response", aTrustAssertionResponse);
- aTrustAssertionResponse.put("authenticatorData", base64.encodeToString(fido2Assertion.response.authenticatorData));
- aTrustAssertionResponse.put("clientDataJson", base64.encodeToString(fido2Assertion.response.clientDataJSON));
- aTrustAssertionResponse.put("signature", base64.encodeToString(fido2Assertion.response.signature));
- if (fido2Assertion.response.userHandle != null)
- aTrustAssertionResponse.put("userHandle", base64.encodeToString(fido2Assertion.response.userHandle));
- else
- aTrustAssertionResponse.put("userHandle", JSONObject.NULL);
-
- html.fido2Block.setFIDOResult(aTrustAssertion.toString());
- return buildFormSubmit(html, "#FidoContinue");
- }
- throw new IllegalStateException("No top-level block is set? Something has gone terribly wrong.");
- }
-
- private static class UrlEncodedFormEntityBuilder {
- private UrlEncodedFormEntityBuilder() {}
- private List<NameValuePair> values = new ArrayList<>();
- public static @Nonnull UrlEncodedFormEntityBuilder create() { return new UrlEncodedFormEntityBuilder(); }
- public @Nonnull UrlEncodedFormEntityBuilder add(String key, String value) { values.add(new BasicNameValuePair(key, value)); return this; }
- public @Nonnull UrlEncodedFormEntity build() { return new UrlEncodedFormEntity(values, Charset.forName("utf-8")); }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java
deleted file mode 100644
index 89f53629..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustParser.java
+++ /dev/null
@@ -1,379 +0,0 @@
-package at.asit.pdfover.gui.bku.mobile;
-
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.jsoup.Jsoup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static at.asit.pdfover.commons.Constants.ISNOTNULL;
-
-public class ATrustParser {
- private static final Logger log = LoggerFactory.getLogger(ATrustParser.class);
-
- private static class ComponentParseFailed extends Exception {}
-
- private static class TopLevelFormBlock {
- protected final @Nonnull org.jsoup.nodes.Document htmlDocument;
- protected final @Nonnull Map<String, String> formOptions;
- protected TopLevelFormBlock(@Nonnull org.jsoup.nodes.Document d, @Nonnull Map<String,String> fO) { this.htmlDocument = d; this.formOptions = fO; }
-
- protected void abortIfElementMissing(@Nonnull String selector) throws ComponentParseFailed {
- if (this.htmlDocument.selectFirst(selector) != null) return;
- log.debug("Tested for element {} -- not found.", selector);
- throw new ComponentParseFailed();
- }
- protected @Nonnull org.jsoup.nodes.Element getElementEnsureNotNull(@Nonnull String selector) throws ComponentParseFailed {
- var elm = this.htmlDocument.selectFirst(selector);
- if (elm == null) { log.warn("Expected element not found in response: {}", selector); throw new ComponentParseFailed(); }
- return elm;
- }
- protected @Nonnull String getAttributeEnsureNotNull(@Nonnull String selector, @Nonnull String attribute) throws ComponentParseFailed {
- var elm = getElementEnsureNotNull(selector);
- if (!elm.hasAttr(attribute)) { log.warn("Element {} is missing expected attribute '{}'.", selector, attribute); throw new ComponentParseFailed(); }
- return ISNOTNULL(elm.attr(attribute));
- }
- protected @Nonnull URI getURIAttributeEnsureNotNull(@Nonnull String selector, @Nonnull String attribute) throws ComponentParseFailed {
- String value = getAttributeEnsureNotNull(selector, attribute);
- try {
- return new URI(value);
- } catch (URISyntaxException e) {
- if (attribute.startsWith("abs:"))
- attribute = ISNOTNULL(attribute.substring(4));
- log.warn("Element {} attribute {} is '{}', could not be parsed as URI", selector, attribute, getAttributeEnsureNotNull(selector, attribute));
- throw new ComponentParseFailed();
- }
- }
- protected @Nonnull URI getLongPollURI() throws ComponentParseFailed {
- var pollingScriptElm = getElementEnsureNotNull("#jsLongPoll script");
- String pollingScript = pollingScriptElm.data();
- int startIdx = pollingScript.indexOf("qrpoll(\"");
- if (startIdx < 0) { log.warn("Failed to find 'qrpoll(\"' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); }
- startIdx += 8;
-
- int endIdx = pollingScript.indexOf("\");", startIdx);
- if (endIdx < 0) { log.warn("Failed to find qrpoll terminator '\");' in jsLongPoll script:\n{}", pollingScript); throw new ComponentParseFailed(); }
-
- String pollingUriString = pollingScript.substring(startIdx, endIdx);
- try {
- return ISNOTNULL(new URI(pollingScriptElm.baseUri()).resolve(pollingUriString));
- } catch (URISyntaxException e) {
- log.warn("Long-poll URI '{}' could not be parsed", pollingUriString);
- throw new ComponentParseFailed();
- }
- }
- }
-
- public static class AutoSkipBlock extends TopLevelFormBlock {
- public final @Nonnull String submitButton;
-
- private AutoSkipBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- if (htmlDocument.baseUri().contains("/tanAppInfo.aspx")) {
- this.submitButton = "#NextBtn";
- } else { throw new ComponentParseFailed(); }
- }
- }
-
- public static class InterstitialBlock extends TopLevelFormBlock {
- public final @Nonnull String submitButton;
- public final @Nonnull String interstitialMessage;
-
- private InterstitialBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- if (htmlDocument.baseUri().contains("/ExpiresInfo.aspx")) {
- this.interstitialMessage = ISNOTNULL(getElementEnsureNotNull("#Label2").ownText());
- this.submitButton = "#Button_Next";
- } else { throw new ComponentParseFailed(); }
- }
- }
-
- public static class ErrorBlock extends TopLevelFormBlock {
- public final boolean isRecoverable;
- public final @Nonnull String errorText;
-
- private ErrorBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
-
- try {
- String documentPath = new URI(htmlDocument.baseUri()).getPath();
- String aspxFile = documentPath.substring(documentPath.lastIndexOf('/'));
-
- // gods this is such a hack, why can't they have a proper error element or something
- if (!(aspxFile.startsWith("/error") && aspxFile.endsWith(".aspx")))
- throw new ComponentParseFailed();
- } catch (URISyntaxException ex) {
- log.warn("Failed to parse document base URI as URI? ({})", htmlDocument.baseUri());
- throw new ComponentParseFailed();
- }
-
- this.isRecoverable = (htmlDocument.selectFirst("#Button_Back") != null);
-
- StringBuilder errorText = new StringBuilder(getElementEnsureNotNull("#Label1").ownText().trim());
- var detailLabel = this.htmlDocument.selectFirst("#LabelDetail");
- if (detailLabel != null)
- errorText.append("\n").append(detailLabel.ownText().trim());
- this.errorText = ISNOTNULL(errorText.toString());
- }
- }
-
- public static class UsernamePasswordBlock extends TopLevelFormBlock {
- private final @Nonnull String usernameKey;
- private final @Nonnull String passwordKey;
- public final @CheckForNull String errorMessage;
-
- public void setUsernamePassword(String username, String password) {
- formOptions.put(usernameKey, username); formOptions.put(passwordKey, password);
- }
-
- private UsernamePasswordBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#handynummer");
- this.usernameKey = getAttributeEnsureNotNull("#handynummer", "name");
- this.passwordKey = getAttributeEnsureNotNull("#signaturpasswort", "name");
- this.errorMessage = null;
- }
- }
-
- public static class SMSTanBlock extends TopLevelFormBlock {
- private final @Nonnull String tanKey;
- public final @Nonnull String referenceValue;
- public final @CheckForNull String errorMessage;
-
- public void setTAN(String tan) {
- formOptions.put(tanKey, tan);
- }
-
- private SMSTanBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#input_tan");
- this.tanKey = getAttributeEnsureNotNull("#input_tan", "name");
- this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText());
- this.errorMessage = null;
- }
- }
-
- public static class QRCodeBlock extends TopLevelFormBlock {
- public final @Nonnull String referenceValue;
- public final @Nonnull URI qrCodeURI;
- public final @Nonnull URI pollingURI;
- public final @Nullable String errorMessage;
-
- private QRCodeBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#qrimage");
-
- this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText());
- this.qrCodeURI = getURIAttributeEnsureNotNull("#qrimage", "abs:src");
- this.pollingURI = getLongPollURI();
-
- this.errorMessage = null;
- }
- }
-
- public static class WaitingForAppBlock extends TopLevelFormBlock {
- public final @Nonnull String referenceValue;
- public final @Nonnull URI pollingURI;
-
- private WaitingForAppBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#smartphoneAnimation");
-
- this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText());
- this.pollingURI = getLongPollURI();
- }
- }
-
- public static class WaitingForBiometryBlock extends TopLevelFormBlock {
- public final @Nonnull String referenceValue;
- public final @Nonnull URI pollingURI;
-
- private WaitingForBiometryBlock(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#biometricimage");
-
- this.referenceValue = ISNOTNULL(getElementEnsureNotNull("#vergleichswert").ownText());
- this.pollingURI = getLongPollURI();
- }
- }
-
- public static class Fido2Block extends TopLevelFormBlock {
- public final @Nonnull String fidoOptions;
- private final @Nonnull String credentialResultKey;
-
- public void setFIDOResult(String result) { formOptions.put(credentialResultKey, result); }
-
- private Fido2Block(@Nonnull org.jsoup.nodes.Document htmlDocument, @Nonnull Map<String, String> formOptions) throws ComponentParseFailed {
- super(htmlDocument, formOptions);
- abortIfElementMissing("#fidoBlock");
- this.fidoOptions = getAttributeEnsureNotNull("#credentialOptions", "value");
- this.credentialResultKey = getAttributeEnsureNotNull("#credentialResult", "name");
- }
- }
-
- public static class HTMLResult {
- public final @Nonnull org.jsoup.nodes.Document htmlDocument;
- public final @Nonnull URI formTarget;
- public final @Nonnull Map<String, String> formOptions = new HashMap<>();
-
- public @Nonnull Iterable<Map.Entry<String, String>> iterateFormOptions() { return ISNOTNULL(formOptions.entrySet()); }
-
- /* optional links (any number may or may not be null) */
- public final @CheckForNull URI signatureDataLink;
- public final @CheckForNull URI smsTanLink;
- public final @CheckForNull URI fido2Link;
-
- /* top-level blocks (exactly one is not null) */
- public final @CheckForNull AutoSkipBlock autoSkipBlock;
- public final @CheckForNull InterstitialBlock interstitialBlock;
- public final @CheckForNull ErrorBlock errorBlock;
- public final @CheckForNull UsernamePasswordBlock usernamePasswordBlock;
- public final @CheckForNull SMSTanBlock smsTanBlock;
- public final @CheckForNull QRCodeBlock qrCodeBlock;
- public final @CheckForNull WaitingForAppBlock waitingForAppBlock;
- public final @CheckForNull WaitingForBiometryBlock waitingForBiometryBlock;
- public final @CheckForNull Fido2Block fido2Block;
-
- private void validate() {
- Set<String> populated = new HashSet<>();
-
- if (autoSkipBlock != null) populated.add("autoSkipBlock");
- if (interstitialBlock != null) populated.add("interstitialBlock");
- if (errorBlock != null) populated.add("errorBlock");
- if (usernamePasswordBlock != null) populated.add("usernamePasswordBlock");
- if (smsTanBlock != null) populated.add("smsTanBlock");
- if (qrCodeBlock != null) populated.add("qrCodeBlock");
- if (waitingForAppBlock != null) populated.add("waitingForAppBlock");
- if (waitingForBiometryBlock != null) populated.add("waitingForBiometryBlock");
- if (fido2Block != null) populated.add("fido2Block");
-
- switch (populated.size()) {
- case 0: log.error("Did not find any top-level blocks.\n{}", this.htmlDocument.toString()); break;
- case 1: /* passed */ return;
- default: log.error("Found too many top-level blocks: {}\n", String.join(", ", populated), this.htmlDocument.toString()); break;
- }
- throw new IllegalArgumentException("Unknown A-Trust page reached?");
- }
-
- private @Nullable URI getHrefIfExists(String selector) {
- var elm = htmlDocument.selectFirst(selector);
- if (elm == null) return null;
-
- String url = elm.absUrl("href");
- try {
- return new URI(url);
- } catch (Exception e) {
- log.warn("Invalid {} href attribute: {} ({})", selector, elm.attr("href"), url);
- return null;
- }
- }
-
- /**
- * tries to parse T using its constructor; if ComponentParseFailed is thrown, swallows it
- */
- private <T extends TopLevelFormBlock> @Nullable T TryParseMainBlock(Class<T> clazz) {
- try {
- return clazz.getDeclaredConstructor(org.jsoup.nodes.Document.class, Map.class).newInstance(this.htmlDocument, this.formOptions);
- } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | IllegalArgumentException | SecurityException e) {
- log.error("Internal parser error; check your method signatures?", e);
- return null;
- } catch (InvocationTargetException wrappedE) {
- Throwable e = wrappedE.getCause();
- if (!(e instanceof ComponentParseFailed)) {
- if (e instanceof RuntimeException)
- throw (RuntimeException)e;
- log.warn("Unexpected parser failure.", e);
- }
- return null;
- }
- }
-
- private HTMLResult(@Nonnull org.jsoup.nodes.Document htmlDocument) {
- log.trace("Now parsing:\n{}", htmlDocument.toString());
- this.htmlDocument = htmlDocument;
-
- var forms = htmlDocument.getElementsByTag("form");
- if (forms.size() != 1) {
- log.error("Found {} forms in A-Trust response document, expected 1. Document:\n{}", forms.size(), htmlDocument.toString());
- throw new IllegalArgumentException("Failed to parse A-Trust response page");
- }
-
- var mainForm = ISNOTNULL(forms.first()); /* size check above */
- String formAction = mainForm.absUrl("action");
- try {
- this.formTarget = new URI(formAction);
- } catch (URISyntaxException e) {
- log.error("Invalid form target in page: {} ({})", mainForm.attr("action"), formAction, e);
- throw new IllegalArgumentException("Failed to parse A-Trust response page");
- }
-
- for (var input : mainForm.select("input")) {
- String name = input.attr("name");
-
- if (name.isEmpty())
- continue;
-
- /* submit inputs omitted here, they only get sent if they are "clicked", cf. MobileBKUConnector::buildFormSubmit */
- if ("submit".equalsIgnoreCase(input.attr("type")))
- continue;
-
- this.formOptions.put(name, input.attr("value"));
- }
-
- this.signatureDataLink = getHrefIfExists("#LinkList a[href*=\"ShowSigobj.aspx\"]"); /* grr, they didn't give it an ID */
- this.smsTanLink = getHrefIfExists("#SmsButton");
- this.fido2Link = getHrefIfExists("#FidoButton"); // TODO hide the button if unsupported?
-
- this.autoSkipBlock = TryParseMainBlock(AutoSkipBlock.class);
- this.interstitialBlock = TryParseMainBlock(InterstitialBlock.class);
- this.errorBlock = TryParseMainBlock(ErrorBlock.class);
- this.usernamePasswordBlock = TryParseMainBlock(UsernamePasswordBlock.class);
- this.smsTanBlock = TryParseMainBlock(SMSTanBlock.class);
- this.qrCodeBlock = TryParseMainBlock(QRCodeBlock.class);
- this.waitingForAppBlock = TryParseMainBlock(WaitingForAppBlock.class);
- this.waitingForBiometryBlock = TryParseMainBlock(WaitingForBiometryBlock.class);
- this.fido2Block = TryParseMainBlock(Fido2Block.class);
-
- validate();
- }
- }
-
- public static class Result {
- public final @CheckForNull String slResponse;
- public final @CheckForNull HTMLResult html;
-
- private Result(@Nonnull String slResponse) { this.slResponse = slResponse; this.html = null; }
- private Result(@Nonnull org.jsoup.nodes.Document htmlDocument) { this.slResponse = null; this.html = new HTMLResult(htmlDocument); }
- }
-
- public static @Nonnull Result Parse(@Nonnull org.jsoup.nodes.Document htmlDocument) { return new Result(htmlDocument); }
-
- public static @Nonnull Result Parse(URI baseURI, String contentType, @Nonnull String content) {
- if (contentType.equals("text/html"))
- {
- var document = Jsoup.parse(content, baseURI.toASCIIString());
- if (document == null)
- {
- log.error("Failed to parse HTML (document == null):\n{}", content);
- throw new IllegalArgumentException("A-Trust parsing failed");
- }
- return Parse(document);
- }
-
- if (contentType.endsWith("/xml"))
- return new Result(content);
-
- log.error("Unknown content-type \"{}\" from URI {}", contentType, baseURI.toString());
- throw new IllegalArgumentException("Unknown A-Trust page reached?");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUValidator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUValidator.java
deleted file mode 100644
index 89dbdf4f..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUValidator.java
+++ /dev/null
@@ -1,93 +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.bku.mobile;
-
-// Imports
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import at.asit.pdfover.gui.exceptions.InvalidPasswordException;
-import at.asit.pdfover.gui.exceptions.PasswordTooLongException;
-import at.asit.pdfover.gui.exceptions.PasswordTooShortException;
-
-/**
- *
- */
-public class MobileBKUValidator {
-
- /**
- * Regular expression for mobile phone numbers: this allows the entry of
- * mobile numbers in the following formats:
- *
- * +(countryCode)99999999999 00(countryCode)99999999999 099999999999
- * 1030199999999999 (A-Trust Test bku)
- */
- private static final String NUMBER_REGEX = "^((\\+[\\d]{2})|(00[\\d]{2})|(0)|(10301))([1-9][\\d]+)$";
-
- /**
- * Validates the Mobile phone number
- *
- * @param number
- * @return the normalized Phone number
- */
- public static String normalizeMobileNumber(String number) {
- // Verify number and normalize
-
- number = number.trim();
-
- String numberWithoutWhitespace = number.replaceAll("\\s","");
- // Compile and use regular expression
- Pattern pattern = Pattern.compile(NUMBER_REGEX);
- Matcher matcher = pattern.matcher(numberWithoutWhitespace);
-
- if (!matcher.find())
- return number; /* might be an idA username, return unchanged */
-
- if (matcher.groupCount() != 6) {
- return number;
- }
-
- String countryCode = matcher.group(1);
-
- String normalNumber = matcher.group(6);
-
- if (countryCode.equals("10301")) {
- // A-Trust Testnumber! Don't change
- return numberWithoutWhitespace;
- }
-
- countryCode = countryCode.replace("00", "+");
-
- if (countryCode.equals("0")) {
- countryCode = "+43";
- }
-
- return countryCode + normalNumber;
- }
-
- /**
- * Validate given Password for Mobile BKU
- *
- * @param password
- * @throws InvalidPasswordException
- */
- public static void validatePassword(String password)
- throws InvalidPasswordException {
- if (password.length() < 5)
- throw new PasswordTooShortException();
- if (password.length() > 200)
- throw new PasswordTooLongException();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
deleted file mode 100644
index 16a47a42..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/Argument.java
+++ /dev/null
@@ -1,127 +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.cliarguments;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-
-/**
- * CLI Argument base class
- *
- * Implementing arguments have to be registered in PrepareConfigurationState
- */
-public abstract class Argument {
-
- private String helpTextKey = null;
-
- private String[] commandOptions = null;
-
- private StateMachine stateMachine;
-
- /**
- * @param commandOptions
- * @param helpTextKey
- */
- protected Argument(String[] commandOptions, String helpTextKey) {
- this.helpTextKey = helpTextKey;
- this.commandOptions = commandOptions;
- }
-
- /**
- * Set the state machine
- * Used for configuration overlay manipulator and status
- * @param stateMachine the state machine
- */
- protected void setStateMachine(StateMachine stateMachine) {
- this.stateMachine = stateMachine;
- }
-
- protected ConfigurationManager getConfiguration() {
- return this.stateMachine.configProvider;
- }
-
- /**
- * Get the status
- * @return the status
- */
- protected Status getStatus() {
- return this.stateMachine.status;
- }
-
- /**
- * Set help text key
- * @param key
- */
- protected void setHelpTextKey(String key) {
- this.helpTextKey = key;
- }
-
- /**
- * Gets help text
- * @return help text
- */
- public String getHelpText() {
- return Messages.getString(this.helpTextKey);
- }
-
- /**
- * Set the command option in format: -...
- *
- * Examples: -h
- *
- * @param value
- */
- protected void setCommandOptions(String[] value) {
- this.commandOptions = value;
- }
-
- /**
- * Get the command option
- *
- * Examples: -h
- * @return the command option
- */
- public String[] getCommandOptions() {
- return this.commandOptions;
- }
-
- /**
- * Invokes the argument to set stuff within the stateMachine
- *
- * It should return the offset within the args array where the last used argument of this Argument was used.
- *
- * Example:
- * args[] = { "-h", "-b", "LOCAL" }
- *
- * Help Argument call:
- * offset = 0
- * returns 0
- *
- * BKU Argument call:
- * offset = 1
- * returns 2
- *
- * @param args
- * @param argOffset
- * @param handler
- * @return returns the argumentOffset ending the section of this Argument
- * @throws InitializationException
- */
- public abstract int handleArgument(String[] args, int argOffset, ArgumentHandler handler) throws InitializationException;
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java
deleted file mode 100644
index 108ccb47..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java
+++ /dev/null
@@ -1,127 +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.cliarguments;
-
-// Imports
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.gui.workflow.StateMachine;
-
-/**
- * Handler to process CLI Arguments
- */
-public class ArgumentHandler {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ArgumentHandler.class);
-
- private Map<String, Argument> cliArguments = new LinkedHashMap<String, Argument>();
-
- private StateMachine stateMachine = null;
-
- private boolean requiredExit = false;
-
- /**
- * Constructor
- *
- * @param stateMachine
- */
- public ArgumentHandler(StateMachine stateMachine) {
- this.stateMachine = stateMachine;
- }
-
- /**
- * Gets available Arguments
- *
- * @return the list of available arguments
- */
- public Set<Argument> getArguments() {
- return new LinkedHashSet<Argument>(this.cliArguments.values());
- }
-
- /**
- * Adds a CLIArgument to the handler
- *
- * @param cliArgument the CLIArgument subclass to add
- */
- public void addCLIArgument(Class<? extends Argument> cliArgument) {
-
- Argument arg;
- try {
- arg = cliArgument.getDeclaredConstructor().newInstance();
-
- arg.setStateMachine(this.stateMachine);
-
- String[] commandOptions = arg.getCommandOptions();
-
- if (commandOptions == null) {
- return;
- }
-
- for (int i = 0; i < commandOptions.length; i++) {
- this.cliArguments.put(commandOptions[i], arg);
- }
- } catch (Exception e) {
- log.error("Error instantiating CLI argument" , e);
- }
- }
-
- /**
- * Handle CLI Arguments
- *
- * @param args
- * @throws InitializationException
- */
- public void handleArguments(String[] args) throws InitializationException {
-
- for (int i = 0; i < args.length; i++) {
- if (this.cliArguments.containsKey(args[i])) {
- i = this.cliArguments.get(args[i]).handleArgument(args, i, this);
- } else {
- // Assume we got the document we want to sign
- if (this.cliArguments.containsKey("-i")) {
- i = this.cliArguments.get("-i").handleArgument(args, i-1, this);
- }
- }
- }
- }
-
- /**
- * Set by a cli argument if it wants the program to exit
- *
- * @param requireExit
- */
- public void setRequireExit(boolean requireExit) {
- this.requiredExit = requireExit;
- }
-
- /**
- * Checks if one argument required the program to exit immediately
- *
- * @return true or false
- */
- public boolean doesRequireExit() {
- return this.requiredExit;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
deleted file mode 100644
index 23d00c06..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/AutomaticPositioningArgument.java
+++ /dev/null
@@ -1,47 +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.cliarguments;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-
-/**
- * CLI Argument to set the BKU to use
- */
-public class AutomaticPositioningArgument extends Argument {
- /**
- * Constructor
- */
- public AutomaticPositioningArgument() {
- super(new String[] { "-a" }, "argument.help.autopos");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang
- * .String[], int, at.asit.pdfover.gui.workflow.StateMachine,
- * at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- getConfiguration().setAutoPositionSignatureOverlay();
- return argOffset;
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java
deleted file mode 100644
index e69383f7..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java
+++ /dev/null
@@ -1,64 +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.cliarguments;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.BKUs;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to set the BKU to use
- */
-public class BKUArgument extends Argument {
- /**
- * Constructor
- */
- public BKUArgument() {
- super(
- new String[] { "-b" }, "argument.help.bku");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang
- * .String[], int, at.asit.pdfover.gui.workflow.StateMachine,
- * at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- BKUs argumentValue = BKUs.valueOf(args[argOffset + 1]);
-
- getConfiguration().setDefaultBKUOverlay(argumentValue);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- throw new InitializationException(
- Messages.getString("argument.invalid.bku") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.bku") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java
deleted file mode 100644
index 725a28f9..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to set the configuration file
- */
-public class ConfigFileArgument extends Argument {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ConfigFileArgument.class);
-
- /**
- * Constructor
- */
- public ConfigFileArgument() {
- super(new String[] {"-c"}, "argument.help.config");
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String configFile = args[argOffset + 1];
-
- getConfiguration().setConfigurationFileName(configFile);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Configuration File Argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.config") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.config") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java
deleted file mode 100644
index fe88d37e..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java
+++ /dev/null
@@ -1,76 +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.cliarguments;
-
-// Imports
-import java.io.File;
-import java.io.FileNotFoundException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to set the emblem file to use for signature
- */
-public class EmblemArgument extends Argument {
- /**
- * Constructor
- */
- public EmblemArgument() {
- super(new String[] {"-e"}, "argument.help.emblem");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(EmblemArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String emblem = args[argOffset + 1];
-
- File emblemFile = new File(emblem);
-
- if(!emblemFile.exists()) {
- throw new FileNotFoundException(emblem);
- }
-
- getConfiguration().setDefaultEmblemOverlay(emblem);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Emblem argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.emblem") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.emblem") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/HelpArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/HelpArgument.java
deleted file mode 100644
index 0bcdaba6..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/HelpArgument.java
+++ /dev/null
@@ -1,95 +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.cliarguments;
-
-// Imports
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to show the useage message
- */
-public class HelpArgument extends Argument {
-
- /**
- * Constructor
- */
- public HelpArgument() {
- super(new String[] {"-h", "-?", "--help" },
- "argument.help.help");
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- Set<Argument> arguments = handler.getArguments();
-
- Iterator<Argument> argumentIterator = arguments.iterator();
-
- StringBuilder message = new StringBuilder(Messages.getString("argument.info.help"));
- message.append("\n");
-
- while(argumentIterator.hasNext()) {
- Argument argument = argumentIterator.next();
-
- for (int i = 0; i < argument.getCommandOptions().length; i++) {
- message.append(argument.getCommandOptions()[i]);
-
- if(i < argument.getCommandOptions().length -1) {
- message.append(", ");
- }
- }
-
- message.append(":\n");
- boolean first = true;
- for (String line : argument.getHelpText().split("\\.\\s+")) {
- message.append(" ");
- if (first) first = false; else message.append(" ");
- message.append(line);
- message.append("\n");
- }
- }
-
- String msg = message.toString();
- System.out.println(msg);
-
- Display display = Display.getCurrent();
- if (display != null) {
- MessageBox box = new MessageBox(new Shell(display), SWT.ICON_INFORMATION | SWT.OK);
- box.setText(Constants.APP_NAME_VERSION);
- box.setMessage(msg);
- box.open();
- }
-
- handler.setRequireExit(true);
-
- return argOffset;
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java
deleted file mode 100644
index b636b825..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java
+++ /dev/null
@@ -1,76 +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.cliarguments;
-
-// Imports
-import java.io.File;
-import java.io.FileNotFoundException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to set the input document to sign
- */
-public class InputDocumentArgument extends Argument {
- /**
- * Constructor
- */
- public InputDocumentArgument() {
- super(new String[] {"-i"}, "argument.help.input");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(InputDocumentArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfovewr.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String signatureDocument = args[argOffset + 1];
-
- File signatureDocumentFile = new File(signatureDocument);
-
- if(!signatureDocumentFile.exists()) {
- throw new FileNotFoundException(signatureDocument);
- }
-
- getStatus().document = signatureDocumentFile;
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Document to sign argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.input") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.input") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java
deleted file mode 100644
index f3e7c1e2..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java
+++ /dev/null
@@ -1,70 +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.cliarguments;
-
-// Imports
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
-
-/**
- * CLI Argument to set the visibility of signature
- */
-public class InvisibleProfile extends Argument {
- /**
- * Constructor
- */
- public InvisibleProfile() {
- super(new String[] {"-v"}, "argument.help.vis");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(InvisibleProfile.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfovewr.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- log.info("Set Profile Invisible");
-
- if (args.length > argOffset + 1) {
- // TODO: this is a colossal monumental terrible hack
- PdfAs4SignatureParameter.PROFILE_VISIBILITY=false;
- log.debug("We are setting the profile visibility to false");
- return argOffset + 1;
- }
-
- } catch (Exception ex) {
- log.error("Signature Profile Visibilty Error", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.vis") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.vis") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreAliasArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreAliasArgument.java
deleted file mode 100644
index 1ef7531e..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreAliasArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the keystore alias
- */
-public class KeystoreAliasArgument extends Argument {
- /**
- * Constructor
- */
- public KeystoreAliasArgument() {
- super(new String[] {"-ksalias"}, "argument.help.keystorealias");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(KeystoreAliasArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String ksAlias = args[argOffset + 1];
-
- getConfiguration().setKeyStoreAliasOverlay(ksAlias);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Keystore alias argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorealias") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorealias") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreFileArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreFileArgument.java
deleted file mode 100644
index adc40dae..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreFileArgument.java
+++ /dev/null
@@ -1,75 +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.cliarguments;
-
-// Imports
-import java.io.File;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.gui.exceptions.KeystoreDoesntExistException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the keystore file
- */
-public class KeystoreFileArgument extends Argument {
- /**
- * Constructor
- */
- public KeystoreFileArgument() {
- super(new String[] {"-ks"}, "argument.help.keystorefile");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(KeystoreFileArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String ksFile = args[argOffset + 1];
-
- File ks = new File(ksFile);
- if(!ks.exists() || !ks.isFile())
- throw new KeystoreDoesntExistException(ks, 0);
-
- getConfiguration().setKeyStoreFileOverlay(ksFile);
- getConfiguration().setKeyStoreEnabledOverlay(true);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Keystore file argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorefile") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorefile") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreKeyPassArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreKeyPassArgument.java
deleted file mode 100644
index f41bbeaa..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreKeyPassArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the keystore key password
- */
-public class KeystoreKeyPassArgument extends Argument {
- /**
- * Constructor
- */
- public KeystoreKeyPassArgument() {
- super(new String[] {"-kskeypass"}, "argument.help.keystorekeypass");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(KeystoreKeyPassArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String ksKeyPass = args[argOffset + 1];
-
- getConfiguration().setKeyStoreKeyPassOverlay(ksKeyPass);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Keystore key password argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorekeypass") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorekeypass") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreStorePassArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreStorePassArgument.java
deleted file mode 100644
index 3c759743..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreStorePassArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the keystore password
- */
-public class KeystoreStorePassArgument extends Argument {
- /**
- * Constructor
- */
- public KeystoreStorePassArgument() {
- super(new String[] {"-kspass"}, "argument.help.keystorestorepass");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(KeystoreStorePassArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String ksStorePass = args[argOffset + 1];
-
- getConfiguration().setKeyStoreStorePassOverlay(ksStorePass);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Keystore password argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorestorepass") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.keystorestorepass") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreTypeArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreTypeArgument.java
deleted file mode 100644
index fa29ba5d..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/KeystoreTypeArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the keystore type
- */
-public class KeystoreTypeArgument extends Argument {
- /**
- * Constructor
- */
- public KeystoreTypeArgument() {
- super(new String[] {"-kstype"}, "argument.help.keystoretype");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(KeystoreTypeArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String ksType = args[argOffset + 1];
-
- getConfiguration().setKeyStoreTypeOverlay(ksType);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Keystore type argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.keystoretype") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.keystoretype") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java
deleted file mode 100644
index 047bf79c..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java
+++ /dev/null
@@ -1,74 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to show the usage message
- */
-public class OutputFolderArgument extends Argument {
- /**
- * Constructor
- */
- public OutputFolderArgument() {
- super(new String[] {"-o"}, "argument.help.output");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(OutputFolderArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
- String outputFolder = args[argOffset + 1];
-
-// File outputFolderDir = new File(outputFolder);
-// if(!outputFolderDir.exists()) {
-// throw new FileNotFoundException(outputFolder);
-// }
-// if(!outputFolderDir.isDirectory()) {
-// throw new IOException(outputFolderDir + Messages.getString("argument.error.output"));
-// }
-
- getConfiguration().setDefaultOutputFolderOverlay(outputFolder);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Output folder argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.output") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.output") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java
deleted file mode 100644
index cbfb1925..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java
+++ /dev/null
@@ -1,70 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.bku.mobile.MobileBKUValidator;
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide Mobile BKU password
- */
-public class PasswordArgument extends Argument {
- /**
- * Constructor
- */
- public PasswordArgument() {
- super(new String[] {"-p"}, "argument.help.password");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(PasswordArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String password = args[argOffset + 1];
-
- MobileBKUValidator.validatePassword(password);
-
- getConfiguration().setDefaultMobilePasswordOverlay(password);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Mobile BKU password argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.password") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.password") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java
deleted file mode 100644
index cc43d7e3..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java
+++ /dev/null
@@ -1,73 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.bku.mobile.MobileBKUValidator;
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide Mobile BKU phone number to use
- */
-public class PhoneNumberArgument extends Argument {
- /**
- * Constructor
- */
- public PhoneNumberArgument() {
- super(new String[] {"-n" }, "argument.help.number");
- }
-
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(PhoneNumberArgument.class);
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
-
- try {
- if (args.length > argOffset + 1) {
-
- String number = args[argOffset + 1];
-
- number = MobileBKUValidator.normalizeMobileNumber(number);
-
- getConfiguration().setDefaultMobileNumberOverlay(number);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Phone Number Argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.number") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.number") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java
deleted file mode 100644
index a77872e5..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the proxy host
- */
-public class ProxyHostArgument extends Argument {
- /**
- * Constructor
- */
- public ProxyHostArgument() {
- super(new String[] {"-proxy"}, "argument.help.proxyhost");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ProxyHostArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String proxyHost = args[argOffset + 1];
-
- getConfiguration().setProxyHostOverlay(proxyHost);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Proxy host argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyhost") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyhost") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPassArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPassArgument.java
deleted file mode 100644
index f9c4e533..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPassArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the proxy password
- */
-public class ProxyPassArgument extends Argument {
- /**
- * Constructor
- */
- public ProxyPassArgument() {
- super(new String[] {"-proxypass"}, "argument.help.proxypass");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ProxyPassArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String proxyPass = args[argOffset + 1];
-
- getConfiguration().setProxyPassOverlay(proxyPass);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Proxy password argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.proxypass") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.proxypass") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java
deleted file mode 100644
index ff9e84df..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java
+++ /dev/null
@@ -1,74 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.gui.exceptions.InvalidPortException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the proxy port
- */
-public class ProxyPortArgument extends Argument {
- /**
- * Constructor
- */
- public ProxyPortArgument() {
- super(new String[] {"-proxyport"}, "argument.help.proxyport");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ProxyPortArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String proxyPortString = args[argOffset + 1];
-
- int port = Integer.parseInt(proxyPortString);
-
- if(port <= 0 || port > 0xFFFF) {
- throw new InvalidPortException(port);
- }
-
- getConfiguration().setProxyPortOverlay(port);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Proxy port argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyport") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyport") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyUserArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyUserArgument.java
deleted file mode 100644
index 82944f9b..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyUserArgument.java
+++ /dev/null
@@ -1,67 +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.cliarguments;
-
-// Imports
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * CLI Argument to provide the proxy username
- */
-public class ProxyUserArgument extends Argument {
- /**
- * Constructor
- */
- public ProxyUserArgument() {
- super(new String[] {"-proxyuser"}, "argument.help.proxyuser");
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ProxyUserArgument.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- try {
- if (args.length > argOffset + 1) {
-
- String proxyUser = args[argOffset + 1];
-
- getConfiguration().setProxyUserOverlay(proxyUser);
-
- return argOffset + 1;
- }
- } catch (Exception ex) {
- log.error("Proxy username argument invalid!", ex);
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyuser") + this.getHelpText(), ex);
- }
-
- throw new InitializationException(
- Messages.getString("argument.invalid.proxyuser") + this.getHelpText(), null);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/SkipFinishArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/SkipFinishArgument.java
deleted file mode 100644
index 0c4247fd..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/SkipFinishArgument.java
+++ /dev/null
@@ -1,46 +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.cliarguments;
-
-import at.asit.pdfover.gui.exceptions.InitializationException;
-
-/**
- * CLI Argument to set the BKU to use
- */
-public class SkipFinishArgument extends Argument {
- /**
- * Constructor
- */
- public SkipFinishArgument() {
- super(new String[] { "-s" }, "argument.help.skipfinish");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang
- * .String[], int, at.asit.pdfover.gui.workflow.StateMachine,
- * at.asit.pdfover.gui.cliarguments.ArgumentHandler)
- */
- @Override
- public int handleArgument(String[] args, int argOffset,
- ArgumentHandler handler)
- throws InitializationException {
- getConfiguration().setSkipFinishOverlay(true);
- return argOffset;
- }
-}
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");
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java
deleted file mode 100644
index 0f3f1642..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java
+++ /dev/null
@@ -1,119 +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.controls;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-
-/**
- *
- */
-public class ClickableCanvas extends Canvas {
-
- private Image image = null;
-
- /**
- * @param parent
- * @param style
- */
- public ClickableCanvas(Composite parent, int style) {
- super(parent, style);
-
- this.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- ClickableCanvas.this.paintControl(e);
- }
- });
-
- final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND);
-
- this.addListener(SWT.Resize, (Event event) -> {
- ClickableCanvas.this.redraw();
- });
-
- this.setCursor(hand);
-
- }
-
- /**
- * Gets the image
- *
- * @return the image
- */
- public Image getImage() {
- return this.image;
- }
-
- /**
- * Sets the Image
- *
- * @param image
- * the imgage to set
- */
- public void setImage(Image image) {
- this.image = image;
- }
-
- /**
- * Main painting method
- *
- * @param e
- */
- void paintControl(PaintEvent e) {
- this.paintText(e);
- }
-
- /**
- * Paint the text or image on the button
- *
- * @param e
- */
- protected void paintText(PaintEvent e) {
- Point size = this.getSize();
- int width = size.x;
-
- // e.gc.fillGradientRectangle(0, 1, width, height / 4, true);
-
- if (this.image != null) {
-
- //log.debug("Width: " + width + " Height: " + height);
-
- int w = 0;
- Image tmp = null;
- if(this.image.getImageData().width < width) {
- tmp = new Image(getDisplay(), this.image.getImageData());
- w = (width - this.image.getImageData().width) / 2;
- } else if(this.image.getImageData().width > width) {
- tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(width, width));
- } else {
- tmp = new Image(getDisplay(), this.image.getImageData());
- }
-
- e.gc.drawImage(tmp, w, w);
- }
-
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java
deleted file mode 100644
index de3fb157..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/Dialog.java
+++ /dev/null
@@ -1,123 +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.controls;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A Message dialog
- */
-public class Dialog {
-
- private MessageBox box;
-
- /**
- * Message box buttons
- */
- public enum BUTTONS {
- /** Display only ok button */
- OK,
- /** Display buttons ok and cancel */
- OK_CANCEL,
- /** Display retry and cancel buttons */
- RETRY_CANCEL,
- /** Display abort, retry and ignore buttons */
- ABORT_RETRY_IGNORE,
- /** Display yes and no buttons */
- YES_NO
- };
-
- /**
- * Message box icon
- */
- public enum ICON {
- /** Error icon */
- ERROR,
- /** Information icon */
- INFORMATION,
- /** Question icon */
- QUESTION,
- /** Warning icon */
- WARNING,
- /** Working icon */
- WORKING
- };
-
- /**
- * @param parent The parent shell
- * @param title The dialog title
- * @param message The dialog message
- * @param button The BUTTONS to be shown
- * @param icon The ICON to be displayed
- */
- public Dialog(Shell parent, String title, String message, BUTTONS button, ICON icon) {
- this.initialize(parent, title, message, button, icon);
- }
-
- private void initialize(Shell parent, String title, String message, BUTTONS button, ICON icon) {
- int boxstyle = 0;
- switch (icon) {
- case ERROR:
- boxstyle |= SWT.ICON_ERROR;
- break;
- case INFORMATION:
- boxstyle |= SWT.ICON_INFORMATION;
- break;
- case QUESTION:
- boxstyle |= SWT.ICON_QUESTION;
- break;
- case WARNING:
- boxstyle |= SWT.ICON_WARNING;
- break;
- case WORKING:
- boxstyle |= SWT.ICON_WORKING;
- break;
- }
-
- switch(button) {
- case OK:
- boxstyle |= SWT.OK;
- break;
- case OK_CANCEL:
- boxstyle |= SWT.OK | SWT.CANCEL;
- break;
- case RETRY_CANCEL:
- boxstyle |= SWT.RETRY | SWT.CANCEL;
- break;
- case ABORT_RETRY_IGNORE:
- boxstyle |= SWT.RETRY | SWT.ABORT | SWT.IGNORE;
- break;
- case YES_NO:
- boxstyle |= SWT.YES | SWT.NO;
- }
-
- this.box = new MessageBox(parent, boxstyle);
- this.box.setMessage(message);
- this.box.setText(title);
- }
-
- /**
- * Open error dialog
- *
- * @return SWT.OK | SWT.IGNORE | SWT.ABORT | SWT.RETRY | SWT.CANCEL
- */
- public int open() {
- return this.box.open();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java
deleted file mode 100644
index f5b5bf9b..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorDialog.java
+++ /dev/null
@@ -1,36 +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.controls;
-
-// Imports
-import org.eclipse.swt.widgets.Shell;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- * An error dialog
- */
-public class ErrorDialog extends Dialog {
- /**
- * @param parent The parent shell
- * @param message The error message
- * @param button The buttons to be shown
- */
- public ErrorDialog(Shell parent, String message, BUTTONS button) {
- super(parent, Messages.getString("error.Title"),
- message, button, ICON.ERROR);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java
deleted file mode 100644
index bd99b887..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ErrorMarker.java
+++ /dev/null
@@ -1,79 +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.controls;
-
-// Imports
-import java.io.InputStream;
-
-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.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-
-/**
- *
- */
-public class ErrorMarker extends Label {
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(ErrorMarker.class);
-
- Image errorImg;
-
- /**
- * Draw an error marker for a faulty entry
- * @param parent the parent composite
- * @param style the SWT style
- * @param message a message describing the error (can be set later through setToolTipText)
- */
- public ErrorMarker(Composite parent, int style,
- String message) {
- super(parent, style);
-
- InputStream stream = this.getClass().getResourceAsStream(Constants.RES_IMG_ERROR);
-
- this.errorImg = new Image(getDisplay(), new ImageData(stream));
-
- this.addPaintListener(new PaintListener() {
- final Rectangle imgSize = ErrorMarker.this.errorImg.getBounds();
-
- @Override
- public void paintControl(PaintEvent e) {
- Rectangle dstSize = ErrorMarker.this.getBounds();
- e.gc.drawImage(ErrorMarker.this.errorImg,
- 0, 0, this.imgSize.width, this.imgSize.height,
- 0, 0, dstSize.width, dstSize.height);
- }
- });
-
- setToolTipText(message);
- }
-
- @Override
- protected void checkSubclass() {
- // Allow subclassing
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java
deleted file mode 100644
index 4845863f..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java
+++ /dev/null
@@ -1,160 +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.controls;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import at.asit.pdfover.gui.utils.SWTUtils;
-
-/**
- *
- */
-public class InputDialog extends org.eclipse.swt.widgets.Dialog {
- /**
- * SLF4J Logger instance
- **/
-// private static final Logger log = LoggerFactory
-// .getLogger(InputDialog.class);
-
- private String prompt;
- String input;
-
- /**
- * SWT flags of the input box
- */
- protected static int TEXT_FLAGS = SWT.BORDER;
-
- /**
- * Create a password input dialog
- * @param parent parent
- * @param title title
- * @param prompt prompt message
- */
- public InputDialog(Shell parent, String title, String prompt) {
- super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- setText(title);
- setMessage(prompt);
- }
-
- /**
- * Get the prompt message
- * @return the prompt message
- */
- public String getPrompt() {
- return this.prompt;
- }
-
- /**
- * set the prompt message
- * @param message the prompt message
- */
- public void setMessage(String message) {
- this.prompt = message;
- }
-
- /**
- * Get the input
- * @return the input
- */
- public String getInput() {
- return this.input;
- }
-
- /**
- * Get the input
- * @param input the input
- */
- public void setInput(String input) {
- this.input = input;
- }
-
- /**
- * Open the dialog
- * @return the input
- */
- public String open() {
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText(getText());
- createContents(shell);
- shell.pack();
- shell.open();
- Display display = parent.getDisplay();
- Rectangle bounds = parent.getBounds();
- Rectangle main = shell.getBounds();
- shell.setLocation(
- bounds.x + (bounds.width - main.width) / 2,
- bounds.y + (bounds.height - main.height) / 2);
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- return getInput();
- }
-
- private void createContents(final Shell shell) {
- GridLayout layout = new GridLayout(2, false);
- layout.verticalSpacing = 10;
- layout.marginLeft = 5;
- layout.marginRight = 5;
- layout.marginTop = 5;
- shell.setLayout(layout);
- Label label = new Label(shell, SWT.NONE);
- label.setText(this.prompt);
- GridData data = new GridData();
- data.horizontalSpan = 2;
- label.setLayoutData(data);
- final Text text = new Text(shell, TEXT_FLAGS);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- text.setLayoutData(data);
- Button ok = new Button(shell, SWT.PUSH);
- SWTUtils.setLocalizedText(ok, "common.Ok");
- data = new GridData(GridData.FILL_HORIZONTAL);
- ok.setLayoutData(data);
- ok.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- InputDialog.this.input = text.getText();
- shell.close();
- }
- });
- Button cancel = new Button(shell, SWT.PUSH);
- SWTUtils.setLocalizedText(cancel, "common.Cancel");
- data = new GridData(GridData.FILL_HORIZONTAL);
- cancel.setLayoutData(data);
- cancel.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- InputDialog.this.input = null;
- shell.close();
- }
- });
- shell.setDefaultButton(ok);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java
deleted file mode 100644
index 52bdf55c..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarButton.java
+++ /dev/null
@@ -1,370 +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.controls;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-import at.asit.pdfover.commons.Constants;
-
-/**
- * Main Bar Button implementation
- */
-public abstract class MainBarButton extends Canvas {
-
- /**
- * If borders are drawn with a gradient effect this sets the size
- */
- public static final int GradientFactor = 5;
-
- /**
- * Number of pixel of the altitude of the triangle representing the arrow within the button shapes
- *
- * This should be a multiple of 2!
- */
- public static final int SplitFactor = 10;
-
- /**
- * the used text color
- */
- protected Color textColor = null;
-
- /**
- * the text size
- */
- protected int textsize = Constants.TEXT_SIZE_BUTTON;
-
- private Color inactiveBackground = null;
- private Color activeBackground1 = null;
- private Color borderColor = null;
- private Color activeBackground = null;
-
- private Color inactiveText = null;
-
- private String text = "";
-
- private boolean active = true;
-
- private Image image = null;
-
-
- /**
- * @param parent
- * @param style
- */
- public MainBarButton(Composite parent, int style) {
- super(parent, style);
- this.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- MainBarButton.this.paintControl(e);
- }
- });
-
- final Cursor hand = new Cursor(this.getDisplay(), SWT.CURSOR_HAND);
-
- this.addListener(SWT.Resize, new Listener() {
-
- @Override
- public void handleEvent(Event event) {
- MainBarButton.this.setRegion(MainBarButton.this
- .getCustomRegion());
- MainBarButton.this.redraw();
- }
- });
-
- this.setCursor(hand);
-
-
- this.inactiveBackground = Constants.MAINBAR_INACTIVE_BACK;
- this.activeBackground1 = Constants.MAINBAR_ACTIVE_BACK_DARK;
- this.activeBackground = Constants.MAINBAR_ACTIVE_BACK_LIGHT;
- //this.textColor = this.getForeground();
- this.textColor = Constants.MAINBAR_ACTIVE_TEXTCOLOR;
- //this.borderColor = new Color(getDisplay(), 0xf9, 0xf9, 0xf9);
- this.borderColor = this.getBackground();
- this.inactiveText = Constants.MAINBAR_INACTIVE_TEXTCOLOR;
- this.textsize = Constants.TEXT_SIZE_BUTTON;
-
- }
-
- /**
- * @param inactiveBackground
- * the inactiveBackground to set
- */
- public void setInactiveBackground(Color inactiveBackground) {
- this.inactiveBackground = inactiveBackground;
- }
-
- /**
- * @param activeBackground
- * the activeBackground to set
- */
- public void setActiveBackground(Color activeBackground) {
- this.activeBackground = activeBackground;
- }
-
- /**
- * @return the textsize
- */
- public int getTextsize() {
- return this.textsize;
- }
-
- /**
- * @param textsize
- * the textsize to set
- */
- public void setTextsize(int textsize) {
- this.textsize = textsize;
- }
-
- /**
- * @param textColor
- * the textColor to set
- */
- public void setTextColor(Color textColor) {
- this.textColor = textColor;
- }
-
- /**
- * @return the borderColor
- */
- public Color getBorderColor() {
- return this.borderColor;
- }
-
- /**
- * @param borderColor
- * the borderColor to set
- */
- public void setBorderColor(Color borderColor) {
- this.borderColor = borderColor;
- }
-
-
- /**
- * Gets the image
- *
- * @return the image
- */
- public Image getImage() {
- return this.image;
- }
-
- /**
- * Sets the Image
- *
- * @param image
- * the imgage to set
- */
- public void setImage(Image image) {
- this.image = image;
- }
-
- /**
- * Sets if this button is active
- *
- * @param active
- * the active state
- */
- public void setActive(boolean active) {
-
- this.active = active;
- if (this.active) {
- this.setBackground(this.activeBackground);
- } else {
- this.setBackground(this.inactiveBackground);
- }
- }
-
- /**
- * Gets if this button is active
- *
- * @return the active state
- */
- public boolean getActive() {
- return this.active;
- }
-
- /**
- * Gets the button text
- *
- * @return the text
- */
- public String getText() {
- return this.text;
- }
-
- /**
- * Sets the text for the button
- *
- * @param text
- * the text to set
- */
- public void setText(String text) {
- this.text = text;
- }
-
- /**
- * Paint 3D style borders
- *
- * @param e
- */
- protected void paintBackground(PaintEvent e) {
- Point size = this.getSize();
- int height = size.y - 4;
-
- int width = size.x;
-
- e.gc.setForeground(this.activeBackground1);
- e.gc.setBackground(this.activeBackground);
-
- e.gc.fillGradientRectangle(0, height, width, -1 * height, true);
-
- //e.gc.setBackground(activeBackground);
-
- // LEFT
- // e.gc.fillGradientRectangle(0, 0, factor, height, false);
-
- // RIGTH
- // e.gc.fillGradientRectangle(width, 0, -1 * (width / factor), height,
- // false);
-
- }
-
- /**
- * Main painting method
- *
- * @param e
- */
- void paintControl(PaintEvent e) {
- Color forecurrent = e.gc.getForeground();
- Color backcurrent = e.gc.getBackground();
-
- e.gc.setForeground(getBorderColor());
- if(this.getActive()) {
- this.paintBackground(e);
- }
-
- e.gc.setForeground(getBorderColor());
-
- this.paintButton(e);
-
- e.gc.setForeground(forecurrent);
- e.gc.setBackground(backcurrent);
-
- this.paintText(e);
- }
-
- /**
- * paint the inner button
- *
- * @param e
- */
- protected void paintButton(PaintEvent e) {
- // could be overwritten by subclasses
- }
-
- /**
- * Paint the text or image on the button
- *
- * @param e
- */
- protected void paintText(PaintEvent e) {
- Point size = this.getSize();
- int height = size.y;
-
- int width = size.x;
-
- // e.gc.fillGradientRectangle(0, 1, width, height / 4, true);
-
- if (this.image == null) {
- Color current = e.gc.getForeground();
-
- if(this.getActive() && this.isEnabled()) {
- e.gc.setForeground(this.textColor);
- } else {
- e.gc.setForeground(this.inactiveText);
- }
-
- String font_name = e.gc.getFont().getFontData()[0].getName();
-
- Font font = new Font(this.getDisplay(), font_name,
- this.getTextsize(),
- e.gc.getFont().getFontData()[0].getStyle());
-
- String text = this.getText();
- e.gc.setFont(font);
- size = e.gc.stringExtent(text);
- int texty = (height - size.y) / 2;
- int textx = (width - size.x) / 2;
- textx = this.changeTextPosition(textx);
- e.gc.drawText(this.getText(), textx, texty, true);
- font.dispose();
-
- e.gc.setForeground(current);
- } else {
-
- //log.debug("Width: " + width + " Height: " + height);
-
- int w = 0;
- Image tmp = null;
- if(this.image.getImageData().width < width) {
- tmp = new Image(getDisplay(), this.image.getImageData());
- w = (width - this.image.getImageData().width) / 2;
- } else if(this.image.getImageData().width > width) {
- tmp = new Image(getDisplay(), this.image.getImageData().scaledTo(width, width));
- } else {
- tmp = new Image(getDisplay(), this.image.getImageData());
- }
-
- e.gc.drawImage(tmp, w, w);
- }
-
- }
-
- /**
- * change the text position
- *
- * @param positionX
- * the position
- * @return the new position
- */
- protected int changeTextPosition(int positionX) {
- return positionX;
- }
-
- /**
- * Gets the region of the button
- *
- * @return the button region
- */
- protected abstract Region getCustomRegion();
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java
deleted file mode 100644
index 1e80aa36..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarEndButton.java
+++ /dev/null
@@ -1,97 +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.controls;
-
-// Imports
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Composite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class MainBarEndButton extends MainBarButton {
- /**
- * @param parent
- * @param style
- */
- public MainBarEndButton(Composite parent, int style) {
- super(parent, style);
- }
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MainBarEndButton.class);
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt
- * .events.PaintEvent)
- */
- @Override
- protected void paintButton(PaintEvent e) {
- Point size = this.getSize();
- int height = size.y - 3;
-
- int split = 10;
- int width = size.x - 1;
-
- e.gc.drawLine(0, 0, width, 0);
- e.gc.drawLine(width, 0, width, height);
- e.gc.drawLine(width, height, 0, height);
- e.gc.drawLine(0, height, 0+split, (height) / 2);
- e.gc.drawLine(0+split, (height) / 2, 0, 0);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion()
- */
- @Override
- protected Region getCustomRegion() {
- Point size = this.getSize();
-
- int height = size.y - 2;
-
- int split = SplitFactor;
-
- int width = size.x;
-
- Region reg = new Region();
- reg.add(new int[] { 0, 0, width, 0, width, height, 0, height,
- 0 + split, (height) / 2, 0, 0 });
- return reg;
- }
-
- /**
- * change the text position
- * @param positionX the position
- * @return the new position
- */
- @Override
- protected int changeTextPosition(int positionX) {
- return positionX + (SplitFactor / 2);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java
deleted file mode 100644
index 452f0a45..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarMiddleButton.java
+++ /dev/null
@@ -1,93 +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.controls;
-
-// Imports
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Composite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class MainBarMiddleButton extends MainBarButton {
- /**
- * @param parent
- * @param style
- */
- public MainBarMiddleButton(Composite parent, int style) {
- super(parent, style);
- }
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MainBarMiddleButton.class);
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt.events.PaintEvent)
- */
- @Override
- protected void paintButton(PaintEvent e) {
-
- Point size = this.getSize();
-
- int height = size.y - 3;
-
- int split = SplitFactor;
- int width = size.x - split;
-
- e.gc.drawLine(0, 0, width, 0);
- e.gc.drawLine(width, 0, width+split, (height) / 2);
- e.gc.drawLine(width+split, (height) / 2, width, height);
- e.gc.drawLine(width, height, 0, height);
- e.gc.drawLine(0, height, 0+split, (height) / 2);
- e.gc.drawLine(0+split, (height) / 2, 0, 0);
-
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion()
- */
- @Override
- protected Region getCustomRegion() {
- Point size = this.getSize();
-
- int height = size.y - 2;
-
- int split = SplitFactor;
-
- int width = size.x - split;
-
- Region reg = new Region();
- reg.add(new int[] {
- 0, 0,
- width, 0,
- width + split, (height) / 2,
- width, height,
- 0, height,
- 0+split, (height) / 2,
- 0, 0 });
-
- return reg;
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java
deleted file mode 100644
index 22a73b15..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarRectangleButton.java
+++ /dev/null
@@ -1,174 +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.controls;
-
-// Imports
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Composite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class MainBarRectangleButton extends MainBarButton {
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MainBarRectangleButton.class);
-
- private Image enabledImg = null;
- private Image disabledImg = null;
-
- /**
- * @param parent
- * @param style
- */
- public MainBarRectangleButton(Composite parent, int style) {
- super(parent, style);
- this.setActiveBackground(null);
- this.setInactiveBackground(null);
- }
-
- /**
- * Set the image to display while this control is enabled
- * @param enabledImg enabled image
- */
- public void setEnabledImage(Image enabledImg) {
- this.enabledImg = enabledImg;
- if (getEnabled())
- setImage(enabledImg);
- }
-
- /**
- * Set the image to display while this control is disabled
- * @param disabledImg disabled image
- */
- public void setDisabledImage(Image disabledImg) {
- this.disabledImg = disabledImg;
- if (!getEnabled())
- setImage(disabledImg);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt
- * .events.PaintEvent)
- */
- @Override
- protected void paintButton(PaintEvent e) {
-
- Point size = this.getSize();
-
- int height = size.y - 3;
-
- int width = size.x;
-
- e.gc.drawLine(0, 0, width, 0);
- e.gc.drawLine(width, 0, width, height);
- e.gc.drawLine(width, height, 0, height);
- e.gc.drawLine(0, height, 0, 0);
-
- }
-
- @Override
- protected void paintBackground(PaintEvent e) {
- Point size = this.getSize();
- int height = size.y - 2;
-
- int width = size.x;
-
- int factor = GradientFactor;
-
- Region left_reg = new Region();
- left_reg.add(new int[] { 0, 0, factor, factor, factor, height-factor, 0, height, 0, 0 });
-
- Region right_reg = new Region();
- right_reg.add(new int[] { width, 0,
- width - factor, factor,
- width - factor, height-factor, width, height, width, 0 });
-
- Region top_reg = new Region();
- top_reg.add(new int[] {
- 0, 0,
- factor, factor,
- width - factor, factor,
- width, 0,
- 0, 0 });
-
- Region bottom_reg = new Region();
- bottom_reg.add(new int[] {
- 0, height,
- factor, height-factor,
- width - factor, height-factor,
- width, height, 0, height });
-
- e.gc.setClipping(top_reg);
-
- //TOP
- e.gc.fillGradientRectangle(0, 0, width, factor, true);
-
- e.gc.setClipping(bottom_reg);
-
- //BOTTOM
- e.gc.fillGradientRectangle(0, height, width, -1 * (factor),
- true);
-
- e.gc.setClipping(left_reg);
-
- // LEFT
- e.gc.fillGradientRectangle(0, 0, factor, height, false);
-
-
- e.gc.setClipping(right_reg);
- // RIGTH
- e.gc.fillGradientRectangle(width, 0, -1 * factor, height,
- false);
-
- e.gc.setClipping((Region)null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.controls.MainBarButton#getCustomRegion()
- */
- @Override
- protected Region getCustomRegion() {
- Point size = this.getSize();
-
- int height = size.y - 2;
-
- int width = size.x;
-
- Region reg = new Region();
- reg.add(new int[] { 0, 0, width, 0, width, height, 0, height, 0, 0 });
- return reg;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- setImage(enabled ? this.enabledImg : this.disabledImg);
- super.setEnabled(enabled);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java
deleted file mode 100644
index ef03fdcb..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/MainBarStartButton.java
+++ /dev/null
@@ -1,154 +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.controls;
-
-// Imports
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.widgets.Composite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public class MainBarStartButton extends MainBarButton {
- /**
- * @param parent
- * @param style
- */
- public MainBarStartButton(Composite parent, int style) {
- super(parent, style);
- }
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MainBarStartButton.class);
-
- @Override
- protected void paintBackground(PaintEvent e) {
- super.paintBackground(e);
- /*
- Point size = this.getSize();
- int height = size.y - 2;
-
- int split = SplitFactor;
- int width = size.x - split;
-
- int factor = GradientFactor;
-
- Region left_reg = new Region();
- left_reg.add(new int[] { 0, 0, factor, factor, factor, height-factor, 0, height, 0, 0 });
-
- Region right1_reg = new Region();
- right1_reg.add(new int[] { width, 0,
- width - factor, factor,
- width - factor, height-factor, width, height, width, 0 });
-
- Region top_reg = new Region();
- top_reg.add(new int[] {
- 0, 0,
- factor, factor,
- width - factor, factor,
- width, 0,
- 0, 0 });
-
- Region bottom_reg = new Region();
- bottom_reg.add(new int[] {
- 0, height,
- factor, height-factor,
- width - factor, height-factor,
- width, height, 0, height });
-
- e.gc.setClipping(top_reg);
-
- //TOP
- e.gc.fillGradientRectangle(0, 0, width, factor, true);
-
- e.gc.setClipping(bottom_reg);
-
- //BOTTOM
- e.gc.fillGradientRectangle(0, height, width, -1 * (factor),
- true);
-
- e.gc.setClipping(left_reg);
-
- // LEFT
- e.gc.fillGradientRectangle(0, 0, factor, height, false);
-
-
- e.gc.setClipping(right1_reg);
- // RIGTH
- e.gc.fillGradientRectangle(width, 0, -1 * factor, height,
- false);
-
- e.gc.setClipping((Region)null);*/
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.controls.MainBarButton#paintButton(org.eclipse.swt.events.PaintEvent)
- */
- @Override
- protected void paintButton(PaintEvent e) {
-
- Point size = this.getSize();
-
- int height = size.y - 3;
-
- int split = SplitFactor;
- int width = size.x - split;
-
- e.gc.drawLine(0, 0, width, 0);
- e.gc.drawLine(width, 0, width + split, (height) / 2);
- e.gc.drawLine(width + split, (height) / 2, width, height);
- e.gc.drawLine(width, height, 0, height);
- e.gc.drawLine(0, height, 0, 0);
-
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.controls.MainBarButton#getRegion()
- */
- @Override
- protected Region getCustomRegion() {
- Point size = this.getSize();
-
- int height = size.y - 2;
-
- int split = SplitFactor;
-
- int width = size.x - split;
-
- Region reg = new Region();
- reg.add(new int[] { 0, 0, width, 0, width + split,
- (height) / 2, width, height, 0, height, 0, 0 });
- return reg;
- }
-
-
- /**
- * change the text position
- * @param positionX the position
- * @return the new position
- */
- @Override
- protected int changeTextPosition(int positionX) {
- return positionX - (SplitFactor / 2);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java
deleted file mode 100644
index 3a15c63a..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/PasswordInputDialog.java
+++ /dev/null
@@ -1,36 +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.controls;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- *
- */
-public class PasswordInputDialog extends InputDialog {
-
- /**
- * @param parent
- * @param title
- * @param prompt
- */
- public PasswordInputDialog(Shell parent, String title, String prompt) {
- super(parent, title, prompt);
- PasswordInputDialog.TEXT_FLAGS = SWT.BORDER | SWT.PASSWORD;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ATrustConnectionException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ATrustConnectionException.java
deleted file mode 100644
index 1b18c99c..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ATrustConnectionException.java
+++ /dev/null
@@ -1,40 +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.exceptions;
-
-// Imports
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class ATrustConnectionException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = -5826910929587650685L;
-
- /**
- * Constructor
- * @param file
- */
- public ATrustConnectionException() {
- super(Messages.getString("error.ATrustConnection"));
- }
-
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java
deleted file mode 100644
index 6bb72ffa..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/CantLoadKeystoreException.java
+++ /dev/null
@@ -1,36 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class CantLoadKeystoreException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = 7554121273052104624L;
-
- /**
- * @param resumeIndex The resume Index
- * @param cause The original exception
- */
- public CantLoadKeystoreException(Throwable cause, int resumeIndex) {
- super(Messages.getString("error.KeyStore"), cause, resumeIndex);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InitializationException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InitializationException.java
deleted file mode 100644
index 8f717391..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InitializationException.java
+++ /dev/null
@@ -1,35 +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.exceptions;
-
-/**
- *
- */
-public class InitializationException extends PDFOverGUIException {
- /**
- *
- */
- private static final long serialVersionUID = 433744698649684034L;
-
- /**
- * @param msg
- * @param cause
- */
- public InitializationException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidEmblemFile.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidEmblemFile.java
deleted file mode 100644
index 27295b1d..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidEmblemFile.java
+++ /dev/null
@@ -1,48 +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.exceptions;
-
-// Imports
-import java.io.File;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class InvalidEmblemFile extends PDFOverGUIException {
- /**
- *
- */
- private static final long serialVersionUID = -5826910929131650685L;
-
- /**
- * Constructor
- * @param file
- */
- public InvalidEmblemFile(final File file) {
- super(Messages.formatString("exception.InvalidEmblemFile", file.getAbsolutePath()));
- }
-
- /**
- * Constructor
- * @param file
- * @param reason
- */
- public InvalidEmblemFile(final File file, Throwable reason) {
- super(Messages.formatString("exception.InvalidEmblemFile", file.getAbsolutePath()), reason);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPasswordException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPasswordException.java
deleted file mode 100644
index 2067c0fc..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPasswordException.java
+++ /dev/null
@@ -1,35 +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.exceptions;
-
-/**
- * Base Class for Invalid password exceptions
- */
-public abstract class InvalidPasswordException extends PDFOverGUIException {
-
- /**
- *
- */
- private static final long serialVersionUID = 6735754648793405145L;
-
- /**
- * Invalid Password
- * @param msg
- */
- public InvalidPasswordException(String msg) {
- super(msg);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPortException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPortException.java
deleted file mode 100644
index 96c09663..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPortException.java
+++ /dev/null
@@ -1,46 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class InvalidPortException extends PDFOverGUIException {
- /**
- *
- */
- private static final long serialVersionUID = -4809078091773253962L;
-
-
- /**
- * Constructor with an invalid port number
- * @param port invalid port number
- */
- public InvalidPortException(int port) {
- super(Messages.formatString("exception.InvalidPort", Integer.toString(port), 1, 0xffff));
- }
-
- /**
- * Constructor with an invalid port string
- * @param source InvalidNumberFormat exception
- * @param portString invalid port string
- */
- public InvalidPortException(String portString, Throwable source) {
- super(Messages.formatString("exception.InvalidPort", portString, 1, 0xffff), source);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasDoesntExistException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasDoesntExistException.java
deleted file mode 100644
index da1a2fe9..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasDoesntExistException.java
+++ /dev/null
@@ -1,36 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class KeystoreAliasDoesntExistException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = 2264150118185552023L;
-
- /**
- * @param alias The keystore key alias
- * @param resumeIndex The resume Index
- */
- public KeystoreAliasDoesntExistException(final String alias, int resumeIndex) {
- super(Messages.formatString("error.KeyStoreAliasExist", alias), resumeIndex);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasNoKeyException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasNoKeyException.java
deleted file mode 100644
index 3b1d28cf..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreAliasNoKeyException.java
+++ /dev/null
@@ -1,36 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class KeystoreAliasNoKeyException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = -4030764219866181859L;
-
- /**
- * @param alias The keystore key alias
- * @param resumeIndex The resume Index
- */
- public KeystoreAliasNoKeyException(final String alias, int resumeIndex) {
- super(Messages.formatString("error.KeyStoreAliasNoKey", alias), resumeIndex);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java
deleted file mode 100644
index 9cd205d4..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreDoesntExistException.java
+++ /dev/null
@@ -1,38 +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.exceptions;
-
-import java.io.File;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class KeystoreDoesntExistException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = 8213496549933275086L;
-
- /**
- * @param keystore The keystore file
- * @param resumeIndex The resume Index
- */
- public KeystoreDoesntExistException(final File keystore, int resumeIndex) {
- super(Messages.formatString("error.KeyStoreFileNotExist", keystore.getPath()), resumeIndex);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreKeyPasswordException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreKeyPasswordException.java
deleted file mode 100644
index 907c5577..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/KeystoreKeyPasswordException.java
+++ /dev/null
@@ -1,35 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class KeystoreKeyPasswordException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = 7734648200275150410L;
-
- /**
- * @param resumeIndex The resume Index
- */
- public KeystoreKeyPasswordException(int resumeIndex) {
- super(Messages.getString("error.KeyStoreKeyPass"), resumeIndex);
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderDoesntExistException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderDoesntExistException.java
deleted file mode 100644
index cddaec98..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderDoesntExistException.java
+++ /dev/null
@@ -1,39 +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.exceptions;
-
-import java.io.File;
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class OutputfolderDoesntExistException extends ResumableException {
- /**
- *
- */
- private static final long serialVersionUID = -1005495921021280599L;
-
- /**
- * @param folder The file
- * @param resumeIndex The resume Index
- */
- public OutputfolderDoesntExistException(final File folder, int resumeIndex) {
- super(Messages.formatString("exception.PathNotExist", folder.getAbsolutePath()), resumeIndex);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderNotADirectoryException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderNotADirectoryException.java
deleted file mode 100644
index 9355ff87..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/OutputfolderNotADirectoryException.java
+++ /dev/null
@@ -1,39 +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.exceptions;
-
-// Imports
-import java.io.File;
-
-
-import at.asit.pdfover.commons.Messages;
-
-/**
- *
- */
-public class OutputfolderNotADirectoryException extends PDFOverGUIException {
- /**
- *
- */
- private static final long serialVersionUID = -3270628002264772405L;
-
- /**
- * @param folder The file
- */
- public OutputfolderNotADirectoryException(File folder) {
- super(Messages.formatString("exception.PathNotDirectory", folder.getAbsolutePath()));
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PDFOverGUIException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PDFOverGUIException.java
deleted file mode 100644
index bdfbe41d..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PDFOverGUIException.java
+++ /dev/null
@@ -1,58 +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.exceptions;
-
-/**
- * Base class for GUI Exceptions
- */
-public class PDFOverGUIException extends Exception {
- /**
- * Serial Version UID
- */
- private static final long serialVersionUID = -3942861617701033882L;
-
- /**
- * Constructor
- */
- public PDFOverGUIException() {
- }
-
- /**
- * Constructor
- * @param msg Exception message
- */
- public PDFOverGUIException(String msg) {
- super(msg);
- }
-
- /**
- * Constructor
- * @param cause Exception causing this one
- */
- public PDFOverGUIException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructor
- * @param msg Exception message
- * @param cause Exception causing this one
- */
- public PDFOverGUIException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooLongException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooLongException.java
deleted file mode 100644
index 6ea2b662..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooLongException.java
+++ /dev/null
@@ -1,38 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-// Imports
-
-/**
- *
- */
-public class PasswordTooLongException extends InvalidPasswordException {
-
- /**
- * Constructor
- */
- public PasswordTooLongException() {
- super(Messages.getString("exception.PasswordTooLong"));
- }
- /**
- *
- */
- private static final long serialVersionUID = -3268343884240608304L;
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooShortException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooShortException.java
deleted file mode 100644
index ac1eafb0..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooShortException.java
+++ /dev/null
@@ -1,38 +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.exceptions;
-
-import at.asit.pdfover.commons.Messages;
-
-// Imports
-
-/**
- *
- */
-public class PasswordTooShortException extends InvalidPasswordException {
- /**
- *
- */
- private static final long serialVersionUID = 3015765967751806169L;
-
- /**
- * Constructor
- */
- public PasswordTooShortException() {
- super(Messages.getString("exception.PasswordTooShort"));
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ResumableException.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ResumableException.java
deleted file mode 100644
index 7cec826f..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/ResumableException.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.exceptions;
-
-/**
- *
- */
-public class ResumableException extends PDFOverGUIException {
-
- /**
- *
- */
- private static final long serialVersionUID = -607216270516492225L;
-
- private int resumeIndex = 0;
-
- /**
- * Create a new resumable exception, thrown by a validator which can be ignored
- * @param msg Error message
- * @param resumeIndex Validator index to resume from
- */
- public ResumableException(String msg, int resumeIndex) {
- super(msg);
- this.resumeIndex = resumeIndex;
- }
-
- /**
- * Create a new resumable exception, thrown by a validator which can be ignored
- * @param msg Error message
- * @param cause Exception causing this one
- * @param resumeIndex Validator index to resume from
- */
- public ResumableException(String msg, Throwable cause, int resumeIndex) {
- super(msg, cause);
- this.resumeIndex = resumeIndex;
- }
-
- /**
- * Return the validator index to resume from
- * @return the resumeIndex
- */
- public int getResumeIndex() {
- return this.resumeIndex;
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/keystore/KeystoreUtils.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/keystore/KeystoreUtils.java
deleted file mode 100644
index 8b7bb59c..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/keystore/KeystoreUtils.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package at.asit.pdfover.gui.keystore;
-
-import java.io.File;
-import java.io.FileInputStream;
-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;
-
-public class KeystoreUtils {
- public static KeyStore tryLoadKeystore(File location, String storeType, String storePass) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
- KeyStore ks = KeyStore.getInstance(storeType);
- FileInputStream fis = new FileInputStream(location);
- try
- {
- ks.load(fis, storePass.toCharArray());
- } catch (IOException e) {
- UnrecoverableKeyException keyCause = (UnrecoverableKeyException)e.getCause();
- if (keyCause != null)
- throw keyCause;
- else
- throw e;
- }
- return ks;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/osx/CocoaUIEnhancer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/osx/CocoaUIEnhancer.java
deleted file mode 100644
index 60e39aac..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/osx/CocoaUIEnhancer.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * Copyright 2014 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.osx;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.internal.C;
-import org.eclipse.swt.internal.Callback;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Listener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-
-/**
- * Provide a hook to connecting the Preferences, About and Quit menu items of
- * the Mac OS X Application menu when using the SWT Cocoa bindings.
- * <p>
- * This code does not require the Cocoa SWT JAR in order to be compiled as it
- * uses reflection to access the Cocoa specific API methods. Use SWT Listeners
- * instead in order to use this class in SWT only applications.
- *
- * </p>
- * <p>
- * This code was influenced by the <a
- * href="http://www.transparentech.com/opensource/cocoauienhancer"
- * >CocoaUIEnhancer - Connect the About, Preferences and Quit menus in Mac OS X
- * Cocoa SWT and JFace applications</a>.
- * </p>
- * <p>
- * This class works with both the 32-bit and 64-bit versions of the SWT Cocoa
- * bindings.
- * <p>
- * <p>
- * This class is released under the Eclipse Public License (<a
- * href="http://www.eclipse.org/legal/epl-v10.html">EPL</a>).
- */
-public class CocoaUIEnhancer {
- static final Logger log = LoggerFactory.getLogger(CocoaUIEnhancer.class);
-
- private static final long kAboutMenuItem = 0;
- private static final long kPreferencesMenuItem = 2;
- // private static final long kServicesMenuItem = 4;
- private static final long kHideApplicationMenuItem = 6;
- private static final long kQuitMenuItem = 10;
-
- static long sel_toolbarButtonClicked_;
- static long sel_preferencesMenuItemSelected_;
- static long sel_aboutMenuItemSelected_;
- static long sel_hideApplicationMenuItemSelected_;
-
- static Callback proc3Args;
-
- /**
- * Class invoked via the Callback object to run the about and preferences
- * actions.
- */
- private static class MenuHookObject {
-
- final Listener about;
- final Listener pref;
-
- public MenuHookObject(final Listener aboutListener,
- final Listener preferencesListener) {
- this.about = aboutListener;
- this.pref = preferencesListener;
- }
-
- /**
- * Will be called on 32bit SWT.
- * @param id
- * @param sel
- * @param arg0
- * @return x
- */
- @SuppressWarnings("unused")
- public int actionProc(final int id, final int sel, final int arg0) {
- return (int) this.actionProc((long) id, (long) sel, (long) arg0);
- }
-
- /**
- * Will be called on 64bit SWT.
- * @param id
- * @param sel
- * @param arg0
- * @return x
- */
- public long actionProc(final long id, final long sel, final long arg0) {
- if (sel == sel_aboutMenuItemSelected_) {
- if (log.isDebugEnabled()) {
- log.debug("[MenuHookObject - actionProc] : About");
- this.about.handleEvent(null);
- }
- } else if (sel == sel_preferencesMenuItemSelected_) {
- if (log.isDebugEnabled()) {
- log.debug("[MenuHookObject - actionProc] : Preferences");
- }
- this.pref.handleEvent(null);
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("[MenuHookObject - actionProc] : Unknow selection!");
- }
- }
- // Return value is not used.
- return 99;
- }
-
- // Getters and setters
- @SuppressWarnings("unused")
- public Listener getAbout() {
- return this.about;
- }
-
- @SuppressWarnings("unused")
- public Listener getPref() {
- return this.pref;
- }
- }
-
- /**
- * Hook the given Listener to the Mac OS X application Quit menu and the
- * IActions to the About and Preferences menus.
- *
- * @param display
- * The Display to use.
- * @param quitListener
- * The listener to invoke when the Quit menu is invoked.
- * @param aboutListener
- * The listener to invoke when the About menu is invoked.
- * @param preferencesListener
- * The listener to invoke when the Preferences menu is invoked.
- */
- public static void hookApplicationMenu(final Display display,
- final Listener quitListener, final Listener aboutListener,
- final Listener preferencesListener) {
- // This is our callbackObject whose 'actionProc' method will be called
- // when the About or
- // Preferences menuItem is invoked.
- final MenuHookObject target = new MenuHookObject(aboutListener,
- preferencesListener);
-
- try {
- // Initialize the menuItems.
- initialize(target);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
-
- // Connect the quit/exit menu.
- if (!display.isDisposed()) {
- display.addListener(SWT.Close, quitListener);
- }
-
- // Schedule disposal of callback object
- display.disposeExec(() -> {
- CocoaUIEnhancer.invoke(proc3Args, "dispose");
- });
- }
-
- private static void initialize(final Object callbackObject) throws Exception {
-
- final Class<?> osCls = classForName("org.eclipse.swt.internal.cocoa.OS");
-
- // Register names in objective-c.
- if (sel_toolbarButtonClicked_ == 0) {
- // sel_toolbarButtonClicked_ = registerName( osCls, "toolbarButtonClicked:" );
- sel_preferencesMenuItemSelected_ = registerName(osCls,
- "preferencesMenuItemSelected:");
- sel_aboutMenuItemSelected_ = registerName(osCls,
- "aboutMenuItemSelected:");
- }
-
- // Create an SWT Callback object that will invoke the actionProc method
- // of our internal
- // callbackObject.
- proc3Args = new Callback(callbackObject, "actionProc", 3);
- final Method getAddress = Callback.class.getMethod("getAddress",
- new Class[0]);
- Object object = getAddress.invoke(proc3Args, (Object[]) null);
- final long proc3 = convertToLong(object);
- if (proc3 == 0) {
- SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
- }
-
- final Class<?> nsmenuCls = classForName("org.eclipse.swt.internal.cocoa.NSMenu");
- final Class<?> nsmenuitemCls = classForName("org.eclipse.swt.internal.cocoa.NSMenuItem");
- final Class<?> nsstringCls = classForName("org.eclipse.swt.internal.cocoa.NSString");
- final Class<?> nsapplicationCls = classForName("org.eclipse.swt.internal.cocoa.NSApplication");
-
- // Instead of creating a new delegate class in objective-c,
- // just use the current SWTApplicationDelegate. An instance of this
- // is a field of the Cocoa Display object and is already the target
- // for the menuItems. So just get this class and add the new methods
- // to it.
- object = invoke(osCls, "objc_lookUpClass",
- new Object[] { "SWTApplicationDelegate" });
- final long cls = convertToLong(object);
-
- // Add the action callbacks for Preferences and About menu items.
- invoke(osCls, "class_addMethod", new Object[] { wrapPointer(cls),
- wrapPointer(sel_preferencesMenuItemSelected_),
- wrapPointer(proc3), "@:@" });
- invoke(osCls, "class_addMethod", new Object[] { wrapPointer(cls),
- wrapPointer(sel_aboutMenuItemSelected_), wrapPointer(proc3),
- "@:@" });
-
- // Get the Mac OS X Application menu.
- final Object sharedApplication = invoke(nsapplicationCls,
- "sharedApplication");
- final Object mainMenu = invoke(sharedApplication, "mainMenu");
- final Object mainMenuItem = invoke(nsmenuCls, mainMenu, "itemAtIndex",
- new Object[] { wrapPointer(0) });
- final Object appMenu = invoke(mainMenuItem, "submenu");
-
- // Create the About <application-name> menu command
- final Object aboutMenuItem = invoke(nsmenuCls, appMenu, "itemAtIndex",
- new Object[] { wrapPointer(kAboutMenuItem) });
- final Object nsStrAbout = invoke(nsstringCls, "stringWith",
- new Object[] { Messages.formatString("main.about", Constants.APP_NAME) });
- invoke(nsmenuitemCls, aboutMenuItem, "setTitle",
- new Object[] { nsStrAbout });
- // Rename the quit action.
- final Object quitMenuItem = invoke(nsmenuCls, appMenu,
- "itemAtIndex", new Object[] { wrapPointer(kQuitMenuItem) });
- final Object nsStrQuit = invoke(nsstringCls, "stringWith",
- new Object[] { Messages.formatString("main.quit", Constants.APP_NAME) });
- invoke(nsmenuitemCls, quitMenuItem, "setTitle",
- new Object[] { nsStrQuit });
-
- // Rename the hide action.
- final Object hideMenuItem = invoke(nsmenuCls, appMenu,
- "itemAtIndex",
- new Object[] { wrapPointer(kHideApplicationMenuItem) });
- final Object nsStrHide = invoke(nsstringCls, "stringWith",
- new Object[] { Messages.formatString("main.hide", Constants.APP_NAME) });
- invoke(nsmenuitemCls, hideMenuItem, "setTitle",
- new Object[] { nsStrHide });
-
- // Enable the Preferences menuItem.
- final Object prefMenuItem = invoke(nsmenuCls, appMenu, "itemAtIndex",
- new Object[] { wrapPointer(kPreferencesMenuItem) });
- invoke(nsmenuitemCls, prefMenuItem, "setEnabled", new Object[] { true });
-
- // Set the action to execute when the About or Preferences menuItem is
- // invoked.
-
- // We don't need to set the target here as the current target is the
- // SWTApplicationDelegate
- // and we have registerd the new selectors on it. So just set the new
- // action to invoke the
- // selector.
- invoke(nsmenuitemCls, prefMenuItem, "setAction",
- new Object[] { wrapPointer(sel_preferencesMenuItemSelected_) });
- invoke(nsmenuitemCls, aboutMenuItem, "setAction",
- new Object[] { wrapPointer(sel_aboutMenuItemSelected_) });
- }
-
- private static long registerName(final Class<?> osCls, final String name)
- throws IllegalArgumentException, SecurityException {
- final Object object = invoke(osCls, "sel_registerName",
- new Object[] { name });
- return convertToLong(object);
- }
-
- private static long convertToLong(final Object object) {
- if (object instanceof Integer) {
- final Integer i = (Integer) object;
- return i.longValue();
- }
- if (object instanceof Long) {
- final Long l = (Long) object;
- return l.longValue();
- }
- return 0;
- }
-
- private static Object wrapPointer(final long value) {
- final Class<?> PTR_CLASS = C.PTR_SIZEOF == 8 ? long.class : int.class;
- if (PTR_CLASS == long.class) {
- return Long.valueOf(value);
- }
- return Integer.valueOf((int) value);
- }
-
- private static Object invoke(final Class<?> clazz, final String methodName,
- final Object[] args) {
- return invoke(clazz, null, methodName, args);
- }
-
- private static Object invoke(final Class<?> clazz, final Object target,
- final String methodName, final Object[] args) {
- try {
- final Class<?>[] signature = new Class<?>[args.length];
- for (int i = 0; i < args.length; i++) {
- final Class<?> thisClass = args[i].getClass();
- if (thisClass == Integer.class) {
- signature[i] = int.class;
- } else if (thisClass == Long.class) {
- signature[i] = long.class;
- } else if (thisClass == Byte.class) {
- signature[i] = byte.class;
- } else if (thisClass == Boolean.class) {
- signature[i] = boolean.class;
- } else {
- signature[i] = thisClass;
- }
- }
- final Method method = clazz.getMethod(methodName, signature);
- return method.invoke(target, args);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- private static Class<?> classForName(final String classname) {
- try {
- final Class<?> cls = Class.forName(classname);
- return cls;
- } catch (final ClassNotFoundException e) {
- throw new IllegalStateException(e);
- }
- }
-
- private static Object invoke(final Class<?> cls, final String methodName) {
- return invoke(cls, methodName, (Class<?>[]) null, (Object[]) null);
- }
-
- private static Object invoke(final Class<?> cls, final String methodName,
- final Class<?>[] paramTypes, final Object... arguments) {
- try {
- final Method m = cls.getDeclaredMethod(methodName, paramTypes);
- return m.invoke(null, arguments);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- static Object invoke(final Object obj, final String methodName) {
- return invoke(obj, methodName, (Class<?>[]) null, (Object[]) null);
- }
-
- private static Object invoke(final Object obj, final String methodName,
- final Class<?>[] paramTypes, final Object... arguments) {
- try {
- final Method m = obj.getClass().getDeclaredMethod(methodName,
- paramTypes);
- return m.invoke(obj, arguments);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/FileUploadSource.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/FileUploadSource.java
deleted file mode 100644
index b0ff16ea..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/FileUploadSource.java
+++ /dev/null
@@ -1,57 +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.utils;
-
-// Imports
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.httpclient.methods.multipart.PartSource;
-
-import at.asit.pdfover.signer.DocumentSource;
-
-/**
- *
- */
-public class FileUploadSource implements PartSource {
-
- private DocumentSource source;
-
- /**
- * Constructor
- *
- * @param source
- * the source
- */
- public FileUploadSource(DocumentSource source) {
- this.source = source;
- }
-
- @Override
- public long getLength() {
- return this.source.getLength();
- }
-
- @Override
- public String getFileName() {
- return "sign.pdf";
- }
-
- @Override
- public InputStream createInputStream() throws IOException {
- return this.source.getInputStream();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.java
deleted file mode 100644
index 5d90ae6f..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/LocaleSerializer.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.utils;
-
-// Imports
-import java.util.Locale;
-
-import javax.annotation.Nonnull;
-
-import at.asit.pdfover.commons.Constants;
-
-/**
- *
- */
-public class LocaleSerializer {
- /**
- * Parse a locale from a string
- * @param localeString the string
- * @return the locale
- */
- public static Locale parseFromString(String localeString) {
-
- if(localeString == null || localeString.isEmpty()) {
- return null;
- }
-
- Locale targetLocale = null;
- Locale[] locale = Locale.getAvailableLocales();
- for(int i = 0; i < locale.length; i++) {
- if(locale[i].toString().equals(localeString)) {
- targetLocale = locale[i];
- break;
- }
- }
- return targetLocale;
- }
-
- /**
- * creates a parsable string for a locale
- * @param locale the locale
- * @return the parsable string
- */
- public static @Nonnull String getParsableString(Locale locale) {
- return Constants.ISNOTNULL(locale.toString());
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java
deleted file mode 100644
index 22e52467..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTUtils.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package at.asit.pdfover.gui.utils;
-
-import java.awt.Desktop;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.function.Consumer;
-
-import javax.annotation.Nullable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Messages;
-
-public final class SWTUtils {
-
- private static final Logger log = LoggerFactory.getLogger(SWTUtils.class);
-
- /* oh how i miss C++, and compile-time safety; this would be so much cleaner as a templated function */
- private static void genericSetText(Object swtObj, String text) {
- try {
- Method m = swtObj.getClass().getMethod("setText", String.class);
- m.invoke(swtObj, text);
- } catch (NoSuchMethodException | IllegalAccessException e) {
- log.error("Attempted to setLocalizedText on object of type {}, which does not have an accessible setText method", swtObj.getClass().getSimpleName(), e);
- } catch (InvocationTargetException e) {
- log.error("Failed to setLocalizedText on object of type {}", swtObj.getClass().getSimpleName(), e);
- }
-
- try {
- // request re-layout if possible, changing the text content will change the bounding box
- Method m = swtObj.getClass().getMethod("requestLayout");
- m.invoke(swtObj);
- } catch (NoSuchMethodException | IllegalAccessException e) {
- // do nothing, this may not exist on every control we use
- } catch (InvocationTargetException e) {
- log.error("Failed to re-layout {}", swtObj.getClass().getSimpleName(), e);
- }
- }
- public static void setLocalizedText(Object o, String messageKey) { genericSetText(o, Messages.getString(messageKey)); }
- public static void setLocalizedText(Object o, String formatMessageKey, Object... formatArgs) { genericSetText(o, Messages.formatString(formatMessageKey, formatArgs)); }
-
- private static void genericSetToolTipText(Object swtObj, String text) {
- try {
- Method m = swtObj.getClass().getMethod("setToolTipText", String.class);
- m.invoke(swtObj, text);
- } catch (NoSuchMethodException | IllegalAccessException e) {
- log.error("Attempted to setLocalizedToolTipText on object of type {}, which does not have an accessible setToolTipText method", swtObj.getClass().getSimpleName(), e);
- } catch (InvocationTargetException e) {
- log.error("Failed to setLocalizedToolTipText on object of type {}", swtObj.getClass().getSimpleName(), e);
- }
- }
- public static void setLocalizedToolTipText(Object o, String messageKey) { genericSetToolTipText(o, Messages.getString(messageKey));}
-
- public static void disableEventDefault(Control c, int event) {
- c.addListener(event, (Event e) -> { e.doit = false; });
- }
-
- public static void scrollPassthrough(Control c) {
- c.addListener(SWT.MouseVerticalWheel, (Event e) -> {
- // disable default handling
- e.doit = false;
-
- // find containing ScrolledComposite
- Composite target = c.getParent();
- while ((target != null) && !(target instanceof ScrolledComposite))
- target = target.getParent();
-
- if (target == null)
- return;
-
- // scroll containing ScrolledComposite
- ScrolledComposite sTarget = (ScrolledComposite)target;
- Point origin = sTarget.getOrigin();
- origin.y -= (e.count * 10);
- sTarget.setOrigin(origin);
- });
- }
-
- public static void setFontHeight(Control c, int height) {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setHeight(height);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static void setFontStyle(Control c, int style) {
- FontData[] fD = c.getFont().getFontData();
- fD[0].setStyle(style);
- Font font = new Font(c.getDisplay(), fD[0]);
- c.setFont(font);
- }
-
- public static class AnchorSetter {
- private final Control c;
- private final FormData fd;
- private AnchorSetter(Control c, boolean isNew)
- {
- this.c = c;
- if (isNew) {
- this.fd = new FormData();
- this.c.setLayoutData(this.fd);
- } else {
- Object layoutData = this.c.getLayoutData();
- try {
- this.fd = (FormData)layoutData;
- } catch (ClassCastException e) {
- log.error("Tried to reanchor() object with layout data of type {} (not FormData)", layoutData.getClass().getSimpleName(), e);
- throw new RuntimeException("Invalid reanchor() use");
- }
- }
- }
-
- public AnchorSetter height(int h) { fd.height = h; return this; }
- public AnchorSetter width(int w) { fd.width = w; return this; }
-
- public AnchorSetter top(FormAttachment a) { fd.top = a; return this; }
- public AnchorSetter left(FormAttachment a) { fd.left = a; return this; }
- public AnchorSetter right(FormAttachment a) { fd.right = a; return this; }
- public AnchorSetter bottom(FormAttachment a) { fd.bottom = a; return this; }
-
- public AnchorSetter top(Control control, int offset, int alignment) { return top(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter top(Control control, int offset) { return top(new FormAttachment(control, offset)); }
- public AnchorSetter top(Control control) { return top(new FormAttachment(control)); }
- public AnchorSetter top(int num, int offset) { return top(new FormAttachment(num, offset)); }
- public AnchorSetter top(int num) { return top(new FormAttachment(num)); }
-
- public AnchorSetter left(Control control, int offset, int alignment) { return left(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter left(Control control, int offset) { return left(new FormAttachment(control, offset)); }
- public AnchorSetter left(Control control) { return left(new FormAttachment(control)); }
- public AnchorSetter left(int num, int offset) { return left(new FormAttachment(num, offset)); }
- public AnchorSetter left(int num) { return left(new FormAttachment(num)); }
-
- public AnchorSetter right(Control control, int offset, int alignment) { return right(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter right(Control control, int offset) { return right(new FormAttachment(control, offset)); }
- public AnchorSetter right(Control control) { return right(new FormAttachment(control)); }
- public AnchorSetter right(int num, int offset) { return right(new FormAttachment(num, offset)); }
- public AnchorSetter right(int num) { return right(new FormAttachment(num)); }
-
- public AnchorSetter bottom(Control control, int offset, int alignment) { return bottom(new FormAttachment(control, offset, alignment)); }
- public AnchorSetter bottom(Control control, int offset) { return bottom(new FormAttachment(control, offset)); }
- public AnchorSetter bottom(Control control) { return bottom(new FormAttachment(control)); }
- public AnchorSetter bottom(int num, int offset) { return bottom(new FormAttachment(num, offset)); }
- public AnchorSetter bottom(int num) { return bottom(new FormAttachment(num)); }
- }
- public static AnchorSetter anchor(Control c) { return new AnchorSetter(c, true); }
- public static AnchorSetter reanchor(Control c) { return new AnchorSetter(c, false); }
-
- /**
- * functional-interface wrapper around swtObj.addSelectionListener
- * @param swtObj SWT widget supporting addSelectionListener
- * @param callback widgetSelected method
- */
- public static void addSelectionListener(Object swtObj, Consumer<SelectionEvent> callback) {
- try {
- Method m = swtObj.getClass().getMethod("addSelectionListener", SelectionListener.class);
- m.invoke(swtObj, new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { callback.accept(e); } });
- } catch (NoSuchMethodException | IllegalAccessException e) {
- log.error("Attempted to pass object of type {} to addSelectionListener; object does not have an accessible addSelectionListener method", swtObj.getClass().getSimpleName(), e);
- } catch (InvocationTargetException e) {
- log.error("Failed to add selection listener on object of type {}", swtObj.getClass().getSimpleName(), e);
- }
- }
-
- /**
- * @see SWTUtils#addSelectionListener(Object, Consumer)
- */
- public static void addSelectionListener(Object swtObj, Runnable callback) {
- addSelectionListener(swtObj, (e) -> { callback.run(); });
- }
-
- /**
- * functional-interface wrapper around swtObj.addMouseListener
- * @param swtObj SWT widget supporting addMouseListener
- * @param callback mouseDown method
- */
- public static void addMouseDownListener(Object swtObj, Consumer<MouseEvent> callback) {
- try {
- Method m = swtObj.getClass().getMethod("addMouseListener", MouseListener.class);
- m.invoke(swtObj, new MouseAdapter() { @Override public void mouseDown (MouseEvent e) { callback.accept(e); } });
- } catch (NoSuchMethodException | IllegalAccessException e) {
- log.error("Attempted to pass object of type {} to addMouseDownListener; object does not have an accessible addMouseListener method", swtObj.getClass().getSimpleName(), e);
- } catch (InvocationTargetException e) {
- log.error("Failed to add selection listeer on object of type {}", swtObj.getClass().getSimpleName(), e);
- }
- }
-
- /**
- * @see SWTUtils#addMouseDownListener(Object, Consumer)
- */
- public static void addMouseDownListener(Object swtObj, Runnable callback) {
- addMouseDownListener(swtObj, (e) -> { callback.run(); });
- }
-
- public static void openURL(@Nullable URI uri) {
- try {
- if (uri == null) return;
- if (Desktop.isDesktopSupported()) {
- Desktop.getDesktop().browse(uri);
- } else {
- Program.launch(uri.toURL().toExternalForm());
- }
- } catch (Exception e) {
- log.warn("Failed to open URI: {}", uri, e);
- }
- }
-
- public static void openURL(@Nullable String uri) {
- if (uri == null) return;
- try {
- openURL(new URI(uri));
- } catch (URISyntaxException e) {
- log.warn("Failed to open URI: {}", uri, e);
- }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/UpdateCheckManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/UpdateCheckManager.java
deleted file mode 100644
index 168f5b18..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/UpdateCheckManager.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package at.asit.pdfover.gui.utils;
-
-import java.util.ArrayList;
-import java.util.function.Consumer;
-
-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.bku.BKUHelper;
-import at.asit.pdfover.gui.controls.Dialog;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.Dialog.ICON;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-
-public final class UpdateCheckManager {
- private static final Logger log = LoggerFactory.getLogger(UpdateCheckManager.class);
- private static Thread updateCheckThread = null;
- private static boolean needsCheck = false;
-
- public enum Status { NOT_CHECKED, CHECKING, OUTDATED, UP_TO_DATE, FAILED };
- private static Status currentStatus = Status.NOT_CHECKED;
- public static Status getCurrentStatus() {
- synchronized (UpdateCheckManager.class) {
- return currentStatus;
- }
- }
-
- private static ArrayList<Consumer<Status>> statusCallbacks = new ArrayList<>();
- public static void registerStatusCallback(Consumer<Status> f) {
- synchronized (UpdateCheckManager.class) {
- statusCallbacks.add(f);
- f.accept(currentStatus);
- }
- }
-
- private static void setStatus(Status status) {
- synchronized(UpdateCheckManager.class) {
- currentStatus = status;
- for (Consumer<Status> f : statusCallbacks)
- f.accept(status);
- }
- }
-
- private static String latestVersionNotified = null;
- private static Status runCheck(Shell shell) {
- HttpClient client = (HttpClient) BKUHelper.getHttpClient();
- GetMethod method = new GetMethod(Constants.CURRENT_RELEASE_URL);
- try {
- client.executeMethod(method);
- final String version = method.getResponseBodyAsString().trim();
- if (!VersionComparator.before(Constants.APP_VERSION, version))
- return Status.UP_TO_DATE;
-
- if ((latestVersionNotified == null) || VersionComparator.before(latestVersionNotified, version)) {
- latestVersionNotified = version;
- // invoke GUI message in main thread
- shell.getDisplay().asyncExec(() -> {
- Dialog info = new Dialog(shell,
- Messages.getString("version_check.UpdateTitle"),
- Messages.formatString("version_check.UpdateText", version),
- BUTTONS.OK_CANCEL, ICON.INFORMATION);
-
- if (info.open() == SWT.OK)
- SWTUtils.openURL(Constants.UPDATE_URL);
- });
- }
-
- return Status.OUTDATED;
- } catch (Exception e) {
- log.error("Error downloading update information: ", e);
- return Status.FAILED;
- }
- }
-
- public static void checkNow(Shell shell) {
- if (Constants.APP_VERSION == null)
- return;
-
- synchronized (UpdateCheckManager.class) {
- if (updateCheckThread != null)
- return;
-
- needsCheck = true;
- updateCheckThread = new Thread(() -> {
- synchronized(UpdateCheckManager.class) {
- setStatus(Status.CHECKING);
- }
- while (true) {
- Status status = runCheck(shell);
- synchronized (UpdateCheckManager.class) {
- if (!UpdateCheckManager.needsCheck) {
- setStatus(status);
- UpdateCheckManager.updateCheckThread = null;
- return;
- }
- UpdateCheckManager.needsCheck = false;
- setStatus(Status.CHECKING);
- }
- }
- });
- updateCheckThread.start();
- }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/VersionComparator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/VersionComparator.java
deleted file mode 100644
index 9d06dfb1..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/VersionComparator.java
+++ /dev/null
@@ -1,101 +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.utils;
-
-// Imports
-import java.util.Comparator;
-
-/**
- *
- */
-public class VersionComparator implements Comparator<String> {
- /* (non-Javadoc)
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(String v1, String v2) {
- String[] v1Parts = v1.split("\\.|-");
- String[] v2Parts = v2.split("\\.|-");
-
- int length = Math.max(v1Parts.length, v2Parts.length);
- for (int i = 0; i < length; ++i) {
- int v1Part = 0;
- try {
- if (i < v1Parts.length)
- v1Part = Integer.parseInt(v1Parts[i]);
- } catch (NumberFormatException e) {
- if (v1Parts[i].equals("SNAPSHOT"))
- v1Part = Integer.MAX_VALUE;
- }
-
- int v2Part = 0;
- try {
- if (i < v2Parts.length)
- v2Part = Integer.parseInt(v2Parts[i]);
- } catch (NumberFormatException e) {
- if (v2Parts[i].equals("SNAPSHOT"))
- v2Part = Integer.MAX_VALUE;
- }
-
- if (v1Part < v2Part)
- return -1;
- if (v1Part > v2Part)
- return 1;
- }
- return 0;
- }
-
- /**
- * Compare two version strings (static version)
- * @param v1 version 1
- * @param v2 version 2
- * @return -1 if v1 &lt; v2, 0 if v1 = v2, 1 if v1 &gt; v2
- */
- public static int compare_s(String v1, String v2) {
- VersionComparator vc = new VersionComparator();
- return vc.compare(v1, v2);
- }
-
- /**
- * Check two version strings for equality
- * @param v1 version 1
- * @param v2 version 2
- * @return v1 == v2
- */
- public static boolean equals(String v1, String v2) {
- return compare_s(v1, v2) == 0;
- }
-
- /**
- * Check two version strings for order
- * @param v1 version 1
- * @param v2 version 2
- * @return v1 &lt; v2
- */
- public static boolean before(String v1, String v2) {
- return compare_s(v1, v2) < 0;
- }
-
- /**
- * Check two version strings for order
- * @param v1 version 1
- * @param v2 version 2
- * @return v1 &gt; v2
- */
- public static boolean after(String v1, String v2) {
- return compare_s(v1, v2) > 0;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Zipper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Zipper.java
deleted file mode 100644
index a25de58a..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/Zipper.java
+++ /dev/null
@@ -1,128 +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.utils;
-
-// Imports
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Zipper/unzipper to backup/extract configuration
- */
-public class Zipper {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(Zipper.class);
-
- /**
- * Compresses the source path to Zip File output stream
- * @param sourcePath
- * @param os
- * @throws IOException
- */
- public static void zip(String sourcePath, OutputStream os) throws IOException {
- zip(sourcePath, os, false);
- }
-
- /**
- * Compresses the source path to Zip File output stream
- * @param sourcePath
- * @param os
- * @param doDelete whether to delete content after compression
- * @throws IOException
- */
- public static void zip(String sourcePath, OutputStream os, boolean doDelete) throws IOException {
- ZipOutputStream zos = new ZipOutputStream(os);
- File dir = new File(sourcePath);
- zip(dir, dir.toURI(), zos, doDelete);
- zos.close();
- }
-
- private static void zip(File f, URI root, ZipOutputStream zos, boolean doDelete) throws IOException {
- if (f.isDirectory()) {
- File[] subDirs = f.listFiles();
- for (File subDir : subDirs) {
- zip(subDir, root, zos, doDelete);
- if (doDelete && !f.toURI().equals(root))
- subDir.delete();
- }
- } else {
- URI path = root.relativize(f.toURI());
- ZipEntry entry = new ZipEntry(path.toString());
- zos.putNextEntry(entry);
- byte[] buffer = new byte[1024];
- int len;
- BufferedInputStream is = new BufferedInputStream(new FileInputStream(f));
- while ((len = is.read(buffer)) >= 0)
- zos.write(buffer, 0, len);
- is.close();
- zos.closeEntry();
- if (doDelete)
- f.delete();
- }
- }
-
- /**
- * Extracts Zip File input stream to target path
- * @param is
- * @param targetPath
- * @throws IOException
- */
- public static void unzip(InputStream is, String targetPath) throws IOException {
- ZipInputStream zis = new ZipInputStream(is);
- ZipEntry entry;
- // while there are entries I process them
- while ((entry = zis.getNextEntry()) != null) {
- log.debug("entry: " + entry.getName() + ", " ////
- + entry.getSize());
- // consume all the data from this entry
-
- if (entry.isDirectory()) {
- log.debug("Extracting directory: " + entry.getName());
-
- File nDir = new File(targetPath + File.separator + entry.getName());
- if(!nDir.exists()) {
- if(!nDir.mkdir()) {
- throw new IOException("Failed to create dir: " + entry.getName());
- }
- }
- continue;
- }
- byte[] buffer = new byte[1024];
- int len;
- BufferedOutputStream out = new BufferedOutputStream(
- new FileOutputStream(targetPath + File.separator + entry.getName()));
- while ((len = zis.read(buffer)) >= 0)
- out.write(buffer, 0, len);
-
- out.close();
- }
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java
deleted file mode 100644
index b5df6ff3..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.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.workflow;
-
-//Imports
-import java.lang.reflect.Constructor;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow;
-import at.asit.pdfover.gui.composites.StateComposite;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState;
-import at.asit.pdfover.gui.workflow.states.State;
-
-/**
- * Workflow holds logical state of signing process and updates the current
- * logical state
- */
-public class StateMachine {
-
- private static final Logger log = LoggerFactory.getLogger(StateMachine.class);
-
- public final Status status;
- public final ConfigurationManager configProvider;
- public final String[] cmdLineArgs;
-
- /**
- * Default constructor
- *
- * @param cmdLineArgs
- */
- public StateMachine(String[] cmdLineArgs) {
- this.status = new Status();
- this.status.setCurrentState(new PrepareConfigurationState(this));
- this.configProvider = new ConfigurationManager();
- this.cmdLineArgs = cmdLineArgs;
- }
-
- /**
- * Sets the workflow state
- * This method should be used to let the user jump
- * around between states. This Method also resets certain properties defined
- * by later states then state
- *
- * @param state
- */
- public void jumpToState(State state) {
- this.status.setCurrentState(state);
- this.invokeUpdate();
- }
-
- /**
- * Update workflow logic and let state machine do its job...
- */
- public synchronized void update() {
- State next = null;
- while (this.status.getCurrentState() != null) {
- State current = this.status.getCurrentState();
- try {
- current.run();
- } catch (Exception e) {
- log.error("StateMachine update: ", e);
- ErrorDialog errorState = new ErrorDialog(this.getMainShell(),
- Messages.getString("error.Unexpected"), BUTTONS.OK);
- //errorState.setException(e);
- //jumpToState(errorState);
- errorState.open();
- this.exit();
- }
-
- if (this.exit) {
- // exit request ignore
- next = null;
- this.status.setCurrentState(next);
- } else {
-
- if (this.mainWindow != null && !this.mainWindow.getShell().isDisposed()) {
- log.debug("Allowing MainWindow to update its state for " + current);
- current.updateMainWindowBehavior();
- this.mainWindow.applyBehavior();
- this.mainWindow.doLayout();
- }
-
- // TODO: i really want this to be a return value from run()
- next = current.nextState();
- if (next == current) {
- break;
- }
-
- if (next == null) {
- log.info("Next state is null -> exit");
- this.status.setCurrentState(next);
- break;
- }
-
- log.debug("Changing state from: "
- + current + " to "
- + next.toString());
- this.status.setCurrentState(next);
- }
- }
- }
-
- /**
- * Invoke Update in UI (Main) Thread
- */
- public void invokeUpdate() {
- if (this.display != null) {
- this.display.asyncExec(() -> {
- this.update();
- });
- }
- }
-
- private Display display = null;
-
- private Shell shell = null;
-
- private Composite container = null;
-
- private MainWindow mainWindow = null;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.workflow.StateMachine#display(org.eclipse.swt.widgets
- * .Composite)
- */
- public void display(StateComposite composite) {
- this.mainWindow.setTopControl(composite);
- }
-
- private void createMainWindow() {
- try {
-
- this.display = Display.getDefault();
-
- this.mainWindow = new MainWindow(this);
- this.mainWindow.open();
-
- this.shell = this.mainWindow.getShell();
-
- this.container = this.mainWindow.getContainer();
-
- this.shell.open();
- this.shell.layout();
- } catch (Exception e) {
- log.warn("Main-Window creation FAILED.", e);
- this.display = null;
- this.mainWindow = null;
- this.shell = null;
- this.container = null;
- throw e;
- }
- }
-
- /**
- * Gets the Shell for drawing the ui
- *
- * @return Composite
- */
- public synchronized Composite getComposite() {
- // Main window will be built on first call
- // returns SWT Composite container for states to draw their GUI
-
- if (this.container == null) {
- this.createMainWindow();
- }
-
- return this.container;
- }
-
- public <T> T createComposite(Class<T> compositeClass, int style, State state) {
- T composite = null;
- try {
- Constructor<T> constructor = compositeClass.getDeclaredConstructor(
- Composite.class, int.class, State.class);
- composite = constructor.newInstance(getComposite(), style, state);
- } catch (Exception e) {
- log.error("Could not create Composite for Class "
- + compositeClass.getName(), e);
- }
- return composite;
- }
-
- /**
- * Only returns a shell if one was already created ...
- *
- * @return
- */
- private Shell nonCreatingGetShell() {
- return this.shell;
- }
-
- private boolean exit = false;
-
- /**
- * Exists the Workflow
- */
- public void exit() {
- this.exit = true;
- if (this.shell != null) {
- this.shell.dispose();
- }
- }
-
- /**
- * Only returns a shell if one was already created ...
- *
- * @return
- */
- private Display nonCreatingGetDisplay() {
- return this.display;
- }
-
- /**
- * Workflow main entrance point
- */
- public void start() {
-
- // Call update to start processing ...
- update();
-
- // if a user interaction is required we have a shell ...
- Shell shell = nonCreatingGetShell();
- Display display = nonCreatingGetDisplay();
-
- if (this.status.getCurrentState() == null) {
- if (shell != null) {
- this.shell.dispose();
- }
- }
-
- if (shell != null && display != null) {
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.dispose();
- }
- }
-
-
- public synchronized Shell getMainShell() {
- if(this.shell == null) {
- this.createMainWindow();
- }
-
- return this.shell;
- }
-
- public void reloadResources() {
- this.mainWindow.reloadLocalization();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java
deleted file mode 100644
index ba5e5fd5..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.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.workflow;
-
-// Imports
-import java.io.File;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.BKUs;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.workflow.states.State;
-import at.asit.pdfover.signer.SignResult;
-import at.asit.pdfover.signer.SignaturePosition;
-import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
-
-public class Status {
- private static final Logger log = LoggerFactory.getLogger(Status.class);
-
- public File document = null;
-
- public SignaturePosition signaturePosition = null;
-
- public BKUs bku = BKUs.NONE;
-
- private State currentState = null;
-
- private State previousState = null;
-
- public PdfAs4SigningState signingState = null;
-
- public SignResult signResult = null;
-
- public final MainWindowBehavior behavior;
-
- public boolean searchForPlacehoderSignature = false;
-
- public Status() {
- this.behavior = new MainWindowBehavior();
- }
-
- public State getCurrentState() {
- return this.currentState;
- }
-
- public void setCurrentState(State newState) {
- log.debug("Changing from " + currentState + " to " + newState);
-
- if ((previousState != null) && (previousState != currentState) && (previousState != newState))
- {
- // Reference to previous state will be lost - perform cleanup
- log.debug("Cleaning up " + previousState);
- previousState.cleanUp();
- }
-
- this.previousState = currentState;
- this.currentState = newState;
- }
-
- public State getPreviousState() {
- return this.previousState;
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
deleted file mode 100644
index adf03913..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java
+++ /dev/null
@@ -1,196 +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.workflow.config;
-
-// Imports
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.Locale;
-import java.util.Objects;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-import at.asit.pdfover.commons.Profile;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-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.bku.mobile.MobileBKUValidator;
-import at.asit.pdfover.gui.exceptions.InvalidEmblemFile;
-import at.asit.pdfover.gui.exceptions.InvalidPortException;
-
-import static at.asit.pdfover.commons.Constants.ISNOTNULL;
-
-/**
- * Implementation of the configuration container
- */
-public class ConfigurationDataInMemory {
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(ConfigurationDataInMemory.class);
-
- /** the emblem size (in mm) for logo only signatures */
- public double logoOnlyTargetSize = Constants.DEFAULT_LOGO_ONLY_SIZE;
-
- /** the emblem File */
- protected String emblemFile = null;
- public String getEmblemPath() { return this.emblemFile; }
- public void setEmblem(String emblemFile) throws InvalidEmblemFile {
- if (emblemFile == null || emblemFile.trim().isEmpty()) {
- // Ok to set no file ...
- } else {
- File imageFile = new File(emblemFile);
- if (!imageFile.exists()) {
- throw new InvalidEmblemFile(imageFile,
- new FileNotFoundException(emblemFile));
- }
-
- try {
- Image img = new Image(Display.getDefault(), new ImageData(
- emblemFile));
-
- img.dispose();
- } catch (Exception ex) {
- throw new InvalidEmblemFile(imageFile, ex);
- }
- }
-
- this.emblemFile = emblemFile;
- }
-
- /** The mobile phone number */
- protected @CheckForNull String mobileNumber = null;
- public @CheckForNull String getMobileNumber() { return this.mobileNumber; }
- public void setMobileNumber(String number) {
- if(number == null || number.trim().isEmpty()) {
- this.mobileNumber = null;
- return;
- }
- this.mobileNumber = MobileBKUValidator.normalizeMobileNumber(number);
- }
-
- /** The mobile phone password */
- public @CheckForNull String mobilePassword = null;
-
- public boolean rememberPassword = false;
-
- /** Holds the proxy host */
- public @CheckForNull String proxyHost = null;
-
- /** Holds the proxy port number */
- protected int proxyPort = -1;
- public int getProxyPort() { return this.proxyPort; }
- public void setProxyPort(int port) throws InvalidPortException {
- if(port > 0 && port <= 0xFFFF) {
- this.proxyPort = port;
- return;
- }
- if(port == -1) {
- this.proxyPort = -1;
- return;
- }
- throw new InvalidPortException(port);
- }
-
- /** Holds the proxy username */
- public @CheckForNull String proxyUser = null;
-
- /** Holds the proxy password */
- public @CheckForNull String proxyPass = null;
-
- /** Holds the default BKU to use */
- public @Nonnull BKUs defaultBKU = BKUs.NONE;
-
- /** Holds the output folder */
- public @CheckForNull String outputFolder = null;
-
- /** Holds the signatureNote */
- public @CheckForNull String signatureNote = null;
-
- /** Holds the locale */
- public @CheckForNull Locale interfaceLocale = null;
-
- /** Holds the signature locale */
- public @CheckForNull Locale signatureLocale = null;
-
- /** Holds the PDF/A compatibility setting */
- public boolean signaturePDFACompat = false;
-
- /** Holds the default signature position */
- public boolean autoPositionSignature = false;
-
- /** Keystore signing options */
- public enum KeyStorePassStorageType { MEMORY, DISK };
- public @CheckForNull Boolean keystoreEnabled = null;
- public @CheckForNull String keystoreFile = null;
- public @CheckForNull String keystoreType = null;
- public @CheckForNull String keystoreAlias = null;
- public @CheckForNull KeyStorePassStorageType keystorePassStorageType = null;
- public @CheckForNull String keystoreStorePass = null;
- public @CheckForNull String keystoreKeyPass = null;
-
- /** Whether to automatically check for updates */
- public boolean updateCheck = true;
-
- /** Holds the main window size
- *
- * @IMPORTANT this must always be valid and non-null, even if configuration failed to load for whatever reason (it is used by error handlers!)
- */
- public @Nonnull Point mainWindowSize = new Point(Constants.DEFAULT_MAINWINDOW_WIDTH, Constants.DEFAULT_MAINWINDOW_HEIGHT);
-
- /** Whether to skip the output state */
- public boolean skipFinish = false;
-
- /** Whether to use an existing signature marker. */
- protected boolean useMarker = false;
- public boolean getUseMarker() { return this.useMarker; }
- public void setUseMarker(boolean useMarker) {
- this.useMarker = useMarker;
- if (useMarker) setUseSignatureFields(false);
- }
-
- /** Either QR-Code or signature fields as marker */
- protected boolean useSignatureFields = false;
- public boolean getUseSignatureFields() { return this.useSignatureFields; }
- public void setUseSignatureFields(boolean useFields) {
- this.useSignatureFields = useFields;
- if (useFields) setUseMarker(false);
- }
-
- /** describes if the placeholder search is enabled */
- public boolean enabledPlaceholderUsage = false;
-
- /** The Signature Profile */
- protected @CheckForNull Profile signatureProfile = null;
- public @Nonnull Profile getSignatureProfile() {
- return ISNOTNULL(Objects.requireNonNullElse(this.signatureProfile, Profile.SIGNATURBLOCK_SMALL));
- }
- public void setSignatureProfile(Profile profile) { this.signatureProfile = profile; }
-
- public @Nonnull String saveFilePostFix = Constants.DEFAULT_POSTFIX;
-
- /** whether fido2 authentication should be selected by default */
- public boolean fido2ByDefault = false;
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
deleted file mode 100644
index 39071667..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java
+++ /dev/null
@@ -1,919 +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.workflow.config;
-
-// Imports
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Properties;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-import at.asit.pdfover.commons.Profile;
-
-import org.apache.commons.io.FileUtils;
-import org.eclipse.swt.graphics.Point;
-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.exceptions.InvalidEmblemFile;
-import at.asit.pdfover.gui.exceptions.InvalidPortException;
-import at.asit.pdfover.gui.utils.LocaleSerializer;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
-import at.asit.pdfover.commons.Messages;
-
-import static at.asit.pdfover.commons.Constants.ISNOTNULL;
-
-/**
- * Implementation of the configuration provider and manipulator
- */
-public class ConfigurationManager {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(ConfigurationManager.class);
-
- private String configurationFile = Constants.DEFAULT_CONFIG_FILENAME;
-
- private boolean loaded = false;
-
- // The persistent configuration read from the config file
- private ConfigurationDataInMemory configuration;
-
- // The configuration overlay built from the cmd line args
- private ConfigurationDataInMemory configurationOverlay;
-
- // whether the configuration screen should crash on startup (for debugging purposes)
- public boolean crashOnConfig = false;
-
- /**
- * Constructor
- */
- public ConfigurationManager() {
- this.configuration = new ConfigurationDataInMemory();
- this.configurationOverlay = new ConfigurationDataInMemory();
- }
-
- static public void factoryResetPersistentConfig() {
- // tell logback to close all file handles
- ((ch.qos.logback.classic.LoggerContext)LoggerFactory.getILoggerFactory()).stop();
-
- File configDirectory = new File(Constants.CONFIG_DIRECTORY);
- File backupDirectory = new File(Constants.CONFIG_BACKUP_DIRECTORY);
-
- // delete existing backup, if any
- FileUtils.deleteQuietly(backupDirectory);
-
- // attempt 1: try to move the old config directory to a backup location
- try {
- FileUtils.moveDirectory(
- configDirectory,
- backupDirectory
- );
- } catch (Exception e) {
- System.out.println("Failed move config directory to backup location:");
- e.printStackTrace();
-
- // attempt 2: try to simply force delete the config directory
- try {
- FileUtils.forceDelete(configDirectory);
- } catch (Exception e2) {
- System.out.println("Failed to delete config directory:");
- e2.printStackTrace();
-
- // attempt 3: try to schedule the config directory for force deletion on JVM exit
- try {
- FileUtils.forceDeleteOnExit(configDirectory);
- } catch (Exception e3) {
- System.out.println("Failed to schedule config directory for deletion:");
- e3.printStackTrace();
- }
- }
- }
- }
-
- /* load from disk */
- public void loadFromDisk() throws IOException {
- if (loaded)
- throw new RuntimeException("ConfigProvider double load?");
-
- Properties diskConfig = new Properties();
-
- diskConfig.load(new FileInputStream(Constants.CONFIG_DIRECTORY + File.separator + getConfigurationFileName()));
-
- { /* for testing of error handlers */
- String crashProperty = diskConfig.getProperty("CRASH");
- if ("startup".equalsIgnoreCase(crashProperty))
- throw new RuntimeException("A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.\n(CRASH=startup is set.)");
- else if ("config".equalsIgnoreCase(crashProperty))
- this.crashOnConfig = true;
- else if (crashProperty != null)
- log.warn("Unknown value '{}' for CRASH property -- you want 'startup' or 'config'.", crashProperty);
- }
-
- setDefaultEmblemPersistent(diskConfig.getProperty(Constants.CFG_EMBLEM));
- try {
- String strProp = diskConfig.getProperty(Constants.CFG_LOGO_ONLY_SIZE);
- if (strProp != null)
- setLogoOnlyTargetSizePersistent(Double.parseDouble(strProp));
- } catch (NumberFormatException e) { log.info("Invalid value for CFG_LOGO_ONLY_SIZE ignored.", e); }
-
- setDefaultMobileNumberPersistent(diskConfig.getProperty(Constants.CFG_MOBILE_NUMBER));
- setRememberMobilePasswordPersistent(Constants.TRUE.equals(diskConfig.getProperty(Constants.CFG_MOBILE_PASSWORD_REMEMBER)));
-
- setProxyHostPersistent(diskConfig.getProperty(Constants.CFG_PROXY_HOST));
- setProxyUserPersistent(diskConfig.getProperty(Constants.CFG_PROXY_USER));
- setProxyPassPersistent(diskConfig.getProperty(Constants.CFG_PROXY_PASS));
-
- setDefaultOutputFolderPersistent(diskConfig.getProperty(Constants.CFG_OUTPUT_FOLDER));
-
- String postFix = diskConfig.getProperty(Constants.CFG_POSTFIX);
- if (postFix == null)
- setSaveFilePostFixPersistent(Constants.DEFAULT_POSTFIX);
- else
- setSaveFilePostFixPersistent(postFix);
-
- String localeString = diskConfig.getProperty(Constants.CFG_LOCALE);
-
- Locale targetLocale = LocaleSerializer.parseFromString(localeString);
- if (targetLocale != null)
- setInterfaceLocalePersistent(targetLocale);
-
- String signatureLocaleString = diskConfig.getProperty(Constants.CFG_SIGNATURE_LOCALE);
-
- Locale signatureTargetLocale = LocaleSerializer.parseFromString(signatureLocaleString);
- if (signatureTargetLocale != null)
- setSignatureLocalePersistent(signatureTargetLocale);
-
- String useMarker = diskConfig.getProperty(Constants.CFG_USE_MARKER);
- if (useMarker != null)
- setUseMarkerPersistent(useMarker.equalsIgnoreCase(Constants.TRUE));
-
- String useSignatureFields = diskConfig.getProperty(Constants.CFG_USE_SIGNATURE_FIELDS);
- if (useSignatureFields != null)
- setUseSignatureFieldsPersistent(useSignatureFields.equalsIgnoreCase(Constants.TRUE));
-
- String enablePlaceholder = diskConfig.getProperty(Constants.CFG_ENABLE_PLACEHOLDER);
- if (enablePlaceholder != null)
- setEnablePlaceholderUsagePersistent(enablePlaceholder.equalsIgnoreCase(Constants.TRUE));
-
- String signatureProfileName = diskConfig.getProperty(Constants.SIGNATURE_PROFILE);
- if (signatureProfileName != null)
- setSignatureProfilePersistent(Profile.getProfile(signatureProfileName));
-
- if (diskConfig.containsKey(Constants.CFG_SIGNATURE_NOTE))
- setSignatureNotePersistent(diskConfig.getProperty(Constants.CFG_SIGNATURE_NOTE));
- else
- setSignatureNotePersistent(getSignatureProfile().getDefaultSignatureBlockNote(getSignatureLocale()));
-
- String compat = diskConfig.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT);
- if (compat != null)
- setSignaturePdfACompatPersistent(compat.equalsIgnoreCase(Constants.TRUE));
-
- String proxyPortString = diskConfig.getProperty(Constants.CFG_PROXY_PORT);
- if (proxyPortString != null && !proxyPortString.trim().isEmpty())
- {
- int port = Integer.parseInt(proxyPortString);
-
- if (port > 0 && port <= 0xFFFF)
- setProxyPortPersistent(port);
- else
- log.warn("Proxy port is out of range!: " + port);
- }
-
- // Set Default BKU
- String bkuString = diskConfig.getProperty(Constants.CFG_BKU);
- BKUs defaultBKU = BKUs.NONE;
- if (bkuString != null) {
- try {
- defaultBKU = BKUs.valueOf(bkuString);
- } catch (IllegalArgumentException ex) {
- log.error("Invalid BKU config value " + bkuString + " using none!");
- defaultBKU = BKUs.NONE;
- } catch (NullPointerException ex) {
- log.error("Invalid BKU config value " + bkuString + " using none!");
- defaultBKU = BKUs.NONE;
- }
- }
- setDefaultBKUPersistent(defaultBKU);
-
- // Set MainWindow size
- int width = Constants.DEFAULT_MAINWINDOW_WIDTH;
- int height = Constants.DEFAULT_MAINWINDOW_HEIGHT;
- String size = diskConfig.getProperty(Constants.CFG_MAINWINDOW_SIZE);
- parse: {
- if (size == null)
- break parse;
- int pos = size.indexOf(',');
- if (pos <= 0)
- break parse;
-
- try {
- width = Integer.parseInt(size.substring(0, pos).trim());
- height = Integer.parseInt(size.substring(pos + 1).trim());
- } catch (NumberFormatException e) {
- log.debug("Couldn't parse main window size", e);
- // ignore parsing exception
- }
- }
- this.configuration.mainWindowSize = new Point(width, height);
-
- // Set Signature Position
- String signaturePositionStr = diskConfig.getProperty(Constants.CFG_SIGNATURE_POSITION);
- setAutoPositionSignaturePersistent(signaturePositionStr != null && signaturePositionStr.trim().equals("auto"));
-
- //Set keystore stuff
- String keystoreEnabled = diskConfig.getProperty(Constants.CFG_KEYSTORE_ENABLED);
- if (keystoreEnabled != null)
- setKeyStoreEnabledPersistent(keystoreEnabled.equalsIgnoreCase(Constants.TRUE));
- setKeyStoreFilePersistent(diskConfig.getProperty(Constants.CFG_KEYSTORE_FILE));
- setKeyStoreTypePersistent(diskConfig.getProperty(Constants.CFG_KEYSTORE_TYPE));
- setKeyStoreAliasPersistent(diskConfig.getProperty(Constants.CFG_KEYSTORE_ALIAS));
- setKeyStoreStorePassPersistent(diskConfig.getProperty(Constants.CFG_KEYSTORE_STOREPASS));
- setKeyStoreKeyPassPersistent(diskConfig.getProperty(Constants.CFG_KEYSTORE_KEYPASS));
- String storeTypeOnDisk = diskConfig.getProperty(Constants.CFG_KEYSTORE_PASSSTORETYPE);
- if (storeTypeOnDisk == null) /* auto-detect based on old config */
- {
- String oldKeyPass = getKeyStoreKeyPassPersistent();
- String oldStorePass = getKeyStoreStorePassPersistent();
- if ((oldKeyPass != null && !oldKeyPass.trim().isEmpty()) || (oldStorePass != null && !oldStorePass.trim().isEmpty())) /* previously stored password exists */
- storeTypeOnDisk = "disk";
- else
- storeTypeOnDisk = "memory";
- }
- if ("disk".equals(storeTypeOnDisk))
- setKeyStorePassStorageTypePersistent(KeyStorePassStorageType.DISK);
- else if ("memory".equals(storeTypeOnDisk))
- setKeyStorePassStorageTypePersistent(KeyStorePassStorageType.MEMORY);
- else
- setKeyStorePassStorageTypePersistent(null);
-
- // Set update check
- String updateCheck = diskConfig.getProperty(Constants.CFG_UPDATE_CHECK);
- if (updateCheck != null)
- setUpdateCheckPersistent(!updateCheck.equalsIgnoreCase(Constants.FALSE));
-
- setFido2ByDefaultPersistent(Constants.TRUE.equalsIgnoreCase(diskConfig.getProperty(Constants.CFG_FIDO2_BY_DEFAULT)));
-
- log.info("Successfully loaded config from: " + getConfigurationFileName());
- loaded = true;
- }
-
- private void setProperty(@Nonnull Properties props, @Nonnull String key, @Nonnull String value) { props.setProperty(key, value); }
- private void setPropertyIfNotNull(@Nonnull Properties props, @Nonnull String key, @CheckForNull String value) { if (value != null) setProperty(props, key, value); }
- private void setPropertyIfNotBlank(@Nonnull Properties props, @Nonnull String key, @Nonnull String value) { if (!value.isEmpty()) setProperty(props, key, value); }
- /* save to file */
- public void saveToDisk() throws IOException {
- String filename = this.getConfigurationFileName();
- File configFile = new File(Constants.CONFIG_DIRECTORY + File.separator + filename);
-
- Properties props = new Properties();
- props.clear();
-
- setProperty(props, Constants.CFG_BKU, ISNOTNULL(getDefaultBKUPersistent().name()));
-
- setPropertyIfNotNull(props, Constants.CFG_PROXY_HOST, getProxyHostPersistent());
- int proxyPort = getProxyPortPersistent();
- if (proxyPort != -1)
- setProperty(props, Constants.CFG_PROXY_PORT, ISNOTNULL(Integer.toString(proxyPort)));
- setPropertyIfNotNull(props, Constants.CFG_PROXY_USER, getProxyUserPersistent());
- setPropertyIfNotNull(props, Constants.CFG_PROXY_PASS, getProxyPassPersistent());
-
- setPropertyIfNotNull(props, Constants.CFG_EMBLEM, getDefaultEmblemPersistent());
- setProperty(props, Constants.CFG_LOGO_ONLY_SIZE, ISNOTNULL(Double.toString(getLogoOnlyTargetSize())));
-
- setPropertyIfNotNull(props, Constants.CFG_SIGNATURE_NOTE, getSignatureNote());
- setPropertyIfNotNull(props, Constants.CFG_MOBILE_NUMBER, getDefaultMobileNumberPersistent());
- if (getRememberMobilePassword())
- setProperty(props, Constants.CFG_MOBILE_PASSWORD_REMEMBER, Constants.TRUE);
- setPropertyIfNotNull(props, Constants.CFG_OUTPUT_FOLDER, getDefaultOutputFolderPersistent());
- setProperty(props, Constants.CFG_POSTFIX, getSaveFilePostFix());
-
- Point size = this.configuration.mainWindowSize;
- setProperty(props, Constants.CFG_MAINWINDOW_SIZE, size.x + "," + size.y);
-
- Locale configLocale = getInterfaceLocale();
- if(configLocale != null) {
- setProperty(props, Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale));
- }
-
- Locale signatureLocale = this.getSignatureLocale();
- if(signatureLocale != null) {
- setProperty(props, Constants.CFG_SIGNATURE_LOCALE, LocaleSerializer.getParsableString(signatureLocale));
- }
-
- if (getUseMarker())
- setProperty(props, Constants.CFG_USE_MARKER, Constants.TRUE);
-
- if (getUseSignatureFields()) {
- setProperty(props, Constants.CFG_USE_SIGNATURE_FIELDS, Constants.TRUE);
- }
-
- if (getEnablePlaceholderUsage()) {
- setProperty(props, Constants.CFG_ENABLE_PLACEHOLDER, Constants.TRUE);
- }
-
- if (getSignaturePdfACompat())
- setProperty(props, Constants.CFG_SIGNATURE_PDFA_COMPAT, Constants.TRUE);
-
- if (!getAutoPositionSignaturePersistent())
- setProperty(props, Constants.CFG_SIGNATURE_POSITION, "");
- else
- setProperty(props, Constants.CFG_SIGNATURE_POSITION, "auto");
-
- if (Constants.THEME != Constants.Themes.DEFAULT)
- setProperty(props, Constants.CFG_THEME, ISNOTNULL(Constants.THEME.name()));
-
- if (getKeyStoreEnabledPersistent())
- setProperty(props, Constants.CFG_KEYSTORE_ENABLED, Constants.TRUE);
- setPropertyIfNotBlank(props, Constants.CFG_KEYSTORE_FILE, getKeyStoreFilePersistent());
- setPropertyIfNotBlank(props, Constants.CFG_KEYSTORE_TYPE, getKeyStoreTypePersistent());
- setPropertyIfNotBlank(props, Constants.CFG_KEYSTORE_ALIAS, getKeyStoreAliasPersistent());
-
- KeyStorePassStorageType keystorePassStorageType = getKeyStorePassStorageType();
- if (keystorePassStorageType == null)
- setProperty(props, Constants.CFG_KEYSTORE_PASSSTORETYPE, "none");
- else if (keystorePassStorageType == KeyStorePassStorageType.MEMORY)
- setProperty(props, Constants.CFG_KEYSTORE_PASSSTORETYPE, "memory");
- else if (keystorePassStorageType == KeyStorePassStorageType.DISK)
- setProperty(props, Constants.CFG_KEYSTORE_PASSSTORETYPE, "disk");
-
- if (keystorePassStorageType == KeyStorePassStorageType.DISK)
- {
- String keystoreStorePass = getKeyStoreStorePassPersistent();
- if (keystoreStorePass == null)
- keystoreStorePass = "";
- setProperty(props, Constants.CFG_KEYSTORE_STOREPASS, keystoreStorePass);
- String keystoreKeyPass = getKeyStoreKeyPassPersistent();
- if (keystoreKeyPass == null)
- keystoreKeyPass = "";
- setProperty(props, Constants.CFG_KEYSTORE_KEYPASS, keystoreKeyPass);
- }
-
- if (!getUpdateCheck())
- setProperty(props, Constants.CFG_UPDATE_CHECK, Constants.FALSE);
-
- if (getFido2ByDefault())
- setProperty(props, Constants.CFG_FIDO2_BY_DEFAULT, Constants.TRUE);
-
- setProperty(props, Constants.SIGNATURE_PROFILE, ISNOTNULL(getSignatureProfile().name()));
-
-
- FileOutputStream outputstream = new FileOutputStream(configFile, false);
-
- props.store(outputstream, "Configuration file was generated!");
-
- log.info("Configuration file saved to " + configFile.getAbsolutePath());
- }
-
- static private <T> T fallThroughOnNull(T one, T two) { return (one != null) ? one : two; }
-
- public void setConfigurationFileName(String configurationFile)
- {
- if (this.configurationFile.equals(configurationFile))
- return;
- if (this.loaded)
- throw new RuntimeException("Cannot change configuration file path after it has been loaded");
- this.configurationFile = configurationFile;
- }
- public String getConfigurationFileName() { return this.configurationFile; }
-
- public void setDefaultBKUPersistent(@Nonnull BKUs bku) {
- this.configuration.defaultBKU = bku;
- }
-
- public void setDefaultBKUOverlay(@Nonnull BKUs bku) {
- this.configurationOverlay.defaultBKU = bku;
- }
-
- public @Nonnull BKUs getDefaultBKU() {
- BKUs bku = this.configurationOverlay.defaultBKU;
- if (bku == BKUs.NONE)
- bku = getDefaultBKUPersistent();
- return bku;
- }
-
- public @Nonnull BKUs getDefaultBKUPersistent() {
- return this.configuration.defaultBKU;
- }
-
- public void setAutoPositionSignaturePersistent(boolean state) {
- this.configuration.autoPositionSignature = state;
- }
-
- public void setAutoPositionSignatureOverlay() {
- this.configurationOverlay.autoPositionSignature = true;
- }
-
- public boolean getAutoPositionSignature() {
- return this.configurationOverlay.autoPositionSignature || getAutoPositionSignaturePersistent();
- }
-
- public boolean getAutoPositionSignaturePersistent() {
- return this.configuration.autoPositionSignature;
- }
-
- public void setDefaultMobileNumberPersistent(String number) {
- if (number == null || number.trim().isEmpty()) {
- this.configuration.setMobileNumber(null);
- } else {
- this.configuration.setMobileNumber(number);
- }
- }
-
- public void setDefaultMobileNumberOverlay(String number) {
- if (number == null || number.trim().isEmpty()) {
- this.configurationOverlay.setMobileNumber(null);
- } else {
- this.configurationOverlay.setMobileNumber(number);
- }
- }
-
- public @CheckForNull String getDefaultMobileNumber() {
- return fallThroughOnNull(this.configurationOverlay.getMobileNumber(), getDefaultMobileNumberPersistent());
- }
-
- public @CheckForNull String getDefaultMobileNumberPersistent() {
- return this.configuration.getMobileNumber();
- }
-
- public void setDefaultMobilePasswordOverlay(String password) {
- if (password == null || password.trim().isEmpty()) {
- this.configurationOverlay.mobilePassword = null;
- } else {
- this.configurationOverlay.mobilePassword = password;
- }
- }
-
- public @CheckForNull String getDefaultMobilePassword() {
- /* this does not exist as a permanent config variable */
- return this.configurationOverlay.mobilePassword;
- }
-
- public boolean getRememberMobilePassword() {
- return this.configuration.rememberPassword;
- }
-
- public void setRememberMobilePasswordPersistent(boolean state) {
- this.configuration.rememberPassword = state;
- }
-
- public void setDefaultEmblemPersistent(String emblem) {
- try {
- if (emblem == null || emblem.trim().isEmpty()) {
- this.configuration.setEmblem(null);
- } else {
- this.configuration.setEmblem(emblem);
- }
- } catch (InvalidEmblemFile e) {
- log.error("Error setting emblem file", e);
- try {
- this.configuration.setEmblem(null);
- } catch (InvalidEmblemFile e1) {
- // Ignore
- }
- }
- }
-
- public void setDefaultEmblemOverlay(String emblem) {
- try {
- if (emblem == null || emblem.trim().isEmpty()) {
- this.configurationOverlay.setEmblem(null);
- } else {
- this.configurationOverlay.setEmblem(emblem);
- }
- } catch (InvalidEmblemFile e) {
- log.error("Error setting emblem file", e);
- try {
- this.configurationOverlay.setEmblem(null);
- } catch (InvalidEmblemFile e1) {
- // Ignore
- }
- }
- }
-
- public @CheckForNull String getDefaultEmblemPath() {
- return fallThroughOnNull(this.configurationOverlay.getEmblemPath(), getDefaultEmblemPersistent());
- }
-
- public @CheckForNull String getDefaultEmblemPersistent() {
- return this.configuration.getEmblemPath();
- }
-
- public void setLogoOnlyTargetSizePersistent(double v) {
- this.configuration.logoOnlyTargetSize = v;
- }
-
- public double getLogoOnlyTargetSize() {
- return this.configuration.logoOnlyTargetSize;
- }
-
- public void setProxyHostPersistent(String host) {
- if (host == null || host.trim().isEmpty()) {
- this.configuration.proxyHost = null;
- } else {
- this.configuration.proxyHost = host;
- }
- }
-
- public void setProxyHostOverlay(String host) {
- if (host == null || host.trim().isEmpty()) {
- this.configurationOverlay.proxyHost = null;
- } else {
- this.configurationOverlay.proxyHost = host;
- }
- }
-
- public @CheckForNull String getProxyHost() {
- return fallThroughOnNull(this.configurationOverlay.proxyHost, getProxyHostPersistent());
- }
-
- public @CheckForNull String getProxyHostPersistent() {
- return this.configuration.proxyHost;
- }
-
- public void setProxyPortPersistent(int port) {
- try {
- this.configuration.setProxyPort(port);
- } catch (InvalidPortException e) {
- log.error("Error setting proxy port" , e);
- // ignore
- }
- }
-
- public void setProxyPortOverlay(int port) {
- try {
- this.configurationOverlay.setProxyPort(port);
- } catch (InvalidPortException e) {
- log.error("Error setting proxy port" , e);
- // ignore
- }
- }
-
- public int getProxyPort() {
- int port = this.configurationOverlay.getProxyPort();
- if (port == -1) // TODO -1 is a terrible, no good, very bad hack
- port = getProxyPortPersistent();
- return port;
- }
-
- public int getProxyPortPersistent() {
- return this.configuration.getProxyPort();
- }
-
- public void setProxyUserPersistent(String user) {
- if (user == null || user.trim().isEmpty()) {
- this.configuration.proxyUser = null;
- } else {
- this.configuration.proxyUser = user;
- }
- }
-
- public void setProxyUserOverlay(String user) {
- if (user == null || user.trim().isEmpty()) {
- this.configurationOverlay.proxyUser = null;
- } else {
- this.configurationOverlay.proxyUser = user;
- }
- }
-
- public @CheckForNull String getProxyUser() {
- return fallThroughOnNull(this.configurationOverlay.proxyUser, getProxyUserPersistent());
- }
-
- public @CheckForNull String getProxyUserPersistent() {
- return this.configuration.proxyUser;
- }
-
- public void setProxyPassPersistent(String pass) {
- if (pass == null || pass.trim().isEmpty()) {
- this.configuration.proxyPass = null;
- } else {
- this.configuration.proxyPass = pass;
- }
- }
-
- public void setProxyPassOverlay(String pass) {
- if (pass == null || pass.trim().isEmpty()) {
- this.configurationOverlay.proxyPass = null;
- } else {
- this.configurationOverlay.proxyPass = pass;
- }
- }
-
- public @CheckForNull String getProxyPass() {
- return fallThroughOnNull(this.configurationOverlay.proxyPass, getProxyPassPersistent());
- }
-
- public @CheckForNull String getProxyPassPersistent() {
- return this.configuration.proxyPass;
- }
-
- public void setDefaultOutputFolderPersistent(String outputFolder) {
- if (outputFolder == null || outputFolder.trim().isEmpty()) {
- this.configuration.outputFolder = null;
- } else {
- this.configuration.outputFolder = outputFolder;
- }
- }
-
- public void setDefaultOutputFolderOverlay(String outputFolder) {
- if (outputFolder == null || outputFolder.trim().isEmpty()) {
- this.configurationOverlay.outputFolder = null;
- } else {
- this.configurationOverlay.outputFolder = outputFolder;
- }
- }
-
- public @CheckForNull String getDefaultOutputFolder() {
- return fallThroughOnNull(this.configurationOverlay.outputFolder, getDefaultOutputFolderPersistent());
- }
-
- public @CheckForNull String getDefaultOutputFolderPersistent() {
- return this.configuration.outputFolder;
- }
-
- public void setSignatureNotePersistent(String note) {
- if (note == null || note.trim().isEmpty()) {
- this.configuration.signatureNote = null;
- } else {
- this.configuration.signatureNote = note;
- }
- }
-
- public @CheckForNull String getSignatureNote() {
- return this.configuration.signatureNote;
- }
-
- public void setInterfaceLocalePersistent(Locale locale) {
- if(locale == null) {
- this.configuration.interfaceLocale = Messages.getDefaultLocale();
- } else {
- this.configuration.interfaceLocale = locale;
- Locale.setDefault(locale);
- Messages.setLocale(locale);
- }
- }
-
- public @Nonnull Locale getInterfaceLocale() {
- Locale locale = this.configuration.interfaceLocale;
- if (locale == null)
- locale = Messages.getDefaultLocale();
- return locale;
- }
-
- public void setSignatureLocalePersistent(Locale locale) {
- if(locale == null) {
- this.configuration.signatureLocale = Messages.getDefaultLocale();
- } else {
- this.configuration.signatureLocale = locale;
- }
- }
-
- public @Nonnull Locale getSignatureLocale() {
- Locale locale = this.configuration.signatureLocale;
- if (locale == null)
- locale = Messages.getDefaultLocale();
- return locale;
- }
-
- public void setSignaturePdfACompatPersistent(boolean compat) {
- this.configuration.signaturePDFACompat = compat;
- }
-
- public boolean getSignaturePdfACompat() {
- return this.configuration.signaturePDFACompat;
- }
-
- public void setKeyStoreEnabledPersistent(Boolean enabled) {
- this.configuration.keystoreEnabled = enabled;
- }
-
- public void setKeyStoreEnabledOverlay(Boolean enabled) {
- this.configurationOverlay.keystoreEnabled = enabled;
- }
-
- public boolean getKeyStoreEnabled() {
- return ISNOTNULL(fallThroughOnNull(this.configurationOverlay.keystoreEnabled, getKeyStoreEnabledPersistent()));
- }
-
- public boolean getKeyStoreEnabledPersistent() {
- return ISNOTNULL(fallThroughOnNull(this.configuration.keystoreEnabled, Boolean.FALSE));
- }
-
- public void setKeyStoreFilePersistent(@CheckForNull String file) {
- if (file == null || file.trim().isEmpty()) {
- this.configuration.keystoreFile = "";
- } else {
- this.configuration.keystoreFile = file;
- }
- }
-
- public void setKeyStoreFileOverlay(@CheckForNull String file) {
- if (file == null || file.trim().isEmpty()) {
- this.configurationOverlay.keystoreFile = null;
- } else {
- this.configurationOverlay.keystoreFile = file;
- }
- }
-
- public @Nonnull String getKeyStoreFile() {
- return ISNOTNULL(fallThroughOnNull(this.configurationOverlay.keystoreFile, getKeyStoreFilePersistent()));
- }
-
- public @Nonnull String getKeyStoreFilePersistent() {
- return ISNOTNULL(this.configuration.keystoreFile);
- }
-
- public void setKeyStoreTypePersistent(@CheckForNull String type) {
- if (type == null || type.trim().isEmpty()) {
- this.configuration.keystoreType = "";
- } else {
- this.configuration.keystoreType = type;
- }
- }
-
- public void setKeyStoreTypeOverlay(@CheckForNull String type) {
- if (type == null || type.trim().isEmpty()) {
- this.configurationOverlay.keystoreType = null;
- } else {
- this.configurationOverlay.keystoreType = type;
- }
- }
-
- public @Nonnull String getKeyStoreType() {
- return ISNOTNULL(fallThroughOnNull(this.configurationOverlay.keystoreType, getKeyStoreTypePersistent()));
- }
-
- public @Nonnull String getKeyStoreTypePersistent() {
- return ISNOTNULL(this.configuration.keystoreType);
- }
-
- public void setKeyStoreAliasPersistent(@CheckForNull String alias) {
- if (alias == null || alias.trim().isEmpty()) {
- this.configuration.keystoreAlias = "";
- } else {
- this.configuration.keystoreAlias = alias;
- }
- }
-
- public void setKeyStoreAliasOverlay(@CheckForNull String alias) {
- if (alias == null || alias.trim().isEmpty()) {
- this.configurationOverlay.keystoreAlias = null;
- } else {
- this.configurationOverlay.keystoreAlias = alias;
- }
- }
-
- public @Nonnull String getKeyStoreAlias() {
- return ISNOTNULL(fallThroughOnNull(this.configurationOverlay.keystoreAlias, getKeyStoreAliasPersistent()));
- }
-
- public @Nonnull String getKeyStoreAliasPersistent() {
- return ISNOTNULL(this.configuration.keystoreAlias);
- }
-
- public void setKeyStorePassStorageTypePersistent(@CheckForNull KeyStorePassStorageType type) {
- this.configuration.keystorePassStorageType = type;
- }
-
- public @CheckForNull KeyStorePassStorageType getKeyStorePassStorageType() {
- return this.configuration.keystorePassStorageType;
- }
-
- public void setKeyStoreStorePassPersistent(@CheckForNull String storePass) {
- this.configuration.keystoreStorePass = storePass;
- }
-
- public void setKeyStoreStorePassOverlay(@CheckForNull String storePass) {
- this.configurationOverlay.keystoreStorePass = storePass;
- }
-
- public @CheckForNull String getKeyStoreStorePass() {
- String storePass = this.configurationOverlay.keystoreStorePass;
- if (storePass != null)
- return storePass;
- if (getKeyStorePassStorageType() != KeyStorePassStorageType.DISK)
- return null;
- return getKeyStoreStorePassPersistent();
- }
-
- public @CheckForNull String getKeyStoreStorePassPersistent() {
- return this.configuration.keystoreStorePass;
- }
-
- public void setKeyStoreKeyPassPersistent(@CheckForNull String keyPass) {
- this.configuration.keystoreKeyPass = keyPass;
- }
-
- public void setKeyStoreKeyPassOverlay(@CheckForNull String keyPass) {
- this.configurationOverlay.keystoreKeyPass = keyPass;
- }
-
- public @CheckForNull String getKeyStoreKeyPass() {
- String keyPass = this.configurationOverlay.keystoreKeyPass;
- if (keyPass != null)
- return keyPass;
- if (getKeyStorePassStorageType() != KeyStorePassStorageType.DISK)
- return null;
- return getKeyStoreKeyPassPersistent();
- }
-
- public @CheckForNull String getKeyStoreKeyPassPersistent() {
- return this.configuration.keystoreKeyPass;
- }
-
- public void setUpdateCheckPersistent(boolean checkUpdate) {
- this.configuration.updateCheck = checkUpdate;
- }
-
- public boolean getUpdateCheck() {
- return this.configuration.updateCheck;
- }
-
- public void setMainWindowSizePersistent(@Nonnull Point size) {
- this.configuration.mainWindowSize = size;
- }
-
- public @Nonnull Point getMainWindowSize() {
- return this.configuration.mainWindowSize;
- }
-
- public boolean getSkipFinish() {
- return this.configurationOverlay.skipFinish;
- }
-
- public void setSkipFinishOverlay(boolean skipFinish) {
- this.configurationOverlay.skipFinish = skipFinish;
- }
-
- public boolean getUseSignatureFields() {
- return this.configuration.getUseSignatureFields();
- }
-
- public void setUseSignatureFieldsPersistent(boolean useFields) {
- this.configuration.setUseSignatureFields(useFields);
- if (useFields) setUseMarkerPersistent(false);
- }
-
- public boolean getUseMarker() {
- return this.configuration.getUseMarker();
- }
-
- public void setUseMarkerPersistent(boolean useMarker) {
- this.configuration.setUseMarker(useMarker);
- if (useMarker) setUseSignatureFieldsPersistent(false);
- }
-
- public void setSaveFilePostFixPersistent(@Nonnull String postFix) {
- this.configuration.saveFilePostFix = postFix;
- }
-
- public @Nonnull String getSaveFilePostFix(){
- return this.configuration.saveFilePostFix;
- }
-
- public @Nonnull Profile getSignatureProfile() {
- return ISNOTNULL(fallThroughOnNull(this.configuration.signatureProfile, Profile.SIGNATURBLOCK_SMALL));
- }
-
- public void setSignatureProfilePersistent(Profile profile) {
- this.configuration.signatureProfile = profile;
- }
-
- public void setEnablePlaceholderUsagePersistent(boolean bool) {
- this.configuration.enabledPlaceholderUsage = bool;
- }
-
- public boolean getEnablePlaceholderUsage() {
- return this.configuration.enabledPlaceholderUsage;
- }
-
- public void setFido2ByDefaultPersistent(boolean bool) {
- this.configuration.fido2ByDefault = bool;
- }
-
- public boolean getFido2ByDefault() {
- return this.configuration.fido2ByDefault;
- }
-
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java
deleted file mode 100644
index d1bdfe0d..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.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.workflow.states;
-
-//Imports
-import java.io.File;
-
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.bku.LocalBKUConnector;
-import at.asit.pdfover.commons.BKUs;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.composites.BKUSelectionComposite;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-
-/**
- * Decides which BKU to use (preconfigured or let user choose)
- */
-public class BKUSelectionState extends State {
-
- /**
- * @param stateMachine
- */
- public BKUSelectionState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- /**
- * SLF4J Logger instance
- **/
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(BKUSelectionState.class);
-
- private BKUSelectionComposite selectionComposite = null;
- private BKUSelectionComposite getSelectionComposite() {
- if (this.selectionComposite == null) {
- this.selectionComposite =
- getStateMachine().createComposite(BKUSelectionComposite.class, SWT.RESIZE, this);
- }
-
- return this.selectionComposite;
- }
-
- private boolean isKeystoreEnabled() {
- if (getStateMachine().configProvider.getKeyStoreEnabled()) {
- File ks = new File(getStateMachine().configProvider.getKeyStoreFile());
- return ks.exists();
- } else
- return false;
- }
-
- @Override
- public void run() {
- Status status = getStateMachine().status;
- State previousState = status.getPreviousState();
-
- final boolean hasLocalBKU = LocalBKUConnector.IsAvailable();
- final boolean hasKeystore = isKeystoreEnabled();
- if (
- (previousState instanceof OpenState) ||
- (previousState instanceof PositioningState)
- ) {
- if (!hasLocalBKU && !hasKeystore)
- status.bku = BKUs.MOBILE;
- } else if (!(previousState instanceof BKUSelectionState)) {
- status.bku = BKUs.NONE;
- }
-
- if(status.bku == BKUs.NONE) {
- BKUSelectionComposite selection = this.getSelectionComposite();
- selection.setLocalBKUEnabled(hasLocalBKU);
- selection.setKeystoreEnabled(hasKeystore);
-
- getStateMachine().display(selection);
- selection.layout();
-
- status.bku = selection.getSelected();
-
- if(status.bku == BKUs.NONE) {
- return;
- }
- }
- this.setNextState(new PrepareSigningState(getStateMachine()));
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.selectionComposite != null)
- this.selectionComposite.dispose();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setEnabled(Buttons.CONFIG, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setEnabled(Buttons.POSITION, true);
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
deleted file mode 100644
index 7393f13e..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java
+++ /dev/null
@@ -1,128 +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.workflow.states;
-
-// Imports
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.composites.ConfigurationComposite;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-
-/**
- *
- */
-public class ConfigurationUIState extends State {
- private static final Logger log = LoggerFactory.getLogger(ConfigurationUIState.class);
-
- private ConfigurationComposite configurationComposite = null;
-
- private ConfigurationComposite getConfigurationComposite() {
- if (this.configurationComposite == null) {
- this.configurationComposite =
- getStateMachine().createComposite(ConfigurationComposite.class, SWT.RESIZE, this);
- this.configurationComposite.setConfigProvider(getStateMachine().configProvider);
- }
-
- return this.configurationComposite;
- }
-
- /**
- * @param stateMachine
- */
- public ConfigurationUIState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#run()
- */
- @Override
- public void run() {
- Status status = getStateMachine().status;
-
- ConfigurationComposite config;
- try {
- config = this.getConfigurationComposite();
- getStateMachine().display(config);
- } catch (Exception e) {
- log.error("Failed to initialize config UI", e);
- ErrorDialog error = new ErrorDialog(
- getStateMachine().getMainShell(),
- Messages.getString("error.ConfigInitialization"),
- BUTTONS.YES_NO
- );
-
- int selection = error.open();
- if (selection == SWT.YES)
- {
- ConfigurationManager.factoryResetPersistentConfig();
- getStateMachine().exit();
- return;
- }
-
- throw e;
- }
-
- if(config.isUserDone())
- {
- this.reloadResources();
- State previousState = status.getPreviousState();
- if (previousState instanceof OutputState)
- this.setNextState(new OpenState(getStateMachine()));
- else
- this.setNextState(previousState); // TODO do we need to tell a previous state to refresh from config settings? (positioning preview)
- }
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if(this.configurationComposite != null)
- this.configurationComposite.dispose();
- }
-
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#updateMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- // Leave the state as it is
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.setEnabled(Buttons.CONFIG, false);
- behavior.setMainBarVisible(false);
- }
-
- /**
- * Triggers to reload the resources
- */
- public void reloadResources() {
- getStateMachine().reloadResources();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java
deleted file mode 100644
index 42a2f605..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java
+++ /dev/null
@@ -1,225 +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.workflow.states;
-
-// Imports
-import java.io.File;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.UnrecoverableKeyException;
-
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.keystore.KeystoreUtils;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.PasswordInputDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType;
-import at.asit.pdfover.signer.SignatureException;
-import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
-
-/**
- * Logical state for performing the BKU Request to a local BKU
- */
-public class KSState extends State {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(KSState.class);
-
- /**
- * Constructor
- * @param stateMachine the StateMachine
- */
- public KSState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- private void showError(String messageKey, Object... args)
- {
- new ErrorDialog(getStateMachine().getMainShell(), Messages.formatString(messageKey, args), BUTTONS.OK).open();
- }
-
- private boolean askShouldRetry(String messageKey, Object... args)
- {
- return SWT.RETRY == (new ErrorDialog(getStateMachine().getMainShell(), Messages.formatString(messageKey, args), BUTTONS.RETRY_CANCEL).open());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui
- * .workflow.Workflow)
- */
- @Override
- public void run() {
- Status status = getStateMachine().status;
-
- PdfAs4SigningState signingState = status.signingState;
- ConfigurationManager config = getStateMachine().configProvider;
-
- try {
- String file = config.getKeyStoreFile();
- File f = new File(file);
- if (!f.isFile()) {
- log.error("Keystore not found");
- if (askShouldRetry("error.KeyStoreFileNotExist", f.getName()))
- this.run();
- else
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
- String type = config.getKeyStoreType();
- KeyStore keyStore = null;
- String storePass = config.getKeyStoreStorePass();
- while (keyStore == null) {
- if (storePass == null)
- {
- storePass = new PasswordInputDialog(
- getStateMachine().getMainShell(),
- Messages.getString("keystore_config.KeystoreStorePass"),
- Messages.getString("keystore.KeystoreStorePassEntry")).open();
-
- if (storePass == null)
- {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
- }
-
- try {
- keyStore = KeystoreUtils.tryLoadKeystore(f, type, storePass);
- } catch (UnrecoverableKeyException e) {
- showError("error.KeyStoreStorePass");
- storePass = null;
- } catch (Exception e) {
- throw new SignatureException("Failed to load keystore", e);
- }
- }
-
- /* we've successfully unlocked the key store, save the entered password if requested */
- if (config.getKeyStorePassStorageType() == KeyStorePassStorageType.DISK)
- {
- /* only save to disk if the current keystore file is the one saved to disk */
- /* (might not be true if overridden from CLI) */
- if (file.equals(config.getKeyStoreFilePersistent()))
- config.setKeyStoreStorePassPersistent(storePass);
- else
- config.setKeyStoreStorePassOverlay(storePass);
- }
- else if (config.getKeyStorePassStorageType() == KeyStorePassStorageType.MEMORY)
- config.setKeyStoreStorePassOverlay(storePass);
-
- /* next, try to load the key from the now-unlocked keystore */
- String alias = config.getKeyStoreAlias();
- Key key = null;
- String keyPass = config.getKeyStoreKeyPass();
- while (key == null) {
- if (keyPass == null) {
- keyPass = new PasswordInputDialog(
- getStateMachine().getMainShell(),
- Messages.getString("keystore_config.KeystoreKeyPass"),
- Messages.getString("keystore.KeystoreKeyPassEntry")).open();
-
- if (keyPass == null)
- {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
- }
-
- try {
- key = keyStore.getKey(alias, keyPass.toCharArray());
- if (key == null) /* alias does not exist */
- {
- if (!askShouldRetry("error.KeyStoreAliasExist", alias))
- {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
- continue;
- }
- } catch (UnrecoverableKeyException e) {
- showError("error.KeyStoreKeyPass");
- keyPass = null;
- } catch (Exception e) {
- throw new SignatureException("Failed to load key from store", e);
- }
- }
-
- if (config.getKeyStorePassStorageType() == KeyStorePassStorageType.DISK)
- {
- if (file.equals(config.getKeyStoreFilePersistent()))
- config.setKeyStoreKeyPassPersistent(keyPass);
- else
- config.setKeyStoreKeyPassOverlay(keyPass);
- }
- else if (config.getKeyStorePassStorageType() == KeyStorePassStorageType.MEMORY)
- config.setKeyStoreKeyPassOverlay(keyPass);
-
- signingState.setKeystoreSigner(file, alias, storePass, keyPass, type);
- } catch (SignatureException e) {
- log.error("Error loading keystore", e);
- if (askShouldRetry("error.KeyStore"))
- this.run(); /* recurse */
- else
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
-
- // OK
- this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- // No composite - no cleanup necessary
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
deleted file mode 100644
index f1bfa5b9..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ /dev/null
@@ -1,215 +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.workflow.states;
-
-// Imports
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.bku.BKUHelper;
-import at.asit.pdfover.gui.bku.LocalBKUConnector;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
-
-/**
- * Logical state for performing the BKU Request to a local BKU
- */
-public class LocalBKUState extends State {
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(LocalBKUState.class);
-
- /**
- * HTTP Response server HEADER
- */
- public final static String BKU_RESPONSE_HEADER_SERVER = "server";
-
- /**
- * HTTP Response user-agent HEADER
- */
- public final static String BKU_RESPONSE_HEADER_USERAGENT = "user-agent";
-
- /**
- * HTTP Response SignatureLayout HEADER
- */
- public final static String BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout";
-
- Exception threadException = null;
-
- /** Whether to use Base64 or FileUpload Request */
- boolean useBase64Request = false;
-
- /**
- * Null-Operation SL-Request
- */
- private final static String NULL_OPERATION_REQUEST = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
- "<sl:NullOperationRequest xmlns:sl=\"http://www.buergerkarte.at/namespaces/securitylayer/1.2#\"/>";
-
- /**
- * Constructor
- * @param stateMachine the StateMachine
- */
- public LocalBKUState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- /**
- *
- */
- private final class SignLocalBKUThread implements Runnable {
-
- private LocalBKUState state;
- private PdfAs4SigningState signingState;
-
-
- /**
- * @param localBKUState
- * @param signingState
- */
- public SignLocalBKUThread(LocalBKUState localBKUState, PdfAs4SigningState signingState) {
- this.state = localBKUState;
- this.signingState = signingState;
- }
-
- @Override
- public void run() {
- try {
-
- HttpClient client = (HttpClient) BKUHelper.getHttpClient();
-
- PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
-
- String sl_request = NULL_OPERATION_REQUEST;
- method.addParameter("XMLRequest", sl_request);
- int returnCode = client.executeMethod(method);
-
- if (returnCode != HttpStatus.SC_OK) {
- this.state.threadException = new HttpException(
- method.getResponseBodyAsString());
- } else {
- String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
- if ((server != null) && (server.contains("trustDeskbasic") || server.contains("asignSecurityLayer")))
- LocalBKUState.this.useBase64Request = true;
-
- this.signingState.signatureResponse = method.getResponseBodyAsString();
- this.signingState.useBase64Request = LocalBKUState.this.useBase64Request;
- }
- } catch (Exception e) {
- log.error("SignLocalBKUThread: ", e);
-
- this.state.threadException = e;
- } finally {
- this.state.updateStateMachine();
- }
- }
-
- /**
- * Returns the value corresponding to the given header name
- * @param method the HTTP method
- * @param headerName the header name
- * @return the header value (or null if not found)
- */
- private String getResponseHeader(HttpMethod method, String headerName) {
- if (method.getResponseHeader(headerName) == null)
- return null;
- return method.getResponseHeader(headerName).getValue();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui
- * .workflow.Workflow)
- */
- @Override
- public void run() {
- Status status = getStateMachine().status;
-
- PdfAs4SigningState signingState = status.signingState;
-
- if ((signingState.signatureResponse == null)
- && this.threadException == null) {
- Thread t = new Thread(new SignLocalBKUThread(this, signingState));
- t.start();
- return;
- }
- signingState.bkuConnector = new LocalBKUConnector();
-
- if (this.threadException != null) {
- ErrorDialog dialog = new ErrorDialog(
- getStateMachine().getMainShell(),
- Messages.getString("error.LocalBKU"),
- BUTTONS.RETRY_CANCEL);
- if (dialog.open() != SWT.RETRY) {
- //getStateMachine().exit();
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
- this.threadException = null;
- this.run();
- return;
- }
-
- // OK
- this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- // No composite - no cleanup necessary
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
deleted file mode 100644
index d858c067..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ /dev/null
@@ -1,668 +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.workflow.states;
-
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.URI;
-import java.net.UnknownHostException;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-// Imports
-import at.asit.pdfover.signer.UserCancelledException;
-import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
-import at.asit.webauthn.PublicKeyCredential;
-import at.asit.webauthn.responsefields.AuthenticatorAssertionResponse;
-
-import org.apache.hc.client5.http.classic.methods.HttpGet;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
-import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
-import org.apache.hc.client5.http.impl.classic.HttpClients;
-import org.apache.hc.core5.http.io.entity.EntityUtils;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.bku.MobileBKUConnector;
-import at.asit.pdfover.gui.composites.WaitingComposite;
-import at.asit.pdfover.gui.composites.mobilebku.MobileBKUEnterNumberComposite;
-import at.asit.pdfover.gui.composites.mobilebku.MobileBKUEnterTANComposite;
-import at.asit.pdfover.gui.composites.mobilebku.MobileBKUFido2Composite;
-import at.asit.pdfover.gui.composites.mobilebku.MobileBKUFingerprintComposite;
-import at.asit.pdfover.gui.composites.mobilebku.MobileBKUQRComposite;
-import at.asit.pdfover.gui.composites.mobilebku.WaitingForAppComposite;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.Dialog.ICON;
-import at.asit.pdfover.gui.controls.Dialog;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-
-import static at.asit.pdfover.commons.Constants.ISNOTNULL;
-
-/**
- * Logical state for performing the BKU Request to the A-Trust Mobile BKU
- */
-public class MobileBKUState extends State {
- static final Logger log = LoggerFactory.getLogger(MobileBKUState.class);
-
- PdfAs4SigningState signingState;
-
- public Exception threadException = null;
-
- public MobileBKUState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- MobileBKUEnterTANComposite mobileBKUEnterTANComposite = null;
-
- WaitingForAppComposite waitingForAppComposite = null;
- WaitingForAppComposite getWaitingForAppComposite() {
- if (this.waitingForAppComposite == null) {
- this.waitingForAppComposite = getStateMachine()
- .createComposite(WaitingForAppComposite.class, SWT.RESIZE, this);
- }
-
- return this.waitingForAppComposite;
- }
-
- WaitingComposite waitingComposite = null;
- WaitingComposite getWaitingComposite() {
- if (this.waitingComposite == null) {
- this.waitingComposite = getStateMachine()
- .createComposite(WaitingComposite.class, SWT.RESIZE, this);
- }
-
- return this.waitingComposite;
- }
-
- MobileBKUEnterTANComposite getMobileBKUEnterTANComposite() {
- if (this.mobileBKUEnterTANComposite == null) {
- this.mobileBKUEnterTANComposite = getStateMachine()
- .createComposite(MobileBKUEnterTANComposite.class, SWT.RESIZE, this);
- }
-
- return this.mobileBKUEnterTANComposite;
- }
-
- MobileBKUQRComposite mobileBKUQRComposite = null;
- MobileBKUQRComposite getMobileBKUQRComposite() {
- if (this.mobileBKUQRComposite == null) {
- this.mobileBKUQRComposite = getStateMachine()
- .createComposite(MobileBKUQRComposite.class, SWT.RESIZE, this);
- }
-
- return this.mobileBKUQRComposite;
- }
-
- MobileBKUEnterNumberComposite mobileBKUEnterNumberComposite = null;
- MobileBKUEnterNumberComposite getMobileBKUEnterNumberComposite() {
- if (this.mobileBKUEnterNumberComposite == null) {
- this.mobileBKUEnterNumberComposite = getStateMachine()
- .createComposite(MobileBKUEnterNumberComposite.class, SWT.RESIZE, this);
- }
-
- return this.mobileBKUEnterNumberComposite;
- }
-
- MobileBKUFingerprintComposite mobileBKUFingerprintComposite = null;
- MobileBKUFingerprintComposite getMobileBKUFingerprintComposite() {
- if (this.mobileBKUFingerprintComposite == null) {
- this.mobileBKUFingerprintComposite = getStateMachine()
- .createComposite(MobileBKUFingerprintComposite.class, SWT.RESIZE, this);
- }
-
- return this.mobileBKUFingerprintComposite;
- }
-
- MobileBKUFido2Composite mobileBKUFido2Composite = null;
- MobileBKUFido2Composite getMobileBKUFido2Composite() {
- if (this.mobileBKUFido2Composite == null) {
- this.mobileBKUFido2Composite = getStateMachine()
- .createComposite(MobileBKUFido2Composite.class, SWT.RESIZE, this);
- }
-
- return this.mobileBKUFido2Composite;
- }
-
- /**
- * @return the signingState
- */
- public PdfAs4SigningState getSigningState() {
- return this.signingState;
- }
-
- /**
- * Display an error message
- *
- * @param e
- * the exception
- */
- public void displayError(Exception e) {
- String message = null;
- if (e instanceof UnknownHostException)
- {
- log.error("Failed to resolve hostname", e);
- message = Messages.formatString("error.CouldNotResolveHostname", e.getMessage());
- } else if (e instanceof ConnectException) {
- log.error("Failed to connect", e);
- message = Messages.formatString("error.FailedToConnect", e.getMessage());
- } else {
- message = Messages.getString("error.Unexpected");
- log.error(message, e);
- String errormsg = e.getLocalizedMessage();
- if (errormsg != null && !errormsg.isEmpty())
- message += ": " + errormsg;
- }
- displayError(message);
- }
-
- /**
- * Display an error message
- *
- * @param message
- * the error message
- */
- public void displayError(final String message) {
- log.error(message);
- Display.getDefault().syncExec(() -> {
- ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(), message, BUTTONS.OK);
- error.open();
- });
- }
-
- public void showInformationMessage(final @Nonnull String message) throws UserCancelledException {
- Display.getDefault().syncCall(() -> {
- Dialog dialog = new Dialog(getStateMachine().getMainShell(), Messages.getString("common.info"), message, BUTTONS.OK, ICON.INFORMATION);
- int result = dialog.open();
- if (result == SWT.CANCEL)
- throw new UserCancelledException();
- return true; /* dummy return to keep java happy */
- });
- }
-
- /**
- * Show an error message to the user with "retry" or "cancel" as options
- * returns normally on "retry", throws UserCancelledException on "cancel"
- */
- public void showRecoverableError(final @Nonnull String errorMessage) throws UserCancelledException {
- Display.getDefault().syncCall(() -> {
- ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(), errorMessage, BUTTONS.RETRY_CANCEL);
- int result = error.open();
- if (result == SWT.CANCEL)
- throw new UserCancelledException();
- return true; /* dummy return */
- });
- }
-
- /**
- * Show an error message to the user with only an "ok" option;
- * throws UserCancelledException afterwards
- */
- public void showUnrecoverableError(final @Nonnull String errorMessage) throws UserCancelledException {
- Display.getDefault().syncCall(() -> {
- ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(), errorMessage, BUTTONS.OK);
- error.open();
- throw new UserCancelledException();
- });
- }
-
- public static class UsernameAndPassword {
- public @CheckForNull String username;
- public @CheckForNull String password;
- public UsernameAndPassword() {}
- public UsernameAndPassword(@Nullable String u, @Nullable String p) { this.username = u; this.password = p; }
- }
- public @Nonnull UsernameAndPassword getRememberedCredentials() {
- UsernameAndPassword r = new UsernameAndPassword();
- storeRememberedCredentialsTo(r);
- return r;
- }
- public void storeRememberedCredentialsTo(@Nonnull UsernameAndPassword output) {
- output.username = getStateMachine().configProvider.getDefaultMobileNumber();
- output.password = getStateMachine().configProvider.getDefaultMobilePassword();
- }
-
- public void rememberCredentialsIfNecessary(@Nullable String username, @Nullable String password) {
- if (getStateMachine().configProvider.getRememberMobilePassword())
- {
- getStateMachine().configProvider.setDefaultMobileNumberPersistent(username);
- getStateMachine().configProvider.setDefaultMobilePasswordOverlay(password);
- }
- }
- public void rememberCredentialsIfNecessary(@Nonnull UsernameAndPassword credentials) {
- rememberCredentialsIfNecessary(credentials.username, credentials.password);
- }
-
- public void clearRememberedPassword() {
- getStateMachine().configProvider.setDefaultMobilePasswordOverlay(null);
- }
-
- public @Nonnull UsernameAndPassword getCredentialsFromUser(@Nullable String currentUsername, @Nullable String errorMessage) throws UserCancelledException {
- UsernameAndPassword r = new UsernameAndPassword(currentUsername, null);
- getCredentialsFromUserTo(r, errorMessage);
- return r;
- }
-
- private void updateRememberPasswordSetting(boolean enabled, boolean allowEnabling) {
- final var config = getStateMachine().configProvider;
- if (enabled == config.getRememberMobilePassword()) /* nothing to do here */
- return;
- if (enabled && !allowEnabling) /* do not allow "cancel" to set the remember checkbox */
- return;
- config.setRememberMobilePasswordPersistent(enabled);
- if (!enabled) { /* clear remembered info */
- config.setDefaultMobileNumberPersistent(null);
- config.setDefaultMobilePasswordOverlay(null);
- }
- }
-
- public void getCredentialsFromUserTo(@Nonnull UsernameAndPassword credentials, @Nullable String errorMessage) throws UserCancelledException {
- Display.getDefault().syncCall(() -> {
- MobileBKUEnterNumberComposite ui = this.getMobileBKUEnterNumberComposite();
-
- if (!ui.userAck) { // We need number and password => show UI!
-
- if (errorMessage != null)
- ui.setErrorMessage(errorMessage);
- else
- ui.setErrorMessage(Messages.getString("mobileBKU.aTrustDisclaimer"));
-
- if ((ui.getMobileNumber() == null) || ui.getMobileNumber().isEmpty()) {
- // set possible phone number
- ui.setMobileNumber(credentials.username);
- }
-
- ui.setRememberPassword(getStateMachine().configProvider.getRememberMobilePassword());
-
- ui.enableButton();
- getStateMachine().display(ui);
-
- Display display = getStateMachine().getMainShell().getDisplay();
- while (!ui.userAck && !ui.userCancel) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- updateRememberPasswordSetting(ui.isRememberPassword(), !ui.userCancel);
-
- if (ui.userCancel) {
- ui.userCancel = false;
- throw new UserCancelledException();
- }
-
- // user hit ok
- ui.userAck = false;
-
- // get number and password from UI
- credentials.username = ui.getMobileNumber();
- credentials.password = ui.getMobilePassword();
-
- // show waiting composite
- getStateMachine().display(this.getWaitingComposite());
-
- return true; /* dummy return for lambda type deduction */
- });
- }
-
- public static class SMSTanResult {
- public static enum ResultType { TO_FIDO2, SMSTAN };
- public final @Nonnull ResultType type;
- public final @CheckForNull String smsTan;
-
- private SMSTanResult(@Nullable String smsTan) { this.type = ResultType.SMSTAN; this.smsTan = smsTan; }
- private SMSTanResult(@Nonnull ResultType type) { this.type = type; this.smsTan = null; }
- }
-
- public @Nonnull SMSTanResult getSMSTanFromUser(final @Nonnull String referenceValue, final @Nullable URI signatureDataURI, final boolean showFido2, final @Nullable String errorMessage) throws UserCancelledException {
- return ISNOTNULL(Display.getDefault().syncCall(() -> {
- MobileBKUEnterTANComposite tan = getMobileBKUEnterTANComposite();
-
- tan.reset();
- tan.setRefVal(referenceValue);
- tan.setSignatureDataURI(signatureDataURI);
- tan.setErrorMessage(errorMessage);
- tan.setFIDO2Enabled(showFido2);
- getStateMachine().display(tan);
-
- Display display = getStateMachine().getMainShell().getDisplay();
- while (!tan.isDone()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- getStateMachine().display(getWaitingComposite());
-
- if (tan.isUserCancel())
- throw new UserCancelledException();
-
- if (tan.isUserFido2())
- return new SMSTanResult(SMSTanResult.ResultType.TO_FIDO2);
-
- return new SMSTanResult(tan.getTan());
- }));
- }
-
- /**
- * start showing the QR code at the indicated URI
- * this method will return immediately */
- public void showQRCode(final @Nonnull String referenceValue, @Nonnull URI qrCodeURI, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2, final @Nullable String errorMessage) {
- byte[] qrCode;
- try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
- try (final CloseableHttpResponse response = httpClient.execute(new HttpGet(qrCodeURI))) {
- qrCode = EntityUtils.toByteArray(response.getEntity());
- }
- } catch (IOException e) {
- log.warn("Failed to load QR code.");
- qrCode = null;
- }
-
- final byte[] qrCodeCopy = qrCode; /* because java is silly */
- Display.getDefault().syncExec(() -> {
- MobileBKUQRComposite qr = getMobileBKUQRComposite();
- qr.reset();
-
- qr.setRefVal(referenceValue);
- qr.setSignatureDataURI(signatureDataURI);
- qr.setErrorMessage(errorMessage);
- qr.setQR(qrCodeCopy);
- qr.setSMSEnabled(showSmsTan);
- qr.setFIDO2Enabled(showFido2);
- getStateMachine().display(qr);
- });
- }
-
- public enum QRResult {
- /* the user has pressed the FIDO2 button */
- TO_FIDO2,
- /* the user has pressed the SMS button */
- TO_SMS,
- /* signalQRScanned has been called; this indicates that we should refresh the page */
- UPDATE
- };
-
- public @Nonnull QRResult waitForQRCodeResult() throws UserCancelledException {
- return ISNOTNULL(Display.getDefault().syncCall(() -> {
- MobileBKUQRComposite qr = getMobileBKUQRComposite();
-
- Display display = getStateMachine().getMainShell().getDisplay();
- while (!qr.isDone()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- getStateMachine().display(this.getWaitingComposite());
-
- if (qr.wasCancelClicked()) {
- clearRememberedPassword();
- throw new UserCancelledException();
- }
-
- if (qr.wasSMSClicked())
- return QRResult.TO_SMS;
-
- if (qr.wasFIDO2Clicked())
- return QRResult.TO_FIDO2;
-
- return QRResult.UPDATE;
- }));
- }
-
- /**
- * indicate that the long polling operation completed
- * (any ongoing waitForQRCodeResult call will then return)
- */
- public void signalQRScanned() {
- getMobileBKUQRComposite().signalPollingDone();
- }
-
- /**
- * start showing the "waiting for app" screen
- * this method will return immediately */
- public void showWaitingForAppOpen(final @Nonnull String referenceValue, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2) {
- Display.getDefault().syncExec(() -> {
- WaitingForAppComposite wfa = getWaitingForAppComposite();
- wfa.reset();
-
- // TODO composite does not currently support: refval, signature data
- wfa.setSMSEnabled(showSmsTan);
- wfa.setFIDO2Enabled(showFido2);
- getStateMachine().display(wfa);
- });
- }
-
- public enum AppOpenResult {
- /* the user has pressed the FIDO2 button */
- TO_FIDO2,
- /* the user has pressed the SMS button */
- TO_SMS,
- /* signalAppOpened has been called; this indicates that we should refresh the page */
- UPDATE
- };
-
- public @Nonnull AppOpenResult waitForAppOpen() throws UserCancelledException {
- return ISNOTNULL(Display.getDefault().syncCall(() -> {
- WaitingForAppComposite wfa = getWaitingForAppComposite();
-
- Display display = wfa.getDisplay();
- while (!wfa.isDone()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- getStateMachine().display(this.getWaitingComposite());
-
- if (wfa.wasCancelClicked()) {
- clearRememberedPassword();
- throw new UserCancelledException();
- }
-
- if (wfa.wasSMSClicked())
- return AppOpenResult.TO_SMS;
-
- if (wfa.wasFIDO2Clicked())
- return AppOpenResult.TO_FIDO2;
-
- return AppOpenResult.UPDATE;
- }));
- }
-
- /**
- * indicate that the long polling operation completed
- * (any ongoing waitForAppOpen call will then return)
- */
- public void signalAppOpened() {
- getWaitingForAppComposite().signalPollingDone();
- }
-
- public void showWaitingForAppBiometry(final @Nonnull String referenceValue, @Nullable URI signatureDataURI, final boolean showSmsTan, final boolean showFido2) {
- Display.getDefault().syncExec(() -> {
- MobileBKUFingerprintComposite bio = getMobileBKUFingerprintComposite();
- bio.reset();
-
- bio.setRefVal(referenceValue);
- bio.signatureDataURI = signatureDataURI;
- bio.setErrorMessage(null); // TODO
- bio.setSMSEnabled(showSmsTan);
- bio.setFIDO2Enabled(showFido2);
- getStateMachine().display(bio);
- });
- }
-
- // TODO can we maybe deduplicate the various waiting screens' logic?
-
- public enum AppBiometryResult {
- /* the user has pressed the FIDO2 button */
- TO_FIDO2,
- /* the user has pressed the SMS button */
- TO_SMS,
- /* signalAppBiometryDone has been called; this indicates that we should refresh the page */
- UPDATE
- };
-
- public @Nonnull AppBiometryResult waitForAppBiometry() throws UserCancelledException {
- return ISNOTNULL(Display.getDefault().syncCall(() -> {
- MobileBKUFingerprintComposite bio = getMobileBKUFingerprintComposite();
-
- Display display = bio.getDisplay();
- while (!bio.isDone()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- getStateMachine().display(this.getWaitingComposite());
-
- if (bio.wasCancelClicked()) {
- clearRememberedPassword();
- throw new UserCancelledException();
- }
-
- if (bio.wasSMSClicked())
- return AppBiometryResult.TO_SMS;
-
- if (bio.wasFIDO2Clicked())
- return AppBiometryResult.TO_FIDO2;
-
- return AppBiometryResult.UPDATE;
- }));
- }
-
- public void signalAppBiometryDone() {
- getMobileBKUFingerprintComposite().signalPollingDone();
- }
-
- public static class FIDO2Result {
- public static enum ResultType { TO_SMS, CREDENTIAL };
- public final @Nonnull ResultType type;
- public final @Nullable PublicKeyCredential<AuthenticatorAssertionResponse> credential;
-
- private FIDO2Result(@Nonnull ResultType type) { this.type = type; this.credential = null; }
- private FIDO2Result(@Nonnull PublicKeyCredential<AuthenticatorAssertionResponse> cred) { this.type = ResultType.CREDENTIAL; this.credential = cred; }
- }
-
- /**
- * prompts user for fido2 auth and blocks until result is available
- * @param fido2Options JSON data from A-Trust
- * @return
- * @throws UserCancelledException
- */
- public @Nonnull FIDO2Result promptUserForFIDO2Auth(final @Nonnull String fido2Options, @Nullable URI signatureDataURI, final boolean showSmsTan) throws UserCancelledException {
- return ISNOTNULL(Display.getDefault().syncCall(() -> {
- MobileBKUFido2Composite fido2 = getMobileBKUFido2Composite();
- fido2.initialize(fido2Options);
- fido2.setSMSEnabled(showSmsTan);
- fido2.setSignatureDataURI(signatureDataURI);
-
- getStateMachine().display(fido2);
-
- Display display = fido2.getDisplay();
- while (!fido2.isDone()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- getStateMachine().display(this.getWaitingComposite());
-
- if (fido2.wasUserCancelClicked())
- throw new UserCancelledException();
-
- if (fido2.wasUserSMSClicked())
- return new FIDO2Result(FIDO2Result.ResultType.TO_SMS);
-
- return new FIDO2Result(ISNOTNULL(fido2.getResultingCredential()));
- }));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui
- * .workflow.Workflow)
- */
- @Override
- public void run() {
- this.signingState = getStateMachine().status.signingState;
-
- this.signingState.bkuConnector = new MobileBKUConnector(this);
- this.signingState.useBase64Request = false;
-
- if (this.threadException != null) {
- displayError(this.threadException);
- return;
- }
-
- getStateMachine().display(
- this.getWaitingComposite());
-
- this.setNextState(new SigningState(getStateMachine()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.mobileBKUEnterNumberComposite != null)
- this.mobileBKUEnterNumberComposite.dispose();
- if (this.mobileBKUEnterTANComposite != null)
- this.mobileBKUEnterTANComposite.dispose();
- if (this.waitingComposite != null)
- this.waitingComposite.dispose();
- if (this.waitingForAppComposite != null)
- this.waitingForAppComposite.dispose();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setEnabled(Buttons.POSITION, true);
- //behavior.setEnabled(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-
- /**
- * invoke state machine update in main thread
- */
- public void invokeUpdate() {
- getStateMachine().invokeUpdate();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
deleted file mode 100644
index 12b16da7..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java
+++ /dev/null
@@ -1,275 +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.workflow.states;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.List;
-
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-
-//Imports
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.MessageBox;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.bku.LocalBKUConnector;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.PlaceholderSelectionGui;
-import at.asit.pdfover.gui.composites.DataSourceSelectComposite;
-import at.asit.pdfover.gui.utils.SWTUtils;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.commons.Profile;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signer.SignaturePosition;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-
-
-
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.PropertiesConfigurationLayout;
-
-
-/**
- * Selects the data source for the signature process.
- */
-public class OpenState extends State {
-
- /**
- * @param stateMachine
- */
- public OpenState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(OpenState.class);
- private static final String advancedConfig = Constants.CONFIG_DIRECTORY + File.separator + "/cfg/advancedconfig.properties";
-
- private DataSourceSelectComposite selectionComposite = null;
-
- private DataSourceSelectComposite getSelectionComposite() {
- if (this.selectionComposite == null) {
- this.selectionComposite =
- getStateMachine().createComposite(DataSourceSelectComposite.class, SWT.RESIZE, this);
- }
- return this.selectionComposite;
- }
-
- @Override
- public void run() {
- ConfigurationManager config = getStateMachine().configProvider;
- Status status = getStateMachine().status;
- if (!(status.getPreviousState() instanceof PrepareConfigurationState)
- && !(status.getPreviousState() instanceof OpenState)) {
- status.bku = config.getDefaultBKU();
- status.document = null;
- status.signaturePosition = ((config.getSignatureProfile() == Profile.INVISIBLE) || config.getAutoPositionSignature()) ? (new SignaturePosition()) : null;
-
- /* ensure that files get closed */
- status.getPreviousState().cleanUp();
- }
-
- /* force static initialization and start polling */
- LocalBKUConnector.IsAvailable();
-
- if (status.document == null) {
- DataSourceSelectComposite selection = this.getSelectionComposite();
-
- getStateMachine().display(selection);
- selection.layout();
-
- status.document = selection.getSelected();
-
- if (status.document == null) {
- // Not selected yet
- return;
- }
- }
- log.debug("Got Datasource: " + getStateMachine().status.document.getAbsolutePath());
-
- // scan for signature placeholders
- // - see if we want to scan for placeholders in the settings
- if (config.getEnablePlaceholderUsage()) {
- try (PDDocument pddocument = PDDocument.load(getStateMachine().status.document)) {
- // - scan for placeholders
- boolean useSignatureFields = config.getUseSignatureFields();
- boolean useMarker = config.getUseMarker();
- log.debug("Placeholder usage enabled. Signature fields: {}, QR Markers: {}", useSignatureFields, useMarker);
- //first check the signature fields placeholder
- if (useSignatureFields) {
-
- List<String> fields = SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(pddocument);
-
- if (fields.size() > 0) {
- while (true)
- {
- // create a dialog with ok and cancel buttons and a question
- // icon
- MessageBox dialog = new MessageBox(getStateMachine().getMainShell(),
- SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
- SWTUtils.setLocalizedText(dialog, "dataSourceSelection.usePlaceholderTitle");
- dialog.setMessage(Messages.getString("dataSourceSelection.usePlaceholderText"));
-
- // open dialog and await user selection
- int result = dialog.open();
- if (result == SWT.YES) {
-
- if (fields.size() == 1) {
- addPlaceholderSelectionToConfig(fields.get(0));
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
-
- } else if (fields.size() > 1) {
-
- PlaceholderSelectionGui gui = new PlaceholderSelectionGui(
- getStateMachine().getMainShell(), 65570, "text",
- "select the fields", fields);
- int res = gui.open();
- if (res != -1) {
- getStateMachine().status.searchForPlacehoderSignature = true;
- addPlaceholderSelectionToConfig(fields.get(res));
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- else
- continue;
- }
-
- } else if (result == SWT.NO) {
- getStateMachine().status.searchForPlacehoderSignature = false;
- } else {
- status.document = null;
- return;
- }
- break;
- }
- }
- // second check if qr code placeholder search is enabled
- } else if (useMarker) {
-
- SignaturePlaceholderData signaturePlaceholderData = SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(pddocument);
-
- if (null != signaturePlaceholderData) {
-
- // create a dialog with ok and cancel buttons and a question icon
- MessageBox dialog = new MessageBox(getStateMachine().getMainShell(),
- SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
- SWTUtils.setLocalizedText(dialog, "dataSourceSelection.usePlaceholderTitle");
- dialog.setMessage(Messages.getString("dataSourceSelection.usePlaceholderText"));
-
- // open dialog and await user selection
- int result = dialog.open();
- if (result == SWT.YES) {
-
- // if the user chooses to use the signature placeholder
- // - fill the position information so that we skip to
- // the
- // next stages without breaking stuff
- status.signaturePosition = new SignaturePosition(
- signaturePlaceholderData.getTablePos().getPosX(),
- signaturePlaceholderData.getTablePos().getPosY(),
- signaturePlaceholderData.getTablePos().getPage());
-
- getStateMachine().status.searchForPlacehoderSignature = true;
-
- } else if (result == SWT.NO) {
- getStateMachine().status.searchForPlacehoderSignature = false;
- } else {
- status.document = null;
- return;
- }
- // TODO: why does this use a different logic (via PositioningState) than the signature placeholders?
- }
-
- } else {
- // Do nothing
- }
-
- } catch (IOException e) {
- // fail silently. In case we got here no dialog has been shown.
- // Just
- // proceed with the usual process.
- }
- }
-
- this.setNextState(new PositioningState(getStateMachine()));
- }
-
- /**
- * The selected placeholder is added to the configuration file
- * @param selection
- */
- private void addPlaceholderSelectionToConfig(String selection) {
- try {
- PropertiesConfiguration config = new PropertiesConfiguration();
- PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config);
- layout.load(new InputStreamReader(new FileInputStream(advancedConfig)));
-
- config.setProperty(Constants.SIGNATURE_FIELD_NAME_CONF, selection);
- layout.save(new FileWriter(advancedConfig, false));
-
- } catch (Exception e) {
- log.error("Failed to add placeholder selection to config", e);
- }
-
- }
-
- /**
- * Open the input document selection dialog
- */
- public void openFileDialog() {
- if (this.selectionComposite != null)
- this.selectionComposite.openFileDialog();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.selectionComposite != null)
- this.selectionComposite.dispose();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setEnabled(Buttons.CONFIG, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setActive(Buttons.OPEN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
deleted file mode 100644
index 308b7d5a..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java
+++ /dev/null
@@ -1,138 +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.workflow.states;
-
-//Imports
-import java.io.File;
-
-import org.eclipse.swt.SWT;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.composites.OutputComposite;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-
-/**
- * Produces the output of the signature process. (save file, open file)
- */
-public class OutputState extends State {
-
- private OutputComposite outputComposite = null;
-
- /**
- * @param stateMachine
- */
- public OutputState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- private OutputComposite getOutputComposite() {
- if (this.outputComposite == null) {
- this.outputComposite = getStateMachine()
- .createComposite(OutputComposite.class, SWT.RESIZE, this);
-
- ConfigurationManager config = getStateMachine().configProvider;
- Status status = getStateMachine().status;
-
- File tmpDir = new File(Constants.CONFIG_DIRECTORY + File.separator + "tmp");
-
- if(!tmpDir.exists()) {
- tmpDir.mkdir();
- }
-
- this.outputComposite.setOutputDir(config.getDefaultOutputFolder());
- this.outputComposite.setSaveFilePostFix(config.getSaveFilePostFix());
- this.outputComposite.setTempDir(tmpDir.getAbsolutePath());
- this.outputComposite.setInputFile(status.document);
-
- this.outputComposite.setSignedDocument(status.signResult.getSignedDocument());
-
- // Save signed document
- this.outputComposite.saveDocument();
-
- if (config.getSkipFinish() && this.outputComposite.getSaveSuccessful()) {
- getStateMachine().exit();
- }
- }
-
- return this.outputComposite;
- }
-
- @Override
- public void run() {
- Status status = getStateMachine().status;
-
- if (status.signResult == null) {
- ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(),
- Messages.getString("error.Signatur"), BUTTONS.RETRY_CANCEL);
- if(error.open() == SWT.RETRY) {
- this.setNextState(new PrepareSigningState(getStateMachine()));
- } else {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- return;
- }
-
- OutputComposite outputComposite = this.getOutputComposite();
-
- // Display dialog
- getStateMachine().display(outputComposite);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
-
- getStateMachine().status.signResult = null;
-
- if (this.outputComposite != null)
- this.outputComposite.dispose();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setEnabled(Buttons.CONFIG, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setEnabled(Buttons.POSITION, true);
- behavior.setEnabled(Buttons.SIGN, true);
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- behavior.setActive(Buttons.FINAL, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
deleted file mode 100644
index b56fb6d7..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java
+++ /dev/null
@@ -1,228 +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.workflow.states;
-
-//Imports
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.composites.PositioningComposite;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signer.Emblem;
-import at.asit.pdfover.signer.SignaturePosition;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignaturePlaceholder;
-
-/**
- * Decides where to position the signature block
- */
-public class PositioningState extends State {
-
- /**
- * @param stateMachine
- */
- public PositioningState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory.getLogger(PositioningState.class);
-
- private PositioningComposite positionComposite = null;
-
- private SignaturePosition previousPosition = null;
-
-
- private File loadedDocumentPath = null;
- private PDDocument document = null;
-
- private void closePDFDocument() {
-
- if (this.document != null)
- {
- try { this.document.close(); } catch (IOException e) { log.warn("Failed to close PDF", e); }
- this.document = null;
- }
- this.loadedDocumentPath = null;
- }
-
- private void openPDFDocument() throws IOException {
- closePDFDocument();
- File documentPath = getStateMachine().status.document;
- PDDocument pdf = null;
- try
- {
- pdf = PDDocument.load(documentPath);
- if (pdf.getNumberOfPages() > 0)
- pdf.getPage(0);
- else
- throw new IOException();
- }
- catch (InvalidPasswordException e) {
- throw new IOException(Messages.getString("error.PDFPwdProtected"), e);
- }
- catch (IOException e) {
- throw new IOException(Messages.getString("error.MayNotBeAPDF"), e);
- }
- this.document = pdf;
- this.loadedDocumentPath = documentPath;
- }
-
- private PositioningComposite getPositioningComposite(PDDocument document) {
- StateMachine stateMachine = getStateMachine();
- if (this.positionComposite == null) {
- this.positionComposite =
- stateMachine.createComposite(PositioningComposite.class, SWT.RESIZE, this);
- log.debug("Displaying " + stateMachine.status.document);
- this.positionComposite.displayDocument(document);
- }
-
- ConfigurationManager config = stateMachine.configProvider;
-
- PdfAs4SignatureParameter param = new PdfAs4SignatureParameter();
- param.signatureProfile = config.getSignatureProfile();
-
- String emblemPath = config.getDefaultEmblemPath();
- if (emblemPath != null && !emblemPath.trim().isEmpty())
- param.emblem = new Emblem(emblemPath);
- if (config.getSignatureNote() != null && !config.getSignatureNote().isEmpty())
- param.signatureNote = config.getSignatureNote();
-
- param.signatureLanguage = config.getSignatureLocale().getLanguage();
- param.enablePDFACompat = config.getSignaturePdfACompat();
- param.targetLogoSize = Math.min(120.0, config.getLogoOnlyTargetSize()); // TODO WORKAROUND FOR #117
-
- PdfAs4SignaturePlaceholder.For(param, (p) -> {
- if (p.hasImage())
- this.positionComposite.setPlaceholder(p.getAWTImage());
- });
-
- if (this.previousPosition != null && !this.previousPosition.useAutoPositioning())
- {
- this.positionComposite.setPosition(
- this.previousPosition.getX(),
- this.previousPosition.getY(),
- this.previousPosition.getPage());
- }
-
- return this.positionComposite;
- }
-
- @Override
- public void run() {
- Status status = getStateMachine().status;
- if (!(status.getPreviousState() instanceof PositioningState) &&
- !(status.getPreviousState() instanceof OpenState))
- {
- this.previousPosition = status.signaturePosition;
- status.signaturePosition = null;
- }
-
- if ((this.document == null) ||
- (this.loadedDocumentPath != getStateMachine().status.document)) {
- log.debug("Checking PDF document for encryption");
- try {
- openPDFDocument();
- } catch (IOException e) {
- this.positionComposite = null;
- log.error("Failed to display PDF document", e);
- String message = e.getLocalizedMessage();
- if (message == null)
- message = Messages.getString("error.IOError");
- ErrorDialog dialog = new ErrorDialog(
- getStateMachine().getMainShell(),
- message, BUTTONS.RETRY_CANCEL);
- if(dialog.open() == SWT.RETRY) {
- run();
- } else {
- setNextState(new OpenState(getStateMachine()));
- }
- return;
- }
- }
-
- if (status.signaturePosition == null) {
- PositioningComposite position = null;
- try {
- position = this.getPositioningComposite(this.document);
- } catch(Exception ex) {
- log.error("Failed to create composite (probably a mac...)", ex);
- ErrorDialog dialog = new ErrorDialog(
- getStateMachine().getMainShell(),
- Messages.getString("error.PositioningNotPossible"), BUTTONS.OK);
- dialog.open();
- status.signaturePosition = new SignaturePosition();
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
-
- getStateMachine().display(position);
-
- status.signaturePosition = position.getPosition();
-
- if(status.signaturePosition != null) {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
-
- this.positionComposite.requestFocus();
- } else {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.positionComposite != null)
- this.positionComposite.dispose();
- closePDFDocument();
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setEnabled(Buttons.CONFIG, true);
- behavior.setEnabled(Buttons.OPEN, true);
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
deleted file mode 100644
index 87693c19..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java
+++ /dev/null
@@ -1,348 +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.workflow.states;
-
-//Imports
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.commons.Constants;
-import at.asit.pdfover.gui.cliarguments.*;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.gui.exceptions.InitializationException;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.utils.UpdateCheckManager;
-import at.asit.pdfover.gui.utils.VersionComparator;
-import at.asit.pdfover.gui.utils.Zipper;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signer.SignaturePosition;
-
-/**
- * Starting state of workflow proccess
- *
- * Reads configuration, command arguments and initializes configured variables
- */
-public class PrepareConfigurationState extends State {
-
- /** SLF4J Logger instance **/
- static final Logger log = LoggerFactory.getLogger(PrepareConfigurationState.class);
-
- private ArgumentHandler handler;
-
- private ArgumentHandler configFileHandler;
-
- /**
- * @param stateMachine
- */
- public PrepareConfigurationState(StateMachine stateMachine) {
- super(stateMachine);
- this.handler = new ArgumentHandler(getStateMachine());
- this.handler.addCLIArgument(HelpArgument.class);
- this.handler.addCLIArgument(InputDocumentArgument.class);
- this.handler.addCLIArgument(OutputFolderArgument.class);
- this.handler.addCLIArgument(BKUArgument.class);
- this.handler.addCLIArgument(PhoneNumberArgument.class);
- this.handler.addCLIArgument(PasswordArgument.class);
- this.handler.addCLIArgument(KeystoreFileArgument.class);
- this.handler.addCLIArgument(KeystoreTypeArgument.class);
- this.handler.addCLIArgument(KeystoreStorePassArgument.class);
- this.handler.addCLIArgument(KeystoreAliasArgument.class);
- this.handler.addCLIArgument(KeystoreKeyPassArgument.class);
- this.handler.addCLIArgument(ProxyHostArgument.class);
- this.handler.addCLIArgument(ProxyPortArgument.class);
- this.handler.addCLIArgument(ProxyUserArgument.class);
- this.handler.addCLIArgument(ProxyPassArgument.class);
- this.handler.addCLIArgument(EmblemArgument.class);
- this.handler.addCLIArgument(AutomaticPositioningArgument.class);
- this.handler.addCLIArgument(SkipFinishArgument.class);
- // adding config file argument to this handler so it appears in help
- this.handler.addCLIArgument(ConfigFileArgument.class);
- this.handler.addCLIArgument(InvisibleProfile.class);
-
- this.configFileHandler = new ArgumentHandler(getStateMachine());
- this.configFileHandler.addCLIArgument(ConfigFileArgument.class);
- }
-
- private void initializeFromConfigurationFile() throws InitializationException {
- try {
- getStateMachine().configProvider.loadFromDisk();
- } catch (IOException ex) {
- throw new InitializationException("Failed to read configuration from config file", ex);
- }
- }
-
- private void initializeFromArguments(String[] args, ArgumentHandler handler) throws InitializationException {
- handler.handleArguments(args);
-
- if (handler.doesRequireExit()) {
- getStateMachine().exit();
- }
- }
-
- private void ensurePdfOverConfigExists() throws InitializationException {
- try {
- File pdfOverConfig = new File(Constants.CONFIG_DIRECTORY + File.separator + Constants.DEFAULT_CONFIG_FILENAME);
- if (!pdfOverConfig.exists())
- pdfOverConfig.createNewFile();
- } catch (Exception e) {
- log.error("Failed to create PDF-Over config file", e);
- throw new InitializationException("Failed to create PDF-Over config file", e);
- }
- }
-
- private void unzipPdfAsConfig(File configDir) throws InitializationException {
- InputStream is = getClass().getResourceAsStream(Constants.RES_CFG_ZIP);
-
- try {
- Zipper.unzip(is, configDir.getAbsolutePath());
- } catch (IOException e) {
- log.error(
- "Failed to create local configuration directory!", e);
- throw new InitializationException(
- "Failed to create local configuration directory!",
- e);
- }
- }
-
- private static void updateVersionFile(File configDir) throws InitializationException {
- File versionFile = new File(configDir, Constants.CONFIG_VERSION_FILENAME);
- try {
- BufferedWriter versionWriter = new BufferedWriter(new FileWriter(versionFile));
- String version = Constants.APP_VERSION == null ? "Unknown" : Constants.APP_VERSION;
- versionWriter.write(version);
- versionWriter.close();
- } catch (IOException e) {
- log.error(
- "Failed to create configuration version file!", e);
- throw new InitializationException(
- "Failed to create configuration version file!",
- e);
- }
- }
-
- private void createConfiguration(File configDir) throws InitializationException {
- boolean allOK = false;
-
- log.info("Creating configuration directory");
- if (!configDir.exists()) {
- configDir.mkdir();
- }
-
- try {
- ensurePdfOverConfigExists();
- unzipPdfAsConfig(configDir);
- updateVersionFile(configDir);
-
- allOK = true;
- } finally {
- if (!allOK) {
- configDir.delete();
- }
- }
- }
-
- /**
- * @return The first valid (not empty, non comment) line of the version file
- * or null if version file cannot be read or does not contain
- * such a line.
- */
- private static String getVersion(File versionFile) {
- if (versionFile.exists() && versionFile.canRead()) {
- BufferedReader versionReader = null;
- try {
- versionReader = new BufferedReader(new FileReader(versionFile));
- String version;
- while ((version = versionReader.readLine()) != null) {
- version = version.trim();
- if (version.length() > 0 && !version.startsWith("#")) {
- log.trace("configuration version from " + versionFile
- + ": " + version);
- return version;
- }
- }
- } catch (IOException ex) {
- log.error("failed to read configuration version from "
- + versionFile, ex);
- } finally {
- try {
- if (versionReader != null)
- versionReader.close();
- } catch (IOException ex) {
- // ignore
- }
- }
- }
- log.debug("unknown configuration version");
- return null;
- }
-
- /**
- * Backup old configuration, create new
- * @param configDir
- * @throws InitializationException
- */
- private void backupAndCreatePdfAsConfiguration(File configDir) throws InitializationException {
- try {
- File backup = File.createTempFile(Constants.PDF_AS_CONFIG_BACKUP_FILENAME, ".zip");
- OutputStream os = new FileOutputStream(backup);
- Zipper.zip(configDir + File.separator + "cfg", os, true);
- os.close();
- unzipPdfAsConfig(configDir);
- File b = new File(configDir, Constants.PDF_AS_CONFIG_BACKUP_FILENAME + ".zip");
- int i = 1;
- while (b.exists()) {
- b = new File(configDir, Constants.PDF_AS_CONFIG_BACKUP_FILENAME + i++ + ".zip");
- }
- backup.renameTo(b);
- updateVersionFile(configDir);
- } catch (FileNotFoundException e) {
- log.error("Backup file not found", e);
- throw new InitializationException("Backup file not found", e);
- } catch (IOException e) {
- log.error("Error creating configuration backup", e);
- throw new InitializationException("Error creating configuration backup", e);
- }
- }
-
- @Override
- public void run() {
- // Read config file
- try {
- StateMachine stateMachine = getStateMachine();
- ConfigurationManager config = stateMachine.configProvider;
- File configDir = new File(Constants.CONFIG_DIRECTORY);
- File configFile = new File(configDir, Constants.DEFAULT_CONFIG_FILENAME);
- if (!configDir.exists() || !configFile.exists()) {
- log.debug("Creating configuration file");
- createConfiguration(configDir);
- } else {
- log.debug("Configuration directory exists!");
- // Check PDF-AS config version
- File versionFile = new File(configDir, Constants.CONFIG_VERSION_FILENAME);
- String configVersion = getVersion(versionFile);
- if (configVersion == null || VersionComparator.before(configVersion, Constants.MIN_PDF_AS_CONFIG_VERSION))
- backupAndCreatePdfAsConfiguration(configDir);
- }
-
-
- // Read cli arguments for config file location first
- try {
- initializeFromArguments(stateMachine.cmdLineArgs, this.configFileHandler);
- } catch (InitializationException e) {
- log.error("Error in cmd line arguments: ", e);
- ErrorDialog error = new ErrorDialog(stateMachine.getMainShell(),
- Messages.getString("error.CmdLineArgs") + "\n" +
- e.getMessage(),
- BUTTONS.OK);
- error.open();
- stateMachine.exit();
- }
-
- // initialize from config file
- initializeFromConfigurationFile();
-
- // Read cli arguments
- try {
- initializeFromArguments(stateMachine.cmdLineArgs, this.handler);
- } catch (InitializationException e) {
- log.error("Error in cmd line arguments: ", e);
- ErrorDialog error;
-
- if (e.getCause() instanceof FileNotFoundException) {
- error = new ErrorDialog(stateMachine.getMainShell(),
- String.format(
- Messages.getString("error.FileNotExist"),
- e.getCause().getMessage()),
- BUTTONS.OK);
- } else {
- error = new ErrorDialog(stateMachine.getMainShell(),
- Messages.getString("error.CmdLineArgs") + "\n" +
- e.getMessage(),
- BUTTONS.OK);
- }
- error.open();
- stateMachine.exit();
- }
-
- // Check for updates
- if (config.getUpdateCheck())
- UpdateCheckManager.checkNow(stateMachine.getMainShell());
-
- // Create PDF Signer
- Status status = stateMachine.status;
- status.bku = getStateMachine().configProvider.getDefaultBKU();
- status.signaturePosition = getStateMachine().configProvider.getAutoPositionSignature() ? (new SignaturePosition()) : null;
-
- setNextState(new OpenState(stateMachine));
-
- } catch (Exception e) {
- log.error("Failed to initialize: ", e);
- ErrorDialog error = new ErrorDialog(
- getStateMachine().getMainShell(),
- Messages.getString("error.Initialization"),
- BUTTONS.YES_NO
- );
- // error.setException(e);
- // setNextState(error);
- int selection = error.open();
- if (selection == SWT.YES)
- ConfigurationManager.factoryResetPersistentConfig();
-
- getStateMachine().exit();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- // No composite - no cleanup necessary
- }
-
- /*
- * (non-Javadoc)
- *
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- // no behavior necessary yet
- }
-
- @Override
- public String toString() {
- return getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
deleted file mode 100644
index 1669f2f8..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java
+++ /dev/null
@@ -1,263 +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.workflow.states;
-
-//Imports
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.composites.WaitingComposite;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signer.Emblem;
-import at.asit.pdfover.signer.PDFFileDocumentSource;
-import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter;
-import at.asit.pdfover.signer.pdfas.PdfAs4Signer;
-import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
-
-/**
- * User waiting state, wait for PDF Signator library to prepare document for
- * signing.
- */
-public class PrepareSigningState extends State {
-
- /**
- * @param stateMachine
- */
- public PrepareSigningState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- private final class PrepareDocumentThread implements Runnable {
-
- private PrepareSigningState state;
-
- /**
- * Default constructor
- *
- * @param state
- */
- public PrepareDocumentThread(PrepareSigningState state) {
- this.state = state;
- }
-
- @Override
- public void run() {
- try {
-
- Status status = this.state.getStateMachine().status;
-
- ConfigurationManager configuration = this.state.getStateMachine().configProvider;
-
- // SET PROXY HOST and PORT settings
- final String proxyHost = configuration.getProxyHost();
- final int proxyPort = configuration.getProxyPort();
- final String proxyUser = configuration.getProxyUser();
- final String proxyPass = configuration.getProxyPass();
-
- if (proxyHost != null && !proxyHost.isEmpty()) {
- log.debug("Setting proxy host to " + proxyHost);
- System.setProperty("http.proxyHost", proxyHost);
- System.setProperty("https.proxyHost", proxyHost);
- }
-
- if (proxyPort > 0 && proxyPort <= 0xFFFF) {
- String port = Integer.toString(proxyPort);
- log.debug("Setting proxy port to " + port);
- System.setProperty("http.proxyPort", port);
- System.setProperty("https.proxyPort", port);
- }
-
- if (proxyUser != null && !proxyUser.isEmpty()) {
- log.debug("Setting proxy username to " + proxyUser);
- System.setProperty("http.proxyUser", proxyUser);
- System.setProperty("https.proxyUser", proxyUser);
- }
-
- if (proxyPass != null) {
- log.debug("Setting proxy password");
- System.setProperty("http.proxyPassword", proxyPass);
- System.setProperty("https.proxyPassword", proxyPass);
- }
-
- if (proxyUser != null && !proxyUser.isEmpty() &&
- proxyPass != null && !proxyPass.isEmpty()) {
- log.debug("Enabling proxy authentication");
- Authenticator.setDefault(new Authenticator() {
- /* (non-Javadoc)
- * @see java.net.Authenticator#getPasswordAuthentication()
- */
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- if (getRequestorType() == RequestorType.PROXY) {
- if (getRequestingHost().equalsIgnoreCase(proxyHost) &&
- (getRequestingPort() == proxyPort)) {
- return new PasswordAuthentication(proxyUser,
- proxyPass.toCharArray());
- }
- }
- return super.getPasswordAuthentication();
- }
- });
- }
-
- if (this.state.signatureParameter == null) {
- this.state.signatureParameter = new PdfAs4SignatureParameter();
- }
-
- this.state.signatureParameter.inputDocument = new PDFFileDocumentSource(status.document);
- this.state.signatureParameter.signatureDevice = status.bku;
- if (status.signaturePosition != null) {
- this.state.signatureParameter.signaturePosition = status.signaturePosition;
- }
-
- if (configuration.getDefaultEmblemPath() != null && !configuration.getDefaultEmblemPath().isEmpty()) {
- this.state.signatureParameter.emblem = new Emblem(configuration.getDefaultEmblemPath());
- }
-
- if (configuration.getSignatureNote() != null && !configuration.getSignatureNote().isEmpty()) {
- this.state.signatureParameter.signatureNote = configuration.getSignatureNote();
- }
-
- this.state.signatureParameter.searchForPlaceholderSignatures = getStateMachine().status.searchForPlacehoderSignature;
- this.state.signatureParameter.signatureLanguage = configuration.getSignatureLocale().getLanguage();
- this.state.signatureParameter.enablePDFACompat = configuration.getSignaturePdfACompat();
- this.state.signatureParameter.signatureProfile = configuration.getSignatureProfile();
- this.state.signatureParameter.targetLogoSize = configuration.getLogoOnlyTargetSize();
-
- this.state.signingState = PdfAs4Signer.prepare(this.state.signatureParameter);
-
- } catch (Exception e) {
- log.error("PrepareDocumentThread: ", e);
- this.state.threadException = e;
- } finally {
- this.state.updateStateMachine();
- }
- }
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(PrepareSigningState.class);
-
- PdfAs4SignatureParameter signatureParameter;
-
- private WaitingComposite waitingComposite = null;
-
- private WaitingComposite getSelectionComposite() {
- if (this.waitingComposite == null) {
- this.waitingComposite = getStateMachine()
- .createComposite(WaitingComposite.class, SWT.RESIZE, this);
- }
-
- return this.waitingComposite;
- }
-
- PdfAs4SigningState signingState = null;
-
- Exception threadException = null;
-
- @Override
- public void run() {
- WaitingComposite waiting = this.getSelectionComposite();
-
- getStateMachine().display(waiting);
-
- Status status = getStateMachine().status;
-
- if (this.signatureParameter == null) {
- this.signatureParameter = new PdfAs4SignatureParameter();
- }
-
- if (this.signingState == null && this.threadException == null) {
- Thread t = new Thread(new PrepareDocumentThread(this));
- t.start();
- return;
- }
-
- if (this.threadException != null) {
- ErrorDialog error = new ErrorDialog(getStateMachine()
- .getMainShell(),
- Messages.getString("error.PrepareDocument"),
- BUTTONS.RETRY_CANCEL);
- this.threadException = null;
- if (error.open() == SWT.RETRY) {
- run();
- } else {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- return;
- }
-
- // We got the Request set it into status and move on to next state ...
- status.signingState = this.signingState;
-
- switch (status.bku)
- {
- case LOCAL:
- this.setNextState(new LocalBKUState(getStateMachine()));
- break;
- case MOBILE:
- this.setNextState(new MobileBKUState(getStateMachine()));
- break;
- case KS:
- this.setNextState(new KSState(getStateMachine()));
- break;
- default:
- log.error("Invalid selected BKU Value \"{}\" in PrepareSigningState!", status.bku.name());
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- }
-
- /*
- * (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- if (this.waitingComposite != null)
- this.waitingComposite.dispose();
- }
-
- /*
- * (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
deleted file mode 100644
index cf4d6d37..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java
+++ /dev/null
@@ -1,158 +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.workflow.states;
-
-//Imports
-import java.net.ConnectException;
-
-import org.eclipse.swt.SWT;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.gui.MainWindowBehavior;
-import at.asit.pdfover.gui.MainWindow.Buttons;
-import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
-import at.asit.pdfover.gui.controls.ErrorDialog;
-import at.asit.pdfover.commons.Messages;
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.Status;
-import at.asit.pdfover.signer.SignatureException;
-import at.asit.pdfover.signer.UserCancelledException;
-import at.asit.pdfover.signer.pdfas.PdfAs4Signer;
-
-/**
- * Logical state for signing process, usually show BKU Dialog during this state.
- */
-public class SigningState extends State {
-
- /**
- *
- */
- private final class FinishSignThread implements Runnable {
-
- private SigningState state;
-
- /**
- * @param signingState
- */
- public FinishSignThread(SigningState signingState) {
- this.state = signingState;
- }
-
- @Override
- public void run() {
- try {
- Status status = this.state.getStateMachine().status;
- status.signResult = PdfAs4Signer.sign(status.signingState);
- } catch(Exception e) {
- this.state.threadException = e;
- } finally {
- this.state.updateStateMachine();
- }
- }
- }
-
- /**
- * @param stateMachine
- */
- public SigningState(StateMachine stateMachine) {
- super(stateMachine);
- }
-
- /**
- * SLF4J Logger instance
- **/
- static final Logger log = LoggerFactory.getLogger(SigningState.class);
-
- Exception threadException = null;
-
- @Override
- public void run() {
- Status status = getStateMachine().status;
-
- if(status.signResult == null &&
- this.threadException == null) {
- Thread t = new Thread(new FinishSignThread(this));
- t.start();
- return;
- }
-
- if(this.threadException != null) {
- String message = Messages.getString("error.Signatur");
- if (this.threadException instanceof SignatureException) {
- Throwable cause = this.threadException;
- while (cause.getCause() != null)
- cause = cause.getCause();
- if (cause instanceof ConnectException)
- message += ": " + cause.getMessage();
- if (cause instanceof IllegalStateException) {
- // TODO legacy hack
- this.threadException = new UserCancelledException();
- }
- }
- if (this.threadException instanceof UserCancelledException) {
- // don't display error, clear remembered password and go back to BKU Selection
- if (this.getConfig().getRememberMobilePassword())
- this.getConfig().setDefaultMobilePasswordOverlay(null);
- this.setNextState(new BKUSelectionState(getStateMachine()));
- return;
- }
-
- // if we have gotten to this point, this is an actual exception
- log.error("FinishSignThread: ", this.threadException);
-
- ErrorDialog error = new ErrorDialog(getStateMachine().getMainShell(),
- message, BUTTONS.RETRY_CANCEL);
- this.threadException = null;
- if(error.open() == SWT.RETRY) {
- this.setNextState(new PrepareSigningState(getStateMachine()));
- } else {
- this.setNextState(new BKUSelectionState(getStateMachine()));
- }
- return;
- }
-
- this.setNextState(new OutputState(getStateMachine()));
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#cleanUp()
- */
- @Override
- public void cleanUp() {
- // No composite - no cleanup necessary
- }
-
- /* (non-Javadoc)
- * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior()
- */
- @Override
- public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().status.behavior;
- behavior.reset();
- behavior.setActive(Buttons.OPEN, true);
- behavior.setActive(Buttons.POSITION, true);
- behavior.setActive(Buttons.SIGN, true);
- //behavior.setEnabled(Buttons.OPEN, true);
- //behavior.setEnabled(Buttons.POSITION, true);
- //behavior.setEnabled(Buttons.SIGN, true);
- }
-
- @Override
- public String toString() {
- return this.getClass().getName();
- }
-}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java
deleted file mode 100644
index c039f21a..00000000
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java
+++ /dev/null
@@ -1,93 +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.workflow.states;
-
-//Imports
-import at.asit.pdfover.gui.workflow.StateMachine;
-import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-
-/**
- * Base state class
- */
-public abstract class State {
-
- /**
- * The StateMachine
- */
- private StateMachine stateMachine;
-
- private State nextState = null;
-
- /**
- * Default Workflow State constructor
- * @param stateMachine the State Machine
- */
- public State(StateMachine stateMachine) {
- this.stateMachine = stateMachine;
- this.nextState = this;
- }
-
- public ConfigurationManager getConfig() { return this.stateMachine.configProvider; }
-
- /**
- * Gets the next logical state or null if this their is no state transition
- * @return the next state (or null)
- */
- public State nextState() {
- return this.nextState;
- }
-
- /**
- * Sets the next logical state
- * @param state
- */
- protected void setNextState(State state) {
- this.nextState = state;
- }
-
- /**
- * Perform main logic for this state
- */
- public abstract void run();
-
- /**
- * Perform status cleanup
- */
- public abstract void cleanUp();
-
- /**
- * Update the state machine
- */
- public void updateStateMachine()
- {
- this.stateMachine.invokeUpdate();
- }
-
- /**
- * Get the state machine
- * @return the StateMachine
- */
- protected StateMachine getStateMachine()
- {
- return this.stateMachine;
- }
-
- /**
- * Update the main window behavior of this state if necessary
- * Should update this.stateMachine.status.getBehavior()
- */
- public abstract void updateMainWindowBehavior();
-}