diff options
author | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2021-04-14 19:05:02 +0200 |
---|---|---|
committer | Alexander Marsalek <amarsalek@iaik.tugraz.at> | 2021-04-14 19:05:02 +0200 |
commit | 1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b (patch) | |
tree | e82cf8d679867779d4dbd2bf1a857dc8e9b3fafa /pdf-as-common/src/main/java/at/gv | |
parent | 97b362c9f6906ecaf94c3f0d4fba10ab60206b2a (diff) | |
download | pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.gz pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.tar.bz2 pdf-as-4-1be82e61c0acf4d7380dcee3e3fcaaa8a8386f1b.zip |
added sbp check
Diffstat (limited to 'pdf-as-common/src/main/java/at/gv')
2 files changed, 34 insertions, 0 deletions
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 6f1519a4..3d70fe96 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 @@ -65,6 +65,9 @@ public class DefaultSignatureProfileSettings { public static final String VALUE_SIG_DATE_DEFAULT = "yyyy-MM-dd'T'HH:mm:ssXXX"; + 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}]){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 new file mode 100644 index 00000000..c2e6b81d --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/CheckSignatureBlockParameters.java @@ -0,0 +1,31 @@ +package at.gv.egiz.pdfas.common.utils; + +import at.gv.egiz.pdfas.common.settings.DefaultSignatureProfileSettings; + +import java.util.Map; + +public class CheckSignatureBlockParameters { + + public static boolean checkSignatureBlockParameterMapIsValid(Map<String, String> map, String keyRegex, + String 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; + } + for(String key : map.keySet()){ + if(isValid(key, keyRegex) == false) + return false; + if(isValid(map.get(key), valueRegex) == false) + return false; + } + + return true; + } + + public static boolean isValid(String s, String regex) { + return s.matches(regex); + } + +} |