summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-01 08:30:44 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-01 08:30:44 +0000
commitfb9c33ffd611c145d605ae770181e576a5b9e681 (patch)
tree030be5b103e01ab201e9a8b6149fee7b2e4726d1 /trunk/pdf-over-gui
parent627b421d5aac2272a6ba8946bbd9a7d50a3c21f6 (diff)
downloadpdf-over-fb9c33ffd611c145d605ae770181e576a5b9e681.tar.gz
pdf-over-fb9c33ffd611c145d605ae770181e576a5b9e681.tar.bz2
pdf-over-fb9c33ffd611c145d605ae770181e576a5b9e681.zip
Added missing CLI Parameter
Using proxy parameters if set Added localization string file git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12541 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/DeveloperMain.java5
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java49
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java46
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java4
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java4
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java80
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java86
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java74
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java4
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java74
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java78
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties8
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java11
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java14
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/TrustedSocketFactory.java10
15 files changed, 521 insertions, 26 deletions
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 1fdb550d..23b14d4c 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
@@ -19,7 +19,6 @@ package at.asit.pdfover.gui;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.asit.pdfover.gui.cliarguments.ArgumentHandler;
import at.asit.pdfover.gui.workflow.StateMachineImpl;
/**
@@ -44,11 +43,11 @@ public class DeveloperMain {
//System.setProperty("log4j.configuration", "log4j.properties");
StateMachineImpl stateMachine = new StateMachineImpl(args);
- log.debug("Starting stateMachine ...");
+ log.debug("Starting stateMachine ..."); //$NON-NLS-1$
stateMachine.start();
- log.debug("Ended stateMachine ...");
+ log.debug("Ended stateMachine ..."); //$NON-NLS-1$
}
}
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 dd735bbf..8a9c217d 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
@@ -25,9 +25,6 @@ import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.FormAttachment;
@@ -75,7 +72,30 @@ public class MainWindow {
* Main bar Buttons
*/
public enum Buttons {
- CONFIG, OPEN, POSITION, SIGN, FINAL
+ /**
+ * the configuration button
+ */
+ CONFIG,
+
+ /**
+ * the open button
+ */
+ OPEN,
+
+ /**
+ * the position button
+ */
+ POSITION,
+
+ /**
+ * the signature button
+ */
+ SIGN,
+
+ /**
+ * the final button
+ */
+ FINAL
}
private Map<Buttons, MainBarButton> buttonMap;
@@ -179,7 +199,7 @@ public class MainWindow {
protected void createContents() {
this.shell = new Shell();
getShell().setSize(500, 800);
- getShell().setText("PDF-Over");
+ getShell().setText(Messages.getString("main.title")); //$NON-NLS-1$
getShell().setLayout(new FormLayout());
@@ -199,7 +219,8 @@ public class MainWindow {
fd_btn_config.top = new FormAttachment(0);
fd_btn_config.left = new FormAttachment(0, 2);
this.btn_config.setLayoutData(fd_btn_config);
- this.btn_config.setText("Config");
+ this.btn_config.setText(Messages.getString("main.configuration")); //$NON-NLS-1$
+ this.btn_config.setToolTipText(Messages.getString("main.configuration")); //$NON-NLS-1$
this.btn_config.addMouseListener(new MouseListener() {
@Override
@@ -220,7 +241,7 @@ public class MainWindow {
});
this.buttonMap.put(Buttons.CONFIG, this.btn_config);
- InputStream is = this.getClass().getResourceAsStream("/img/config.png");
+ InputStream is = this.getClass().getResourceAsStream("/img/config.png"); //$NON-NLS-1$
this.btn_config.setImage(new Image(Display.getDefault(), new ImageData(is)));
@@ -231,7 +252,8 @@ public class MainWindow {
fd_btn_open.top = new FormAttachment(0);
fd_btn_open.left = new FormAttachment(0, 45);
this.btn_open.setLayoutData(fd_btn_open);
- this.btn_open.setText("Open");
+ this.btn_open.setText(Messages.getString("main.open")); //$NON-NLS-1$
+ this.btn_open.setToolTipText(Messages.getString("main.open")); //$NON-NLS-1$
this.btn_open.addMouseListener(new MouseListener() {
@Override
@@ -259,7 +281,8 @@ public class MainWindow {
fd_btn_position.top = new FormAttachment(0);
fd_btn_position.left = new FormAttachment(35, -5);
this.btn_position.setLayoutData(fd_btn_position);
- this.btn_position.setText("Positon ...");
+ this.btn_position.setText(Messages.getString("main.position")); //$NON-NLS-1$
+ this.btn_position.setToolTipText(Messages.getString("main.position")); //$NON-NLS-1$
this.btn_position.addMouseListener(new MouseListener() {
@Override
@@ -287,7 +310,8 @@ public class MainWindow {
fd_btn_sign.top = new FormAttachment(0);
fd_btn_sign.left = new FormAttachment(60, -5);
this.btn_sign.setLayoutData(fd_btn_sign);
- this.btn_sign.setText("Sign ...");
+ this.btn_sign.setText(Messages.getString("main.signature")); //$NON-NLS-1$
+ this.btn_sign.setToolTipText(Messages.getString("main.signature")); //$NON-NLS-1$
this.buttonMap.put(Buttons.SIGN, this.btn_sign);
MainBarEndButton end = new MainBarEndButton(composite, SWT.NONE);
@@ -297,7 +321,8 @@ public class MainWindow {
fd_btn_end.top = new FormAttachment(0);
fd_btn_end.left = new FormAttachment(85, -5);
end.setLayoutData(fd_btn_end);
- end.setText("Done");
+ end.setText(Messages.getString("main.done")); //$NON-NLS-1$
+ end.setToolTipText(Messages.getString("main.done")); //$NON-NLS-1$
this.buttonMap.put(Buttons.FINAL, end);
this.container = new Composite(getShell(), SWT.RESIZE);
@@ -317,7 +342,7 @@ public class MainWindow {
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");
+ this.lbl_status.setText("DEBUG LABEL!!"); //$NON-NLS-1$
}
/**
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java
new file mode 100644
index 00000000..3f700f14
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java
@@ -0,0 +1,46 @@
+/*
+ * 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.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ *
+ */
+public class Messages {
+ private static final String BUNDLE_NAME = "at.asit.pdfover.gui.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ /**
+ * Gets the localized message
+ * @param key
+ * @return the localized message
+ */
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
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
index e8d721ca..5c039c83 100644
--- 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
@@ -57,11 +57,11 @@ public class BKUArgument extends CLIArgument {
}
} catch (Exception ex) {
throw new InitializationException(
- "BKU Argument invalid! Use: " + this.getHelpText(), ex); //$NON-NLS-1$
+ "BKU Argument invalid! Use: " + this.getHelpText(), ex);
}
throw new InitializationException(
- "BKU Argument invalid! Use: " + this.getHelpText(), null); //$NON-NLS-1$
+ "BKU Argument invalid! Use: " + this.getHelpText(), null);
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java
index 9ddeaf6c..d08ce7c6 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java
@@ -62,11 +62,11 @@ public class ConfigFileArgument extends CLIArgument {
} catch (Exception ex) {
log.error("Configuration File Argument invalid!", ex); //$NON-NLS-1$
throw new InitializationException(
- "Configuration File Argument invalid! Use: " + this.getHelpText(), ex); //$NON-NLS-1$
+ "Configuration File Argument invalid! Use: " + this.getHelpText(), ex);
}
throw new InitializationException(
- "Configuration File invalid! Use: " + this.getHelpText(), null); //$NON-NLS-1$
+ "Configuration File invalid! Use: " + this.getHelpText(), null);
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java
new file mode 100644
index 00000000..1b7260c1
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.cliarguments;
+
+// Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.StateMachine;
+
+/**
+ *
+ */
+public class EmblemArgument extends CLIArgument {
+ /**
+ * Constructor
+ */
+ public EmblemArgument() {
+ super(new String[] {"-e"}, "Sets the emblem file to use for the signature. Example: -e <emblem file>"); //$NON-NLS-1$
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(EmblemArgument.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
+ */
+ @Override
+ public int handleArgument(String[] args, int argOffset,
+ StateMachine stateMachine, ArgumentHandler handler)
+ throws InitializationException {
+ try {
+ if (args.length > argOffset + 1) {
+
+ String emblem = args[argOffset + 1];
+
+ File emblemFile = new File(emblem);
+
+ if(!emblemFile.exists()) {
+ throw new FileNotFoundException(emblem);
+ }
+
+ ConfigManipulator configManipulator = stateMachine.getConfigManipulator();
+
+ configManipulator.setDefaultEmblem(emblem);
+
+ return argOffset + 1;
+ }
+ } catch (Exception ex) {
+ log.error("Emblem argument invalid!", ex); //$NON-NLS-1$
+ throw new InitializationException(
+ "Emblem invalid! Use: " + this.getHelpText(), ex);
+ }
+
+ throw new InitializationException(
+ "Emblem argument invalid! Use: " + this.getHelpText(), null);
+ }
+
+}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java
new file mode 100644
index 00000000..5aea45bf
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.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.cliarguments;
+
+// Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.exceptions.InvalidPortException;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.StateMachine;
+
+/**
+ *
+ */
+public class OutputFolderArgument extends CLIArgument {
+ /**
+ * Constructor
+ */
+ public OutputFolderArgument() {
+ super(new String[] {"-o"}, "Sets the output folder to use. Example: -o <folder>"); //$NON-NLS-1$
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(OutputFolderArgument.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
+ */
+ @Override
+ public int handleArgument(String[] args, int argOffset,
+ StateMachine stateMachine, ArgumentHandler handler)
+ throws InitializationException {
+ try {
+ if (args.length > argOffset + 1) {
+
+ String outputFolder = args[argOffset + 1];
+
+ File outputFolderDir = new File(outputFolder);
+
+ if(!outputFolderDir.exists()) {
+ throw new FileNotFoundException(outputFolder);
+ }
+
+ if(!outputFolderDir.isDirectory()) {
+ throw new IOException(outputFolderDir + " is not a directory");
+ }
+
+ ConfigManipulator configManipulator = stateMachine.getConfigManipulator();
+
+ configManipulator.setDefaultOutputFolder(outputFolder);
+
+ return argOffset + 1;
+ }
+ } catch (Exception ex) {
+ log.error("Output folder argument invalid!", ex); //$NON-NLS-1$
+ throw new InitializationException(
+ "Output folder argument invalid! Use: " + this.getHelpText(), ex);
+ }
+
+ throw new InitializationException(
+ "Output folder argument invalid! Use: " + this.getHelpText(), null);
+ }
+
+}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java
new file mode 100644
index 00000000..ab239c88
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.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.cliarguments;
+
+// Imports
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+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.gui.workflow.states.mobilebku.ATrustHelper;
+
+/**
+ *
+ */
+public class PasswordArgument extends CLIArgument {
+ /**
+ * Constructor
+ */
+ public PasswordArgument() {
+ super(new String[] {"-p"}, "Sets the password to use for mobile bku. Example: -p <password>"); //$NON-NLS-1$
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(PasswordArgument.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
+ */
+ @Override
+ public int handleArgument(String[] args, int argOffset,
+ StateMachine stateMachine, ArgumentHandler handler)
+ throws InitializationException {
+ try {
+ if (args.length > argOffset + 1) {
+
+ String password = args[argOffset + 1];
+
+ ATrustHelper.validatePassword(password);
+
+ ConfigManipulator configManipulator = stateMachine.getConfigManipulator();
+
+ configManipulator.setDefaultPassword(password);
+
+ return argOffset + 1;
+ }
+ } catch (Exception ex) {
+ log.error("Mobile BKU password argument invalid!", ex); //$NON-NLS-1$
+ throw new InitializationException(
+ "Mobile BKU password invalid! Use: " + this.getHelpText(), ex);
+ }
+
+ throw new InitializationException(
+ "Mobile BKU password argument invalid! Use: " + this.getHelpText(), null);
+ }
+
+}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java
index 255b4f91..6d344c42 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java
@@ -67,11 +67,11 @@ public class PhoneNumberArgument extends CLIArgument {
} catch (Exception ex) {
log.error("Phone Number Argument invalid!", ex); //$NON-NLS-1$
throw new InitializationException(
- "Phone Number Argument invalid! Use: " + this.getHelpText(), ex); //$NON-NLS-1$
+ "Phone Number Argument invalid! Use: " + this.getHelpText(), ex);
}
throw new InitializationException(
- "Phone Number invalid! Use: " + this.getHelpText(), null); //$NON-NLS-1$
+ "Phone Number invalid! Use: " + this.getHelpText(), null);
}
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java
new file mode 100644
index 00000000..cb6ce596
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.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.cliarguments;
+
+// Imports
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.StateMachine;
+
+/**
+ *
+ */
+public class ProxyHostArgument extends CLIArgument {
+ /**
+ * Constructor
+ */
+ public ProxyHostArgument() {
+ super(new String[] {"-proxy"}, "Sets the proxy host to use. Example: -proxy <hostname/IP>"); //$NON-NLS-1$
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(ProxyHostArgument.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
+ */
+ @Override
+ public int handleArgument(String[] args, int argOffset,
+ StateMachine stateMachine, ArgumentHandler handler)
+ throws InitializationException {
+ try {
+ if (args.length > argOffset + 1) {
+
+ String proxyHost = args[argOffset + 1];
+
+ ConfigManipulator configManipulator = stateMachine.getConfigManipulator();
+
+ configManipulator.setProxyHost(proxyHost);
+
+ return argOffset + 1;
+ }
+ } catch (Exception ex) {
+ log.error("Proxy host argument invalid!", ex); //$NON-NLS-1$
+ throw new InitializationException(
+ "Proxy host invalid! Use: " + this.getHelpText(), ex);
+ }
+
+ throw new InitializationException(
+ "Proxy host argument invalid! Use: " + this.getHelpText(), null);
+ }
+
+}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java
new file mode 100644
index 00000000..aa0d5d81
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://joinup.ec.europa.eu/software/page/eupl
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ */
+package at.asit.pdfover.gui.cliarguments;
+
+// Imports
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.exceptions.InitializationException;
+import at.asit.pdfover.gui.exceptions.InvalidPortException;
+import at.asit.pdfover.gui.workflow.ConfigManipulator;
+import at.asit.pdfover.gui.workflow.StateMachine;
+
+/**
+ *
+ */
+public class ProxyPortArgument extends CLIArgument {
+ /**
+ * Constructor
+ */
+ public ProxyPortArgument() {
+ super(new String[] {"-proxyport"}, "Sets the proxy port to use. Example: -proxyport <port>"); //$NON-NLS-1$
+ }
+
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(ProxyPortArgument.class);
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.gui.cliarguments.CLIArgument#handleArgument(java.lang.String[], int, at.asit.pdfover.gui.workflow.StateMachine, at.asit.pdfover.gui.cliarguments.ArgumentHandler)
+ */
+ @Override
+ public int handleArgument(String[] args, int argOffset,
+ StateMachine stateMachine, ArgumentHandler handler)
+ throws InitializationException {
+ try {
+ if (args.length > argOffset + 1) {
+
+ String proxyPortString = args[argOffset + 1];
+
+ int port = Integer.parseInt(proxyPortString);
+
+ if(port <= 0 || port > 0xFFFF) {
+ throw new InvalidPortException(port);
+ }
+
+ ConfigManipulator configManipulator = stateMachine.getConfigManipulator();
+
+ configManipulator.setProxyPort(port);
+
+ return argOffset + 1;
+ }
+ } catch (Exception ex) {
+ log.error("Proxy port argument invalid!", ex); //$NON-NLS-1$
+ throw new InitializationException(
+ "Proxy port argument invalid! Use: " + this.getHelpText(), ex);
+ }
+
+ throw new InitializationException(
+ "Proxy port argument invalid! Use: " + this.getHelpText(), null);
+ }
+
+}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties
new file mode 100644
index 00000000..3726b7c9
--- /dev/null
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties
@@ -0,0 +1,8 @@
+TrustedSocketFactory.FailedToCreateSecureConnection=Failed to create secure network connection
+
+main.title=PDF-Over
+main.configuration=Configuration
+main.open=Open
+main.position=Positioning
+main.signature=Signing
+main.done=Finish \ No newline at end of file
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 3cf0861f..f720cb57 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
@@ -28,8 +28,13 @@ import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.cliarguments.ArgumentHandler;
import at.asit.pdfover.gui.cliarguments.BKUArgument;
import at.asit.pdfover.gui.cliarguments.ConfigFileArgument;
+import at.asit.pdfover.gui.cliarguments.EmblemArgument;
import at.asit.pdfover.gui.cliarguments.HelpArgument;
+import at.asit.pdfover.gui.cliarguments.OutputFolderArgument;
+import at.asit.pdfover.gui.cliarguments.PasswordArgument;
import at.asit.pdfover.gui.cliarguments.PhoneNumberArgument;
+import at.asit.pdfover.gui.cliarguments.ProxyHostArgument;
+import at.asit.pdfover.gui.cliarguments.ProxyPortArgument;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.exceptions.InitializationException;
import at.asit.pdfover.gui.workflow.ConfigManipulator;
@@ -53,7 +58,11 @@ public class PrepareConfigurationState extends State {
this.handler.addCLIArgument(new HelpArgument());
this.handler.addCLIArgument(new BKUArgument());
this.handler.addCLIArgument(new PhoneNumberArgument());
-
+ this.handler.addCLIArgument(new EmblemArgument());
+ this.handler.addCLIArgument(new PasswordArgument());
+ this.handler.addCLIArgument(new ProxyHostArgument());
+ this.handler.addCLIArgument(new ProxyPortArgument());
+ this.handler.addCLIArgument(new OutputFolderArgument());
// adding config file argument to this handler so it appears in help
this.handler.addCLIArgument(new ConfigFileArgument());
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 4ed59e5a..38215593 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
@@ -65,6 +65,20 @@ public class PrepareSigningState extends State {
ConfigProvider configuration = this.state.stateMachine.getConfigProvider();
+ // SET PROXY HOST and PORT settings
+ String proxyHost = configuration.getProxyHost();
+ int proxyPort = configuration.getProxyPort();
+
+ if(proxyPort > 0 && proxyPort <= 0xFFFF) {
+ System.setProperty("http.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
+ System.setProperty("https.proxyPort", Integer.toString(proxyPort)); //$NON-NLS-1$
+ }
+
+ if(proxyHost != null && !proxyHost.equals("")) { //$NON-NLS-1$
+ System.setProperty("http.proxyHost", proxyHost); //$NON-NLS-1$
+ System.setProperty("https.proxyHost", proxyHost); //$NON-NLS-1$
+ }
+
if(this.state.signer == null) {
this.state.signer = this.state.stateMachine.getPDFSigner().getPDFSigner();
}
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/TrustedSocketFactory.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/TrustedSocketFactory.java
index 91aa6caa..c7430bab 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/TrustedSocketFactory.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/TrustedSocketFactory.java
@@ -36,6 +36,8 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import at.asit.pdfover.gui.Messages;
+
/**
*
*/
@@ -78,7 +80,7 @@ public class TrustedSocketFactory implements ProtocolSocketFactory {
throw (UnknownHostException) ex;
} else {
throw new IOException(
- "Not really an IOException! See inner exception", ex);
+ Messages.getString("TrustedSocketFactory.FailedToCreateSecureConnection"), ex); //$NON-NLS-1$
}
}
}
@@ -106,7 +108,7 @@ public class TrustedSocketFactory implements ProtocolSocketFactory {
throw (UnknownHostException) ex;
} else {
throw new IOException(
- "Not really an IOException! See inner exception", ex);
+ Messages.getString("TrustedSocketFactory.FailedToCreateSecureConnection"), ex); //$NON-NLS-1$
}
}
}
@@ -125,7 +127,7 @@ public class TrustedSocketFactory implements ProtocolSocketFactory {
UnknownHostException, ConnectTimeoutException {
try {
if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null");
+ throw new IllegalArgumentException("Parameters may not be null"); //$NON-NLS-1$
}
int timeout = params.getConnectionTimeout();
Socket socket = null;
@@ -151,7 +153,7 @@ public class TrustedSocketFactory implements ProtocolSocketFactory {
throw (UnknownHostException) ex;
} else {
throw new IOException(
- "Not really an IOException! See inner exception", ex);
+ Messages.getString("TrustedSocketFactory.FailedToCreateSecureConnection"), ex); //$NON-NLS-1$
}
}
}