diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:58:07 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:58:07 +0000 |
commit | b8b015d3fa3b58cb5e70b4cd2ad1b8fe2a424af9 (patch) | |
tree | 6094be25392267d91bbcf03027782cb61bbc20ed /pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments | |
parent | df925d1606a38624c20cdc68bfa0a23da14d29a0 (diff) | |
download | mocca-b8b015d3fa3b58cb5e70b4cd2ad1b8fe2a424af9.tar.gz mocca-b8b015d3fa3b58cb5e70b4cd2ad1b8fe2a424af9.tar.bz2 mocca-b8b015d3fa3b58cb5e70b4cd2ad1b8fe2a424af9.zip |
Added missing CLI Parameter
Using proxy parameters if set
Added localization string file
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@60 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments')
8 files changed, 398 insertions, 6 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java index e8d721ca..5c039c83 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/BKUArgument.java @@ -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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java index 9ddeaf6c..d08ce7c6 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ConfigFileArgument.java @@ -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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/EmblemArgument.java new file mode 100644 index 00000000..1b7260c1 --- /dev/null +++ b/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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/OutputFolderArgument.java new file mode 100644 index 00000000..5aea45bf --- /dev/null +++ b/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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java new file mode 100644 index 00000000..ab239c88 --- /dev/null +++ b/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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java index 255b4f91..6d344c42 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java @@ -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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyHostArgument.java new file mode 100644 index 00000000..cb6ce596 --- /dev/null +++ b/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/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/ProxyPortArgument.java new file mode 100644 index 00000000..aa0d5d81 --- /dev/null +++ b/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); + } + +} |