aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java101
1 files changed, 94 insertions, 7 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
index eb04dde8..3c6a7f21 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/config/WebConfiguration.java
@@ -1,24 +1,111 @@
package at.gv.egiz.pdfas.web.config;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class WebConfiguration {
+
+ public static final String PUBLIC_URL = "public.url";
+ public static final String LOCAL_BKU_URL = "bku.local.url";
+ public static final String ONLINE_BKU_URL = "bku.online.url";
+ public static final String MOBILE_BKU_URL = "bku.mobile.url";
+ public static final String ERROR_DETAILS = "error.showdetails";
+ public static final String PDF_AS_WORK_DIR = "pdfas.dir";
+
+ public static final String KEYSTORE_ENABLED = "ks.enabled";
+ public static final String KEYSTORE_FILE = "ks.file";
+ public static final String KEYSTORE_TYPE = "ks.type";
+ public static final String KEYSTORE_PASS = "ks.pass";
+ public static final String KEYSTORE_ALIAS = "ks.key.alias";
+ public static final String KEYSTORE_KEY_PASS = "ks.key.pass";
+
+ private static Properties properties = new Properties();
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(WebConfiguration.class);
+
+ public static void configure(String config) {
+ try {
+ properties.load(new FileInputStream(config));
+ } catch(Exception e) {
+ logger.error("Failed to load configuration: " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ String pdfASDir = getPdfASDir();
+ if(pdfASDir == null) {
+ logger.error("Please configure pdf as working directory in the web configuration");
+ throw new RuntimeException("Please configure pdf as working directory in the web configuration");
+ }
+
+ File f = new File(pdfASDir);
+
+ if(!f.exists() || !f.isDirectory()) {
+ logger.error("Pdf As working directory does not exists or is not a directory!: " + pdfASDir);
+ throw new RuntimeException("Pdf As working directory does not exists or is not a directory!");
+ }
+ }
+
public static String getPublicURL() {
- return null;
+ return properties.getProperty(PUBLIC_URL);
}
public static String getLocalBKUURL() {
- // TODO: Read URL from config
- return "http://127.0.0.1:3495/http-security-layer-request";
+ return properties.getProperty(LOCAL_BKU_URL);
}
public static String getOnlineBKUURL() {
- // TODO: Read URL from config
- return "http://abyss.iaik.tugraz.at/bkuonline/http-security-layer-request";
+ return properties.getProperty(ONLINE_BKU_URL);
}
public static String getHandyBKUURL() {
- // TODO: Read URL from config
- return "http://127.0.0.1:3495/http-security-layer-request";
+ return properties.getProperty(MOBILE_BKU_URL);
+ }
+
+ public static String getPdfASDir() {
+ return properties.getProperty(PDF_AS_WORK_DIR);
+ }
+
+ public static String getKeystoreFile() {
+ return properties.getProperty(KEYSTORE_FILE);
+ }
+ public static String getKeystoreType() {
+ return properties.getProperty(KEYSTORE_TYPE);
+ }
+ public static String getKeystorePass() {
+ return properties.getProperty(KEYSTORE_PASS);
+ }
+ public static String getKeystoreAlias() {
+ return properties.getProperty(KEYSTORE_ALIAS);
+ }
+ public static String getKeystoreKeyPass() {
+ return properties.getProperty(KEYSTORE_KEY_PASS);
+ }
+
+
+ public static boolean getKeystoreEnabled() {
+ String value = properties.getProperty(KEYSTORE_ENABLED);
+ if(value != null) {
+ if(value.equals("true")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isShowErrorDetails() {
+ String value = properties.getProperty(ERROR_DETAILS);
+ if(value != null) {
+ if(value.equals("true")) {
+ return true;
+ }
+ }
+ return false;
}
}