summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java10
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java5
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties113
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java6
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java58
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java116
6 files changed, 157 insertions, 151 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
index 43762b13..809c1d7d 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Main.java
@@ -16,6 +16,8 @@
package at.asit.pdfover.gui;
//Imports
+import java.io.File;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,6 +38,14 @@ public class Main {
*/
public static void main(String[] args) {
StateMachineImpl stateMachine = new StateMachineImpl(args);
+
+ File configDir = new File(System.getProperty("user.home")+"/.pdfover");
+
+ if(!configDir.exists()) {
+ configDir.mkdir();
+
+ }
+
log.debug("Starting stateMachine ..."); //$NON-NLS-1$
stateMachine.start();
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
index 2c25bd61..4b342cad 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
+++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java
@@ -333,7 +333,10 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite {
// load advanced settings
this.performBKUSelectionChanged(this.configurationContainer.getBKUSelection());
- this.performOutputFolderChanged(this.configurationContainer.getOutputFolder());
+ String outputFolder = this.configurationContainer.getOutputFolder();
+ if(outputFolder != null) {
+ this.performOutputFolderChanged(outputFolder);
+ }
this.performPositionSelection(this.configurationContainer.getAutomaticPosition());
}
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
deleted file mode 100644
index 244cfb3d..00000000
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/messages.properties
+++ /dev/null
@@ -1,113 +0,0 @@
-TrustedSocketFactory.FailedToCreateSecureConnection=Failed to create secure network connection
-
-main.title=PDF-Over
-main.configuration=Configuration
-main.position=Positioning
-main.signature=Signing
-main.done=Finish
-
-common.browse=browse
-common.Cancel=Cancel
-common.Ok=OK
-common.Save=Save
-common.PDFExtension_Description=PDF documents
-common.JPGExtension_Description=JPG Dateien
-common.GIFExtension_Description=Gif Dateien
-common.ALLExtension_Description=All files
-common.file=File:
-common.file_not_exists= does not exist!
-common.open=Open
-
-config.Simple=Simple
-config.Advanced=Advanced
-
-advanced_config.AutoPosition_Title=Positioning
-advanced_config.AutoPosition=Automatic positioning
-advanced_config.BKUSelection_Title=BKU Selection
-advanced_config.OutputFolder_Title=Output location
-advanced_config.OutputFolder=Default output folder:
-advanced_config.OutputFolder.Dialog_Title=Select Output folder
-advanced_config.OutputFolder.Dialog=Select a folder
-
-simple_config.Emblem_Title=Emblem
-simple_config.EmblemEmpty=No Image. Drag and Drop a Image. Or use the browse button to select an emblem.
-simple_config.UseEmblem=Use emblem
-simple_config.MobileBKU_Title=Mobile signature
-simple_config.PhoneNumber=Mobile number:
-simple_config.ExampleNumber=+43676123456789
-simple_config.Proxy_Title=Proxy
-simple_config.ProxyHost=Host:
-simple_config.ProxyHostTemplate=Hostname or IP of proxy server
-simple_config.ProxyPort=Port:
-simple_config.ProxyPortTemplate=port proxy server [1-65535]
-
-
-
-dataSourceSelection.DropLabel=To sign a document\ndrag and drop it here\nor use the button below
-
-bku_selection.card=CARD
-bku_selection.mobile=MOBILE
-
-mobileBKU.number=Number:
-mobileBKU.password=Password:
-
-tanEnter.tries= tries left!"
-tanEnter.ReferenceValue=reference value
-tanEnter.TAN=TAN:
-
-BKU.LOCAL=Local BKU
-BKU.MOBILE=Mobile BKU
-BKU.NONE=no default
-
-error.SaveOutputFolder=Failed to save signed document to configured output folder.
-error.Signatur=Signature error
-error.PrepareDocument=Failed to prepare document for signature.
-error.Initialization=Initialization failed. Please check your configuration.
-error.Unexpected=Unexpected Error
-error.LocalBKU=Please check if a local BKU is running
-error.Details=Details
-error.Retry=Retry
-error.InvalidBKU=Invalid BKU selection. Please check.
-error.InvalidSettings=Invalid settings are still present. Please check your input.
-error.FailedToSaveSettings=Failed to save configuration file!
-error.InvalidPhoneNumber=Given phone number is invalid! Example: +43664123456789
-error.EnteredReferenceValue=You entered the reference value!
-error.TanTooLong=Entered TAN too long
-error.FailedToGetSignedDocument=Failed to get signed document.
-error.FailedToLoadEmblem=Failed to load the emblem
-
-exception.InvalidEmblemFile= is an invalid emblem file!
-exception.InvalidPort= is invalid has to be between 1 and
-exception.PasswordTooLong=Given password is too long!
-exception.PasswordTooShort=Given password is too short!
-
-argument.help.bku=Select the BKU to use values are: LOCAL, MOBILE (example: -b <option>
-argument.invalid.bku=BKU Argument invalid! Use:
-
-argument.help.config=Defines which configuration file to use. Example: -c <config file>
-argument.invalid.config=Configuration File Argument invalid! Use:
-
-argument.help.emblem=Sets the emblem file to use for the signature. Example: -e <emblem file>
-argument.invalid.emblem=Emblem argument invalid! Use:
-
-argument.help.help=shows this help message
-argument.info.help=The following options are available:
-
-argument.help.input=Sets the document to sign. Example: -i <input document>
-argument.invalid.input=Document to sign argument invalid! Use:
-
-argument.help.output=Sets the output folder to use. Example: -o <folder>
-argument.invalid.output=Output folder argument invalid! Use:
-argument.error.output= is not a directory
-
-argument.help.password=Sets the password to use for mobile bku. Example: -p <password>
-argument.invalid.password=Mobile BKU password invalid! Use:
-
-argument.help.number=Sets the telephone number to use for mobile bku. Example: -n <number>
-argument.invalid.number=Phone Number Argument invalid! Use:
-
-argument.help.proxyhost=Sets the proxy host to use. Example: -proxy <hostname/IP>
-argument.invalid.proxyhost=Proxy host argument invalid! Use:
-
-argument.help.proxyport=Sets the proxy port to use. Example: -proxyport <port>
-argument.invalid.proxyport=Proxy port argument invalid! Use: \ No newline at end of file
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
index ea4088c6..a95423e3 100644
--- 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
@@ -309,7 +309,11 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator {
*/
@Override
public void setDefaultOutputFolder(String outputFolder) {
- this.outputFolder = outputFolder;
+ if (outputFolder == null || outputFolder.trim().equals("")) { //$NON-NLS-1$
+ this.outputFolder = STRING_EMPTY;
+ } else {
+ this.outputFolder = outputFolder;
+ }
}
/*
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 f04805a7..18f913ef 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
@@ -150,11 +150,12 @@ public class MobileBKUState extends State {
MobileBKUStatus mobileStatus = this.getStatus();
if (this.threadException != null) {
- ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
+ ErrorDialog error = new ErrorDialog(
+ this.stateMachine.getGUIProvider().getMainShell(),
SWT.NONE,
Messages.getString("error.Unexpected"), this.threadException, false); //$NON-NLS-1$
- //error.setException(this.threadException);
- //this.setNextState(error);
+ // error.setException(this.threadException);
+ // this.setNextState(error);
error.open();
this.stateMachine.exit();
return;
@@ -165,7 +166,8 @@ public class MobileBKUState extends State {
this.stateMachine.getGUIProvider().display(
this.getWaitingComposite());
Thread postSLRequestThread = new Thread(new PostSLRequestThread(
- this, this.stateMachine.getConfigProvider().getMobileBKUURL()));
+ this, this.stateMachine.getConfigProvider()
+ .getMobileBKUURL()));
postSLRequestThread.start();
break;
case POST_NUMBER:
@@ -208,16 +210,26 @@ public class MobileBKUState extends State {
} else {
// We need number and password => show UI!
+
+ if (mobileStatus.getErrorMessage() != null
+ && !mobileStatus.getErrorMessage().equals("")) { //$NON-NLS-1$
+ // set possible error message
+ ui.setErrorMessage(mobileStatus.getErrorMessage());
+ mobileStatus.setErrorMessage(null);
+ }
- // set possible error message
- ui.setErrorMessage(mobileStatus.getErrorMessage());
-
- // set possible phone number
- ui.setMobileNumber(mobileStatus.getPhoneNumber());
-
- // set possible password
- ui.setMobilePassword(mobileStatus.getMobilePassword());
-
+
+ if (ui.getMobileNumber() == null
+ || ui.getMobileNumber().equals("")) { //$NON-NLS-1$
+ // set possible phone number
+ ui.setMobileNumber(mobileStatus.getPhoneNumber());
+ }
+
+ if (ui.getMobilePassword() == null
+ || ui.getMobilePassword().equals("")) { //$NON-NLS-1$
+ // set possible password
+ ui.setMobilePassword(mobileStatus.getMobilePassword());
+ }
this.stateMachine.getGUIProvider().display(ui);
}
}
@@ -231,23 +243,23 @@ public class MobileBKUState extends State {
if (tan.isUserAck()) {
// user hit ok!
tan.setUserAck(false);
-
+
mobileStatus.setTan(tan.getTan());
-
+
// post to BKU!
Thread postTanThread = new Thread(new PostTanThread(this));
postTanThread.start();
} else {
tan.setVergleichswert(mobileStatus.getVergleichswert());
-
- if(mobileStatus.getTanTries() < MobileBKUStatus.MOBILE_MAX_TAN_TRIES
+
+ if (mobileStatus.getTanTries() < MobileBKUStatus.MOBILE_MAX_TAN_TRIES
&& mobileStatus.getTanTries() > 0) {
// show warning message x tries left!
-
+
tan.setTries(mobileStatus.getTanTries());
-
- }
+
+ }
this.stateMachine.getGUIProvider().display(tan);
}
@@ -265,11 +277,11 @@ public class MobileBKUState extends State {
*/
@Override
public void cleanUp() {
- if(this.mobileBKUEnterNumberComposite != null)
+ if (this.mobileBKUEnterNumberComposite != null)
this.mobileBKUEnterNumberComposite.dispose();
- if(this.mobileBKUEnterTANComposite != null)
+ if (this.mobileBKUEnterTANComposite != null)
this.mobileBKUEnterTANComposite.dispose();
- if(this.waitingComposite != null)
+ if (this.waitingComposite != null)
this.waitingComposite.dispose();
}
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 6957f85c..237dffa9 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,21 @@
package at.asit.pdfover.gui.workflow.states;
//Imports
+import java.io.BufferedInputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.asit.pdfover.gui.Messages;
+import at.asit.pdfover.gui.Unzipper;
import at.asit.pdfover.gui.cliarguments.ArgumentHandler;
import at.asit.pdfover.gui.cliarguments.BKUArgument;
import at.asit.pdfover.gui.cliarguments.ConfigFileArgument;
@@ -50,7 +55,11 @@ import at.asit.pdfover.signator.Signator;
*/
public class PrepareConfigurationState extends State {
-
+ /**
+ * PDFOver config directory
+ */
+ public static String CONFIG_DIRECTORY = System.getProperty("user.home") + "/.pdfover"; //$NON-NLS-1$ //$NON-NLS-2$
+
/**
* @param stateMachine
*/
@@ -68,8 +77,7 @@ public class PrepareConfigurationState extends State {
this.handler.addCLIArgument(new InputDocumentArgument());
// adding config file argument to this handler so it appears in help
this.handler.addCLIArgument(new ConfigFileArgument());
-
-
+
this.configFilehandler = new ArgumentHandler(this.stateMachine);
this.configFilehandler.addCLIArgument(new ConfigFileArgument());
}
@@ -89,10 +97,11 @@ public class PrepareConfigurationState extends State {
try {
try {
- this.stateMachine.getConfigProvider().loadConfiguration(new FileInputStream(filename));
-
+ this.stateMachine.getConfigProvider().loadConfiguration(
+ new FileInputStream(CONFIG_DIRECTORY + "/" + filename)); //$NON-NLS-1$
+
log.info("Loaded config from file : " + filename); //$NON-NLS-1$
-
+
} catch (FileNotFoundException ex) {
if (filename.equals(ConfigManipulator.DEFAULT_CONFIG_FILE)) {
// we only check for resource config file if it is the
@@ -100,8 +109,9 @@ public class PrepareConfigurationState extends State {
try {
InputStream is = this.getClass().getResourceAsStream(
"/" + filename); //$NON-NLS-1$
- this.stateMachine.getConfigProvider().loadConfiguration(is);
-
+ this.stateMachine.getConfigProvider()
+ .loadConfiguration(is);
+
log.info("Loaded config from resource : " + filename); //$NON-NLS-1$
} catch (Exception eex) {
throw ex;
@@ -110,7 +120,7 @@ public class PrepareConfigurationState extends State {
throw ex;
}
}
-
+
} catch (IOException ex) {
throw new InitializationException(
"Failed to read configuration from config file", ex); //$NON-NLS-1$
@@ -130,6 +140,85 @@ public class PrepareConfigurationState extends State {
public void run() {
// Read config file
try {
+
+ File configDir = new File(CONFIG_DIRECTORY);
+ File configFile = new File(CONFIG_DIRECTORY + "/" //$NON-NLS-1$
+ + ConfigManipulator.DEFAULT_CONFIG_FILE);
+ if (!configDir.exists() || !configFile.exists()) {
+ boolean allOK = false;
+
+ log.info("Creating configuration directory"); //$NON-NLS-1$
+
+ try {
+ if (!configDir.exists()) {
+ configDir.mkdir();
+ }
+ // Copy PDFOver config to config Dir
+
+ // 1Kb buffer
+ byte[] buffer = new byte[1024];
+ int byteCount = 0;
+
+ InputStream inputStream = null;
+ FileOutputStream pdfOverConfig = null;
+ try {
+ inputStream = this.getClass().getResourceAsStream(
+ "/" + ConfigManipulator.DEFAULT_CONFIG_FILE); //$NON-NLS-1$
+ pdfOverConfig = new FileOutputStream(CONFIG_DIRECTORY
+ + "/" //$NON-NLS-1$
+ + ConfigManipulator.DEFAULT_CONFIG_FILE);
+
+ while ((byteCount = inputStream.read(buffer)) >= 0) {
+ pdfOverConfig.write(buffer, 0, byteCount);
+ }
+ } catch (Exception e) {
+ log.error(
+ "Failed to write PDF Over config file to config directory", e); //$NON-NLS-1$
+ throw new InitializationException(
+ "Failed to write PDF Over config file to config directory",
+ e);
+ } finally {
+ if (pdfOverConfig != null) {
+ try {
+ pdfOverConfig.close();
+ } catch (IOException e) {
+ log.warn(
+ "Failed to close File stream for PDFOver config", e); //$NON-NLS-1$
+ }
+ }
+
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.warn(
+ "Failed to close Resource stream for PDFOver config", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ InputStream is = this.getClass().getResourceAsStream(
+ "/cfg/PDFASConfig.zip"); //$NON-NLS-1$
+
+ try {
+ Unzipper.unzip(is, configDir.getAbsolutePath());
+ } catch (IOException e) {
+ log.error(
+ "Failed to create local configuration directory!", e); //$NON-NLS-1$
+ throw new InitializationException(
+ "Failed to create local configuration directory!",
+ e);
+ }
+ allOK = true;
+ } finally {
+ if (!allOK) {
+ configDir.delete();
+ }
+ }
+ } else {
+ log.debug("Configuration directory exists!");
+ }
+
// Read cli arguments with for config file!
this.initializeFromArguments(this.stateMachine.getCmdArgs(),
this.configFilehandler);
@@ -158,11 +247,12 @@ public class PrepareConfigurationState extends State {
} catch (InitializationException e) {
log.error("Failed to initialize: ", e); //$NON-NLS-1$
- ErrorDialog error = new ErrorDialog(this.stateMachine.getGUIProvider().getMainShell(),
- SWT.NONE, Messages.getString("error.Initialization"), //$NON-NLS-1$
+ ErrorDialog error = new ErrorDialog(this.stateMachine
+ .getGUIProvider().getMainShell(), SWT.NONE,
+ Messages.getString("error.Initialization"), //$NON-NLS-1$
e, false);
- //error.setException(e);
- //this.setNextState(error);
+ // error.setException(e);
+ // this.setNextState(error);
error.open();
this.stateMachine.exit();
}