diff options
8 files changed, 65 insertions, 34 deletions
diff --git a/build.gradle b/build.gradle index 05be9494..bd578147 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { allprojects { apply plugin: "com.github.ben-manes.versions" repositories { mavenCentral() } - version = '4.2.0-RC3' + version = '4.2.0-RC4' } configurations { diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java index ff9c6d0f..6e288a27 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/settings/DefaultSignatureProfileSettings.java @@ -68,8 +68,7 @@ public class DefaultSignatureProfileSettings { public static final String SIG_BLOCK_PARAMETER_DEFAULT_KEY_REGEX = "^([A-za-z]){1,20}$"; // public static final String SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX = "^([\\p{Print}-ß_'\\+\\!\u00e4\u00f6\u00fc" + // "\u00c4\u00d6\u00dc]){1,100}$"; -public static final String SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX = "^([\\p{Print}ߧ€\u00e4\u00f6\u00fc\u00c4\u00d6" + - "\u00dc]){1,100}$"; +public static final String SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX = "^([\\p{Print}\u00df\u00A7\u20AC\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc]){1,100}$"; static { profileSettings.put(KEY_SIG_SUBJECT, new SignatureProfileEntry(KEY_SIG_SUBJECT, KEY_SIG_SUBJECT_DEFAULT, VALUE_SIG_SUBJECT_DEFAULT) ); diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/CheckSignatureBlockParameters.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/CheckSignatureBlockParameters.java index c2e6b81d..756a240c 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/CheckSignatureBlockParameters.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/CheckSignatureBlockParameters.java @@ -1,24 +1,35 @@ package at.gv.egiz.pdfas.common.utils; import at.gv.egiz.pdfas.common.settings.DefaultSignatureProfileSettings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Map; public class CheckSignatureBlockParameters { + private static final Logger logger = LoggerFactory + .getLogger(CheckSignatureBlockParameters.class); public static boolean checkSignatureBlockParameterMapIsValid(Map<String, String> map, String keyRegex, String valueRegex) { + + logger.trace("regex1:"+keyRegex+", regex1:"+valueRegex); if(keyRegex == null || keyRegex.length() == 0) { keyRegex = DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_KEY_REGEX; } if(valueRegex == null || valueRegex.length() == 0) { valueRegex = DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX; } + logger.trace("regex2:"+keyRegex+", regex2:"+valueRegex); for(String key : map.keySet()){ - if(isValid(key, keyRegex) == false) + if(isValid(key, keyRegex) == false) { + logger.error("Invalid key:"+key+", regex:"+keyRegex); return false; - if(isValid(map.get(key), valueRegex) == false) + } + if(isValid(map.get(key), valueRegex) == false) { + logger.error("Invalid value:"+map.get(key)+", regex:"+valueRegex); return false; + } } return true; diff --git a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTestSOAP.java b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTestSOAP.java index 54db66c0..b6f496df 100644 --- a/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTestSOAP.java +++ b/pdf-as-web-client/src/test/java/at/gv/egiz/pdfas/web/client/test/SimpleTestSOAP.java @@ -46,30 +46,22 @@ public class SimpleTestSOAP { public static void main(String[] args) { try { -// String file = "/Users/amarsalek/Documents/pdf-as-4/unsigned.pdf"; - String file = "/Users/amarsalek/Downloads/qr2.pdf"; + String file = "/Users/amarsalek/Documents/pdf-as-4/unsigned.pdf"; +// String file = "/Users/amarsalek/Downloads/qr2.pdf"; FileInputStream fis = new FileInputStream(file); byte[] inputData = IOUtils.toByteArray(fis); PDFASSignParameters signParameters = new PDFASSignParameters(); -// signParameters.setConnector(Connector.JKS); - signParameters.setConnector(Connector.BKU); + signParameters.setConnector(Connector.JKS); +// signParameters.setConnector(Connector.BKU); signParameters.setPosition(null); - signParameters.setProfile("SIGNATURBLOCK_SMALL_DE1"); +// signParameters.setProfile("SIGNATURBLOCK_SMALL_DE1"); + signParameters.setProfile("SIGNATURBLOCK_DE_SCHOOL1"); signParameters.setQRCodeContent("TEST CONTENT"); //signParameters.setKeyIdentifier("test"); - PDFASSignRequest request = new PDFASSignRequest(); - request.setInputData(inputData); - request.setParameters(signParameters); - request.setRequestID("SOME TEST ID"); - request.getSignatureBlockParameters().put("abc","SOAP Test"); - //URL endpoint = new - //URL("http://demo.egiz.gv.at/demoportal-pdf_as/wssign?wsdl"); - //URL endpoint = new - // URL("http://www.buergerkarte.at/pdf-as-extern-4/wssign?wsdl"); -// String baseUrl = "http://demo.egiz.gv.at/demoportal-pdf_as/services/"; - String baseUrl = "http://localhost:8080/pdf-as-web/services/"; +// String baseUrl = "http://localhost:8080/pdf-as-web/services/"; + String baseUrl = "https://pdf.egiz.gv.at/pdf-as-extern-4/services/"; //URL endpoint = new URL( // "http://192.168.56.10/pdf-as-web/wssign?wsdl"); @@ -82,15 +74,16 @@ public class SimpleTestSOAP { signrequest.setParameters(signParameters); signParameters.setTransactionId("MYID ...."); signrequest.getSignatureBlockParameters().put("abc","SOAP Test 5555"); + signrequest.getSignatureBlockParameters().put("school","SOAP Test äöüßÄÖÜ"); System.out.println("Simple Request:"); PDFASSignResponse response = signer.signPDFDokument(signrequest); System.out.println("Sign Error: " + response.getError()); System.out.println("redirect url: " + response.getRedirectUrl()); -// File outputFile = new File(file+"_signedSOAP.pdf"); -// try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { -// outputStream.write(response.getSignedPDF()); -// } + File outputFile = new File(file+"_signedSOAP.pdf"); + try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { + outputStream.write(response.getSignedPDF()); + } System.out.println("Done!"); } catch (Throwable e) { diff --git a/pdf-as-web/src/main/assembly/tomcat/setVariables.bat b/pdf-as-web/src/main/assembly/tomcat/setVariables.bat index 606f84e1..57bd2f9a 100644 --- a/pdf-as-web/src/main/assembly/tomcat/setVariables.bat +++ b/pdf-as-web/src/main/assembly/tomcat/setVariables.bat @@ -59,10 +59,10 @@ rem Maximum PermGenSize in M set JVM_MAXPERMSIZE=256
rem COMMAND LINE OPTIONS
-set JAVA_OPTS=-server -Xss%JVM_XSS%k -Xms%JVM_XMS%m -Xmx%JVM_XMX%m -XX:MaxPermSize=%JVM_MAXPERMSIZE%m
+set JAVA_OPTS=-server -Xss%JVM_XSS%k -Xms%JVM_XMS%m -Xmx%JVM_XMX%m -XX:MaxPermSize=%JVM_MAXPERMSIZE%m -Dfile.encoding=UTF8
set CATALINA_OPTS=%PDFAS_WORK_DIR_PARAM%
rem SERVICE OPTIONS
-set SERVICE_OPTS=%PDFAS_WORK_DIR_PARAM%;-XX:MaxPermSize=%JVM_MAXPERMSIZE%m
+set SERVICE_OPTS=%PDFAS_WORK_DIR_PARAM%;-XX:MaxPermSize=%JVM_MAXPERMSIZE%m -Dfile.encoding=UTF8
:END
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 00ca9446..31fbf46d 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 @@ -23,6 +23,7 @@ ******************************************************************************/ package at.gv.egiz.pdfas.web.helper; +import java.nio.charset.Charset; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -31,6 +32,8 @@ import javax.servlet.http.HttpServletRequest; import at.gv.egiz.pdfas.lib.api.IConfigurationConstants; import at.gv.egiz.pdfas.lib.api.verify.VerifyParameter.SignatureVerificationLevel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PdfAsParameterExtractor { @@ -76,6 +79,9 @@ public class PdfAsParameterExtractor { public static final String PARAM_QRCODE_CONTENT = "qrcontent"; public static final String PARAM_DYNAMIC_SIGNATURE_BLOCK_PARAMETER = "sbp:"; + private static final Logger logger = LoggerFactory + .getLogger(PdfAsParameterExtractor.class); + public static String getConnector(HttpServletRequest request) { String connector = (String)request.getAttribute(PARAM_CONNECTOR); if(connector != null) { @@ -86,15 +92,19 @@ public class PdfAsParameterExtractor { public static Map<String,String> getDynamicSignatureBlockParameters(HttpServletRequest request) throws Exception { HashMap<String, String> signatureBlockParametersMap = new HashMap<String, String>(); - + logger.debug("Default charset:"+ Charset.defaultCharset()); + logger.debug("Request charset:"+ request.getCharacterEncoding()); + Enumeration<String> parameterNames = request.getAttributeNames(); while(parameterNames.hasMoreElements()) { String parameterName = parameterNames.nextElement(); if (parameterName.startsWith(PARAM_DYNAMIC_SIGNATURE_BLOCK_PARAMETER)) { String key = parameterName.substring(PARAM_DYNAMIC_SIGNATURE_BLOCK_PARAMETER.length()); String value = (String) request.getAttribute(parameterName); - if(value != null && !value.isEmpty()) + if(value != null && !value.isEmpty()){ signatureBlockParametersMap.put(key, value); + logger.debug("Setting key "+ key +" to "+ value ); + } } } return signatureBlockParametersMap; diff --git a/pdf-as-web/src/main/webapp/WEB-INF/web.xml b/pdf-as-web/src/main/webapp/WEB-INF/web.xml index 9b69c983..7920ad91 100644 --- a/pdf-as-web/src/main/webapp/WEB-INF/web.xml +++ b/pdf-as-web/src/main/webapp/WEB-INF/web.xml @@ -31,7 +31,22 @@ <param-value>*</param-value> </init-param> </filter> - + <!-- A filter that sets character encoding that is used to decode --> + <!-- parameters in a POST request --> + <filter> + <filter-name>setCharacterEncodingFilter</filter-name> + <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class> + <init-param> + <param-name>encoding</param-name> + <param-value>UTF-8</param-value> + </init-param> + </filter> + + <!-- The mapping for the Set Character Encoding Filter --> + <filter-mapping> + <filter-name>setCharacterEncodingFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> <!-- filter-mapping> <filter-name>sitemesh</filter-name> diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp index a52d1361..bbf608b0 100644 --- a/pdf-as-web/src/main/webapp/index.jsp +++ b/pdf-as-web/src/main/webapp/index.jsp @@ -2,17 +2,20 @@ <%@page import="at.gv.egiz.pdfas.web.helper.PdfAsHelper"%> <html> <head> -<title>PDF-Signatur</title> + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> + <title>PDF-Signatur</title> </head> <body> - <form action="Sign" method="POST" - enctype="multipart/form-data"> + +<form action="Sign" method="POST" enctype="multipart/form-data" > + + <input name="utf8" type="hidden" value="✓" /> <input type="hidden" name="source" id="source" value="internal" /> <input type="file" name="pdf-file" id="pdf-file" accept="application/pdf"> <% if (request.getAttribute("FILEERR") != null) { %> - <p>Bitte die zu signierende PDF Datei angeben.</p> + <p>Bitte die zu signierende PDF Datei angeben. öäüÖÄÜ</p> <% } %> |