From 065d2df5e1df70d21534c6cbda608dca5b7d500b Mon Sep 17 00:00:00 2001 From: tkellner Date: Mon, 1 Oct 2012 08:30:37 +0000 Subject: Configuration Changes git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12530 3a0b52a2-8410-0410-bc02-ff6273a87459 --- .../java/at/asit/pdfover/gui/DeveloperMain.java | 10 +- .../main/java/at/asit/pdfover/gui/MainWindow.java | 26 ++ .../pdfover/gui/cliarguments/ArgumentHandler.java | 115 +++++++ .../asit/pdfover/gui/cliarguments/BKUArgument.java | 67 ++++ .../asit/pdfover/gui/cliarguments/CLIArgument.java | 102 ++++++ .../gui/cliarguments/ConfigFileArgument.java | 72 +++++ .../pdfover/gui/cliarguments/HelpArgument.java | 71 +++++ .../gui/cliarguments/PhoneNumberArgument.java | 77 +++++ .../composites/AdvancedConfigurationComposite.java | 60 ++++ .../gui/composites/BaseConfigurationComposite.java | 42 +++ .../gui/composites/ConfigurationComposite.java | 218 +++++++++++++ .../gui/composites/ConfigurationContainer.java | 114 +++++++ .../gui/composites/ConfigurationContainerImpl.java | 227 ++++++++++++++ .../composites/MobileBKUEnterNumberComposite.java | 96 +++--- .../composites/SimpleConfigurationComposite.java | 349 +++++++++++++++++++++ .../gui/exceptions/InitializationException.java | 35 +++ .../pdfover/gui/exceptions/InvalidEmblemFile.java | 53 ++++ .../gui/exceptions/InvalidNumberException.java | 36 +++ .../gui/exceptions/InvalidPasswordException.java | 35 +++ .../gui/exceptions/InvalidPortException.java | 35 +++ .../gui/exceptions/PasswordTooLongException.java | 36 +++ .../gui/exceptions/PasswordTooShortException.java | 36 +++ .../pdfover/gui/workflow/ConfigManipulator.java | 126 ++++++++ .../asit/pdfover/gui/workflow/ConfigProvider.java | 36 +++ .../pdfover/gui/workflow/ConfigProviderImpl.java | 206 +++++++++++- .../at/asit/pdfover/gui/workflow/StateMachine.java | 13 + .../pdfover/gui/workflow/StateMachineImpl.java | 86 +++-- .../at/asit/pdfover/gui/workflow/StatusImpl.java | 4 +- .../gui/workflow/states/ConfigurationUIState.java | 93 ++++++ .../pdfover/gui/workflow/states/ErrorState.java | 6 +- .../pdfover/gui/workflow/states/LocalBKUState.java | 2 + .../gui/workflow/states/MobileBKUState.java | 12 +- .../workflow/states/PrepareConfigurationState.java | 237 +++++++++++++- .../states/mobilebku/ASITTrustManager.java | 179 ++++++++++- .../workflow/states/mobilebku/ATrustHelper.java | 112 ++++++- .../states/mobilebku/TrustedSocketFactory.java | 4 +- .../pdf-over-gui/src/main/resources/PDFOver.config | 1 + .../resources/certificates/A-Trust-Qual-01a.crt | Bin 0 -> 1111 bytes .../resources/certificates/A-Trust-Qual-02a.crt | Bin 0 -> 975 bytes .../resources/certificates/A-Trust-Qual-03a.crt | Bin 0 -> 975 bytes .../resources/certificates/A-Trust-nQual-01a.crt | Bin 0 -> 865 bytes .../resources/certificates/A-Trust-nQual-03.crt | Bin 0 -> 979 bytes .../resources/certificates/used_certificates.xml | 8 + .../src/main/resources/log4j.properties | 9 +- 44 files changed, 2898 insertions(+), 148 deletions(-) create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/CLIArgument.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/HelpArgument.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BaseConfigurationComposite.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainer.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationContainerImpl.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InitializationException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidEmblemFile.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidNumberException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPasswordException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/InvalidPortException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooLongException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/exceptions/PasswordTooShortException.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigManipulator.java create mode 100644 trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java create mode 100644 trunk/pdf-over-gui/src/main/resources/PDFOver.config create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/A-Trust-Qual-01a.crt create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/A-Trust-Qual-02a.crt create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/A-Trust-Qual-03a.crt create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/A-Trust-nQual-01a.crt create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/A-Trust-nQual-03.crt create mode 100644 trunk/pdf-over-gui/src/main/resources/certificates/used_certificates.xml (limited to 'trunk/pdf-over-gui/src') diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java index a27113f9..1fdb550d 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java @@ -18,6 +18,8 @@ package at.asit.pdfover.gui; //Imports import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.cliarguments.ArgumentHandler; import at.asit.pdfover.gui.workflow.StateMachineImpl; /** @@ -41,12 +43,12 @@ public class DeveloperMain { // Set PDF-AS log4j configuration: //System.setProperty("log4j.configuration", "log4j.properties"); - StateMachineImpl flow = new StateMachineImpl(args); - log.debug("Starting workflow ..."); + StateMachineImpl stateMachine = new StateMachineImpl(args); + log.debug("Starting stateMachine ..."); - flow.start(); + stateMachine.start(); - log.debug("Ended workflow ..."); + log.debug("Ended stateMachine ..."); } } 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 index 1e465467..b8cd9ea7 100644 --- 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 @@ -24,6 +24,7 @@ import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.SelectionAdapter; 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; @@ -37,6 +38,7 @@ 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.ConfigurationUIState; import at.asit.pdfover.gui.workflow.states.OpenState; import at.asit.pdfover.gui.workflow.states.PositioningState; @@ -45,6 +47,29 @@ import at.asit.pdfover.gui.workflow.states.PositioningState; */ public class MainWindow { + /** + * + */ + private final class ConfigSelectionListener implements SelectionListener { + /** + * + */ + public ConfigSelectionListener() { + // Nothing to do here + } + + @Override + public void widgetSelected(SelectionEvent e) { + MainWindow.this.stateMachine.jumpToState(new ConfigurationUIState( + MainWindow.this.stateMachine)); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Nothing to do here + } + } + /** * Selection Listener for Position Button */ @@ -220,6 +245,7 @@ public class MainWindow { fd_config.bottom = new FormAttachment(100, 0); this.btn_config.setLayoutData(fd_config); this.btn_config.setText("Config ..."); + this.btn_config.addSelectionListener(new ConfigSelectionListener()); this.buttonMap.put(Buttons.CONFIG, this.btn_config); this.btn_open = new Button(composite, SWT.NONE); diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java new file mode 100644 index 00000000..f43b636c --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ArgumentHandler.java @@ -0,0 +1,115 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.cliarguments; + +// Imports +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.exceptions.InitializationException; +import at.asit.pdfover.gui.workflow.StateMachine; + +/** + * + */ +public class ArgumentHandler { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(ArgumentHandler.class); + + private Map cliArguments = new HashMap(); + + private StateMachine stateMachine = null; + + private boolean requiredExit = false; + + /** + * Constructor + * @param stateMachine + */ + public ArgumentHandler(StateMachine stateMachine) { + this.stateMachine = stateMachine; + } + + /** + * Gets available Arguments + * @return the list of available arguments + */ + public Set getArguments() { + return new HashSet(this.cliArguments.values()); + } + + /** + * Adds a CLIArgument to the handler + * + * @param arg + */ + public void addCLIArgument(CLIArgument arg) { + if(arg == null) { + return; + } + + String[] commandOptions = arg.getCommandOptions(); + + if(commandOptions == null) { + return; + } + + for(int i = 0; i < commandOptions.length; i++) + { + this.cliArguments.put(commandOptions[i], arg); + } + } + + /** + * Handle CLI Arguments + * + * @param args + * @throws InitializationException + */ + public void handleArguments(String[] args) throws InitializationException { + for(int i = 0; i < args.length; i++) { + if(this.cliArguments.containsKey(args[i])) { + this.cliArguments.get(args[i]).handleArgument(args, i, this.stateMachine, this); + } + } + } + + /** + * Set by an cli argument if it wants the program to exit + * @param requireExit + */ + public void setRequireExit(boolean requireExit) { + this.requiredExit = requireExit; + } + + /** + * Checks if one argument required the program to exit again + * + * @return true or false + */ + public boolean IsRequireExit() { + return this.requiredExit; + } +} diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java new file mode 100644 index 00000000..e8d721ca --- /dev/null +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://joinup.ec.europa.eu/software/page/eupl + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + */ +package at.asit.pdfover.gui.cliarguments; + +import at.asit.pdfover.gui.exceptions.InitializationException; +import at.asit.pdfover.gui.workflow.ConfigManipulator; +import at.asit.pdfover.gui.workflow.StateMachine; +import at.asit.pdfover.signator.BKUs; + +/** + * + */ +public class BKUArgument extends CLIArgument { + /** + * Constructor + */ + public BKUArgument() { + super( + new String[] { "-b" }, "Select the BKU to use values are: LOCAL, MOBILE (example: -b