/*******************************************************************************
* Copyright 2014 by E-Government Innovation Center EGIZ, Graz, Austria
* PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
* joint initiative of the Federal Chancellery Austria and Graz University of
* Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
******************************************************************************/
package at.gv.egiz.pdfas.web.config;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.web.helper.PdfAsHelper;
public class WebConfiguration implements IConfigurationConstants {
public static final String PUBLIC_URL = "public.url";
public static final String PUBLIC_DATA_URL = "public.data.url";
public static final String LOCAL_BKU_ENABLED = "bku.sign.enabled";
public static final String ONLINE_BKU_ENABLED = "moc.sign.enabled";
public static final String MOBILE_BKU_ENABLED = "mobile.sign.enabled";
public static final String SL20_BKU_ENABLED = "sl20.sign.enabled";
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 SL20_BKU_URL = "sl20.mobile.url";
public static final String ERROR_DETAILS = "error.showdetails";
public static final String PDF_AS_WORK_DIR = "pdfas.dir";
public static final String STATISTIC_BACKEND_LIST = "statistic.backends";
public static final String ALLOW_EXT_OVERWRITE = "allow.ext.overwrite";
public static final String ALLOW_EXT_WHITELIST_VALUE_PRE = "ext.overwrite.wl.";
public static final String MOA_SS_ENABLED = "moa.enabled";
public static final String SOAP_SIGN_ENABLED = "soap.sign.enabled";
public static final String SOAP_VERIFY_ENABLED = "soap.verify.enabled";
public static final String RELOAD_PASSWORD = "reload.pwd";
public static final String RELOAD_ENABLED = "reload.enabled";
public static final String KEEP_SIGNED_DOCUMENT = "keep.signed";
public static final String JSON_API_ENABLED = "json.enabled";
public static final String MOA_LIST = "moal";
public static final String MOA_URL = "url";
public static final String MOA_KEYID = "KeyIdentifier";
public static final String MOA_CERT = "Certificate";
public static final String KEYSTORE_LIST = "ksl";
public static final String KEYSTORE_DEFAULT = "ks";
public static final String KEYSTORE_ENABLED = "enabled";
public static final String KEYSTORE_FILE = "file";
public static final String KEYSTORE_TYPE = "type";
public static final String KEYSTORE_PASS = "pass";
public static final String KEYSTORE_ALIAS = "key.alias";
public static final String KEYSTORE_KEY_PASS = "key.pass";
public static final String KEYSTORE_DEFAULT_ENABLED = KEYSTORE_DEFAULT + "." + KEYSTORE_ENABLED;
public static final String KEYSTORE_DEFAULT_FILE = KEYSTORE_DEFAULT + "." + KEYSTORE_FILE;
public static final String KEYSTORE_DEFAULT_TYPE = KEYSTORE_DEFAULT + "." + KEYSTORE_TYPE;
public static final String KEYSTORE_DEFAULT_PASS = KEYSTORE_DEFAULT + "." + KEYSTORE_PASS;
public static final String KEYSTORE_DEFAULT_ALIAS = KEYSTORE_DEFAULT + "." + KEYSTORE_ALIAS;
public static final String KEYSTORE_DEFAULT_KEY_PASS = KEYSTORE_DEFAULT + "." + KEYSTORE_KEY_PASS;
//SL20 stuff
public static final String SL20_PREFIX = "sl20";
public static final String SL20_KEYSTORE_PREFIX = SL20_PREFIX + ".keystore";
public static final String SL20_KEYSTORE_FILE = SL20_KEYSTORE_PREFIX + "." + "file";
public static final String SL20_KEYSTORE_TYPE = SL20_KEYSTORE_PREFIX + "." + "type";
public static final String SL20_KEYSTORE_PASS = SL20_KEYSTORE_PREFIX + "." + "pass";
public static final String SL20_KEYSTORE_KEY_SIGN_ALIAS = SL20_KEYSTORE_PREFIX + "." + "sign.key.alias";
public static final String SL20_KEYSTORE_KEY_SIGN_PASS = SL20_KEYSTORE_PREFIX + "." + "sign.key.pass";
public static final String SL20_KEYSTORE_KEY_ENCRYPTION_ALIAS = SL20_KEYSTORE_PREFIX + "." + "enc.key.alias";
public static final String SL20_KEYSTORE_KEY_ENCRYPTION_PASS = SL20_KEYSTORE_PREFIX + "." + "enc.key.pass";
public static final String SL20_DEBUG_VALIDATION_DISABLED = SL20_PREFIX + ".debug.validation.disable";
public static final String SL20_DEBUG_SIGNING_ENABLED = SL20_PREFIX + ".debug.signed.result.enabled";
public static final String SL20_DEBUG_SIGNING_REQUIRED = SL20_PREFIX + ".debug.signed.result.required";
public static final String SL20_DEBUG_ENCRYPTION_ENABLED = SL20_PREFIX + ".debug.encryption.enabled";
public static final String SL20_DEBUG_ENCRYPTION_REQUIRED = SL20_PREFIX + ".debug.encryption.required";
public static final String WHITELIST_ENABLED = "whitelist.enabled";
public static final String WHITELIST_VALUE_PRE = "whitelist.url.";
public static final String REQUEST_STORE = "request.store";
public static final String REQUEST_STORE_INMEM = "at.gv.egiz.pdfas.web.store.InMemoryRequestStore";
public static final String REQUEST_STORE_DB = "at.gv.egiz.pdfas.web.store.DBRequestStore";
public static final String DB_REQUEST_TIMEOUT = "request.db.timeout";
public static final String HIBERNATE_PREFIX = "hibernate.props.";
public static final String UPLOAD_FILESIZE_THRESHOLD = "web.upload.filesizeThreshold";
public static final String UPLOAD_MAX_FILESIZE = "web.upload.filesizeMax";
public static final String UPLOAD_MAX_REQUESTSIZE = "web.upload.RequestsizeMax";
public static final String PLACEHOLDER_GENERATOR_ENABLED = "qr.placeholder.generator.enabled";
private static final int THRESHOLD_SIZE = 1024 * 1024 * 3; // 3MB
private static final int MAX_FILE_SIZE = 1024 * 1024 * 40; // 40MB
private static final int MAX_REQUEST_SIZE = 1024 * 1024 * 50; // 50MB
private static Properties properties = new Properties();
private static Properties hibernateProps = new Properties();
private static final Logger logger = LoggerFactory
.getLogger(WebConfiguration.class);
private static List whiteListregEx = new ArrayList();
private static List overwritewhiteListregEx = new ArrayList();
public static void configure(String config) {
properties.clear();
whiteListregEx.clear();
overwritewhiteListregEx.clear();
try {
properties.load(new FileInputStream(config));
} catch (Exception e) {
logger.error("Failed to load configuration: " + e.getMessage());
throw new RuntimeException(e);
}
if (isWhiteListEnabled()) {
Iterator