aboutsummaryrefslogtreecommitdiff
path: root/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-04-10 14:24:11 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-04-10 14:24:11 +0200
commitb3d3d3af963ed03704d73272aaf906e2eb109c0d (patch)
treeed2788300338b410e3a708c2d7d543d56960c7bd /id/ConfigWebTool/src/main/java/at/gv/egovernment/moa
parent42819b8b0bc4a99a0e9ff47ea9d4b3228bc0648f (diff)
downloadmoa-id-spss-b3d3d3af963ed03704d73272aaf906e2eb109c0d.tar.gz
moa-id-spss-b3d3d3af963ed03704d73272aaf906e2eb109c0d.tar.bz2
moa-id-spss-b3d3d3af963ed03704d73272aaf906e2eb109c0d.zip
change all file paths to relative or absolute paths
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment/moa')
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java58
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/MailHelper.java19
2 files changed, 32 insertions, 45 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java
index e65163946..bcc9a87ab 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java
@@ -55,6 +55,7 @@ import at.gv.egovernment.moa.id.configuration.auth.pvp2.MetaDataVerificationFilt
import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException;
import at.gv.egovernment.moa.id.configuration.utils.UserRequestCleaner;
import at.gv.egovernment.moa.id.protocols.pvp2x.config.PVPConfiguration;
+import at.gv.egovernment.moa.util.FileUtils;
import at.gv.egovernment.moa.util.MiscUtil;
@@ -190,14 +191,15 @@ public class ConfigurationProvider {
}
- String file = getPVP2MetadataKeystoreURL();
- log.debug("Load KeyStore from URL " + file);
- if (MiscUtil.isEmpty(file)) {
+ String fileURL = getPVP2MetadataKeystoreURL();
+ log.debug("Load KeyStore from URL " + fileURL);
+ if (MiscUtil.isEmpty(fileURL)) {
log.info("Metadata KeyStoreURL is empty");
throw new ConfigurationException("Metadata KeyStoreURL is empty");
}
-
- FileInputStream inputStream = new FileInputStream(file);
+
+ URL keystoreURL = new URL((FileUtils.makeAbsoluteURL(fileURL, getConfigRootDir())));
+ InputStream inputStream = keystoreURL.openStream();
keyStore.load(inputStream, getPVP2MetadataKeystorePassword().toCharArray());
inputStream.close();
}
@@ -344,11 +346,7 @@ public class ConfigurationProvider {
String url = props.getProperty("general.mail.useraccountrequest.verification.template");
if (MiscUtil.isNotEmpty(url)) {
- if (url.startsWith(Constants.FILEPREFIX))
- return url;
-
- else
- return configRootDir + "/" + url;
+ return url;
} else {
log.warn("MailUserAcountVerificationTemplate is empty");
@@ -363,19 +361,15 @@ public class ConfigurationProvider {
public String getMailUserAcountActivationTemplate() throws ConfigurationException {
String url = props.getProperty("general.mail.useraccountrequest.isactive.template");
-
if (MiscUtil.isNotEmpty(url)) {
- if (url.startsWith(Constants.FILEPREFIX))
- return url;
-
- else
- return configRootDir + "/" + url;
-
+ return url;
+
} else {
- log.warn("MailUserAcountVerificationTemplate is empty");
+ log.warn("MailUserAcountActivationTemplate is empty");
throw new ConfigurationException("MailUserAcountActivationTemplate is empty");
-
+
}
+
}
public String getMailOAActivationSubject() {
@@ -394,29 +388,22 @@ public class ConfigurationProvider {
String url = props.getProperty("general.mail.createOArequest.isactive.template");
if (MiscUtil.isNotEmpty(url)) {
- if (url.startsWith(Constants.FILEPREFIX))
- return url;
-
- else
- return configRootDir + "/" + url;
-
+ return url;
+
} else {
log.warn("MailOAActivationTemplate is empty");
throw new ConfigurationException("MailOAActivationTemplate is empty");
-
+
}
+
}
public String getMailUserAcountRevocationTemplate() throws ConfigurationException {
String url = props.getProperty("general.mail.useraccountrequest.rejected.template");
if (MiscUtil.isNotEmpty(url)) {
- if (url.startsWith(Constants.FILEPREFIX))
return url;
-
- else
- return configRootDir + "/" + url;
-
+
} else {
log.warn("MailUserAcountVerificationTemplate is empty");
throw new ConfigurationException("MailUserAcountRevocationTemplate is empty");
@@ -432,11 +419,7 @@ public class ConfigurationProvider {
String url = props.getProperty("general.mail.admin.adresses.template");
if (MiscUtil.isNotEmpty(url)) {
- if (url.startsWith(Constants.FILEPREFIX))
- return url;
-
- else
- return configRootDir + "/" + url;
+ return url;
} else {
log.warn("MailUserAcountVerificationTemplate is empty");
@@ -462,7 +445,8 @@ public class ConfigurationProvider {
throw new ConfigurationException("NO IDP Certificate to verify IDP Metadata");
}
- InputStream certstream = new FileInputStream(metadataCert);
+ URL keystoreURL = new URL((FileUtils.makeAbsoluteURL(metadataCert, getConfigRootDir())));
+ InputStream certstream = keystoreURL.openStream();
X509Certificate cert = new X509Certificate(certstream);
BasicX509Credential idpCredential = new BasicX509Credential();
idpCredential.setEntityCertificate(cert);
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/MailHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/MailHelper.java
index 0aeed8cb5..caed3e469 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/MailHelper.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/MailHelper.java
@@ -27,6 +27,7 @@ import java.io.FileInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
+import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
@@ -48,6 +49,7 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
import at.gv.egovernment.moa.id.configuration.Constants;
import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider;
import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException;
+import at.gv.egovernment.moa.util.FileUtils;
import at.gv.egovernment.moa.util.MiscUtil;
public class MailHelper {
@@ -67,7 +69,7 @@ public class MailHelper {
ConfigurationProvider config = ConfigurationProvider.getInstance();
String templateurl = config.getMailUserAcountVerificationTemplate();
- String template = readTemplateFromURL(templateurl);
+ String template = readTemplateFromURL(templateurl, config.getConfigRootDir());
if (userdb.isIsMandateUser() != null && userdb.isIsMandateUser()) {
template = template.replace(PATTERN_GIVENNAME, userdb.getInstitut());
@@ -100,7 +102,7 @@ public class MailHelper {
ConfigurationProvider config = ConfigurationProvider.getInstance();
String templateurl = config.getMailAdminTemplate();
- String template = readTemplateFromURL(templateurl);
+ String template = readTemplateFromURL(templateurl, config.getConfigRootDir());
template = template.replace(PATTERN_OPENOAS, String.valueOf(numOpenOAs));
template = template.replace(PATTERN_OPENUSERS, String.valueOf(numOpenUsers));
@@ -115,7 +117,7 @@ public class MailHelper {
ConfigurationProvider config = ConfigurationProvider.getInstance();
String templateurl = config.getMailUserAcountActivationTemplate();
- String template = readTemplateFromURL(templateurl);
+ String template = readTemplateFromURL(templateurl, config.getConfigRootDir());
if (MiscUtil.isNotEmpty(institut)) {
template = template.replace(PATTERN_GIVENNAME, institut);
template = template.replace(PATTERN_FAMILYNAME, "");
@@ -143,7 +145,7 @@ public class MailHelper {
ConfigurationProvider config = ConfigurationProvider.getInstance();
String templateurl = config.getMailOAActivationTemplate();
- String template = readTemplateFromURL(templateurl);
+ String template = readTemplateFromURL(templateurl, config.getConfigRootDir());
if (MiscUtil.isNotEmpty(institut)) {
template = template.replace(PATTERN_GIVENNAME, institut);
template = template.replace(PATTERN_FAMILYNAME, "");
@@ -172,7 +174,7 @@ public class MailHelper {
ConfigurationProvider config = ConfigurationProvider.getInstance();
String templateurl = config.getMailUserAcountRevocationTemplate();
- String template = readTemplateFromURL(templateurl);
+ String template = readTemplateFromURL(templateurl, config.getConfigRootDir());
if (userdb.isIsMandateUser() != null && userdb.isIsMandateUser()) {
template = template.replace(PATTERN_GIVENNAME, userdb.getInstitut());
@@ -190,11 +192,12 @@ public class MailHelper {
userdb.getMail(), template);
}
- private static String readTemplateFromURL(String templateurl) throws ConfigurationException {
+ private static String readTemplateFromURL(String templateurl, String rootDir) throws ConfigurationException {
InputStream input;
try {
- File file = new File(templateurl);
- input = new FileInputStream(file);
+
+ URL keystoreURL = new URL(FileUtils.makeAbsoluteURL(templateurl, rootDir));
+ input = keystoreURL.openStream();
StringWriter writer = new StringWriter();
IOUtils.copy(input, writer);
input.close();