diff options
Diffstat (limited to 'id/ConfigWebTool')
7 files changed, 95 insertions, 57 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java index 69ac58d15..70241fafb 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java @@ -56,6 +56,7 @@ public class Constants { public static final String SESSION_OAUTH20SECRET = "oauth20secret"; public static final String SESSION_BKUSELECTIONTEMPLATE = "bkuSelectionTemplate"; public static final String SESSION_SENDASSERTIONTEMPLATE = "sendAssertionTemplate"; + public static final String SESSION_SLTRANSFORMATION = "slTransformation"; public static final String SESSION_I18n = "WW_TRANS_I18N_LOCALE"; 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/data/oa/OASTORKConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java index 03d2d6d1e..b43e76d53 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java @@ -106,8 +106,15 @@ public class OASTORKConfig { } // fetch vidp config - setVidpEnabled(config.isVidpEnabled()); - setRequireConsent(config.isRequireConsent()); + if (config.isVidpEnabled() != null) + setVidpEnabled(config.isVidpEnabled()); + else + setVidpEnabled(false); + + if (config.isRequireConsent() != null) + setRequireConsent(config.isRequireConsent()); + else + setRequireConsent(false); attributeProviderPlugins = config.getAttributeProviders(); // - if no attribute providers are configured, add a dummy 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(); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java index cb3a2a1ff..a54d6c74a 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java @@ -165,13 +165,31 @@ public class EditGeneralConfigAction extends BasicAction { log.info("General MOA-ID configuration has some errors."); for (String el : errors) addActionError(el); + + if (moaconfig.getSecLayerTransformation() != null) { + session.setAttribute(Constants.SESSION_SLTRANSFORMATION, moaconfig.getSecLayerTransformation()); + } formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); + return Constants.STRUTS_ERROR_VALIDATION; + + } else { + if (moaconfig.getSecLayerTransformation() == null && + session.getAttribute(Constants.SESSION_SLTRANSFORMATION) != null && + session.getAttribute(Constants.SESSION_SLTRANSFORMATION) instanceof Map<?, ?> ) { + moaconfig.setSecLayerTransformation((Map<String, byte[]>) + session.getAttribute(Constants.SESSION_SLTRANSFORMATION)); + + } } + + String error = saveFormToDatabase(); + + session.setAttribute(Constants.SESSION_SLTRANSFORMATION, null); if (error != null) { log.warn("General MOA-ID config can not be stored in Database"); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java index cc2cf3bf0..d2a2cfdf7 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java @@ -864,12 +864,25 @@ public class EditOAAction extends BasicAction { } Mandates mandates = new Mandates(); - if (generalOA.isUseMandates()) { - mandates.setProfiles(generalOA.getMandateProfiles()); - - } else { - mandates.setProfiles(new String()); - } + if (generalOA.isUseMandates()) { + if (MiscUtil.isNotEmpty(generalOA.getMandateProfiles())) { + List<MandatesProfileNameItem> profileList = new ArrayList<MandatesProfileNameItem>(); + String[] inputList = generalOA.getMandateProfiles().split(","); + for (int i=0; i<inputList.length; i++) { + + MandatesProfileNameItem item = new MandatesProfileNameItem(); + item.setItem(inputList[i]); + profileList.add(item); + } + mandates.setProfileNameItems(profileList ); + mandates.setProfiles(null); + } + + + } else { + mandates.setProfiles(null); + mandates.setProfileNameItems(null); + } authoa.setMandates(mandates); bkuselectioncustom.setMandateLoginButton(MiscUtil.isNotEmpty(generalOA.getMandateProfiles())); @@ -943,10 +956,12 @@ public class EditOAAction extends BasicAction { authoa.setOAPVP2(pvp2); } - pvp2.setMetadataURL(pvp2OA.getMetaDataURL()); try { - if (pvp2OA.getFileUpload() != null) pvp2.setCertificate(pvp2OA.getCertificate()); + if (pvp2OA.getFileUpload() != null) { + pvp2.setCertificate(pvp2OA.getCertificate()); + pvp2OA.setReLoad(true); + } } catch (CertificateException e) { log.info("Uploaded Certificate can not be found", e); @@ -956,6 +971,14 @@ public class EditOAAction extends BasicAction { return LanguageHelper.getErrorString("validation.pvp2.certificate.format", request); } + if (pvp2OA.getMetaDataURL() != null && + !pvp2OA.getMetaDataURL().equals(pvp2.getMetadataURL())) + pvp2OA.setReLoad(true); + pvp2.setMetadataURL(pvp2OA.getMetaDataURL()); + + if (pvp2OA.isReLoad()) + pvp2.setUpdateRequiredItem(new Date()); + OASAML1 saml1 = authoa.getOASAML1(); if (saml1 == null) { saml1 = new OASAML1(); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/ValidationHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/ValidationHelper.java index c1feddfb8..3749975df 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/ValidationHelper.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/ValidationHelper.java @@ -234,11 +234,13 @@ public class ValidationHelper { Matcher matcher = pattern.matcher(target); boolean b = matcher.matches(); if (b) { - log.debug("Parameter Target erfolgreich ueberprueft"); + log.debug("Parameter SSO-Target erfolgreich ueberprueft. SSO Target is PublicService."); return true; } else { - log.error("Fehler Ueberpruefung Parameter Target. Target entspricht nicht den Kriterien (nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang)"); + log.info("Parameter SSO-Target entspricht nicht den Kriterien " + + "(nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang) fuer den oeffentlichen Bereich. " + + "Valiere SSO-Target fuer privatwirtschaftliche Bereiche."); return false; } } |