aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-lib/src/configuration/cfg/config.properties4
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java3
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java45
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java3
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderWebConfiguration.java18
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java10
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java14
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java5
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java47
-rw-r--r--pdf-as-web/src/main/webapp/assets/img/localBKU.pngbin0 -> 6650 bytes
-rw-r--r--pdf-as-web/src/main/webapp/index.jsp2
11 files changed, 68 insertions, 83 deletions
diff --git a/pdf-as-lib/src/configuration/cfg/config.properties b/pdf-as-lib/src/configuration/cfg/config.properties
index fe2385a8..42193ec5 100644
--- a/pdf-as-lib/src/configuration/cfg/config.properties
+++ b/pdf-as-lib/src/configuration/cfg/config.properties
@@ -102,6 +102,4 @@ include.01 = profiles/*.properties
# Legt das Standard-Signaturprofil fest
sig_obj.type.default=SIGNATURBLOCK_SMALL_DE_NOTE
-##################
-# Protect PDF files from copying and extractiong content
-# Set values to be true|false|unchanged
+
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
index 3c560142..e9e7e0f4 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
@@ -44,7 +44,8 @@ public interface IConfigurationConstants {
public static final String LEGACY_POSITIONING = ".legacy.pos";
public static final String LEGACY_40_POSITIONING = ".legacy40.pos";
public static final String MIN_WIDTH = "minWidth";
-
+
+ public static final String PLACEHOLDER_WEB_ID = "placeholder_web_id";
public static final String PLACEHOLDER_ID = "placeholder_id";
public static final String PLACEHOLDER_MODE = "placeholder_mode";
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
index c3c2b6fd..f917de64 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java
@@ -23,17 +23,26 @@
******************************************************************************/
package at.gv.egiz.pdfas.lib.api;
+import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
+import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
+import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
+import at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator;
+import at.gv.egiz.pdfas.lib.impl.PdfAsImpl;
+import at.gv.egiz.pdfas.lib.impl.SignParameterImpl;
+import at.gv.egiz.pdfas.lib.impl.VerifyParameterImpl;
+import at.gv.egiz.pdfas.lib.impl.configuration.ConfigValidatorLoader;
import iaik.security.ec.provider.ECCelerate;
import iaik.security.provider.IAIK;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.awt.Graphics2D;
+import javax.activation.DataSource;
+import javax.crypto.Cipher;
+import java.awt.*;
import java.awt.image.BufferedImage;
-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.io.*;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
@@ -44,28 +53,6 @@ import java.util.Map.Entry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import javax.activation.DataSource;
-import javax.crypto.Cipher;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter;
-import at.gv.egiz.pdfas.lib.configuration.ConfigurationValidator;
-import at.gv.egiz.pdfas.lib.impl.PdfAsImpl;
-import at.gv.egiz.pdfas.lib.impl.SignParameterImpl;
-import at.gv.egiz.pdfas.lib.impl.VerifyParameterImpl;
-import at.gv.egiz.pdfas.lib.impl.configuration.ConfigValidatorLoader;
-
-
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-
public class PdfAsFactory implements IConfigurationConstants {
private static final Logger logger = LoggerFactory
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
index b20215fc..69d83239 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderConfiguration.java
@@ -47,8 +47,7 @@ public class PlaceholderConfiguration extends SpecificBaseConfiguration
}
return false;
}
-
-
+
/**
* Match selected Profile for Placeholder
* Enables to activate placeholder search/match for different profiles
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderWebConfiguration.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderWebConfiguration.java
new file mode 100644
index 00000000..8c63ed02
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/PlaceholderWebConfiguration.java
@@ -0,0 +1,18 @@
+package at.gv.egiz.pdfas.lib.impl.configuration;
+
+import java.util.Properties;
+
+public class PlaceholderWebConfiguration {
+
+ protected static Properties properties = new Properties();
+
+ public static void setValue(String key, String value)
+ {
+ properties.setProperty(key,value);
+ }
+ public static String getValue(String key)
+ {
+ return properties.getProperty(key);
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
index 4b1a5a49..455077a8 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/placeholder/PlaceholderFilter.java
@@ -30,6 +30,7 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsErrorCarrier;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.settings.ISettings;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
+import at.gv.egiz.pdfas.lib.impl.configuration.PlaceholderWebConfiguration;
import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
public class PlaceholderFilter implements IConfigurationConstants,
@@ -42,9 +43,14 @@ public class PlaceholderFilter implements IConfigurationConstants,
if (status.getPlaceholderConfiguration().isGlobalPlaceholderEnabled()) {
PlaceholderExtractor extractor = status.getBackend()
.getPlaceholderExtractor();
- String placeholderID = settings.getValue(PLACEHOLDER_ID);
- String placeholderModeString = settings.getValue(PLACEHOLDER_MODE);
+ String placeholderID = PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID);
+ if(placeholderID == null)
+ {
+ placeholderID = settings.getValue(PLACEHOLDER_ID);
+ }
+
+ String placeholderModeString = settings.getValue(PLACEHOLDER_MODE);
int placeholderMode = PLACEHOLDER_MATCH_MODE_MODERATE;
if (placeholderModeString != null) {
try {
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
index 0398e75b..5db09ea1 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
@@ -299,7 +299,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
// handle rotated page
int targetPageNumber = positioningInstruction.getPage();
logger.debug("Target Page: " + targetPageNumber);
- //umjesto -1 da probamo -2
PDPage targetPage = doc.getPages().get(targetPageNumber - 1);
int rot = targetPage.getRotation();
logger.debug("Page rotation: " + rot);
@@ -589,8 +588,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- /*/ Check if document should be protected*/
-
synchronized (doc) {
doc.saveIncremental(bos);
byte[] outputDocument = bos.toByteArray();
@@ -606,10 +603,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
runPDFAPreflight(new ByteArrayDataSource(pdfObject.getSignedDocument()));
}
-
- /*Check if doc has to be protected*/
-
-
} catch (IOException e1) {
e1.printStackTrace();
}
@@ -641,13 +634,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
logger.debug("Signature done!");
}
-
-
- AccessPermission ap_new = doc.getCurrentAccessPermission();
- Boolean canextract = ap_new.canExtractContent();
- Boolean bool = ap_new.isReadOnly();
- String test = "";
-
}
/**
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
index 29b7eb21..ee41a8cf 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsParameterExtractor.java
@@ -29,6 +29,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
public class PdfAsParameterExtractor {
@@ -71,7 +72,6 @@ public class PdfAsParameterExtractor {
public static final String PARAM_PREPROCESSOR_PREFIX = "pp:";
public static final String PARAM_OVERWRITE_PREFIX = "ov:";
public static final String PARAM_QRCODE_CONTENT = "qrcontent";
- public static final String PARAM_PLACEHOLDERID = "placeholder_id";
@@ -89,8 +89,7 @@ public class PdfAsParameterExtractor {
}
public static String getPlaceholderId(HttpServletRequest request) {
- String placeholderId = (String)request.getAttribute(PARAM_PLACEHOLDERID);
- return placeholderId;
+ return (String)request.getAttribute(IConfigurationConstants.PLACEHOLDER_WEB_ID);
}
public static String getTransactionId(HttpServletRequest request) {
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
index 07fb7d65..3cea5247 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/ExternSignServlet.java
@@ -23,28 +23,14 @@
******************************************************************************/
package at.gv.egiz.pdfas.web.servlets;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsSettingsValidationException;
import at.gv.egiz.pdfas.common.settings.ISettings;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel;
+import at.gv.egiz.pdfas.lib.impl.configuration.PlaceholderWebConfiguration;
import at.gv.egiz.pdfas.web.config.WebConfiguration;
import at.gv.egiz.pdfas.web.exception.PdfAsWebException;
import at.gv.egiz.pdfas.web.filter.UserAgentFilter;
@@ -57,6 +43,19 @@ import at.gv.egiz.pdfas.web.stats.StatisticEvent.Operation;
import at.gv.egiz.pdfas.web.stats.StatisticEvent.Source;
import at.gv.egiz.pdfas.web.stats.StatisticEvent.Status;
import at.gv.egiz.pdfas.web.stats.StatisticFrontend;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
/**
* Servlet implementation class Sign
@@ -171,9 +170,6 @@ public class ExternSignServlet extends HttpServlet {
try {
byte[] filecontent = null;
-
-
-
// checks if the request actually contains upload file
if (!ServletFileUpload.isMultipartContent(request)) {
// No Uploaded data!
@@ -185,11 +181,6 @@ public class ExternSignServlet extends HttpServlet {
}
} else {
-
- //takes placeholder id if exist
- //if(request.getParameter("placeholder_id")!=null && !request.getParameter("placeholder_id").isEmpty()){
- // String placeholder_id = request.getParameter("placeholder_id");
- //}
// configures upload settings
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold(WebConfiguration.getFilesizeThreshold());
@@ -345,7 +336,9 @@ public class ExternSignServlet extends HttpServlet {
String locale = PdfAsParameterExtractor.getLocale(request);
PdfAsHelper.setLocale(request, response, locale);
+ //read and set placholder web id
String placeholder_id = PdfAsParameterExtractor.getPlaceholderId(request);
+ PlaceholderWebConfiguration.setValue(IConfigurationConstants.PLACEHOLDER_WEB_ID, placeholder_id);
String filename = PdfAsParameterExtractor.getFilename(request);
if(filename != null) {
@@ -416,9 +409,7 @@ public class ExternSignServlet extends HttpServlet {
throw new PdfAsWebException("Invalid connector moa is not supported");
}
}
-
-
-
+
byte[] pdfSignedData = PdfAsHelper.synchornousSignature(request,
response, pdfData);
PdfAsHelper.setSignedPdf(request, response, pdfSignedData);
@@ -434,7 +425,5 @@ public class ExternSignServlet extends HttpServlet {
} else {
throw new PdfAsWebException("Invalid connector (bku | moa | jks)");
}
-
}
-
}
diff --git a/pdf-as-web/src/main/webapp/assets/img/localBKU.png b/pdf-as-web/src/main/webapp/assets/img/localBKU.png
new file mode 100644
index 00000000..2ec41892
--- /dev/null
+++ b/pdf-as-web/src/main/webapp/assets/img/localBKU.png
Binary files differ
diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp
index bc20936e..de41028b 100644
--- a/pdf-as-web/src/main/webapp/index.jsp
+++ b/pdf-as-web/src/main/webapp/index.jsp
@@ -32,6 +32,8 @@
%>
<img src="assets/img/mobileBKU.png" />
<button type="submit" value="mobilebku" name="connector" id="mobilebku">Handy</button>
+ <label for="placeholder_web_id">Placeholder ID</label>
+ <input type="text" id="placeholder_web_id" name="placeholder_web_id">
<%
}
%>