aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle5
-rw-r--r--pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/CheckSignatureParametersTest.java48
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java4
-rw-r--r--pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java37
-rw-r--r--pdf-as-web/build.gradle2
5 files changed, 75 insertions, 21 deletions
diff --git a/build.gradle b/build.gradle
index b13b7f31..9eb8a547 100644
--- a/build.gradle
+++ b/build.gradle
@@ -58,8 +58,9 @@ subprojects {
}
dependencies {
- compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
- annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
+ implementation "org.projectlombok:lombok:1.18.28"
+ annotationProcessor "org.projectlombok:lombok:1.18.28"
+ testAnnotationProcessor "org.projectlombok:lombok:1.18.28"
testImplementation 'junit:junit:4.13.2'
}
diff --git a/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/CheckSignatureParametersTest.java b/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/CheckSignatureParametersTest.java
new file mode 100644
index 00000000..5ec0541b
--- /dev/null
+++ b/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/CheckSignatureParametersTest.java
@@ -0,0 +1,48 @@
+package at.gv.egiz.pdfas.common.test.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+import at.gv.egiz.pdfas.common.settings.DefaultSignatureProfileSettings;
+import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class CheckSignatureParametersTest {
+
+ @Test
+ public void singleTest() {
+ assertTrue("valid characters are not possilbe",
+ CheckSignatureBlockParameters.isValid("Güssing",
+ DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+
+ }
+
+ @Test
+ public void specialCharactersCompiletimeConfig() {
+ Map<String, String> toTest = new HashMap<>();
+ toTest.put("test", "Güssing");
+
+ assertTrue("valid characters are not possilbe",
+ CheckSignatureBlockParameters.checkSignatureBlockParameterMapIsValid(toTest , null, null));
+
+ }
+
+ @Test
+ public void specialCharactersExampleConfig() {
+ Map<String, String> toTest = new HashMap<>();
+ toTest.put("test", "Güssing");
+
+ assertFalse("valid characters are not possilbe",
+ CheckSignatureBlockParameters.checkSignatureBlockParameterMapIsValid(toTest ,
+ "^([A-za-z]){1,20}$", "^([\\p{Print}]){1,100}$"));
+
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
index 79854641..3183f0a6 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/configuration/ConfigurationImpl.java
@@ -102,10 +102,6 @@ public class ConfigurationImpl implements ISettings, Configuration {
}
}
- if (valueMap.isEmpty()) {
- return null;
- }
-
return valueMap;
}
diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java
index 7ba6747a..e94d21e8 100644
--- a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java
+++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/stamping/CertificateAndRequestParameterResolverTest.java
@@ -4,8 +4,10 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.security.cert.CertificateException;
+import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
+import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
@@ -13,6 +15,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
+import at.gv.egiz.pdfas.common.settings.IProfileConstants;
import at.gv.egiz.pdfas.common.settings.ISettings;
import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
@@ -76,18 +79,23 @@ public class CertificateAndRequestParameterResolverTest {
}
private ISettings buildDummySettings() {
- return new ISettings() {
-
+ Map<String, String> configMap = new HashMap<>();
+ configMap.put(IProfileConstants.SIG_OBJ + "test", "test");
+
+ return new ISettings() {
+
@Override
public boolean hasValue(String key) {
- // TODO Auto-generated method stub
- return false;
+ return configMap.containsKey(key);
}
@Override
public boolean hasPrefix(String prefix) {
- // TODO Auto-generated method stub
- return false;
+ return configMap.keySet().stream()
+ .filter(el -> el.startsWith(prefix))
+ .findFirst()
+ .isPresent();
+
}
@Override
@@ -98,14 +106,16 @@ public class CertificateAndRequestParameterResolverTest {
@Override
public Map<String, String> getValuesPrefix(String prefix) {
- // TODO Auto-generated method stub
- return null;
+ return configMap.entrySet().stream()
+ .filter(el -> el.getKey().startsWith(prefix))
+ .collect(Collectors.toMap(key -> key.getKey(), value -> value.getValue()));
+
}
@Override
public String getValue(String key) {
- // TODO Auto-generated method stub
- return null;
+ return configMap.get(key);
+
}
@Override
@@ -116,14 +126,13 @@ public class CertificateAndRequestParameterResolverTest {
@Override
public boolean isValue(String key) {
- // TODO Auto-generated method stub
- return false;
+ return isValue(key, false);
}
@Override
public boolean isValue(String key, boolean defaultValue) {
- return defaultValue;
+ return hasValue(key) ? Boolean.valueOf(getValue(key)) : defaultValue;
}
- };
+ };
}
}
diff --git a/pdf-as-web/build.gradle b/pdf-as-web/build.gradle
index 2601d42a..3123668d 100644
--- a/pdf-as-web/build.gradle
+++ b/pdf-as-web/build.gradle
@@ -73,7 +73,7 @@ dependencies {
api 'org.json:json:20230227'
api group: 'javax.jws', name: 'javax.jws-api', version: '1.1'
compileOnly 'javax.servlet:javax.servlet-api:3.0.1'
- testRuntime 'org.springframework:spring-test:5.3.26'
+ testImplementation 'org.springframework:spring-test:5.3.28'
}