aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 10:38:13 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-15 10:38:13 +0200
commit3e96eedd7b1daca1d4ee02f21d9221cbbc288478 (patch)
treea606554e24b7487bff9e831913fea7d63581434a /pdf-as-lib/src/main
parent9cfe09c62a519209e0193eaf2872872ca4f35a26 (diff)
downloadpdf-as-4-3e96eedd7b1daca1d4ee02f21d9221cbbc288478.tar.gz
pdf-as-4-3e96eedd7b1daca1d4ee02f21d9221cbbc288478.tar.bz2
pdf-as-4-3e96eedd7b1daca1d4ee02f21d9221cbbc288478.zip
Security providers are optional registered in PDF-AS #44
Diffstat (limited to 'pdf-as-lib/src/main')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java2
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/PdfAsFactory.java55
2 files changed, 40 insertions, 17 deletions
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 fa8857a9..a3988add 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
@@ -85,6 +85,8 @@ public interface IConfigurationConstants {
public static final String MOC_SIGN_URL = "moc.sign.url";
public static final String MOBILE_SIGN_URL = "mobile.sign.url";
+ public static final String REGISTER_PROVIDER = "registerSecurityProvider";
+
public static final String SL_REQUEST_TYPE = "sl.request.type";
public static final String SL_REQUEST_TYPE_BASE64 = "b64";
public static final String SL_REQUEST_TYPE_UPLOAD = "upload";
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 f5f14626..b0b34f5e 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
@@ -46,7 +46,7 @@ import at.gv.egiz.pdfas.lib.impl.PdfAsImpl;
import at.gv.egiz.pdfas.lib.impl.SignParameterImpl;
import at.gv.egiz.pdfas.lib.impl.VerifyParameterImpl;
-public class PdfAsFactory {
+public class PdfAsFactory implements IConfigurationConstants {
private static final Logger logger = LoggerFactory
.getLogger(PdfAsFactory.class);
@@ -86,6 +86,36 @@ public class PdfAsFactory {
private static boolean initialized = false;
private static Object init_mutex = new Object();
+ private static void registerSecurityProvider(ISettings configuration) {
+ boolean doRegister = true;
+
+ String register = configuration.getValue(REGISTER_PROVIDER);
+ if (register != null) {
+ if (register.equals("false")) {
+ doRegister = false;
+ }
+ }
+
+ if (doRegister) {
+ logger.info("Registering Security Providers!");
+
+ registerProvider(new IAIK(), 1);
+ // TODO: register ECCelerate in second position when TLS issue is
+ // fixed
+ registerProvider(new ECCelerate(), -1);
+
+ teeInformation("+ IAIK-JCE Version: " + IAIK.getVersionInfo());
+ teeInformation("+ ECCelerate Version: " + ECCelerate.getInstance().getVersion());
+ } else {
+ logger.info("Skipping Security Provider registration!");
+ }
+ }
+
+ private static void teeInformation(String str) {
+ System.out.println(str);
+ logger.info(str);
+ }
+
/**
* Configure log.
*
@@ -97,22 +127,13 @@ public class PdfAsFactory {
synchronized (init_mutex) {
if (!initialized) {
initialized = true;
-
- registerProvider(new IAIK(), 1);
- registerProvider(new ECCelerate(), -1);
-
- System.out
- .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- System.out.println("+ PDF-AS: " + getVersion());
- System.out.println("+ PDF-AS SCM Revision: "
- + getSCMRevision());
- System.out.println("+ IAIK-JCE Version: "
- + IAIK.getVersionInfo());
- System.out.println("+ ECCelerate Version: "
- + ECCelerate.getInstance().getVersion());
- System.out
- .println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
-
+
+ teeInformation("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ teeInformation("+ PDF-AS: " + getVersion());
+ teeInformation("+ PDF-AS SCM Revision: " + getSCMRevision());
+ registerSecurityProvider(configuration);
+ teeInformation("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+
listRegisteredSecurityProviders();
}
}