aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java4
-rw-r--r--pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java93
2 files changed, 59 insertions, 38 deletions
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 b5600729..b2845959 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
@@ -401,9 +401,9 @@ public class PdfAsFactory implements IConfigurationConstants {
jarAttributes = mainAttributes;
return mainAttributes;
} catch (Exception e) {
- jarAttributes = new Attributes();
+
}
- return null;
+ return new Attributes();
}
/**
diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java
index 1cebd8ef..23422e8e 100644
--- a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java
+++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/SignatureBlockParameterTest.java
@@ -5,59 +5,80 @@ import at.gv.egiz.pdfas.common.utils.CheckSignatureBlockParameters;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
@RunWith(JUnit4.class)
public class SignatureBlockParameterTest {
-
@Test
public void testKeyInvalid() {
- if(checkValid( "aaaaaaaaaaaaaaaaaaaaa" , "^([A-za-z]){1,20}$") == true){assert(false);}
- if(checkValid( "" , "^([A-za-z]){1,20}$") == true){assert(false);}
- if(checkValid( "a9" , "^([A-za-z]){1,20}$") == true){assert(false);}
+ assertFalse(checkValid( "aaaaaaaaaaaaaaaaaaaaa" , "^([A-za-z]){1,20}$"));
+ assertFalse(checkValid( "" , "^([A-za-z]){1,20}$"));
+ assertFalse(checkValid( "a9" , "^([A-za-z]){1,20}$"));
}
+
@Test
public void testKeyValid() {
- if(checkValid( "aaa" +"aa", "^([A-za-z]){1,20}$") == false){assert(false);}
- if(checkValid( "aaa" , "^([A-za-z]){1,20}$") == false){assert(false);}
- if(checkValid( "aaaaaaaaaaaaaaaaaaaa", "^([A-za-z]){1,20}$") == false){assert(false);}
- if(checkValid( "AA", "^([A-za-z]){1,20}$") == false){assert(false);}
+ assertTrue(checkValid( "aaa" +"aa", "^([A-za-z]){1,20}$"));
+ assertTrue(checkValid( "aaa" , "^([A-za-z]){1,20}$"));
+ assertTrue(checkValid( "aaaaaaaaaaaaaaaaaaaa", "^([A-za-z]){1,20}$"));
+ assertTrue(checkValid( "AA", "^([A-za-z]){1,20}$"));
}
+
@Test
public void testValueValid() {
- if(checkValid( "aaa" +"aa", "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "aaa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "a!\"$%&/()[]=?aa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
-// if(checkValid( "a!\"§$%&/()=?aa" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "aa!%&/()=?a" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "a{\"a!%&/()=?a" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "BB" , "^([\\p{Print}]){1,100}$") == false){assert(false);}
- if(checkValid( "BB " , "^([\\p{Print}]){1,100}$") == false){assert(false);}
+ assertTrue(checkValid( "aaa" +"aa", "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "aaa" , "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , "^([\\p{Print}]){1,100}$"));
+// assertTrue(checkValid( "a!\"§$%&/()=?aa" , "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "aa!%&/()=?a" , "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "a{\"a!%&/()=?a" , "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "BB" , "^([\\p{Print}]){1,100}$"));
+ assertTrue(checkValid( "BB " , "^([\\p{Print}]){1,100}$"));
}
+
@Test
- public void testValueInvalid() {
- if(checkValid((char) 13 +"aaa" +"aa", "^([\\p{Print}]){1,100}$") == true){assert(false);}
- if(checkValid((char) 13 +"", "^([\\p{Print}]){1,100}$") == true){assert(false);}
- if(checkValid( "aaa" +(char) 13, "^([\\p{Print}]){1,100}$") == true){assert(false);}
- if(checkValid("", "^([\\p{Print}]){1,100}$") == true){assert(false);}
- if(checkValid("a", "^([\\p{Print}]){2,100}$") == true){assert(false);}
- if(checkValid("aaa"+(char) 13 +"aa", "^([\\p{Print}]){1,100}$") == true){assert(false);}
+ public void testValueValidWithDefaultRegex() {
+ assertTrue(checkValid( "aaa" +"aa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "aaa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "a!\"$%&/()[]=?aa-_,;.:[]|{}" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+// assertTrue(checkValid( "a!\"§$%&/()=?aa" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "aa!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "a{\"a!%&/()=?a" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "BB" , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "BB " , DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("! €%&/()?`$\"§", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("€", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("$", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("! €\"§$%&/()=?`", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("#", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("-_", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("'", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#-_ß?+#*",
+ DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ }
+ @Test
+ public void testValueInvalid() {
+ assertFalse(checkValid((char) 13 +"aaa" +"aa", "^([\\p{Print}]){1,100}$"));
+ assertFalse(checkValid((char) 13 +"", "^([\\p{Print}]){1,100}$"));
+ assertFalse(checkValid( "aaa" +(char) 13, "^([\\p{Print}]){1,100}$"));
+ assertFalse(checkValid("", "^([\\p{Print}]){1,100}$"));
+ assertFalse(checkValid("a", "^([\\p{Print}]){2,100}$"));
+ assertFalse(checkValid("aaa"+(char) 13 +"aa", "^([\\p{Print}]){1,100}$"));
}
+
@Test
public void testUmlauteValid() {
- if(checkValid( "ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "Ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "Ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "Ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "ÄÖÜöäüjhsbdjej", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "aauacnhuisdc Ä Ü Ö aaxsa ö aÜaÖa",
- DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
- if(checkValid( "NMS Güssing", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX) == false){assert(false);}
-
+ assertTrue(checkValid( "ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "Ä", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "Ö", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "Ü", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "ÄÖÜöäüjhsbdjej", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "aauacnhuisdc Ä Ü Ö aaxsa ö aÜaÖa", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
+ assertTrue(checkValid( "NMS Güssing", DefaultSignatureProfileSettings.SIG_BLOCK_PARAMETER_DEFAULT_VALUE_REGEX));
}
public boolean checkValid(String s, String regex) {