From eb68e29e371ef3e944f682239e6f3f92cb084697 Mon Sep 17 00:00:00 2001 From: tknall Date: Mon, 9 Jun 2008 15:27:50 +0000 Subject: Web-Application: Configuration may be declared via system property "pdf-as.work-dir" or via Servlet-Init-Parameter "work-dir". Bug fixed in RetrieveSignatureDataServlet: Response header didn't contain a content length attribute. The ITS Mac BKU rejects those requests. Workaround for ITS Mac BKU integrated. A redirect via response does only work if the response contains a valid SL request (e.g. a NullOperationRequest). API: The configuration folder may be omitted at instantiating the api. Configuration may be set via system property "pdf-as.work-dir". If no configuration is given at all, the current user's home directory is searched for a folder "PDF-AS". If not found a default configuration is created. If the configuration is explicitely given than the temporary folder is located within the given directory otherwise within the user's temporary directory. Declaring the configuration folder, replacements for system properties like "${catalina.base}/conf/pdfas" may be used. Web-Application: Session is now being invalidated after download of the signed pdf file. Web-Application: Every hardcoded context "pdf-as" has been replaced. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@277 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../java/at/gv/egiz/pdfas/commandline/Main.java | 37 +++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/gv/egiz/pdfas/commandline/Main.java') diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java index b4546e4..0ec6a55 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/Main.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/Main.java @@ -33,6 +33,7 @@ import org.apache.log4j.PropertyConfigurator; import at.gv.egiz.pdfas.PdfAsFactory; import at.gv.egiz.pdfas.api.PdfAs; import at.gv.egiz.pdfas.api.commons.Constants; +import at.gv.egiz.pdfas.api.exceptions.ConfigUtilsException; import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.io.DataSink; import at.gv.egiz.pdfas.api.io.DataSource; @@ -46,18 +47,17 @@ import at.gv.egiz.pdfas.api.verify.VerifyResult; import at.gv.egiz.pdfas.api.verify.VerifyResults; import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.exceptions.ErrorCodeHelper; -import at.gv.egiz.pdfas.exceptions.external.ExternalErrorException; import at.gv.egiz.pdfas.framework.config.SettingsHelper; import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters; import at.gv.egiz.pdfas.io.FileBasedDataSink; import at.gv.egiz.pdfas.io.FileBasedDataSource; import at.gv.egiz.pdfas.io.StringTextBasedDataSource; +import at.gv.egiz.pdfas.utils.ConfigUtils; import at.knowcenter.wag.egov.egiz.PdfAS; import at.knowcenter.wag.egov.egiz.PdfASID; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException; import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; -import at.knowcenter.wag.egov.egiz.exceptions.PlaceholderException; import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException; import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException; @@ -119,6 +119,13 @@ public abstract class Main * verified. */ protected static final String PARAMETER_VERIFY_WHICH = "-verify_which"; + + /** + * Command line parameter that starts the deployment of the default configuration to the current + * user's home folder. + * @see Constants#USERHOME_CONFIG_FOLDER + */ + protected static final String PARAMETER_DEPLOY_DEFAULT_CONFIGURATION = "-ddc"; /** * The application mode sign @@ -166,6 +173,23 @@ public abstract class Main { // ConfigLogger.setLevel(Level.DEBUG); + // search for PARAMETER_DEPLOY_DEFAULT_CONFIGURATION before initializing the SettingsReader + for (int i = 0; i < args.length; i++) { + if (args[i].trim().equals(PARAMETER_DEPLOY_DEFAULT_CONFIGURATION)) { + try { + if (ConfigUtils.deployDefaultConfiguration()) { + System.out.println("Default configuration successfully deployed to the current user's home."); + } else { + System.out.println("Default configuration NOT deployed because to the current user's home because it already exists."); + } + System.exit(0); + } catch (ConfigUtilsException e) { + System.err.println("Deployment of default configuration failed: " + e.getMessage()); + System.exit(1); + } + } + } + SettingsReader.initializeForCommandLine(); PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); @@ -417,7 +441,7 @@ public abstract class Main logger_.error("Couldn't delete output file " + output); } } - } + } finally { SettingsReader.clearTemporaryDirectory(); @@ -807,7 +831,7 @@ public abstract class Main */ public static void printUsage(PrintStream writer) throws PresentableException { - writer.println("Usage: pdf-as [OPTIONS] [output file]"); + writer.println("Usage: pdf-as [[OPTIONS] [output file]|UTILOPTIONS]"); writer.println(" Required OPTIONS:"); writer.println(" " + PARAMETER_MODE + " <" + VALUE_MODE_SIGN + "|" + VALUE_MODE_VERIFY + ">"); @@ -840,6 +864,10 @@ public abstract class Main writer.println(" " + id + " ... " + ci[i].getDescription()); } + writer.println(" Resp. required UTILity OPTIONS"); + + writer.println(" " + PARAMETER_DEPLOY_DEFAULT_CONFIGURATION + " ... deploys the default configuration to the current user's home"); + writer.println(" OPTIONS for signation:"); writer.println(" " + PARAMETER_SIGNATURE_MODE + " <" + VALUE_SIGNATURE_MODE_BINARY + "|" + VALUE_SIGNATURE_MODE_TEXTUAL + ">"); @@ -901,6 +929,7 @@ public abstract class Main writer.println(" Example usage:"); writer.println(" pdf-as " + PARAMETER_MODE + " " + VALUE_MODE_SIGN + " " + PARAMETER_CONNECTOR + " moa some_document.pdf"); writer.println(" pdf-as " + PARAMETER_MODE + " " + VALUE_MODE_VERIFY + " some_document.pdf_out.pdf"); + writer.println(" pdf-as " + PARAMETER_DEPLOY_DEFAULT_CONFIGURATION); } /** -- cgit v1.2.3