From 52edf7dfea3015e807e72e0812d99abbb53e6f9f Mon Sep 17 00:00:00 2001 From: tkellner Date: Fri, 24 Aug 2012 17:04:50 +0000 Subject: State Machine refactoring git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12388 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../.settings/org.eclipse.jdt.core.prefs | 2 +- .../main/java/at/asit/pdfover/gui/MainWindow.java | 318 ++++++++++++++++++++ .../at/asit/pdfover/gui/MainWindowBehavior.java | 74 +++++ .../gui/components/BKUSelectionComposite.java | 167 ----------- .../gui/components/DataSourceSelectComposite.java | 296 ------------------- .../at/asit/pdfover/gui/components/MainWindow.java | 327 --------------------- .../gui/components/PositioningComposite.java | 120 -------- .../pdfover/gui/components/StateComposite.java | 32 -- .../pdfover/gui/components/WaitingComposite.java | 66 ----- .../main_behavior/ConfigOpenEnabled.java | 45 --- .../main_behavior/ConfigOpenPositionEnabled.java | 45 --- .../main_behavior/MainWindowAllDisabled.java | 46 --- .../main_behavior/MainWindowAllEnable.java | 46 --- .../main_behavior/MainWindowBehavior.java | 29 -- .../main_behavior/OnlyConfigEnabled.java | 45 --- .../asit/pdfover/gui/workflow/ConfigProvider.java | 19 +- .../pdfover/gui/workflow/ConfigProviderImpl.java | 54 ++++ .../at/asit/pdfover/gui/workflow/GUIProvider.java | 44 +++ .../at/asit/pdfover/gui/workflow/PDFSigner.java | 43 +++ .../asit/pdfover/gui/workflow/PDFSignerImpl.java | 72 +++++ .../java/at/asit/pdfover/gui/workflow/State.java | 77 ----- .../at/asit/pdfover/gui/workflow/StateMachine.java | 44 ++- .../pdfover/gui/workflow/StateMachineImpl.java | 286 ++++++------------ .../java/at/asit/pdfover/gui/workflow/Status.java | 43 ++- .../at/asit/pdfover/gui/workflow/StatusImpl.java | 124 ++++++++ .../gui/workflow/states/BKUSelectionState.java | 36 ++- .../workflow/states/DataSourceSelectionState.java | 81 ----- .../pdfover/gui/workflow/states/LocalBKUState.java | 29 +- .../gui/workflow/states/MobileBKUState.java | 30 +- .../pdfover/gui/workflow/states/OpenState.java | 93 ++++++ .../pdfover/gui/workflow/states/OutputState.java | 34 ++- .../gui/workflow/states/PositioningState.java | 47 ++- .../workflow/states/PrepareConfigurationState.java | 67 ++--- .../gui/workflow/states/PrepareSigningState.java | 57 ++-- .../pdfover/gui/workflow/states/SigningState.java | 22 +- .../at/asit/pdfover/gui/workflow/states/State.java | 86 ++++++ .../asit/pdfover/signer/pdfas/PDFASSLRequest.java | 4 +- .../at/asit/pdfover/signer/pdfas/PDFASSigner.java | 2 + 38 files changed, 1309 insertions(+), 1743 deletions(-) create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/BKUSelectionComposite.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/DataSourceSelectComposite.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/MainWindow.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/PositioningComposite.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/StateComposite.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/WaitingComposite.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenEnabled.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenPositionEnabled.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllDisabled.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllEnable.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowBehavior.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/OnlyConfigEnabled.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSigner.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSignerImpl.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/State.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java delete mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java diff --git a/trunk/pdf-over-gui/.settings/org.eclipse.jdt.core.prefs b/trunk/pdf-over-gui/.settings/org.eclipse.jdt.core.prefs index 482b5e85..c2132b91 100644 --- a/trunk/pdf-over-gui/.settings/org.eclipse.jdt.core.prefs +++ b/trunk/pdf-over-gui/.settings/org.eclipse.jdt.core.prefs @@ -60,7 +60,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java new file mode 100644 index 00000000..706064bd --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -0,0 +1,318 @@ +/* + * 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.util.EnumMap; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.custom.StackLayout; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +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.Composite; +import org.eclipse.swt.widgets.Control; +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.composites.StateComposite; +import at.asit.pdfover.gui.workflow.StateMachine; +import at.asit.pdfover.gui.workflow.states.OpenState; +import at.asit.pdfover.gui.workflow.states.PositioningState; + +/** + * The Main Window of PDFOver 4.0 + */ +public class MainWindow { + + /** + * Selection Listener for Position Button + */ + private final class PositionSelectionListener implements SelectionListener { + /** + * Default constructor + */ + public PositionSelectionListener() { + // Nothing to do here + } + + @Override + public void widgetSelected(SelectionEvent e) { + MainWindow.this.stateMachine.jumpToState(new PositioningState( + MainWindow.this.stateMachine)); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Nothing to do here + } + } + + /** + * Selection Listener for Open Button + */ + private final class DataSourceSelectionListener implements + SelectionListener { + /** + * Default constructor + */ + public DataSourceSelectionListener() { + // Nothing to do here + } + + @Override + public void widgetSelected(SelectionEvent e) { + MainWindow.this.stateMachine + .jumpToState(new OpenState( + MainWindow.this.stateMachine)); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Nothing to do here + } + } + + /** + * SFL4J Logger instance + **/ + static final Logger log = LoggerFactory.getLogger(MainWindow.class); + + private Shell shell; + private CLabel lbl_status; + private Composite container; + private StackLayout stack; + StateMachine stateMachine; + private Button btn_sign; + private Button btn_position; + private Button btn_open; + private Button btn_config; + + public enum Buttons { + CONFIG, OPEN, POSITION, SIGN, FINAL + } + + private Map buttonMap; + + /** + * Default constructor + * + * @param stateMachine + * The main workflow + */ + public MainWindow(StateMachine stateMachine) { + super(); + + this.stateMachine = stateMachine; + + this.buttonMap = new EnumMap(Buttons.class); + } + + /** + * Set current status (may be removed in production release) + * + * @param value + */ + public void setStatus(String value) { + if (this.getShell().isDisposed()) { + return; + } + this.lbl_status.setText("[DEBUG]: Current workflow state: " + value); + } + + /** + * Sets top level composite for stack layout + * + * @param ctrl + */ + public void setTopControl(Control ctrl) { + log.debug("Top control: " + ctrl.toString()); + this.stack.topControl = ctrl; + this.doLayout(); + } + + /** + * Layout the Main Window + */ + public void doLayout() { + Control ctrl = this.stack.topControl; + this.container.layout(true, true); + this.shell.layout(true, true); + // Note: SWT only layouts children! No grandchildren! + if (ctrl instanceof StateComposite) { + ((StateComposite) ctrl).doLayout(); + } + } + + /** + * Gets the container composite + * + * @return the container composite + */ + public Composite getContainer() { + return this.container; + } + + /** + * Entrance point for swt designer + * + * @param args + */ + public static void main(String[] args) { + Display display = Display.getDefault(); + + MainWindow window = new MainWindow(null); + + window.open(); + + window.getShell().open(); + window.getShell().layout(); + while (!window.getShell().isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + } + + /** + * Open the window. + * + * @wbp.parser.entryPoint + */ + public void open() { + createContents(); + } + + /** + * Create contents of the window. + */ + protected void createContents() { + this.shell = new Shell(); + getShell().setSize(450, 329); + getShell().setText("PDF-Over"); + + getShell().setLayout(new FormLayout()); + + Composite composite = new Composite(getShell(), SWT.NONE); + FormData fd_composite = new FormData(); + fd_composite.left = new FormAttachment(0, 5); + fd_composite.right = new FormAttachment(100, -5); + fd_composite.top = new FormAttachment(0, 5); + fd_composite.bottom = new FormAttachment(0, 40); + composite.setLayoutData(fd_composite); + composite.setLayout(new FormLayout()); + + this.btn_config = new Button(composite, SWT.NONE); + FormData fd_config = new FormData(); + fd_config.left = new FormAttachment(0, 0); + fd_config.right = new FormAttachment(25, 0); + fd_config.top = new FormAttachment(0, 0); + fd_config.bottom = new FormAttachment(100, 0); + this.btn_config.setLayoutData(fd_config); + this.btn_config.setText("Config ..."); + buttonMap.put(Buttons.CONFIG, btn_config); + + this.btn_open = new Button(composite, SWT.NONE); + FormData fd_open = new FormData(); + fd_open.left = new FormAttachment(25, 0); + fd_open.right = new FormAttachment(50, 0); + fd_open.top = new FormAttachment(0, 0); + fd_open.bottom = new FormAttachment(100, 0); + this.btn_open.setLayoutData(fd_open); + this.btn_open.setText("Open ..."); + this.btn_open.addSelectionListener(new DataSourceSelectionListener()); + buttonMap.put(Buttons.OPEN, btn_open); + + this.btn_position = new Button(composite, SWT.NONE); + FormData fd_position = new FormData(); + fd_position.left = new FormAttachment(50, 0); + fd_position.right = new FormAttachment(75, 0); + fd_position.top = new FormAttachment(0, 0); + fd_position.bottom = new FormAttachment(100, 0); + this.btn_position.setLayoutData(fd_position); + this.btn_position.setText("Positon ..."); + this.btn_position.addSelectionListener(new PositionSelectionListener()); + buttonMap.put(Buttons.POSITION, btn_position); + + this.btn_sign = new Button(composite, SWT.NONE); + FormData fd_sign = new FormData(); + fd_sign.left = new FormAttachment(75, 0); + fd_sign.right = new FormAttachment(100, 0); + fd_sign.top = new FormAttachment(0, 0); + fd_sign.bottom = new FormAttachment(100, 0); + this.btn_sign.setLayoutData(fd_sign); + this.btn_sign.setText("Sign ..."); + buttonMap.put(Buttons.SIGN, btn_sign); + + this.container = new Composite(getShell(), SWT.BORDER | SWT.RESIZE); + FormData fd_composite_1 = new FormData(); + fd_composite_1.bottom = new FormAttachment(100, -25); + fd_composite_1.right = new FormAttachment(100, -5); + fd_composite_1.top = new FormAttachment(0, 45); + fd_composite_1.left = new FormAttachment(0, 5); + this.container.setLayoutData(fd_composite_1); + this.stack = new StackLayout(); + this.container.setLayout(this.stack); + + this.lbl_status = new CLabel(getShell(), SWT.NONE); + FormData fd_lblNewLabel = new FormData(); + fd_lblNewLabel.right = new FormAttachment(100, -5); + fd_lblNewLabel.bottom = new FormAttachment(100, -5); + fd_lblNewLabel.top = new FormAttachment(100, -20); + fd_lblNewLabel.left = new FormAttachment(0, 5); + this.lbl_status.setLayoutData(fd_lblNewLabel); + this.lbl_status.setText("New Label"); + + } + + /** + * Update MainWindow to fit new status + */ + public void applyBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus() + .getBehavior(); + + log.debug("Updating MainWindow state for : " + + this.stateMachine.getStatus().getCurrentState().toString()); + + for (Buttons button : Buttons.values()) { + boolean active = behavior.getActive(button); + boolean enabled = behavior.getEnabled(button); + + Button theButton = buttonMap.get(button); + if (theButton != null) + { + theButton.setEnabled(enabled); + } + } + + //TODO: Display/Hide main bar + } + + /** + * @return the shell + */ + public Shell getShell() { + return this.shell; + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java new file mode 100644 index 00000000..63c2dafd --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindowBehavior.java @@ -0,0 +1,74 @@ +/* + * 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 { + protected Map buttonsEnabled; + protected Map buttonsActive; + protected boolean mainBarVisible; + + public MainWindowBehavior() { + this.buttonsActive = new EnumMap(MainWindow.Buttons.class); + this.buttonsEnabled = new EnumMap( MainWindow.Buttons.class); + reset(); + } + + public void setActive(Buttons button, boolean active) { + this.buttonsActive.put(button, active); + } + + public boolean getActive(Buttons button) { + return this.buttonsActive.get(button); + } + + public void setEnabled(Buttons button, boolean enabled) { + this.buttonsEnabled.put(button, enabled); + } + + 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); + } + + public void setMainBarVisible(boolean visible) { + this.mainBarVisible = visible; + } + + public boolean getMainBarVisible() { + return this.mainBarVisible; + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/BKUSelectionComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/BKUSelectionComposite.java deleted file mode 100644 index 84b38a07..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/BKUSelectionComposite.java +++ /dev/null @@ -1,167 +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.components; - -// Imports -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Composite; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.states.BKUSelectionState; -import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; - -/** - * - */ -public class BKUSelectionComposite extends Composite implements StateComposite { - - - /** - * Listener for local bku selection - */ - private final class LocalSelectionListener implements SelectionListener { - - /** - * Default constructor - */ - public LocalSelectionListener() { - // Nothing here - } - - @Override - public void widgetSelected(SelectionEvent e) { - log.debug("Setting BKU to LOCAL"); - setSelected(BKUs.LOCAL); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing here - } - } - - /** - * Listener for mobile bku selection - */ - private final class MobileSelectionListener implements SelectionListener { - - /** - * Default constructor - */ - public MobileSelectionListener() { - // Nothing here - } - - @Override - public void widgetSelected(SelectionEvent e) { - log.debug("Setting BKU to MOBILE"); - setSelected(BKUs.MOBILE); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing here - } - } - - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(BKUSelectionComposite.class); - - private BKUSelectionState state; - - private BKUs selected = BKUs.NONE; - - /** - * Gets selected BKU type - * @return BKUS enum - */ - public BKUs getSelected() { - return this.selected; - } - - /** - * Sets selected BKU and updates workflow - * @param selected - */ - public void setSelected(final BKUs selected) { - this.selected = selected; - this.state.updateStateMachine(); - } - - /** - * Create the composite. - * @param parent - * @param style - * @param state - */ - public BKUSelectionComposite(Composite parent, int style, BKUSelectionState state) { - super(parent, style); - - this.state = state; - - this.setLayout(new FormLayout()); - - - Button btn_mobile = new Button(this, SWT.NATIVE | SWT.RESIZE); - btn_mobile.setText("MOBILE"); - //Point mobile_size = btn_mobile.computeSize(SWT.DEFAULT, SWT.DEFAULT); - FormData fd_btn_mobile = new FormData(); - fd_btn_mobile.left = new FormAttachment(40, 0); - fd_btn_mobile.right = new FormAttachment(50, 0); - fd_btn_mobile.top = new FormAttachment(45, 0); - fd_btn_mobile.bottom = new FormAttachment(55, 0); - btn_mobile.setLayoutData(fd_btn_mobile); - btn_mobile.addSelectionListener(new MobileSelectionListener()); - - Button btn_card = new Button(this, SWT.NATIVE | SWT.RESIZE); - btn_card.setText("CARD"); - //Point card_size = btn_card.computeSize(SWT.DEFAULT, SWT.DEFAULT); - FormData fd_btn_card = new FormData(); - fd_btn_card.left = new FormAttachment(50, 0); - fd_btn_card.right = new FormAttachment(60, 0); - fd_btn_card.top = new FormAttachment(45, 0); - fd_btn_card.bottom = new FormAttachment(55, 0); - btn_card.setLayoutData(fd_btn_card); - btn_card.addSelectionListener(new LocalSelectionListener()); - - this.pack(); - } - - @Override - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.StateComposite#doLayout() - */ - @Override - public void doLayout() { - this.layout(true, true); - } - -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/DataSourceSelectComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/DataSourceSelectComposite.java deleted file mode 100644 index fe0cb2ee..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/DataSourceSelectComposite.java +++ /dev/null @@ -1,296 +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.components; - -// Imports -import java.io.File; - -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.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.eclipse.swt.graphics.Color; -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.layout.FormLayout; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.*; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; - -import at.asit.pdfover.gui.workflow.StateMachineImpl; - -/** - * - * - */ -public class DataSourceSelectComposite extends Composite implements - StateComposite { - - /** - * - */ - private final class FileBrowseDialog implements SelectionListener { - /** - * - */ - public FileBrowseDialog() { - // Nothing to do here - } - - @Override - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(DataSourceSelectComposite.this.getShell(), SWT.OPEN); - dialog.setFilterExtensions(new String[] {"*.pdf"}); - dialog.setFilterNames(new String[] {"PDF Dateien"}); - String fileName = dialog.open(); - File file = null; - if (fileName != null) { - file = new File(fileName); - if(file.exists()) { - DataSourceSelectComposite.this.setSelected(file); - } - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing to do here - } - } - - /** - * SFL4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(DataSourceSelectComposite.class); - - private StateMachineImpl workflow; - - /** - * 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; - workflow.update(); - } - - /** - * Gets the selected file - * - * @return the selected file - */ - public File getSelected() { - return this.selected; - } - - /** - * Create the composite. - * - * @param parent - * @param style - * @param flow - */ - public DataSourceSelectComposite(Composite parent, int style, StateMachineImpl flow) { - super(parent, style); - - this.workflow = flow; - - this.setLayout(new FormLayout()); - - Color back = new Color(Display.getCurrent(), 77, 190, 250); - - this.drop_area = new Composite(this, SWT.RESIZE | SWT.BORDER_DASH); - FormData fd_drop_area = new FormData(); - fd_drop_area.left = new FormAttachment(0, 0); - fd_drop_area.right = new FormAttachment(100, 0); - fd_drop_area.top = new FormAttachment(0, 0); - fd_drop_area.bottom = new FormAttachment(100, 0); - this.drop_area.setLayoutData(fd_drop_area); - this.drop_area.setLayout(new FormLayout()); - this.drop_area.setBackground(back); - - DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_DEFAULT - | DND.DROP_COPY); - final FileTransfer fileTransfer = FileTransfer.getInstance(); - Transfer[] types = new Transfer[] { fileTransfer }; - dnd_target.setTransfer(types); - - dnd_target.addDropListener(new DropTargetListener() { - - @Override - public void dropAccept(DropTargetEvent event) { - // TODO Auto-generated method stub - - } - - @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: " + files[0] + " doesnot exists!"); - return; - } - DataSourceSelectComposite.this.setSelected(file); - } - } - } - - @Override - public void dragOver(DropTargetEvent event) { - // TODO Auto-generated method stub - - } - - @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 dragLeave(DropTargetEvent event) { - // No need to do anything here... - } - - @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; - } - } - } - }); - - final Label lbl_drag = new Label(this.drop_area, SWT.NONE | SWT.RESIZE); - FormData fd_lbl_drag = new FormData(); - fd_lbl_drag.left = new FormAttachment(5, 5); - fd_lbl_drag.right = new FormAttachment(100, -5); - fd_lbl_drag.top = new FormAttachment(5, 5); - fd_lbl_drag.bottom = new FormAttachment(55, -5); - lbl_drag.setLayoutData(fd_lbl_drag); - FontData[] fD = lbl_drag.getFont().getFontData(); - fD[0].setHeight(18); - lbl_drag.setFont(new Font(Display.getCurrent(), fD[0])); - lbl_drag.setText("Drag and Drop"); - lbl_drag.setAlignment(SWT.CENTER); - lbl_drag.setBackground(back); - - Button btn_open = new Button(this.drop_area, SWT.NATIVE | SWT.RESIZE); - btn_open.setText("Choose file ..."); - Point size = btn_open.computeSize(SWT.DEFAULT, SWT.DEFAULT); - FormData fd_btn_open = new FormData(); - fd_btn_open.left = new FormAttachment(100, size.x * -1 - 10); - fd_btn_open.right = new FormAttachment(100, -5); - fd_btn_open.top = new FormAttachment(100, size.y * -1 - 10); - fd_btn_open.bottom = new FormAttachment(100, -5); - btn_open.setLayoutData(fd_btn_open); - btn_open.setBackground(back); - btn_open.addSelectionListener(new FileBrowseDialog()); - this.drop_area.pack(); - - /* - * Button btn = new Button(this, SWT.NATIVE); btn.setBounds(50, 20, 100, - * 50); btn.setText("Click Me"); btn.addSelectionListener(new - * SelectionListener() { - * - * @Override public void widgetSelected(SelectionEvent arg0) { - * DataSourceSelectComposite.this.setPress(true); - * DataSourceSelectComposite.this.workflow.update(); } - * - * @Override public void widgetDefaultSelected(SelectionEvent arg0) { // - * TODO Auto-generated method stub - * - * } }); - */ - } - - private boolean press = false; - - private Composite drop_area; - - @Override - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } - - /** - * @return the press - */ - public boolean isPress() { - return this.press; - } - - /** - * @param press - * the press to set - */ - public void setPress(boolean press) { - this.press = press; - } - - /* - * (non-Javadoc) - * - * @see at.asit.pdfover.gui.components.StateComposite#doLayout() - */ - @Override - public void doLayout() { - this.layout(true, true); - this.drop_area.layout(true, true); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/MainWindow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/MainWindow.java deleted file mode 100644 index 96195780..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/MainWindow.java +++ /dev/null @@ -1,327 +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.components; - -// Imports -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Composite; -import org.eclipse.swt.widgets.Control; -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.components.main_behavior.ConfigOpenEnabled; -import at.asit.pdfover.gui.components.main_behavior.ConfigOpenPositionEnabled; -import at.asit.pdfover.gui.components.main_behavior.MainWindowAllDisabled; -import at.asit.pdfover.gui.components.main_behavior.MainWindowBehavior; -import at.asit.pdfover.gui.components.main_behavior.OnlyConfigEnabled; -import at.asit.pdfover.gui.workflow.State; -import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.gui.workflow.states.BKUSelectionState; -import at.asit.pdfover.gui.workflow.states.DataSourceSelectionState; -import at.asit.pdfover.gui.workflow.states.LocalBKUState; -import at.asit.pdfover.gui.workflow.states.MobileBKUState; -import at.asit.pdfover.gui.workflow.states.OutputState; -import at.asit.pdfover.gui.workflow.states.PositioningState; -import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState; -import at.asit.pdfover.gui.workflow.states.PrepareSigningState; -import at.asit.pdfover.gui.workflow.states.SigningState; - -/** - * The Main Window of PDFOver 4.0 - */ -public class MainWindow { - - /** - * - */ - private final class DataSourceSelectionListener implements - SelectionListener { - /** - * - */ - public DataSourceSelectionListener() { - // Nothing to do here - } - - @Override - public void widgetSelected(SelectionEvent e) { - MainWindow.this.stateMachine.setState(new DataSourceSelectionState()); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing to do here - } - } - - /** - * SFL4J Logger instance - **/ - private static final Logger log = LoggerFactory.getLogger(MainWindow.class); - private Shell shell; - private CLabel lbl_status; - private Composite container; - private StackLayout stack; - private StateMachine stateMachine; - private Button btn_sign; - - /** - * Gets the sign button - * @return the sign button - */ - public Button getBtn_sign() { - return this.btn_sign; - } - - private Button btn_position; - - /** - * Gets the position button - * @return the position button - */ - public Button getBtn_position() { - return this.btn_position; - } - - private Button btn_open; - - /** - * Gets the open button - * @return the open button - */ - public Button getBtn_open() { - return this.btn_open; - } - - private Button btn_config; - - /** - * Gets the config button - * @return the config button - */ - public Button getBtn_config() { - return this.btn_config; - } - - private Map behavior = new HashMap(); - - /** - * Default contsructor - * @param stateMachine The main workflow - */ - public MainWindow(StateMachine stateMachine) { - super(); - - this.behavior.put(PrepareConfigurationState.class, new MainWindowAllDisabled()); - this.behavior.put(PrepareSigningState.class, new MainWindowAllDisabled()); - this.behavior.put(SigningState.class, new MainWindowAllDisabled()); - this.behavior.put(LocalBKUState.class, new MainWindowAllDisabled()); - this.behavior.put(MobileBKUState.class, new MainWindowAllDisabled()); - - this.behavior.put(OutputState.class, new MainWindowAllDisabled()); - - this.behavior.put(DataSourceSelectionState.class, new OnlyConfigEnabled()); - - this.behavior.put(PositioningState.class, new ConfigOpenEnabled()); - - this.behavior.put(BKUSelectionState.class, new ConfigOpenPositionEnabled()); - - this.stateMachine = stateMachine; - } - - /** - * Set current status (may be removed in production release) - * @param value - */ - public void setStatus(String value) { - if(this.getShell().isDisposed()) { - return; - } - this.lbl_status.setText("[DEBUG]: Current workflow state: " + value); - } - - /** - * Sets top level composite for stack layout - * @param ctrl - */ - public void setTopControl(Control ctrl) { - log.debug("Top control: " + ctrl.toString()); - this.stack.topControl = ctrl; - this.doLayout(); - } - - /** - * Layout the Main Window - */ - public void doLayout() { - Control ctrl = this.stack.topControl; - this.container.layout(true, true); - this.shell.layout(true, true); - // Note: SWT only layouts children! No grandchildren! - if(ctrl instanceof StateComposite) { - ((StateComposite)ctrl).doLayout(); - } - } - - /** - * Gets the container composite - * @return - */ - public Composite getContainer() { - return this.container; - } - - /** - * Entrance point for swt designer - * @param args - */ - public static void main(String[] args) { - Display display = Display.getDefault(); - - MainWindow window = new MainWindow(null); - - window.open(); - - window.getShell().open(); - window.getShell().layout(); - while (!window.getShell().isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - } - - /** - * Open the window. - * @wbp.parser.entryPoint - */ - public void open() { - createContents(); - } - - /** - * Create contents of the window. - */ - protected void createContents() { - this.shell = new Shell(); - getShell().setSize(450, 329); - getShell().setText("PDF OVER 4.0! :)"); - - getShell().setLayout(new FormLayout()); - - - - Composite composite = new Composite(getShell(), SWT.NONE); - FormData fd_composite = new FormData(); - fd_composite.left = new FormAttachment(0, 5); - fd_composite.right = new FormAttachment(100, -5); - fd_composite.top = new FormAttachment(0, 5); - fd_composite.bottom = new FormAttachment(0, 40); - composite.setLayoutData(fd_composite); - composite.setLayout(new FormLayout()); - - this.btn_config = new Button(composite, SWT.NONE); - FormData fd_config = new FormData(); - fd_config.left = new FormAttachment(0, 0); - fd_config.right = new FormAttachment(25, 0); - fd_config.top = new FormAttachment(0, 0); - fd_config.bottom = new FormAttachment(100, 0); - this.btn_config.setLayoutData(fd_config); - this.btn_config.setText("Config ..."); - - this.btn_open = new Button(composite, SWT.NONE); - FormData fd_open = new FormData(); - fd_open.left = new FormAttachment(25, 0); - fd_open.right = new FormAttachment(50, 0); - fd_open.top = new FormAttachment(0, 0); - fd_open.bottom = new FormAttachment(100, 0); - this.btn_open.setLayoutData(fd_open); - this.btn_open.setText("Open ..."); - this.btn_open.addSelectionListener(new DataSourceSelectionListener()); - - this.btn_position = new Button(composite, SWT.NONE); - FormData fd_position = new FormData(); - fd_position.left = new FormAttachment(50, 0); - fd_position.right = new FormAttachment(75, 0); - fd_position.top = new FormAttachment(0, 0); - fd_position.bottom = new FormAttachment(100, 0); - this.btn_position.setLayoutData(fd_position); - this.btn_position.setText("Positon ..."); - - this.btn_sign = new Button(composite, SWT.NONE); - FormData fd_sign = new FormData(); - fd_sign.left = new FormAttachment(75, 0); - fd_sign.right = new FormAttachment(100, 0); - fd_sign.top = new FormAttachment(0, 0); - fd_sign.bottom = new FormAttachment(100, 0); - this.btn_sign.setLayoutData(fd_sign); - this.btn_sign.setText("Sign ..."); - - this.container = new Composite(getShell(), SWT.BORDER | SWT.RESIZE); - FormData fd_composite_1 = new FormData(); - fd_composite_1.bottom = new FormAttachment(100, -25); - fd_composite_1.right = new FormAttachment(100, -5); - fd_composite_1.top = new FormAttachment(0, 45); - fd_composite_1.left = new FormAttachment(0, 5); - this.container.setLayoutData(fd_composite_1); - this.stack = new StackLayout(); - this.container.setLayout(this.stack); - - this.lbl_status = new CLabel(getShell(), SWT.NONE); - FormData fd_lblNewLabel = new FormData(); - fd_lblNewLabel.right = new FormAttachment(100, -5); - fd_lblNewLabel.bottom = new FormAttachment(100, -5); - fd_lblNewLabel.top = new FormAttachment(100, -20); - fd_lblNewLabel.left = new FormAttachment(0, 5); - this.lbl_status.setLayoutData(fd_lblNewLabel); - this.lbl_status.setText("New Label"); - - } - - /** - * Update MainWindow to fit new status - */ - public void UpdateNewState() { - State state = this.stateMachine.getState(); - - log.debug("Updating MainWindow state for : " + state.toString()); - - if(this.behavior.containsKey(state.getClass())) { - this.behavior.get(state.getClass()).SetState(this); - } - } - - /** - * @return the shell - */ - public Shell getShell() { - return this.shell; - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/PositioningComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/PositioningComposite.java deleted file mode 100644 index c924ef79..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/PositioningComposite.java +++ /dev/null @@ -1,120 +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.components; - -// Imports -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.signator.SignaturePosition; - -/** - * - * - */ -public class PositioningComposite extends Composite implements StateComposite { - - /** - * Selection listener when position was fixed - */ - private final class PositionSelectedListener implements SelectionListener { - - /** - * Default constructor - */ - public PositionSelectedListener() { - // Nothing to do - } - - @Override - public void widgetSelected(SelectionEvent e) { - // TODO: FIX to get real position - PositioningComposite.this.setPosition(new SignaturePosition()); // Setting auto position for testing - PositioningComposite.this.workflow.update(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - // Nothing to do - } - } - - /** - * SFL4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(PositioningComposite.class); - - private StateMachineImpl workflow; - - private SignaturePosition position = null; - - /** - * Gets the Position - * @return - */ - public SignaturePosition getPosition() { - return this.position; - } - - /** - * Sets the position - * @param position - */ - public void setPosition(SignaturePosition position) { - this.position = position; - } - - /** - * Create the composite. - * @param parent - * @param style - */ - public PositioningComposite(Composite parent, int style, StateMachineImpl workflow) { - super(parent, style); - - this.workflow = workflow; - - Label test = new Label(this, SWT.NATIVE); - test.setBounds(10, 20, 100, 30); - test.setText("POSITIONING ---- TODO!!"); - - Button btn_position = new Button(this, SWT.NATIVE | SWT.RESIZE); - btn_position.setBounds(10, 50, 100, 30); - btn_position.setText("FAKE Position"); - btn_position.addSelectionListener(new PositionSelectedListener()); - } - - @Override - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.StateComposite#doLayout() - */ - @Override - public void doLayout() { - this.layout(true, true); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/StateComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/StateComposite.java deleted file mode 100644 index 0bfd7b87..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/StateComposite.java +++ /dev/null @@ -1,32 +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.components; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Composite interface for workflow state gui implementations - */ -public interface StateComposite { - - /** - * Performs layout for all children in composite - * (SWT layout(...) only layouts children no grandchildren!) - */ - public void doLayout(); -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/WaitingComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/WaitingComposite.java deleted file mode 100644 index 6ce53b22..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/WaitingComposite.java +++ /dev/null @@ -1,66 +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.components; - -// Imports -import org.eclipse.swt.widgets.Composite; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.eclipse.swt.widgets.ProgressBar; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormAttachment; - -import at.asit.pdfover.gui.workflow.StateMachineImpl; - -/** - * - */ -public class WaitingComposite extends Composite { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(WaitingComposite.class); - - private StateMachineImpl workflow; - - /** - * Create the composite. - * @param parent - * @param style - */ - public WaitingComposite(Composite parent, int style, StateMachineImpl workflow) { - super(parent, style); - setLayout(new FormLayout()); - - this.workflow = workflow; - - ProgressBar progressBar = new ProgressBar(this, SWT.HORIZONTAL | SWT.INDETERMINATE); - FormData fd_progressBar = new FormData(); - fd_progressBar.top = new FormAttachment(50, -15); - fd_progressBar.bottom = new FormAttachment(50, +15); - fd_progressBar.left = new FormAttachment(50, -100); - fd_progressBar.right = new FormAttachment(50, +100); - progressBar.setLayoutData(fd_progressBar); - } - - @Override - protected void checkSubclass() { - // Disable the check that prevents subclassing of SWT components - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenEnabled.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenEnabled.java deleted file mode 100644 index a9280624..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenEnabled.java +++ /dev/null @@ -1,45 +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.components.main_behavior; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public class ConfigOpenEnabled implements MainWindowBehavior { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(ConfigOpenEnabled.class); - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.MainWindowBehavior#SetState(at.asit.pdfover.gui.components.MainWindow) - */ - @Override - public void SetState(MainWindow window) { - log.debug("ENABLING config & open"); - window.getBtn_config().setEnabled(true); - window.getBtn_open().setEnabled(true); - window.getBtn_position().setEnabled(false); - window.getBtn_sign().setEnabled(false); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenPositionEnabled.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenPositionEnabled.java deleted file mode 100644 index 7e1af1ef..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/ConfigOpenPositionEnabled.java +++ /dev/null @@ -1,45 +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.components.main_behavior; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public class ConfigOpenPositionEnabled implements MainWindowBehavior { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(ConfigOpenPositionEnabled.class); - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.MainWindowBehavior#SetState(at.asit.pdfover.gui.components.MainWindow) - */ - @Override - public void SetState(MainWindow window) { - log.debug("ENABLING config & open & position"); - window.getBtn_config().setEnabled(true); - window.getBtn_open().setEnabled(true); - window.getBtn_position().setEnabled(true); - window.getBtn_sign().setEnabled(false); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllDisabled.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllDisabled.java deleted file mode 100644 index c5b70852..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllDisabled.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.components.main_behavior; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public class MainWindowAllDisabled implements MainWindowBehavior { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(MainWindowAllDisabled.class); - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.MainWindowBehavior#SetState(at.asit.pdfover.gui.components.MainWindow) - */ - @Override - public void SetState(MainWindow window) { - log.debug("DISABLING ALL"); - window.getBtn_config().setEnabled(false); - window.getBtn_open().setEnabled(false); - window.getBtn_position().setEnabled(false); - window.getBtn_sign().setEnabled(false); - } - -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllEnable.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllEnable.java deleted file mode 100644 index 91d5237a..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowAllEnable.java +++ /dev/null @@ -1,46 +0,0 @@ -package at.asit.pdfover.gui.components.main_behavior; -/* - * 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. - */ - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public class MainWindowAllEnable implements MainWindowBehavior { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(MainWindowAllEnable.class); - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.MainWindowBehavior#SetState(at.asit.pdfover.gui.components.MainWindow) - */ - @Override - public void SetState(MainWindow window) { - log.debug("ENABLING ALL"); - window.getBtn_config().setEnabled(true); - window.getBtn_open().setEnabled(true); - window.getBtn_position().setEnabled(true); - window.getBtn_sign().setEnabled(true); - } - -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowBehavior.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowBehavior.java deleted file mode 100644 index b36f6b51..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/MainWindowBehavior.java +++ /dev/null @@ -1,29 +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.components.main_behavior; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public interface MainWindowBehavior { - /** - * Changes the state of the main window - * @param window - */ - public void SetState(MainWindow window); -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/OnlyConfigEnabled.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/OnlyConfigEnabled.java deleted file mode 100644 index 2a7e863f..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/components/main_behavior/OnlyConfigEnabled.java +++ /dev/null @@ -1,45 +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.components.main_behavior; - -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.components.MainWindow; - -/** - * - */ -public class OnlyConfigEnabled implements MainWindowBehavior { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(OnlyConfigEnabled.class); - - /* (non-Javadoc) - * @see at.asit.pdfover.gui.components.MainWindowBehavior#SetState(at.asit.pdfover.gui.components.MainWindow) - */ - @Override - public void SetState(MainWindow window) { - log.debug("ENABLING ONLY config"); - window.getBtn_config().setEnabled(true); - window.getBtn_open().setEnabled(false); - window.getBtn_position().setEnabled(false); - window.getBtn_sign().setEnabled(false); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java index 1296b373..30d7aed8 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProvider.java @@ -15,13 +15,24 @@ */ package at.asit.pdfover.gui.workflow; -// Imports -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; +import at.asit.pdfover.signator.SignaturePosition; /** * */ public interface ConfigProvider { - + //TODO: define interface for config provider .... + + /** + * Get the default configured BKU + * @return the default configured BKU + */ + public BKUs getDefaultBKU(); + + /** + * Get the default configured SignaturePosition + * @return the default configured SignaturePosition or null if not configured + */ + public SignaturePosition getDefaultSignaturePosition(); } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java new file mode 100644 index 00000000..3787ef50 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java @@ -0,0 +1,54 @@ +/* + * 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * + */ +public class ConfigProviderImpl implements ConfigProvider { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(ConfigProviderImpl.class); + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultBKU() + */ + @Override + public BKUs getDefaultBKU() { + // TODO Read Config + return BKUs.NONE; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getDefaultSignaturePosition() + */ + @Override + public SignaturePosition getDefaultSignaturePosition() { + // TODO Read Config + return null; + } + +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java new file mode 100644 index 00000000..4e7955fd --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/GUIProvider.java @@ -0,0 +1,44 @@ +/* + * 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; + +import org.eclipse.swt.widgets.Composite; + + +/** + * + */ +public interface GUIProvider { + /** + * Get the container Composite + * @return the container Composite + */ + public Composite getComposite(); + + /** + * Create a new Composite + * @param compositeClass The class of the Composite to create + * @param style the SWT style + * @return the new Composite + */ + public T createComposite(Class compositeClass, int style); + + /** + * Display the composite as top most in main window + * @param composite the composite + */ + public void display(final Composite composite); +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSigner.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSigner.java new file mode 100644 index 00000000..33e8c176 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSigner.java @@ -0,0 +1,43 @@ +/* + * 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 at.asit.pdfover.signator.Signator; +import at.asit.pdfover.signator.Signer; + +/** + * + */ +public interface PDFSigner { + /** + * Gets the PDF Signer Type + * @return the signer type + */ + public Signator.Signers getUsedPDFSignerLibrary(); + + /** + * Set PDF Signer Type + * @param signer the signer type + */ + public void setUsedPDFSignerLibrary(Signator.Signers signer); + + /** + * Gets the currently used PDF Signer + * @return the pdf signer + */ + public Signer getPDFSigner(); +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSignerImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSignerImpl.java new file mode 100644 index 00000000..812e6ba0 --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/PDFSignerImpl.java @@ -0,0 +1,72 @@ +/* + * 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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.Signator; +import at.asit.pdfover.signator.Signator.Signers; +import at.asit.pdfover.signator.Signer; + +/** + * + */ +public class PDFSignerImpl implements PDFSigner { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(PDFSignerImpl.class); + + private Signers signer = Signator.Signers.PDFAS; + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PDFSigner#getPDFSignerType() + */ + @Override + public Signers getUsedPDFSignerLibrary() { + return this.signer; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PDFSigner#setPDFSignerType(at.asit.pdfover.signator.Signator.Signers) + */ + @Override + public void setUsedPDFSignerLibrary(Signers signer) { + if(signer != this.signer) { + // TYPE CHANGE remove cached signer! + this.signerLib = null; + } + this.signer = signer; + } + + private Signer signerLib; + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.PDFSigner#getPDFSigner() + */ + @Override + public Signer getPDFSigner() { + if(this.signerLib == null) { + this.signerLib = Signator.getSigner(getUsedPDFSignerLibrary()); + } + return this.signerLib; + } + +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/State.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/State.java deleted file mode 100644 index 305c5033..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/State.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 org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Base state class - */ -public abstract class State { - - /** - * The StateMachine - */ - protected StateMachine stateMachine; - - /** - * SFL4J Logger instance - **/ - @SuppressWarnings("unused") - private static final Logger log = LoggerFactory.getLogger(State.class); - - private State nextState = null; - - /** - * Default Workflow State constructor - */ - public State(StateMachine stateMachine) { - this.stateMachine = stateMachine; - this.nextState = this; - } - - /** - * 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 - * @param stateMachine the state machine - */ - public abstract void run(); - - /** - * Update the state machine - */ - public void updateStateMachine() - { - stateMachine.update(); - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java index 92505d19..1298bda8 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachine.java @@ -15,7 +15,7 @@ */ package at.asit.pdfover.gui.workflow; -import org.eclipse.swt.widgets.Composite; +import at.asit.pdfover.gui.workflow.states.State; /** * @@ -28,30 +28,48 @@ public interface StateMachine { public ConfigProvider getConfigProvider(); /** - * Get the container Composite - * @return the container Composite + * Get the PDF Signer + * @return the PDF Signer */ - public Composite getComposite(); - - /** - * Create a new Composite - * @param compositeClass The class of the Composite to create - * @return the new Composite - */ - public T createComposite(Class compositeClass); - - //public void display(Composite composite) + public PDFSigner getPDFSigner(); + /** * Get the Status * @return the Status */ public Status getStatus(); + + /** + * Gets the GUI provider + * @return the GUI provider + */ + public GUIProvider getGUIProvider(); + + /** + * Jump to specific state + * + * Sets the state machine 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 the target state. + * + * Example: Usually the MainWindow allows the user to jump to the states: + * DataSourceSelectionState, PositioningState and BKUSelectionState + * + * @param state the state to jump to + */ + public void jumpToState(State state); /** * Update state machine * Calls the next state. */ public void update(); + + /** + * Update state machine from other thread + * Calls the next state within the main thread + */ + public void InvokeUpdate(); /** * Exit state machine execution diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java index 8549007c..bb292c74 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StateMachineImpl.java @@ -19,38 +19,36 @@ package at.asit.pdfover.gui.workflow; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Properties; - -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import at.asit.pdfover.gui.components.BKUSelectionComposite; -import at.asit.pdfover.gui.components.MainWindow; +import at.asit.pdfover.gui.MainWindow; import at.asit.pdfover.gui.workflow.states.BKUSelectionState; -import at.asit.pdfover.gui.workflow.states.DataSourceSelectionState; +import at.asit.pdfover.gui.workflow.states.OpenState; import at.asit.pdfover.gui.workflow.states.PositioningState; import at.asit.pdfover.gui.workflow.states.PrepareConfigurationState; +import at.asit.pdfover.gui.workflow.states.State; import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; -import at.asit.pdfover.signator.Signator; -import at.asit.pdfover.signator.SignatureParameter; -import at.asit.pdfover.signator.Signer; /** * Workflow holds logical state of signing process and updates the current * logical state */ -public class StateMachineImpl implements StateMachine { +public class StateMachineImpl implements StateMachine, GUIProvider { /** * SFL4J Logger instance **/ - private static final Logger log = LoggerFactory.getLogger(StateMachineImpl.class); + private static final Logger log = LoggerFactory + .getLogger(StateMachineImpl.class); + + private StatusImpl status; + + private PDFSignerImpl pdfSigner; + + private ConfigProviderImpl configProvider; /** * Default constructor @@ -58,61 +56,49 @@ public class StateMachineImpl implements StateMachine { * @param cmdLineArgs */ public StateMachineImpl(String[] cmdLineArgs) { + this.status = new StatusImpl(); + this.status.setCurrentState(new PrepareConfigurationState(this)); + this.pdfSigner = new PDFSignerImpl(); + this.configProvider = new ConfigProviderImpl(); setCmdLineAargs(cmdLineArgs); } /** - * @uml.property name="state" - * @uml.associationEnd multiplicity="(1 1)" aggregation="shared" - * inverse="workflow1:at.asit.pdfover.gui.workflow.WorkflowState" - */ - private State state = new PrepareConfigurationState(); - - /** - * Getter of the property state - * - * @return Returns the state. - * @uml.property name="state" - */ - public State getState() { - return this.state; - } - - /** - * Sets the workflow state This method should be used to let the user jump + * 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 setState(State state) { - if (this.state != state && state != null) { - this.state = state; + @Override + public void jumpToState(State state) { + if (this.status.getCurrentState() != state && state != null) { + this.status.setCurrentState(state); + // TODO rewrite when Config is done ... if (state instanceof PositioningState) { // User jumps to positioning state ! // restore possible default for bku selection / forget BKU // selection - this.setSelectedBKU(PrepareConfigurationState - .readSelectedBKU(this.getConfigurationValues())); + this.getStatus().setBKU( + this.getConfigProvider().getDefaultBKU()); // forget position - this.getParameter().setSignaturePosition(null); + this.getStatus().setSignaturePosition(null); } else if (state instanceof BKUSelectionState) { // User jumps to bku selection state ! // forget bku selection - this.setSelectedBKU(BKUs.NONE); - } else if (state instanceof DataSourceSelectionState) { + this.getStatus().setBKU(BKUs.NONE); + } else if (state instanceof OpenState) { // User jumps to data source selection state ! // forget bku selection / restore possible default for bku // selection - this.setSelectedBKU(PrepareConfigurationState - .readSelectedBKU(this.getConfigurationValues())); + this.getStatus().setBKU( + this.getConfigProvider().getDefaultBKU()); // forget position / restore possible default for position - this.getParameter().setSignaturePosition( - PrepareConfigurationState.readDefinedPosition(this - .getConfigurationValues())); + this.getStatus().setSignaturePosition( + this.getConfigProvider().getDefaultSignaturePosition()); // forget data source selection - this.setDataSource(null); + this.getStatus().setDocument(null); } this.update(); @@ -125,24 +111,29 @@ public class StateMachineImpl implements StateMachine { @Override public void update() { State next = null; - while (this.state != null) { - this.state.run(); - if (this.mainWindow != null && !this.mainWindow.getShell().isDisposed()) { - log.debug("Allowing MainWindow to update its state for " + this.state.toString()); - this.mainWindow.UpdateNewState(); + while (this.status.getCurrentState() != null) { + State current = this.status.getCurrentState(); + current.run(); + 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(); } - next = this.state.nextState(); - if (next == this.state) { + next = current.nextState(); + if (next == current) { break; } - // this.state.hideGUI(); - log.debug("Changing state from: " + this.state.toString() + " to " + log.debug("Changing state from: " + + current + " to " + next.toString()); - this.state = next; + this.status.setCurrentState(next); } - if (this.state != null) { - this.setCurrentStateMessage(this.state.toString()); + if (this.status.getCurrentState() != null) { + this.setCurrentStateMessage(this.status.getCurrentState() + .toString()); } else { this.setCurrentStateMessage(""); } @@ -151,10 +142,11 @@ public class StateMachineImpl implements StateMachine { /** * Invoke Update in UI (Main) Thread */ + @Override public void InvokeUpdate() { - if(this.display != null) { + if (this.display != null) { this.display.asyncExec(new Runnable() { - + @Override public void run() { StateMachineImpl.this.update(); @@ -162,7 +154,7 @@ public class StateMachineImpl implements StateMachine { }); } } - + private Display display = null; private Shell shell = null; @@ -182,13 +174,16 @@ public class StateMachineImpl implements StateMachine { } } - /** - * Used by active workflow state to show its own gui component + /* + * (non-Javadoc) * - * @param ctrl + * @see + * at.asit.pdfover.gui.workflow.StateMachine#display(org.eclipse.swt.widgets + * .Composite) */ - public void setTopControl(final Control ctrl) { - this.mainWindow.setTopControl(ctrl); + @Override + public void display(Composite composite) { + this.mainWindow.setTopControl(composite); } private void createMainWindow() { @@ -228,13 +223,16 @@ public class StateMachineImpl implements StateMachine { } @Override - public T createComposite(Class compositeClass) { + public T createComposite(Class compositeClass, int style) { T composite = null; try { - Constructor constructor = compositeClass.getDeclaredConstructor(Composite.class, int.class, BKUSelectionState.class); - composite = constructor.newInstance(getComposite(), SWT.RESIZE, this); + Constructor constructor = compositeClass.getDeclaredConstructor( + Composite.class, int.class, BKUSelectionState.class); + composite = constructor.newInstance(getComposite(), style, this); } catch (Exception e) { - log.error("Could not create Composite for Class " + compositeClass.getName(), e); + log.error( + "Could not create Composite for Class " + + compositeClass.getName(), e); } return composite; } @@ -286,22 +284,42 @@ public class StateMachineImpl implements StateMachine { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see at.asit.pdfover.gui.workflow.StateMachine#getConfigProvider() */ @Override public ConfigProvider getConfigProvider() { - // TODO Auto-generated method stub - return null; + return this.configProvider; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see at.asit.pdfover.gui.workflow.StateMachine#getStatus() */ @Override public Status getStatus() { - // TODO Auto-generated method stub - return null; + return this.status; + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.workflow.StateMachine#getPDFSigner() + */ + @Override + public PDFSigner getPDFSigner() { + return this.pdfSigner; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.StateMachine#getGUIProvider() + */ + @Override + public GUIProvider getGUIProvider() { + return this; } // Data Section @@ -328,120 +346,4 @@ public class StateMachineImpl implements StateMachine { public String[] getCmdArgs() { return this.cmdLineArgs; } - - // Key Value String properties - // ------------------------------------------------------- - private Properties configurationValues = new Properties(); - - /** - * Gets the persistent state - * - * @return the persistent state - */ - public Properties getConfigurationValues() { - return this.configurationValues; - } - - // Data source - // ------------------------------------------------------- - private File dataSource = null; - - /** - * Gets the DataSource - * - * @return The data source file - */ - public File getDataSource() { - return this.dataSource; - } - - /** - * Sets the DataSource - * - * @param file - */ - public void setDataSource(File file) { - this.dataSource = file; - } - - // Selected BKU - // ------------------------------------------------------- - - /** - * The selected BKU - */ - private BKUs selectedBKU = BKUs.NONE; - - /** - * Gets the selected BKU - * - * @return the selectedBKU - */ - public BKUs getSelectedBKU() { - return this.selectedBKU; - } - - /** - * Sets the selected BKU - * - * @param selectedBKU - * the selectedBKU to set - */ - public void setSelectedBKU(BKUs selectedBKU) { - this.selectedBKU = selectedBKU; - } - - private Signator.Signers usedSignerLib = Signator.Signers.PDFAS; - - /** - * The PDF Signer - */ - private Signer pdfSigner = null; - - /** - * @return the pdfSigner - */ - public Signer getPdfSigner() { - return this.pdfSigner; - } - - /** - * @param pdfSigner - * the pdfSigner to set - */ - public void setPdfSigner(Signer pdfSigner) { - this.pdfSigner = pdfSigner; - } - - private SignatureParameter parameter = null; - - /** - * @return the parameter - */ - public SignatureParameter getParameter() { - return this.parameter; - } - - /** - * @param parameter - * the parameter to set - */ - public void setParameter(SignatureParameter parameter) { - this.parameter = parameter; - } - - /** - * @return the usedSignerLib - */ - public Signator.Signers getUsedSignerLib() { - return this.usedSignerLib; - } - - /** - * @param usedSignerLib - * the usedSignerLib to set - */ - public void setUsedSignerLib(Signator.Signers usedSignerLib) { - this.usedSignerLib = usedSignerLib; - } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java index ff06286b..9af0b034 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java @@ -17,19 +17,60 @@ package at.asit.pdfover.gui.workflow; import java.io.File; +import at.asit.pdfover.gui.MainWindowBehavior; import at.asit.pdfover.gui.workflow.states.BKUSelectionState; +import at.asit.pdfover.gui.workflow.states.State; import at.asit.pdfover.signator.SignaturePosition; /** - * + * Interface for persistent status of state machine */ public interface Status { + /** + * Sets the document + * @param document the document + */ public void setDocument(File document); + + /** + * Gets the document + * @return the document + */ public File getDocument(); + /** + * Sets the signature position + * @param position the position + */ public void setSignaturePosition(SignaturePosition position); + + /** + * Gets the signature position + * @return the signature position + */ public SignaturePosition getSignaturePosition(); + /** + * Sets the selected BKU + * @param bku the selected BKU + */ public void setBKU(BKUSelectionState.BKUs bku); + + /** + * Gets the selected BKU + * @return the selected BKU + */ public BKUSelectionState.BKUs getBKU(); + + /** + * Gets the current state + * @return the current state + */ + public State getCurrentState(); + + /** + * Gets the main window behavior + * @return the main window behavior + */ + public MainWindowBehavior getBehavior(); } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java new file mode 100644 index 00000000..9bc4bfec --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/StatusImpl.java @@ -0,0 +1,124 @@ +/* + * 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.gui.MainWindowBehavior; +import at.asit.pdfover.gui.workflow.states.State; +import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; +import at.asit.pdfover.signator.SignaturePosition; + +/** + * + */ +public class StatusImpl implements Status { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(StatusImpl.class); + + private File document = null; + + private SignaturePosition signaturePosition = null; + + private BKUs bku = BKUs.NONE; + + private State currentState = null; + + private MainWindowBehavior behavior; + + /** + * Constructor + */ + public StatusImpl() { + this.behavior = new MainWindowBehavior(); + } + + @Override + public State getCurrentState() { + return this.currentState; + } + + /** + * Sets the current state + * @param currentState + */ + public void setCurrentState(State currentState) { + this.currentState = currentState; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#setDocument(java.io.File) + */ + @Override + public void setDocument(File document) { + this.document = document; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#getDocument() + */ + @Override + public File getDocument() { + return this.document; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#setSignaturePosition(at.asit.pdfover.signator.SignaturePosition) + */ + @Override + public void setSignaturePosition(SignaturePosition position) { + this.signaturePosition = position; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#getSignaturePosition() + */ + @Override + public SignaturePosition getSignaturePosition() { + return this.signaturePosition; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#setBKU(at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs) + */ + @Override + public void setBKU(BKUs bku) { + this.bku = bku; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#getBKU() + */ + @Override + public BKUs getBKU() { + return this.bku; + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.Status#getBehavior() + */ + @Override + public MainWindowBehavior getBehavior() { + return behavior; + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java index 1d2c5524..86bd50c9 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -20,10 +20,10 @@ import org.eclipse.swt.SWT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.components.BKUSelectionComposite; +import at.asit.pdfover.gui.MainWindowBehavior; +import at.asit.pdfover.gui.MainWindow.Buttons; +import at.asit.pdfover.gui.composites.BKUSelectionComposite; import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.gui.workflow.State; /** * Decides which BKU to use (preconfigured or let user choose) @@ -67,8 +67,8 @@ public class BKUSelectionState extends State { private BKUSelectionComposite getSelectionComposite() { if (this.selectionComposite == null) { - this.selectionComposite = new BKUSelectionComposite( - this.stateMachine.getComposite(), SWT.RESIZE, this); + this.selectionComposite = new BKUSelectionComposite( + this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this); } return this.selectionComposite; @@ -81,21 +81,35 @@ public class BKUSelectionState extends State { BKUSelectionComposite selection = this .getSelectionComposite(); - this.stateMachine.setTopControl(selection); + this.stateMachine.getGUIProvider().display(selection); selection.layout(); - this.stateMachine.setSelectedBKU(selection.getSelected()); + this.stateMachine.getStatus().setBKU(selection.getSelected()); - if(this.stateMachine.getSelectedBKU() == BKUs.NONE) { - this.setNextState(this); + if(this.stateMachine.getStatus().getBKU() == BKUs.NONE) { return; } } - this.setNextState(new PrepareSigningState()); + this.setNextState(new PrepareSigningState(this.stateMachine)); } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + 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 "BKUSelectionState"; + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java deleted file mode 100644 index 6b69947a..00000000 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/DataSourceSelectionState.java +++ /dev/null @@ -1,81 +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.components.DataSourceSelectComposite; -import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.gui.workflow.State; - -/** - * Selects the data source for the signature process. - */ -public class DataSourceSelectionState extends State { - - /** - * SFL4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(DataSourceSelectionState.class); - - private DataSourceSelectComposite selectionComposite = null; - - private DataSourceSelectComposite getSelectionComposite(StateMachineImpl workflow) { - if (this.selectionComposite == null) { - this.selectionComposite = new DataSourceSelectComposite( - workflow.getComposite(), SWT.RESIZE, workflow); - } - - return this.selectionComposite; - } - - @Override - public void run(StateMachine stateMachine) { - - if (workflow.getDataSource() == null) { - DataSourceSelectComposite selection = this - .getSelectionComposite(workflow); - - workflow.setTopControl(selection); - selection.layout(); - - File source = selection.getSelected(); - if(source != null) { - workflow.setDataSource(source); - } - - if (workflow.getDataSource() == null) { - // Not selected yet - this.setNextState(this); - return; - } - } - log.debug("Got Datasource: " + workflow.getDataSource().getAbsolutePath()); - this.setNextState(new PositioningState()); - } - - @Override - public String toString() { - return "DataSourceSelectionState"; - } -} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java index 2a53dcbc..2d3a31ec 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java @@ -19,16 +19,25 @@ package at.asit.pdfover.gui.workflow.states; 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.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.State; /** * Logical state for performing the BKU Request to a local BKU */ public class LocalBKUState extends State { + /** + * @param stateMachine + */ + public LocalBKUState(StateMachine stateMachine) { + super(stateMachine); + } + /** * SLF4J Logger instance **/ + @SuppressWarnings("unused") private static final Logger log = LoggerFactory .getLogger(LocalBKUState.class); @@ -36,14 +45,26 @@ public class LocalBKUState extends State { * @see at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui.workflow.Workflow) */ @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO Process SL Request and set SL Response - this.setNextState(new SigningState()); + this.setNextState(new SigningState(this.stateMachine)); } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + behavior.reset(); + behavior.setActive(Buttons.OPEN, true); + behavior.setActive(Buttons.POSITION, true); + behavior.setActive(Buttons.SIGN, true); + } + @Override public String toString() { - return "LocalBKUState"; + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 169e9e59..c160a524 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -19,16 +19,25 @@ package at.asit.pdfover.gui.workflow.states; 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.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.State; /** * Logical state for performing the BKU Request to the A-Trust Mobile BKU */ public class MobileBKUState extends State { + /** + * @param stateMachine + */ + public MobileBKUState(StateMachine stateMachine) { + super(stateMachine); + } + /** * SLF4J Logger instance **/ + @SuppressWarnings("unused") private static final Logger log = LoggerFactory .getLogger(MobileBKUState.class); @@ -36,15 +45,26 @@ public class MobileBKUState extends State { * @see at.asit.pdfover.gui.workflow.WorkflowState#update(at.asit.pdfover.gui.workflow.Workflow) */ @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO Process SL Request and set SL Response - - this.setNextState(new SigningState()); + this.setNextState(new SigningState(this.stateMachine)); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + behavior.reset(); + behavior.setActive(Buttons.OPEN, true); + behavior.setActive(Buttons.POSITION, true); + behavior.setActive(Buttons.SIGN, true); } @Override public String toString() { - return "MobileBKUState"; + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java new file mode 100644 index 00000000..ee90a69b --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java @@ -0,0 +1,93 @@ +/* + * 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.gui.MainWindowBehavior; +import at.asit.pdfover.gui.MainWindow.Buttons; +import at.asit.pdfover.gui.composites.DataSourceSelectComposite; +import at.asit.pdfover.gui.workflow.StateMachine; + +/** + * Selects the data source for the signature process. + */ +public class OpenState extends State { + + /** + * @param stateMachine + */ + public OpenState(StateMachine stateMachine) { + super(stateMachine); + } + + /** + * SFL4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(OpenState.class); + + private DataSourceSelectComposite selectionComposite = null; + + private DataSourceSelectComposite getSelectionComposite() { + if (this.selectionComposite == null) { + this.selectionComposite = new DataSourceSelectComposite( + this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this); + } + + return this.selectionComposite; + } + + @Override + public void run() { + + if (this.stateMachine.getStatus().getDocument() == null) { + DataSourceSelectComposite selection = this + .getSelectionComposite(); + + this.stateMachine.getGUIProvider().display(selection); + selection.layout(); + + this.stateMachine.getStatus().setDocument(selection.getSelected()); + + if (this.stateMachine.getStatus().getDocument() == null) { + // Not selected yet + return; + } + } + log.debug("Got Datasource: " + this.stateMachine.getStatus().getDocument().getAbsolutePath()); + this.setNextState(new PositioningState(this.stateMachine)); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + behavior.reset(); + behavior.setEnabled(Buttons.CONFIG, true); + behavior.setActive(Buttons.OPEN, true); + } + + @Override + public String toString() { + return this.getClass().getName(); + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java index 933dd559..8a04dd3f 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -19,14 +19,22 @@ package at.asit.pdfover.gui.workflow.states; 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.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.State; /** * Procduces the output of the signature process. (save file, open file) */ public class OutputState extends State { + /** + * @param stateMachine + */ + public OutputState(StateMachine stateMachine) { + super(stateMachine); + } + /** * SFL4J Logger instance **/ @@ -34,15 +42,31 @@ public class OutputState extends State { private static final Logger log = LoggerFactory.getLogger(OutputState.class); @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO Preform output operations ... end workflow - stateMachine.exit(); + this.stateMachine.exit(); } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ @Override - public String toString() { - return "OutputState"; + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + 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/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 5b764084..c7c92a89 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -20,16 +20,23 @@ import org.eclipse.swt.SWT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.components.PositioningComposite; +import at.asit.pdfover.gui.MainWindowBehavior; +import at.asit.pdfover.gui.MainWindow.Buttons; +import at.asit.pdfover.gui.composites.PositioningComposite; import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.gui.workflow.State; /** * Decides where to position the signature block */ public class PositioningState extends State { + /** + * @param stateMachine + */ + public PositioningState(StateMachine stateMachine) { + super(stateMachine); + } + /** * SFL4J Logger instance **/ @@ -39,35 +46,47 @@ public class PositioningState extends State { private PositioningComposite positionComposite = null; - private PositioningComposite getPositioningComosite(StateMachineImpl workflow) { + private PositioningComposite getPositioningComosite() { if (this.positionComposite == null) { this.positionComposite = new PositioningComposite( - workflow.getComposite(), SWT.NONE, workflow); + this.stateMachine.getGUIProvider().getComposite(), SWT.NONE, this); } return this.positionComposite; } @Override - public void run(StateMachine stateMachine) { + public void run() { - if(workflow.getParameter().getSignaturePosition() == null) { - PositioningComposite position = this.getPositioningComosite(workflow); + if(this.stateMachine.getStatus().getSignaturePosition() == null) { + PositioningComposite position = this.getPositioningComosite(); - workflow.setTopControl(position); + this.stateMachine.getGUIProvider().display(position); - workflow.getParameter().setSignaturePosition(position.getPosition()); + this.stateMachine.getStatus().setSignaturePosition(position.getPosition()); - if(workflow.getParameter().getSignaturePosition() == null) { - this.setNextState(this); + if(this.stateMachine.getStatus().getSignaturePosition() == null) { return; } } - this.setNextState(new BKUSelectionState()); + this.setNextState(new BKUSelectionState(this.stateMachine)); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + 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 "PositioningState"; + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index 45e04dfd..4fa9e362 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -16,16 +16,12 @@ package at.asit.pdfover.gui.workflow.states; //Imports -import java.util.Properties; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.State; -import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; import at.asit.pdfover.signator.Signator; -import at.asit.pdfover.signator.SignaturePosition; + /** * Starting state of workflow proccess @@ -34,7 +30,12 @@ import at.asit.pdfover.signator.SignaturePosition; */ public class PrepareConfigurationState extends State { - public final static String BKU_SELECTION_CONFIG = "DEFAULT_BKU"; + /** + * @param stateMachine + */ + public PrepareConfigurationState(StateMachine stateMachine) { + super(stateMachine); + } /** * SFL4J Logger instance @@ -44,55 +45,29 @@ public class PrepareConfigurationState extends State { .getLogger(PrepareConfigurationState.class); @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO: Read config file and command line arguments // Set usedSignerLib ... - + this.stateMachine.getPDFSigner().setUsedPDFSignerLibrary(Signator.Signers.PDFAS); + // Create PDF Signer - workflow.setPdfSigner(Signator.getSigner(workflow.getUsedSignerLib())); - - workflow.setParameter(workflow.getPdfSigner().newParameter()); - - workflow.setSelectedBKU(PrepareConfigurationState.readSelectedBKU(workflow.getConfigurationValues())); + this.stateMachine.getStatus().setBKU(this.stateMachine.getConfigProvider().getDefaultBKU()); - workflow.getParameter().setSignaturePosition(readDefinedPosition(workflow.getConfigurationValues())); + this.stateMachine.getStatus().setSignaturePosition(this.stateMachine.getConfigProvider().getDefaultSignaturePosition()); - this.setNextState(new DataSourceSelectionState()); + this.setNextState(new OpenState(this.stateMachine)); } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ @Override - public String toString() { - return "PrepareConfigurationState"; + public void updateMainWindowBehavior() { + //no behavior necessary yet } - /** - * Gets BKUS value from Properties - * @param props - * @return The BKUS value - */ - public static BKUs readSelectedBKU(final Properties props) { - if (props.containsKey(BKU_SELECTION_CONFIG)) { - String value = props.getProperty(BKU_SELECTION_CONFIG); - value = value.trim().toLowerCase(); - - if (value.equals(BKUs.LOCAL.toString().trim().toLowerCase())) { - - return BKUs.LOCAL; - } else if (value - .equals(BKUs.MOBILE.toString().trim().toLowerCase())) { - return BKUs.MOBILE; - } - } - return BKUs.NONE; - } - - /** - * Gets BKUS value from Properties - * @param props - * @return The BKUS value - */ - public static SignaturePosition readDefinedPosition(final Properties props) { - // TODO - return null; + @Override + public String toString() { + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index efccc5de..061869c1 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -20,10 +20,10 @@ import org.eclipse.swt.SWT; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.components.WaitingComposite; +import at.asit.pdfover.gui.MainWindowBehavior; +import at.asit.pdfover.gui.MainWindow.Buttons; +import at.asit.pdfover.gui.composites.WaitingComposite; import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.StateMachineImpl; -import at.asit.pdfover.gui.workflow.State; import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; /** @@ -31,18 +31,25 @@ import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; */ public class PrepareSigningState extends State { + /** + * @param stateMachine + */ + public PrepareSigningState(StateMachine stateMachine) { + super(stateMachine); + } + /** * Debug background thread */ private final class DebugSleeperThread implements Runnable { - private StateMachineImpl workflow; + private StateMachine workflow; /** * Default constructor * @param work */ - public DebugSleeperThread(StateMachineImpl work) { + public DebugSleeperThread(final StateMachine work) { this.workflow = work; } @@ -65,10 +72,10 @@ public class PrepareSigningState extends State { private WaitingComposite selectionComposite = null; - private WaitingComposite getSelectionComposite(StateMachineImpl workflow) { + private WaitingComposite getSelectionComposite() { if (this.selectionComposite == null) { this.selectionComposite = new WaitingComposite( - workflow.getComposite(), SWT.RESIZE, workflow); + this.stateMachine.getGUIProvider().getComposite(), SWT.RESIZE, this); } return this.selectionComposite; @@ -77,14 +84,14 @@ public class PrepareSigningState extends State { private boolean run = false; @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO SHOW BACKGROUND ACTIVITY .... - WaitingComposite waiting = this.getSelectionComposite(workflow); + WaitingComposite waiting = this.getSelectionComposite(); - workflow.setTopControl(waiting); + this.stateMachine.getGUIProvider().display(waiting); if(!this.run) { - Thread t = new Thread(new DebugSleeperThread(workflow)); + Thread t = new Thread(new DebugSleeperThread(this.stateMachine)); this.run = true; t.start(); return; @@ -92,20 +99,30 @@ public class PrepareSigningState extends State { // WAIT FOR SLREQUEST and dispatch according to BKU selection - if(workflow.getSelectedBKU() == BKUs.LOCAL) { - this.setNextState(new LocalBKUState()); - } else if(workflow.getSelectedBKU() == BKUs.MOBILE) { - this.setNextState(new MobileBKUState()); + if(this.stateMachine.getStatus().getBKU() == BKUs.LOCAL) { + this.setNextState(new LocalBKUState(this.stateMachine)); + } else if(this.stateMachine.getStatus().getBKU() == BKUs.MOBILE) { + this.setNextState(new MobileBKUState(this.stateMachine)); } else { - log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); - this.setNextState(new BKUSelectionState()); + log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); //$NON-NLS-1$ + this.setNextState(new BKUSelectionState(this.stateMachine)); } } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + MainWindowBehavior behavior = this.stateMachine.getStatus().getBehavior(); + behavior.reset(); + behavior.setActive(Buttons.OPEN, true); + behavior.setActive(Buttons.POSITION, true); + behavior.setActive(Buttons.SIGN, true); + } + @Override public String toString() { - return "PrepareSigningState"; + return this.getClass().getName(); } - - } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java index 27dd7420..3447fc4c 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -20,13 +20,19 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.workflow.StateMachine; -import at.asit.pdfover.gui.workflow.State; /** * Logical state for signing process, usually show BKU Dialog during this state. */ public class SigningState extends State { + /** + * @param stateMachine + */ + public SigningState(StateMachine stateMachine) { + super(stateMachine); + } + /** * SFL4J Logger instance **/ @@ -34,14 +40,22 @@ public class SigningState extends State { private static final Logger log = LoggerFactory.getLogger(SigningState.class); @Override - public void run(StateMachine stateMachine) { + public void run() { // TODO Wait until output ready and set output - this.setNextState(new OutputState()); + this.setNextState(new OutputState(this.stateMachine)); } + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.states.State#setMainWindowBehavior() + */ + @Override + public void updateMainWindowBehavior() { + //no change of behavior necessary + } + @Override public String toString() { - return "SigningState"; + return this.getClass().getName(); } } diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java new file mode 100644 index 00000000..8b9a3ebb --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/State.java @@ -0,0 +1,86 @@ +/* + * 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.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.MainWindowBehavior; +import at.asit.pdfover.gui.workflow.StateMachine; + +/** + * Base state class + */ +public abstract class State { + + /** + * The StateMachine + */ + protected StateMachine stateMachine; + + /** + * SFL4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(State.class); + + private State nextState = null; + + /** + * Default Workflow State constructor + * @param stateMachine the State Machine + */ + public State(StateMachine stateMachine) { + this.stateMachine = stateMachine; + this.nextState = this; + } + + /** + * 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(); + + /** + * Update the state machine + */ + public void updateStateMachine() + { + this.stateMachine.update(); + } + + /** + * Update the main window behavior of this state if necessary + * Should update this.stateMachine.getStatus().getBehavior() + */ + public abstract void updateMainWindowBehavior(); +} diff --git a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java index 3c03a018..02fccca0 100644 --- a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java +++ b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java @@ -32,12 +32,14 @@ public class PDFASSLRequest implements SLRequest { **/ private static final Logger log = LoggerFactory.getLogger(PDFASSLRequest.class); + private String request; + /** * Default constructor * @param slRequest */ public PDFASSLRequest(String slRequest) { - //TODO: Analyze Request ... + this.request = slRequest; } @Override diff --git a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java index 949bbce1..cf93c96c 100644 --- a/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java +++ b/trunk/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigner.java @@ -76,6 +76,8 @@ public class PDFASSigner implements Signer { String slRequest = pdfasInternal.prepareLocalSignRequest(params, false, URL_TEMPLATE, sdi); + //DataSource sig_data = sdi.getSignatureData(); + PDFASSLRequest request = new PDFASSLRequest(slRequest); state.setSignatureRequest(request); -- cgit v1.2.3