aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java54
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java22
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java99
-rw-r--r--src/main/java/at/gv/egiz/pdfas/commandline/Main.java37
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java35
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java176
-rw-r--r--src/main/java/at/gv/egiz/pdfas/utils/StreamUtils.java1
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/SessionHelper.java1
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java66
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java7
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java165
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java3
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/Utils.java22
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java5
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java1
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java23
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java42
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java42
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java4
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java22
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java3
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java10
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java2
-rw-r--r--src/main/resources/DefaultConfiguration.zipbin0 -> 192100 bytes
-rw-r--r--src/main/webapp/META-INF/context.xml4
-rw-r--r--src/main/webapp/WEB-INF/web.xml16
-rw-r--r--src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp2
-rw-r--r--src/main/webapp/jsp/dataok.jsp2
-rw-r--r--src/main/webapp/jsp/download.jsp4
-rw-r--r--src/main/webapp/jsp/error.jsp4
-rw-r--r--src/main/webapp/jsp/error_verify.jsp4
-rw-r--r--src/main/webapp/jsp/null_request_page.jsp2
-rw-r--r--src/main/webapp/jsp/results.jsp2
-rw-r--r--src/main/webapp/jsp/signpreview.jsp2
-rw-r--r--src/main/webapp/jsp/signupload.jsp4
-rw-r--r--src/main/webapp/jsp/verifylist.jsp2
-rw-r--r--src/main/webapp/jsp/verifypreview.jsp2
-rw-r--r--src/main/webapp/jsp/verifyupload.jsp6
-rw-r--r--src/main/webapp/parentpage/standalone.jsp2
-rw-r--r--src/site/changes.xml30
41 files changed, 769 insertions, 163 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java b/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
index bc6f89d..6ec16f1 100644
--- a/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
+++ b/src/main/java/at/gv/egiz/pdfas/PdfAsFactory.java
@@ -8,6 +8,7 @@ import java.io.File;
import at.gv.egiz.pdfas.api.PdfAs;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.impl.api.PdfAsObject;
+import at.knowcenter.wag.egov.egiz.PdfAS;
/**
* Main factory for creating a PDF-AS API Instance (PdfAs Interface).
@@ -18,22 +19,41 @@ import at.gv.egiz.pdfas.impl.api.PdfAsObject;
*/
public class PdfAsFactory
{
- /**
- * Creates a PDF-AS API instance for the given work directory.
- *
- * @param workDirectory
- * The work directory.
- *
- * @return Returns an instance of the PDF-AS API.
- * @throws IllegalArgumentException
- * Thrown, if the workDirectory doesn't exist.
- * @throws PdfAsException
- * Thrown, if the work directory does not meet its requirements, or
- * if the config file is invalid.
- */
- public static PdfAs createPdfAs(File workDirectory) throws PdfAsException
- {
- return new PdfAsObject(workDirectory);
- }
+ /**
+ * Creates a PDF-AS API instance for the given work directory.
+ *
+ * @param workDirectory
+ * The work directory. If <code>null</code> the configuration is assumed to be located
+ * within the user's home directory.
+ *
+ * @return Returns an instance of the PDF-AS API.
+ * @throws IllegalArgumentException
+ * Thrown, if the workDirectory doesn't exist.
+ * @throws PdfAsException
+ * Thrown, if the work directory does not meet its requirements, or
+ * if the config file is invalid.
+ * @see PdfAS#USERHOME_CONFIG_FOLDER
+ */
+ public static PdfAs createPdfAs(File workDirectory) throws PdfAsException
+ {
+ return new PdfAsObject(workDirectory);
+ }
+
+ /**
+ * Creates a PDF-AS API instance assuming that the configuration is located within the user's
+ * home directory.
+ *
+ * @return Returns an instance of the PDF-AS API.
+ * @throws IllegalArgumentException
+ * Thrown, if the work directory doesn't exist within the user's home directory.
+ * @throws PdfAsException
+ * Thrown, if the work directory does not meet its requirements, or
+ * if the config file is invalid.
+ * @see PdfAS#USERHOME_CONFIG_FOLDER
+ */
+ public static PdfAs createPdfAs() throws PdfAsException
+ {
+ return createPdfAs(null);
+ }
}
diff --git a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
index e8ebc16..33a418e 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java
@@ -74,4 +74,26 @@ public final class Constants
* All signatures are verified.
*/
public static int VERIFY_ALL = -1;
+
+ /**
+ * The system property that may be used to declare the pdf-as configuration folder.
+ */
+ public final static String CONFIG_SYSTEM_PROPERTY = "pdf-as.work-dir";
+
+ /**
+ * The zip file containing the default configuration.
+ */
+ public final static String DEFAULT_CONFIGURATION_ZIP_RESOURCE = "DefaultConfiguration.zip";
+
+ /**
+ * The configuration folder for pdf-as within the user's home folder.
+ */
+ public static final String USERHOME_CONFIG_FOLDER = "PDF-AS";
+
+ /**
+ * The name of the directory, where temporary files are stored.
+ */
+ public final static String TEMP_DIR_NAME = "pdfastmp";
+
}
+
diff --git a/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java b/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java
new file mode 100644
index 0000000..d4feedd
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/api/exceptions/ConfigUtilsException.java
@@ -0,0 +1,99 @@
+package at.gv.egiz.pdfas.api.exceptions;
+
+/**
+ * @author <a href="mailto:thomas.knall@egiz.gv.at">Thomas Knall</a>
+ */
+public class ConfigUtilsException extends Exception {
+
+ /**
+ * Marker for serialization.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The underlying exception.
+ */
+ private Exception wrappedException;
+
+ /**
+ * Returns the underlying exception.
+ *
+ * @return The underlying exception.
+ */
+ public Exception getException() {
+ return this.wrappedException;
+ }
+
+ /**
+ * Returns the message of the wrapped exception.
+ *
+ * @return The message of the wrapped exception.
+ */
+ public String getMessage() {
+ String message = super.getMessage();
+ if (message == null && this.wrappedException != null) {
+ return this.wrappedException.getMessage();
+ } else {
+ return message;
+ }
+ }
+
+ /**
+ * Instantiation of a new exception based on a message and another (wrapped)
+ * exception.
+ *
+ * @param message
+ * The exception message.
+ * @param exception
+ * Another exception.
+ */
+ public ConfigUtilsException(final String message, final Exception exception) {
+ super(message);
+ this.wrappedException = exception;
+ }
+
+ /**
+ * Instantiated a new exception based on a message.
+ *
+ * @param message
+ * The message of the new exception.
+ */
+ public ConfigUtilsException(final String message) {
+ super(message);
+ this.wrappedException = null;
+ }
+
+ /**
+ * Instantiates a new exception based on another (wrapped) exception.
+ *
+ * @param exception
+ * The wrapped exception.
+ */
+ public ConfigUtilsException(final Exception exception) {
+ super();
+ this.wrappedException = exception;
+ }
+
+ /**
+ * Instantiates a new (unspecified) exception.
+ */
+ public ConfigUtilsException() {
+ super();
+ this.wrappedException = null;
+
+ }
+
+ /**
+ * Returns the text representation of this instance.
+ *
+ * @return The text representation of this instance.
+ */
+ public String toString() {
+ if (this.wrappedException != null) {
+ return this.wrappedException.toString();
+ } else {
+ return super.toString();
+ }
+ }
+
+}
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] <input file> [output file]");
+ writer.println("Usage: pdf-as [[OPTIONS] <input file> [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);
}
/**
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
index b744d2a..303d48f 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
@@ -29,6 +29,7 @@ import at.gv.egiz.pdfas.api.verify.VerifyResult;
import at.gv.egiz.pdfas.api.verify.VerifyResults;
import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.framework.ConnectorFactory;
import at.gv.egiz.pdfas.framework.config.SettingsHelper;
import at.gv.egiz.pdfas.framework.input.ExtractionStage;
import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
@@ -65,10 +66,6 @@ import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
*/
public class PdfAsObject implements PdfAs
{
- /**
- * The work directory.
- */
- protected File workDirectory = null;
/**
* The log.
@@ -86,21 +83,23 @@ public class PdfAsObject implements PdfAs
*/
public PdfAsObject(File workDirectory) throws PdfAsException
{
- if (workDirectory == null)
- {
- throw new IllegalArgumentException("The work directory must not be null.");
- }
- if (!workDirectory.isDirectory())
- {
- throw new IllegalArgumentException("The work directory does not exist or is not a directory. " + workDirectory.getPath());
- }
-
- this.workDirectory = workDirectory;
-
- SettingsReader.initialize(workDirectory.getPath());
+ String path = workDirectory != null ? workDirectory.getPath() : null;
+ SettingsReader.initialize(path, path);
reloadConfig();
}
-
+
+ /**
+ * This constructor is for internal use only - use
+ * {@link at.gv.egiz.pdfas.PdfAsFactory} instead.
+ *
+ * @throws PdfAsException
+ * Thrown, if the configuration cannot be processed.
+ */
+ public PdfAsObject() throws PdfAsException
+ {
+ this(null);
+ }
+
/**
* @see at.gv.egiz.pdfas.api.PdfAs#reloadConfig()
*/
@@ -235,7 +234,7 @@ public class PdfAsObject implements PdfAs
TablePos pos = PosHelper.formTablePos(signParameters.getSignaturePositioning());
String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice());
-
+
SignatorInformation si = PdfAS
.signCommandline(new PdfDataSourceAdapter(signParameters.getDocument()), new DataSinkAdapter(signParameters.getOutput()), signatorId, connectorId, signParameters.getSignatureProfileId(), pos);
diff --git a/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
new file mode 100644
index 0000000..c98cb59
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/utils/ConfigUtils.java
@@ -0,0 +1,176 @@
+package at.gv.egiz.pdfas.utils;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.pdfas.api.commons.Constants;
+import at.gv.egiz.pdfas.api.exceptions.ConfigUtilsException;
+
+/**
+ * @author <a href="mailto:thomas.knall@egiz.gv.at">Thomas Knall</a>
+ */
+public final class ConfigUtils {
+
+ private ConfigUtils() {
+ }
+
+ /**
+ * The log.
+ */
+ private static final Log logger_ = LogFactory.getLog(ConfigUtils.class);
+
+ /**
+ * Deploys the default configuration with apache commons vfs.
+ *
+ * @param destination The destination folder.
+ * @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ */
+ /*
+ private static boolean deployWithCommonsVFS(String destination, boolean overwriteExisting) throws ConfigUtilsException {
+ try {
+ FileSystemManager fsManager = VFS.getManager();
+ FileObject defaultConfigurationFile = fsManager.resolveFile("res:DefaultConfiguration");
+ FileObject destinationFile = fsManager.resolveFile(destination);
+
+ if (destinationFile.exists() && !overwriteExisting) {
+ return false;
+ }
+
+ destinationFile.copyFrom(defaultConfigurationFile, new AllFileSelector());
+ return true;
+ } catch (FileSystemException e) {
+ throw new ConfigUtilsException(e);
+ }
+ }
+ */
+
+
+ /**
+ * Deploys the default configuration from an included zip file.
+ *
+ * @param destination The destination folder.
+ * @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ */
+ private static boolean deployFromZIP(String destination, boolean overwriteExisting) throws ConfigUtilsException {
+ try {
+ File destinationFolder = new File(destination);
+ if (destinationFolder.exists() && !overwriteExisting) {
+ return false;
+ }
+ InputStream in = ConfigUtils.class.getClassLoader().getResourceAsStream(Constants.DEFAULT_CONFIGURATION_ZIP_RESOURCE);
+ if (in == null) {
+ throw new ConfigUtilsException("Unable to find default configuration resource \"" + Constants.DEFAULT_CONFIGURATION_ZIP_RESOURCE + "\".");
+ }
+ ZipInputStream zis = new ZipInputStream(in);
+ ZipEntry ze;
+ destinationFolder.mkdirs();
+ logger_.debug("Extracting default configuration to folder \"" + destinationFolder.getCanonicalPath() + "\".");
+ while ((ze = zis.getNextEntry()) != null) {
+ if (ze.isDirectory()) {
+ File newFolder = new File(destinationFolder, ze.getName());
+ logger_.debug("Extracting folder \"" + newFolder.getPath() + "\".");
+ newFolder.mkdirs();
+ } else {
+ File destFile = new File(destinationFolder, ze.getName());
+ logger_.trace("Extracting file \"" + destFile.getName() + "\".");
+ toFile(zis, destFile);
+ }
+ zis.closeEntry();
+ }
+ zis.close();
+ return true;
+ } catch (IOException e) {
+ throw new ConfigUtilsException(e);
+ }
+ }
+
+ /**
+ * Deploys the default configuration to the given destination folder.
+ *
+ * @param destination The destination folder.
+ * @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ */
+ public static boolean deployDefaultConfiguration(String destination, boolean overwriteExisting) throws ConfigUtilsException {
+ if (destination == null) {
+ throw new NullPointerException("Destination must not be null.");
+ }
+ if (destination.length() == 0) {
+ throw new IllegalArgumentException("Destination must not be empty.");
+ }
+ return deployFromZIP(destination, overwriteExisting);
+ }
+
+ /**
+ * Deploys the default configuration to the user's home directory to the subdirectory specified by
+ * <code>Constants.Constants.USERHOME_CONFIG_FOLDER</code>.
+ *
+ * @param overwriteExisting If set <code>true</code> an already existing configuration is overwritten. If <code>false</code> nothing is being copied if the destination folder already exists.
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ * @see Constants#USERHOME_CONFIG_FOLDER
+ */
+ public static boolean deployDefaultConfiguration(boolean overwriteExisting) throws ConfigUtilsException {
+ String userHome = System.getProperty("user.home");
+ if (userHome == null || userHome.length() == 0) {
+ return false;
+ }
+ return deployDefaultConfiguration(userHome + File.separator + Constants.USERHOME_CONFIG_FOLDER, overwriteExisting);
+ }
+
+ /**
+ * Deploys the default configuration to the user's home directory to the subdirectory specified by
+ * <code>Constants.Constants.USERHOME_CONFIG_FOLDER</code>.
+ *
+ * @return <code>true</code> if the configuration has been deployed, <code>false</code> if not.
+ * @throws ConfigUtilsException Thrown if there was an error during the deployment of the configuration.
+ * @see Constants#USERHOME_CONFIG_FOLDER
+ */
+ public static boolean deployDefaultConfiguration() throws ConfigUtilsException {
+ return deployDefaultConfiguration(false);
+ }
+
+ public static boolean toFile(InputStream inputStream, File file) throws IOException {
+ boolean result = false;
+ BufferedOutputStream bufferedOutputStream = null;
+ try {
+ bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
+ writeInputStreamToOutputStream(inputStream, bufferedOutputStream);
+ } finally {
+ if (bufferedOutputStream != null) {
+ try {
+ bufferedOutputStream.close();
+ result = true;
+ } catch (IOException e) {
+ result = false;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static void writeInputStreamToOutputStream(InputStream inputStream, OutputStream outputStream) throws IOException {
+ final int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+ int len = -1;
+ while ((len = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, len);
+ }
+ outputStream.flush();
+ }
+
+}
diff --git a/src/main/java/at/gv/egiz/pdfas/utils/StreamUtils.java b/src/main/java/at/gv/egiz/pdfas/utils/StreamUtils.java
index acf7e75..44303b0 100644
--- a/src/main/java/at/gv/egiz/pdfas/utils/StreamUtils.java
+++ b/src/main/java/at/gv/egiz/pdfas/utils/StreamUtils.java
@@ -16,6 +16,7 @@ public class StreamUtils
{
os.write(buffer, 0, read);
}
+ os.flush();
is.close();
os.close();
}
diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/SessionHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/SessionHelper.java
index 5752838..93c0aa2 100644
--- a/src/main/java/at/gv/egiz/pdfas/web/helper/SessionHelper.java
+++ b/src/main/java/at/gv/egiz/pdfas/web/helper/SessionHelper.java
@@ -3,7 +3,6 @@
*/
package at.gv.egiz.pdfas.web.helper;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
index 5dbc8b6..341b97c 100644
--- a/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
+++ b/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java
@@ -129,7 +129,7 @@ public class SignServletHelper
// TODO TR: Web-Applikation verwendet in Loc-Ref-Variante ext. Referenz, um performanter zu sein;
// nachfolend auskommentieren, wenn anstatt SwA-Connector LocRef-Connector verwendet wird
- URL signature_data_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL signature_data_URL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String signature_data_url = response.encodeURL(signature_data_URL.toString());
Connector c = ConnectorChooser.chooseWebConnectorForSign(si.connector, si.type, signature_data_url);
diff --git a/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java b/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
index e3f10ed..e7ce3ac 100644
--- a/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
+++ b/src/main/java/at/gv/egiz/pdfas/web/helper/TempDirHelper.java
@@ -48,6 +48,69 @@ public class TempDirHelper
protected static long runningIndex = 0;
+ /**
+ * Assembles the File of the temporary directory without checking if it really
+ * exists.
+ */
+ public static File assembleTemporaryDirectoryFile()
+ {
+ File temp_dir = new File(SettingsReader.TMP_PATH);
+ return temp_dir;
+ }
+
+ /**
+ * Returns the directory where temporary files should be stored.
+ *
+ * <p>
+ * If the directory doesn't exist, it is created.
+ * </p>
+ *
+ * @return Returns the directory where temporary files should be stored.
+ */
+ public static File getTemporaryDirectory()
+ {
+ File temp_dir = assembleTemporaryDirectoryFile();
+ if (!temp_dir.exists())
+ {
+ temp_dir.mkdirs();
+ }
+ return temp_dir;
+ }
+
+ /**
+ * Deletes all files in the temporary directory, if it exists.
+ *
+ * <p>
+ * This should be used to clear temporary files when the application shuts
+ * down.
+ * </p>
+ */
+ public static void clearTemporaryDirectory()
+ {
+ File temp_dir = assembleTemporaryDirectoryFile();
+ log.debug("Clearing temporary directory: " + temp_dir);
+
+ if (!temp_dir.exists())
+ {
+ return;
+ }
+
+ File[] files = temp_dir.listFiles();
+ for (int i = 0; i < files.length; i++)
+ {
+ // added by tknall: do not try to remove svn-metadata
+ if (files[i].getName().endsWith(".svn")) {
+ continue;
+ }
+ log.debug(" Clearing temporary file: " + files[i]);
+ boolean delete_success = files[i].delete();
+ if (!delete_success)
+ {
+ log.error("Couldn't delete the temporary file: " + files[i]);
+ }
+ }
+ }
+
public static void storeTextSignatureHoldersIfApplicable(List shs, String fileNameSuffix) throws IOException
{
Iterator it = shs.iterator();
@@ -166,7 +229,8 @@ public class TempDirHelper
protected static File getFileInTempDir (String fileName)
{
- File tempDir = new File(new File(SettingsReader.RESOURCES_PATH), "pdfastmp");
+// File tempDir = new File(new File(SettingsReader.RESOURCES_PATH), "pdfastmp");
+ File tempDir = assembleTemporaryDirectoryFile();
File tmpFile = new File(tempDir, fileName);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index c0e340c..5dbc7fb 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -92,7 +92,12 @@ import com.lowagie.text.pdf.PdfReader;
public abstract class PdfAS
{
- public static final String PDFAS_VERSION = "3.0.5-20080529";
+ /**
+ * The current version of the pdf-as library. This version string is logged on every invocation
+ * of the api or the web application.
+ */
+ public static final String PDFAS_VERSION = "3.0.5-20080603";
+
/**
* The key of the strict mode setting.
*/
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
index 1fa3ad6..231da06 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/cfg/SettingsReader.java
@@ -33,12 +33,18 @@ import java.util.Properties;
import java.util.Vector;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.text.StrSubstitutor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import at.gv.egiz.pdfas.api.commons.Constants;
+import at.gv.egiz.pdfas.api.exceptions.ConfigUtilsException;
+import at.gv.egiz.pdfas.utils.ConfigUtils;
+import at.gv.egiz.pdfas.web.helper.TempDirHelper;
import at.knowcenter.wag.egov.egiz.PdfAS;
import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
+import at.knowcenter.wag.egov.egiz.pdf.Utils;
/**
* The SettingsReader reads the <code>settings.txt</code> file. The
@@ -186,6 +192,11 @@ public class SettingsReader implements Serializable
* </p>
*/
public static String RESOURCES_PATH = null;
+
+ /**
+ * The path for temporary files.
+ */
+ public static String TMP_PATH = null;
/**
* The path of the configuration directory.
@@ -197,11 +208,6 @@ public class SettingsReader implements Serializable
*/
public static String CERT_PATH = null;
- /**
- * The name of the directory, where temporary files are stored.
- */
- protected static String TEMP_DIR_NAME = "pdfastmp";
-
// /**
// * The application config path for the command line tool
// */
@@ -386,6 +392,14 @@ public class SettingsReader implements Serializable
{
if (instance_ == null)
{
+ int length = Utils.max(new int[] { RESOURCES_PATH.length(), TMP_PATH.length(), CONFIG_PATH.length(), CERT_PATH.length() });
+
+ logger_.info(StringUtils.repeat("*", length + 25));
+ logger_.info(" resources path = \"" + RESOURCES_PATH + "\"");
+ logger_.info(" configuration path = \"" + CONFIG_PATH + "\"");
+ logger_.info(" certstore path = \"" + CERT_PATH + "\"");
+ logger_.info(" temporary path = \"" + TMP_PATH + "\"");
+ logger_.info(StringUtils.repeat("*", length + 25));
instance_ = new SettingsReader(settingsFile);
}
return instance_;
@@ -631,11 +645,11 @@ public class SettingsReader implements Serializable
/**
* Assembles the File of the temporary directory without checking if it really
* exists.
+ * @see TempDirHelper#assembleTemporaryDirectoryFile()
*/
protected static File assembleTemporaryDirectoryFile()
{
- File temp_dir = new File(RESOURCES_PATH + TEMP_DIR_NAME);
- return temp_dir;
+ return TempDirHelper.assembleTemporaryDirectoryFile();
}
/**
@@ -646,15 +660,11 @@ public class SettingsReader implements Serializable
* </p>
*
* @return Returns the directory where temporary files should be stored.
+ * @see TempDirHelper#getTemporaryDirectory()
*/
public static File getTemporaryDirectory()
{
- File temp_dir = assembleTemporaryDirectoryFile();
- if (!temp_dir.exists())
- {
- temp_dir.mkdirs();
- }
- return temp_dir;
+ return TempDirHelper.getTemporaryDirectory();
}
/**
@@ -664,38 +674,109 @@ public class SettingsReader implements Serializable
* This should be used to clear temporary files when the application shuts
* down.
* </p>
+ * @see TempDirHelper#clearTemporaryDirectory()
*/
public static void clearTemporaryDirectory()
{
- File temp_dir = assembleTemporaryDirectoryFile();
- logger_.debug("Clearing temporary directory: " + temp_dir);
-
- if (!temp_dir.exists())
- {
- return;
- }
-
- File[] files = temp_dir.listFiles();
- for (int i = 0; i < files.length; i++)
- {
- // added by tknall: do not try to remove svn-metadata
- if (files[i].getName().endsWith(".svn")) {
- continue;
- }
- logger_.debug(" Clearing temporary file: " + files[i]);
- boolean delete_success = files[i].delete();
- if (!delete_success)
- {
- logger_.error("Couldn't delete the temporary file: " + files[i]);
+ TempDirHelper.clearTemporaryDirectory();
+ }
+
+ private static String assertFileSeparator(String path) {
+ if (path == null) {
+ throw new NullPointerException("Path must not be null.");
+ }
+ if (path.endsWith(File.separator) || path.endsWith("/") || path.endsWith("\\")) {
+ return path;
+ } else {
+ return (path + File.separator);
+ }
+ }
+
+ public static synchronized void initialize(String configdir, String tmpdir) {
+
+ boolean defaultConfigDeployed = false;
+ // resolve work directory
+ // configuration explicitely given ?
+ if (configdir == null) {
+
+ // configuration via system property ?
+ logger_.debug("No configuration directory given. Looking for system property \"" + Constants.CONFIG_SYSTEM_PROPERTY + "\".");
+ configdir = System.getProperty(Constants.CONFIG_SYSTEM_PROPERTY);
+ if (configdir == null) {
+
+ // configuration via user's home directory ?
+ logger_.debug("System property not set. Trying to locate configuration within the user's home directory.");
+ String userHome = System.getProperty("user.home");
+ if (userHome == null || userHome.length() == 0) {
+ throw new RuntimeException("Unable to resolve user's home directory.");
+ }
+ configdir = assertFileSeparator(userHome) + Constants.USERHOME_CONFIG_FOLDER;
+ try {
+ defaultConfigDeployed = ConfigUtils.deployDefaultConfiguration(configdir, false);
+ } catch (ConfigUtilsException e) {
+ throw new RuntimeException(e);
+ }
+ if (defaultConfigDeployed) {
+ logger_.info("** Default configuration successfully deployed to the current user's home. **");
+ } else {
+ logger_.debug("Default configuration NOT deployed because to the current user's home because it already exists.");
+ }
+ } else {
+ logger_.debug("Configuration set by system property.");
+ }
+ } else {
+ logger_.debug("Configuration path explicitely set.");
+ }
+ File configdirFile = new File(StrSubstitutor.replaceSystemProperties(configdir));
+ try {
+ configdir = assertFileSeparator(configdirFile.getCanonicalPath());
+ } catch (IOException e) {
+ configdir = assertFileSeparator(configdirFile.getPath());
}
- }
+ if (!configdirFile.isDirectory())
+ {
+ throw new IllegalArgumentException("The config directory \"" + configdir + "\" does not exist or is not a directory.");
+ }
+
+ // resolve temporary dir
+ if (tmpdir == null) {
+ logger_.debug("Temporary directory not explicitely set. Looking for user's temp directory.");
+ tmpdir = System.getProperty("java.io.tmpdir");
+ if (tmpdir == null) {
+ logger_.debug("Unable to resolve user's temporary directory. Assuming temporary directory located within config dir.");
+ tmpdir = configdir;
+ }
+ } else {
+ logger_.debug("Temporary directory explicitely set.");
+ }
+ File tmpdirFile = new File(StrSubstitutor.replaceSystemProperties(assertFileSeparator(tmpdir) + Constants.TEMP_DIR_NAME));
+ try {
+ tmpdir = assertFileSeparator(tmpdirFile.getCanonicalPath());
+ } catch (IOException e) {
+ tmpdir = assertFileSeparator(tmpdirFile.getPath());
+ }
+
+ RESOURCES_PATH = configdir;
+ TMP_PATH = tmpdir;
+ CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP;
+ CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP;
+
+ int length = Utils.max(new int[] { RESOURCES_PATH.length(), TMP_PATH.length(), CONFIG_PATH.length(), CERT_PATH.length() });
+
+ logger_.debug(StringUtils.repeat("*", length + 25));
+ logger_.debug(" resources path = \"" + RESOURCES_PATH + "\"");
+ logger_.debug(" configuration path = \"" + CONFIG_PATH + "\"");
+ logger_.debug(" certstore path = \"" + CERT_PATH + "\"");
+ logger_.debug(" temporary path = \"" + TMP_PATH + "\"");
+ if (defaultConfigDeployed) {
+ logger_.debug(" default configuration was deployed to the current user's home directory ");
+ }
+ logger_.debug(StringUtils.repeat("*", length + 25));
}
public static void initialize(String base_dir)
{
- RESOURCES_PATH = base_dir + FILE_SEP; //CATALINA_HOME + FILE_SEP + WEB_APPL_DIR;
- CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP;
- CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP;
+ initialize(base_dir, null);
}
/**
@@ -707,10 +788,7 @@ public class SettingsReader implements Serializable
*/
public static void initializeForWeb(String base_dir)
{
- initialize(base_dir);
-// RESOURCES_PATH = base_dir + FILE_SEP; //CATALINA_HOME + FILE_SEP + WEB_APPL_DIR;
-// CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP;
-// CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP;
+ initialize(base_dir, base_dir);
}
/**
@@ -718,10 +796,7 @@ public class SettingsReader implements Serializable
*/
public static void initializeForCommandLine()
{
- initialize(USER_DIR);
-// RESOURCES_PATH = USER_DIR + FILE_SEP;
-// CONFIG_PATH = RESOURCES_PATH + CFG + FILE_SEP;
-// CERT_PATH = RESOURCES_PATH + CERT + FILE_SEP;
+ initialize(null);
}
static {
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
index c03db24..ad3a24c 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java
@@ -309,6 +309,9 @@ public class PDFSignatureObjectIText implements PDFSignatureObject
throw new PDFDocumentException(220, "Image file \"" + img_file.getCanonicalPath() + "\" doesn't exist.");
}
Image image = Image.getInstance(img_file.getCanonicalPath());
+ logger_.debug("Using image file \"" + img_file.getCanonicalPath() + "\".");
+
+ // TODO[tknall]: enable image scaling defined by configuration
image.scaleToFit(80.0f, 80.0f);
// tknall end
boolean fit = true;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Utils.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Utils.java
index c075d45..39d353b 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Utils.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/Utils.java
@@ -17,6 +17,7 @@
*/
package at.knowcenter.wag.egov.egiz.pdf;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -92,5 +93,24 @@ public abstract class Utils
return signature_text;
}
-
+
+ public static int max(int[] ints) {
+ int max = Integer.MIN_VALUE;
+ for (int i = 0; i < ints.length; i++) {
+ if (ints[i] > max) {
+ max = ints[i];
+ }
+ }
+ return max;
+ }
+
+ public static String resolveCanonical(String path) {
+ File file = new File(path);
+ try {
+ return file.getCanonicalPath();
+ } catch (IOException e) {
+ return file.getPath();
+ }
+ }
+
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
index f1896d7..5dbc0a6 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java
@@ -3,7 +3,6 @@
*/
package at.knowcenter.wag.egov.egiz.sig.connectors.bku;
-import java.io.File;
import java.security.cert.X509Certificate;
import java.util.Properties;
@@ -73,7 +72,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
this.params = connectorParameters;
this.environment = new Environment(this.params.getProfileId(), loc_ref_content);
}
-
+
/**
* Prepares the sign request xml to be sent using the sign request template.
*
@@ -92,6 +91,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
String sign_keybox_identifier = this.environment.getSignKeyboxIdentifier();
String mime_type = data.getMimeType();
String loc_ref_content = this.environment.getLocRefContent();
+
if (log.isDebugEnabled())
{
log.debug("sign keybox identifier = " + sign_keybox_identifier); //$NON-NLS-1$
@@ -103,6 +103,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector
sign_request_xml = sign_request_xml.replaceFirst(TemplateReplaces.MIME_TYPE_REPLACE, mime_type);
sign_request_xml = sign_request_xml.replaceFirst(TemplateReplaces.LOC_REF_CONTENT_REPLACE, loc_ref_content);
+ log.debug("sign_request_xml = " + sign_request_xml);
log.debug("prepareSignRequestDetached finished."); //$NON-NLS-1$
return sign_request_xml;
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java
index 53ac7cf..50b7bad 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/FileHelper.java
@@ -21,6 +21,7 @@ package at.knowcenter.wag.egov.egiz.tools;
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileReader;
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
index 8ee09dc..2f02944 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/LocalRequestHelper.java
@@ -84,7 +84,7 @@ public abstract class LocalRequestHelper
public static String processLocalSign(SignSessionInformation si, HttpServletRequest request, HttpServletResponse response) throws IOException, PresentableException
{
String host = request.getServerName(); // "129.27.153.77"
- URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL loc_ref_URL = new URL(getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
LocalConnector c = ConnectorChooser.chooseLocalConnectorForSign(si.connector, si.type, loc_ref_url);
@@ -175,7 +175,7 @@ public abstract class LocalRequestHelper
// si.finished = false;
String host = request.getServerName();
- URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL loc_ref_URL = new URL(getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
for (int i = 0; i < si.currentLocalOperation.requests.length; i++)
@@ -414,7 +414,15 @@ public abstract class LocalRequestHelper
URL local_server = null;
try
{
- local_server = new URL(request.getScheme(), host, request.getServerPort(), "/");
+ String scheme = request.getScheme();
+ int port = request.getServerPort();
+ if ("http".equalsIgnoreCase(scheme) && port == 80) {
+ local_server = new URL(scheme, host, "/");
+ } else if ("https".equalsIgnoreCase(scheme) && port == 443) {
+ local_server = new URL(scheme, host, "/");
+ } else {
+ local_server = new URL(scheme, host, port, "/");
+ }
}
catch (MalformedURLException e)
{
@@ -424,6 +432,15 @@ public abstract class LocalRequestHelper
return loc_server;
}
+
+ public static String getLocalContextAddress(HttpServletRequest request, HttpServletResponse response) {
+ String serverURL = getLocalServerAddress(request, response);
+ String context = request.getContextPath();
+ if (serverURL.endsWith("/") && context.startsWith("/")) {
+ context = context.substring(1);
+ }
+ return serverURL + context;
+ }
/**
* Returns the URL for accessing the local service.
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java
index adb31be..e33a5ec 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/PdfASServletContextListener.java
@@ -17,15 +17,13 @@
*/
package at.knowcenter.wag.egov.egiz.web;
-import java.io.File;
-import java.io.IOException;
-
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
+import at.gv.egiz.pdfas.api.commons.Constants;
import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
@@ -44,6 +42,14 @@ public class PdfASServletContextListener implements ServletContextListener
* The logger.
*/
private static final Logger logger = ConfigLogger.getLogger(PdfASServletContextListener.class);
+
+
+ /**
+ * The servlet init parameter that may be used to declare the pdf-as configuration folder. The
+ * init parameter may be set in web.xml or in META-INF/context.xml resp.
+ * conf/Catalina/localhost/pdf-as.xml if deployed.
+ */
+ private final static String CONFIG_SERVLET_INIT_PARAMETER = "work-dir";
/**
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
@@ -52,19 +58,28 @@ public class PdfASServletContextListener implements ServletContextListener
{
logger.info("PDF-AS Context init"); //$NON-NLS-1$
- String sysPropWorkdir = System.getProperty("pdf-as.work-dir");
+ String sysPropWorkdir = System.getProperty(Constants.CONFIG_SYSTEM_PROPERTY);
+ String scWorkdir = sce.getServletContext().getInitParameter(CONFIG_SERVLET_INIT_PARAMETER);
+
String work_dir;
+
+ // search for system property
if (sysPropWorkdir != null && sysPropWorkdir.length() > 0) {
work_dir = sysPropWorkdir;
- logger.info("Work-dir configuration via system property.");
- logger.info("PDF-AS work-dir via system property = " + work_dir); //$NON-NLS-1$
+ logger.debug("Work-dir configuration via system property \"" + Constants.CONFIG_SYSTEM_PROPERTY + "\" = \"" + sysPropWorkdir + "\".");
+
+ // search for servlet parameter
+ } else if (scWorkdir != null && scWorkdir.length() > 0){
+ work_dir = scWorkdir;
+ logger.debug("Work-dir configuration via servlet init parameter \"" + CONFIG_SERVLET_INIT_PARAMETER + "\" = \"" + scWorkdir + "\".");
+
+ // assume configuration to be located in webapp path
} else {
- work_dir = sce.getServletContext().getInitParameter("work-dir"); //$NON-NLS-1$
- logger.info("PDF-AS work-dir context parameter = " + work_dir); //$NON-NLS-1$
+ work_dir = sce.getServletContext().getRealPath("/");
+ logger.debug("PDF-AS work-dir not explicitely given. Assuming configuration is located in webapp folder \"" + work_dir + "\".");
}
- String base_dir = sce.getServletContext().getRealPath("/"); //$NON-NLS-1$
- logger.info("PDF-AS real path = " + base_dir); //$NON-NLS-1$
+ logger.info("PDF-AS configuration location = \"" + work_dir + "\"");
// try
// {
@@ -76,13 +91,8 @@ public class PdfASServletContextListener implements ServletContextListener
// e.printStackTrace();
// }
- if (work_dir != null && work_dir.length() > 0)
- {
- base_dir = work_dir;
- }
- logger.info("The PDF-AS application will be initialized for the directory: " + base_dir);
- SettingsReader.initializeForWeb(base_dir);
+ SettingsReader.initializeForWeb(work_dir);
PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties");
SettingsReader.clearTemporaryDirectory();
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
index 3c2ba28..cbb33ba 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java
@@ -4,6 +4,7 @@
package at.knowcenter.wag.egov.egiz.web.servlets;
import java.io.IOException;
+import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.ArrayList;
@@ -41,6 +42,7 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector;
import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection;
import at.knowcenter.wag.egov.egiz.web.FormFields;
import at.knowcenter.wag.egov.egiz.web.LocalRequest;
+import at.knowcenter.wag.egov.egiz.web.LocalRequestHelper;
import at.knowcenter.wag.egov.egiz.web.SessionAttributes;
/**
@@ -84,7 +86,26 @@ public class DataURLServlet extends HttpServlet
dispatch(request, response, "/jsp/results.jsp");
}
- /**
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ this.doPost(req, resp);
+ }
+
+ private static void temporaryRedirect(String redirectURL, HttpServletResponse response) throws IOException {
+ String encodedRedirect = response.encodeRedirectURL(redirectURL);
+ response.addHeader("Location", encodedRedirect);
+ response.setContentType("text/xml");
+ response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
+ String nop = "<?xml version='1.0' encoding='UTF-8'?><NullOperationRequest xmlns='http://www.buergerkarte.at/namespaces/securitylayer/1.2#'/>";
+ PrintWriter pw = response.getWriter();
+ response.setCharacterEncoding("UTF-8");
+ response.setContentLength(nop.getBytes("UTF-8").length);
+ log.debug("Redirecting via NullOperationRequest to " + encodedRedirect + ".");
+ pw.println(nop);
+ pw.flush();
+ pw.close();
+ }
+
+/**
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@@ -148,7 +169,7 @@ public class DataURLServlet extends HttpServlet
if (isNullResponse(xml_response))
{
log.debug("Received a NullOperationResponse -> answering with the first request."); //$NON-NLS-1$
-
+
assert si.outputAvailable == false;
assert si.response_properties == null;
@@ -158,6 +179,7 @@ public class DataURLServlet extends HttpServlet
String request_string = local_request.getRequestString();
+ log.debug("request = " + request_string);
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
response.getWriter().println(request_string);
@@ -208,10 +230,16 @@ public class DataURLServlet extends HttpServlet
HttpSession session = request.getSession(true);
log.debug("Putting signed document into session (" + session.getId() + ").");
session.setAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT, si);
- session.setAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT, response.encodeRedirectURL("/pdf-as/ProvidePDF"));
- String redirectURL = response.encodeRedirectURL("/pdf-as/jsp/download.jsp");
- log.debug("Redirecting to " + redirectURL + ".");
- response.sendRedirect(redirectURL);
+// String serverURL = LocalRequestHelper.getLocalServerAddress(request, response);
+ String downloadURL = response.encodeRedirectURL(LocalRequestHelper.getLocalContextAddress(request, response) + "/ProvidePDF");
+ log.debug("Creating download URL \"" + downloadURL + "\".");
+ session.setAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT, downloadURL);
+
+// String redirectURL = response.encodeRedirectURL("/pdf-as/jsp/download.jsp");
+// log.debug("Redirecting to " + redirectURL + ".");
+// response.sendRedirect(redirectURL);
+ temporaryRedirect(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/download.jsp", response);
+
return;
// SignServletHelper.returnSignResponse(si, response);
}
@@ -275,7 +303,7 @@ public class DataURLServlet extends HttpServlet
si.currentLocalOperation = null;
- URL btlURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + "/jsp/verifylist.jsp");
+ URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
String backToListURL = response.encodeURL(btlURL.toString());
dispatchToResults(results, request, response, backToListURL);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
index 6d486a5..03bd074 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java
@@ -56,9 +56,11 @@ public class ProvidePDFServlet extends HttpServlet {
disp.forward(request, response);
return;
} else {
- log.debug("Signed pdf found. Removing from session.");
+ log.debug("Signed pdf found.");
session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT);
log.debug("Returning signed pdf to browser.");
+ log.debug("Invalidating session.");
+ session.invalidate();
SignServletHelper.returnSignResponse(si, response);
return;
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java
index 6653a60..61996da 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/RetrieveSignatureDataServlet.java
@@ -12,22 +12,17 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import at.gv.egiz.pdfas.exceptions.web.SessionExpiredException;
-import at.gv.egiz.pdfas.framework.input.DataSource;
+import at.gv.egiz.pdfas.utils.StreamUtils;
import at.gv.egiz.pdfas.web.SignSessionInformation;
import at.gv.egiz.pdfas.web.VerifySessionInformation;
import at.gv.egiz.pdfas.web.helper.SessionHelper;
-import at.gv.egiz.pdfas.utils.StreamUtils;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
import at.knowcenter.wag.egov.egiz.sig.SignatureData;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
/**
* Retrieves the Signature Data from the session and returns it.
@@ -63,13 +58,16 @@ public class RetrieveSignatureDataServlet extends HttpServlet
disp.forward(request, response);
}
- /**
+/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
- log.debug("Request for receiving signature data."); //$NON-NLS-1$
+ if (log.isDebugEnabled()) {
+ log.debug("Request for receiving signature data."); //$NON-NLS-1$
+ log.debug("Requested session id is = " + request.getRequestedSessionId());
+ }
try
{
@@ -141,6 +139,8 @@ public class RetrieveSignatureDataServlet extends HttpServlet
response.setContentType(sd.getMimeType());
response.setCharacterEncoding(sd.getCharacterEncoding());
+ // [tknall] content length must be set, otherwise ITS BKU for Mac rejects the request.
+ response.setContentLength(sd.getDataSource().getLength());
StreamUtils.writeInputStreamToOutputStream(sd.getDataSource().createInputStream(), response.getOutputStream());
// response.getOutputStream().write(sd.getData());
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
index e2de8ae..a608b74 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java
@@ -299,7 +299,8 @@ public class SignServlet extends HttpServlet
// for performance measurement
if (log.isInfoEnabled()) {
long endTime = System.currentTimeMillis();
- String toReport = "SIGN;" + si.mode + ";" + si.filename + ";"+ fileSize + ";" +
+// String toReport = "SIGN;" + si.mode + ";" + si.filename + ";"+ fileSize + ";" +
+ String toReport = "SIGN;" + si.mode + ";XXX;"+ fileSize + ";" +
(endTime - startTime);
log.info(toReport);
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
index 571a8e1..9a91567 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java
@@ -101,7 +101,7 @@ public class VerifyPreviewServlet extends HttpServlet
protected String formBackToListURL(HttpServletRequest request, HttpServletResponse response) throws MalformedURLException
{
- URL btlURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + "/jsp/verifylist.jsp");
+ URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
String backToListURL = response.encodeURL(btlURL.toString());
return backToListURL;
@@ -566,7 +566,7 @@ public class VerifyPreviewServlet extends HttpServlet
}
String host = request.getServerName();
- URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL loc_ref_URL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
List results = PdfAS.verifySignatureHoldersWeb(holders_to_verify, si, loc_ref_url);
@@ -575,7 +575,7 @@ public class VerifyPreviewServlet extends HttpServlet
{
backbutton = false;
}
- URL btlURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + "/jsp/verifylist.jsp");
+ URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
String backToListURL = response.encodeURL(btlURL.toString());
dispatchToResults(results, request, response, backbutton, backToListURL);
@@ -685,12 +685,12 @@ public class VerifyPreviewServlet extends HttpServlet
}
String host = request.getServerName();
- URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL loc_ref_URL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
List results = PdfAS.verifySignatureHoldersWeb(holders_to_verify, si, loc_ref_url);
- URL btlURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + "/jsp/verifylist.jsp");
+ URL btlURL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/jsp/verifylist.jsp");
String backToListURL = response.encodeURL(btlURL.toString());
dispatchToResults(results, request, response, true, backToListURL);
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
index c9ed314..97a1e6f 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyServlet.java
@@ -151,7 +151,7 @@ public class VerifyServlet extends HttpServlet
String host = request.getServerName();
// TODO still required for old communication with MOA-SS/SP
- URL loc_ref_URL = new URL(request.getScheme(), host, request.getServerPort(), request.getContextPath() + "/RetrieveSignatureData");
+ URL loc_ref_URL = new URL(LocalRequestHelper.getLocalContextAddress(request, response) + "/RetrieveSignatureData");
String loc_ref_url = response.encodeURL(loc_ref_URL.toString());
List results = PdfAS.verifySignatureHoldersWeb(signature_holders, si, loc_ref_url);
diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip
new file mode 100644
index 0000000..693ed95
--- /dev/null
+++ b/src/main/resources/DefaultConfiguration.zip
Binary files differ
diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml
index 0b4f656..b27ca81 100644
--- a/src/main/webapp/META-INF/context.xml
+++ b/src/main/webapp/META-INF/context.xml
@@ -2,8 +2,8 @@
<Context path="/pdf-as" cookies="false" reloadable="false">
<Manager pathname="" />
- <!-- Use system property "pdf-as.work-dir" instead. -->
+ <!-- Use system property "pdf-as.work-dir" or web.xml parameter "work-dir" instead. -->
<!--
- <Parameter name="work-dir" value="D:/dev/proj/PDF-AS/work" override="false"/>
+ <Parameter name="work-dir" value="${catalina.base}/conf/pdf-as" override="false"/>
-->
</Context>
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index f9903a6..6d675b4 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -4,20 +4,22 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
- <description>
- EGIZ PDF-AS
- </description>
+ <description>EGIZ PDF-AS</description>
<display-name>PDF-AS</display-name>
-
+
+ <!--
<context-param>
<description>
The working directory of PDF-AS.
Points to a directory on the local file system where templates, config files, certificates etc. are found.
- If empty, the base of the web application will be chosen.
+ Alternatively the configuration can be declared by system property "pdf-as.work-dir"
+ (which is the recommended way) or servlet init parameter "work-dir" in context descriptor
+ file "pdf-as.xml".
</description>
- <param-name></param-name>
- <param-value>override this in your context file (pdf-as.xml)</param-value>
+ <param-name>work-dir</param-name>
+ <param-value>REPLACE_WITH_PATH_TO_PDFAS_CONFIGURATION</param-value>
</context-param>
+ -->
<filter>
<filter-name>sitemesh</filter-name>
diff --git a/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp b/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp
index 3264093..3b48294 100644
--- a/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp
+++ b/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp
@@ -15,7 +15,7 @@
</td>
</tr>
<tr>
- <td rowspan="6"><img src="/pdf-as/images/signatur-logo_de-100.png" width="100" alt="Signatur-Logo"/></td>
+ <td rowspan="6"><img src="<%= request.getContextPath() %>/images/signatur-logo_de-100.png" width="100" alt="Signatur-Logo"/></td>
<td class="pdfaslabel" nowrap="nowrap">Unterzeichner</td>
<td class="pdfasvalue"><input type="text" name="signer" value="&lt;wird aus dem Zertifikat extrahiert&gt;" readonly="readonly" disabled="disabled" size="40" maxlength="255"/></td>
</tr>
diff --git a/src/main/webapp/jsp/dataok.jsp b/src/main/webapp/jsp/dataok.jsp
index 7fc1b96..c77fb46 100644
--- a/src/main/webapp/jsp/dataok.jsp
+++ b/src/main/webapp/jsp/dataok.jsp
@@ -2,7 +2,7 @@
<html>
<head>
<title>PDF-AS Amtssignaturen</title>
-<link rel="stylesheet" type="text/css" href="/pdf-as/css/styles.css" />
+<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/styles.css" />
</head>
<body>
<div class="maindiv">
diff --git a/src/main/webapp/jsp/download.jsp b/src/main/webapp/jsp/download.jsp
index 62a5417..841f1d0 100644
--- a/src/main/webapp/jsp/download.jsp
+++ b/src/main/webapp/jsp/download.jsp
@@ -1,6 +1,7 @@
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="at.knowcenter.wag.egov.egiz.web.SessionAttributes" %>
+<%@ page import="at.knowcenter.wag.egov.egiz.web.LocalRequestHelper" %>
<%
String downloadURL = (String) session.getAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT);
@@ -23,6 +24,7 @@
}
-->
</script>
+ <base href="<%= LocalRequestHelper.getLocalContextAddress(request, response) %>/"/>
</head>
<body>
@@ -34,7 +36,7 @@
<input type="submit" id="SendRequestButton" value="Signiertes Dokument herunterladen" onclick="return hitButton();"/>
</form>
<div class="pdfasverticalspace"></div>
- <a href="/pdf-as/">zur&uuml;ck</a>
+ <a href="<%= request.getContextPath() %>/">zur&uuml;ck</a>
</body>
</html>
diff --git a/src/main/webapp/jsp/error.jsp b/src/main/webapp/jsp/error.jsp
index 48a7f50..0ec94d8 100644
--- a/src/main/webapp/jsp/error.jsp
+++ b/src/main/webapp/jsp/error.jsp
@@ -9,7 +9,7 @@
<head>
<title>PDF-Signaturen Resultat</title>
- <base href="http://www.buergerkarte.at/pdf-as/"/>
+ <base href="<%=LocalRequestHelper.getLocalContextAddress(request,response)%>/"/>
</head>
<%
@@ -30,7 +30,7 @@
<div class="pdfasnote"><%= error %></div>
<div class="pdfasnote">Ursache: <strong><%= cause %></strong></div>
<div class="pdfasverticalspace"></div>
- <a href="<%=LocalRequestHelper.getLocalServerAddress(request,response)%>pdf-as/">zur&uuml;ck</a>
+ <a href="<%=LocalRequestHelper.getLocalContextAddress(request,response)%>/">zur&uuml;ck</a>
<pre style="display:none">
<%
if (pe != null) {
diff --git a/src/main/webapp/jsp/error_verify.jsp b/src/main/webapp/jsp/error_verify.jsp
index 3e8421d..3b82a32 100644
--- a/src/main/webapp/jsp/error_verify.jsp
+++ b/src/main/webapp/jsp/error_verify.jsp
@@ -9,7 +9,7 @@
<head>
<title>PDF-Signaturen Resultat</title>
- <base href="http://www.buergerkarte.at/pdf-as/"/>
+ <base href="<%=LocalRequestHelper.getLocalContextAddress(request,response)%>/"/>
</head>
<%
@@ -30,7 +30,7 @@
<div class="pdfasnote"><%= error %></div>
<div class="pdfasnote">Ursache: <strong><%= cause %></strong></div>
<div class="pdfasverticalspace"></div>
- <a href="<%=LocalRequestHelper.getLocalServerAddress(request,response)%>pdf-as/jsp/verifyupload.jsp">zur&uuml;ck</a>
+ <a href="<%=LocalRequestHelper.getLocalContextAddress(request,response)%>/jsp/verifyupload.jsp">zur&uuml;ck</a>
<pre style="display:none">
<%
if (pe != null) {
diff --git a/src/main/webapp/jsp/null_request_page.jsp b/src/main/webapp/jsp/null_request_page.jsp
index 89df7cf..5773f63 100644
--- a/src/main/webapp/jsp/null_request_page.jsp
+++ b/src/main/webapp/jsp/null_request_page.jsp
@@ -35,7 +35,7 @@
<input type="submit" id="SendRequestButton" value="Absenden..." />
</form>
<div class="pdfasverticalspace"></div>
- <a href="/pdf-as/">zur&uuml;ck</a>
+ <a href="<%= request.getContextPath() %>/">zur&uuml;ck</a>
<script language="javascript" type="text/javascript">
<!--
window.setTimeout("hitButton()", 800);
diff --git a/src/main/webapp/jsp/results.jsp b/src/main/webapp/jsp/results.jsp
index 990e33e..faabc27 100644
--- a/src/main/webapp/jsp/results.jsp
+++ b/src/main/webapp/jsp/results.jsp
@@ -69,7 +69,7 @@
%>
<div class="pdfasverticalspace"></div>
<% if (backbutton) { %>
- <a href="/pdf-as/jsp/verifyupload.jsp">zur&uuml;ck</a>
+ <a href="<%= request.getContextPath() %>/jsp/verifyupload.jsp">zur&uuml;ck</a>
<% } %>
<% if (btlurl != null) { %>
<a href="<%=btlurl%>">zur&uuml;ck zur Liste</a>
diff --git a/src/main/webapp/jsp/signpreview.jsp b/src/main/webapp/jsp/signpreview.jsp
index a1e6349..6ff6da6 100644
--- a/src/main/webapp/jsp/signpreview.jsp
+++ b/src/main/webapp/jsp/signpreview.jsp
@@ -62,7 +62,7 @@
}
%>
<div class="pdfasverticalspace"></div>
- <a href="/pdf-as/">zur&uuml;ck</a>
+ <a href="<%= request.getContextPath() %>/">zur&uuml;ck</a>
</body>
</html>
diff --git a/src/main/webapp/jsp/signupload.jsp b/src/main/webapp/jsp/signupload.jsp
index 6293564..e6c243f 100644
--- a/src/main/webapp/jsp/signupload.jsp
+++ b/src/main/webapp/jsp/signupload.jsp
@@ -15,7 +15,7 @@
enctype="multipart/form-data"
accept-charset="UTF-8"
method="post"
- action="/pdf-as/Sign">
+ action="<%= request.getContextPath() %>/Sign">
<table border="0" cellspacing="0" cellpadding="4" id="pdfasupperformtable">
<tr>
<td nowrap="nowrap"><label>PDF Datei:</label></td>
@@ -57,7 +57,7 @@
<div class="pdfasnote">Das Erscheinungsbild der Signaturmarke kann abh&auml;ngig vom Signatur Typ, vom Signatur Modus, von der verwendeten B&uuml;rgerkarte, sowie von der verwendeten B&uuml;rgerkartenumgebung variieren.</div>
<div>
<!-- =============================================== Start BKU-Erkennung -->
- <iframe src="/pdf-as/bku-erkennung/bku-erkennung_iframe.html" width="152" height="57" id="sep_iframe" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true"></iframe>
+ <iframe src="<%= request.getContextPath() %>/bku-erkennung/bku-erkennung_iframe.html" width="152" height="57" id="sep_iframe" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true"></iframe>
<!-- ================================================ Stop BKU-Erkennung -->
</div>
<input type="submit" value="Signatur erstellen" />
diff --git a/src/main/webapp/jsp/verifylist.jsp b/src/main/webapp/jsp/verifylist.jsp
index 22a2a4e..fac5755 100644
--- a/src/main/webapp/jsp/verifylist.jsp
+++ b/src/main/webapp/jsp/verifylist.jsp
@@ -68,6 +68,6 @@
<input type="submit" value="Alle pr&uuml;fen" />
</form>
<div class="pdfasverticalspace"></div>
- <a href="/pdf-as/jsp/verifyupload.jsp">zur&uuml;ck</a>
+ <a href="<%= request.getContextPath() %>/jsp/verifyupload.jsp">zur&uuml;ck</a>
</body>
</html>
diff --git a/src/main/webapp/jsp/verifypreview.jsp b/src/main/webapp/jsp/verifypreview.jsp
index 975b5ce..1b0adfa 100644
--- a/src/main/webapp/jsp/verifypreview.jsp
+++ b/src/main/webapp/jsp/verifypreview.jsp
@@ -49,7 +49,7 @@
<input type="submit" value="Werte &uuml;bernehmen und pr&uuml;fen" onclick="document.submitform.verify.value='true'" />
</form>
<div class="pdfasverticalspace"></div>
-<a href="/pdf-as/jsp/verifyupload.jsp">zur&uuml;ck</a>
+<a href="<%= request.getContextPath() %>/jsp/verifyupload.jsp">zur&uuml;ck</a>
<a href="<%=btlurl%>">zur&uuml;ck zur Liste</a>
<script language="javascript" type="text/javascript">
<!--
diff --git a/src/main/webapp/jsp/verifyupload.jsp b/src/main/webapp/jsp/verifyupload.jsp
index 97cdcde..54823f5 100644
--- a/src/main/webapp/jsp/verifyupload.jsp
+++ b/src/main/webapp/jsp/verifyupload.jsp
@@ -9,7 +9,7 @@
<h1>PDF-Signaturen</h1>
<h2>Dokument Signatur pr&uuml;fen</h2>
<div class="pdfasnote">Hier bitte den vollst&auml;ndigen Dokumenttext samt Signaturblock eingeben.<br/></div>
-<form name="submitform" enctype="multipart/form-data" method="post" action="/pdf-as/Verify" accept-charset="UTF-8">
+<form name="submitform" enctype="multipart/form-data" method="post" action="<%= request.getContextPath() %>/Verify" accept-charset="UTF-8">
<textarea class="pdfaspreviewfield" rows="14" name="<%= FormFields.FIELD_UPLOAD %>"></textarea>
<table border="0" cellspacing="0" cellpadding="4" id="pdfasupperformtable">
<tr>
@@ -24,7 +24,7 @@
<div>
<!-- =============================================== Start BKU-Erkennung -->
- <iframe src="/pdf-as/bku-erkennung/bku-erkennung_iframe.html" width="152" height="57" id="sep_iframe" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true"></iframe>
+ <iframe src="<%= request.getContextPath() %>/bku-erkennung/bku-erkennung_iframe.html" width="152" height="57" id="sep_iframe" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" allowtransparency="true"></iframe>
<!-- ================================================ Stop BKU-Erkennung -->
</div>
<input type="hidden" name="<%= FormFields.FIELD_PREVIEW %>" value="false" />
@@ -33,6 +33,6 @@
</form>
<div class="pdfasverticalspace"></div>
-<a href="/pdf-as/">zur&uuml;ck</a>
+<a href="<%= request.getContextPath() %>/">zur&uuml;ck</a>
</body>
</html> \ No newline at end of file
diff --git a/src/main/webapp/parentpage/standalone.jsp b/src/main/webapp/parentpage/standalone.jsp
index 716ab00..691857f 100644
--- a/src/main/webapp/parentpage/standalone.jsp
+++ b/src/main/webapp/parentpage/standalone.jsp
@@ -9,7 +9,7 @@
<head>
<decorator:head/>
- <link rel="stylesheet" type="text/css" href="<%=LocalRequestHelper.getLocalServerAddress(request,response)%>pdf-as/css/pdfas-styles.css" />
+ <link rel="stylesheet" type="text/css" href="<%=LocalRequestHelper.getLocalContextAddress(request,response)%>/css/pdfas-styles.css" />
</head>
<body><decorator:body/></body>
diff --git a/src/site/changes.xml b/src/site/changes.xml
index 9410600..df953a6 100644
--- a/src/site/changes.xml
+++ b/src/site/changes.xml
@@ -13,6 +13,36 @@
</release>
-->
+ <release version="3.0.5" date="2008-06-03" description="subsequent release">
+ <action dev="wprinz" type="add">
+ Support of a minimal signature mark layout for binary signatures added.
+ </action>
+ <action dev="tknall" type="add">
+ Web-Application: Every hardcoded context "pdf-as" has been replaced.
+ </action>
+ <action dev="tknall" type="add">
+ Web-Application: Session is now being invalidated after download of the signed pdf file.
+ </action>
+ <action dev="tknall" type="add">
+ Web-Application: Configuration may be declared via system property "pdf-as.work-dir" or via Servlet-Init-Parameter "work-dir".
+ </action>
+ <action dev="tknall" type="fix">
+ Bug fixed in RetrieveSignatureDataServlet: Response header didn't contain a content length attribute. The ITS Mac BKU rejects those requests.
+ </action>
+ <action dev="tknall" type="fix">
+ 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).
+ </action>
+ <action dev="tknall" type="add">
+ 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.
+ </action>
+ <action dev="tknall" type="add">
+ If the configuration is explicitely given than the temporary folder is located within the given directory otherwise within the user's temporary directory.
+ </action>
+ <action dev="tknall" type="add">
+ Declaring the configuration folder, replacements for system properties like "${catalina.base}/conf/pdfas" may be used.
+ </action>
+ </release>
+
<release version="3.0.4" date="2008-04-24"
description="first release">
<action dev="tknall" type="fix">