aboutsummaryrefslogtreecommitdiff
path: root/id/ConfigWebTool/src/main/java/at
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2013-10-16 20:09:40 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2013-10-16 20:09:40 +0200
commit8d417057d38d56510a1d3d2e39381a1df3dd96ee (patch)
tree26e2d71409bdb10a5fefad1b538af583e984b776 /id/ConfigWebTool/src/main/java/at
parenta7c22b659f5bc760cb46d5892409dab12cc047d6 (diff)
downloadmoa-id-spss-8d417057d38d56510a1d3d2e39381a1df3dd96ee.tar.gz
moa-id-spss-8d417057d38d56510a1d3d2e39381a1df3dd96ee.tar.bz2
moa-id-spss-8d417057d38d56510a1d3d2e39381a1df3dd96ee.zip
@ConfigWebTool
--add JS ColorPicker to select colors easier --add BKUSelectionFrom preview --add useMandate checkbox --change position of some checkboxes in OA configuration @MOAID lib --change API of BKUFormCustomization utils
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at')
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java5
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java7
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java79
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java31
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java146
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAGeneralConfigValidation.java8
6 files changed, 241 insertions, 35 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 915ddf8ff..9dc49bba8 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
@@ -22,12 +22,17 @@ public class Constants {
public static final String SESSION_FORM = "form";
public static final String SESSION_PVP2REQUESTID = "pvp2requestid";
public static final String SESSION_RETURNAREA = "returnarea";
+ public static final String SESSION_BKUFORMPREVIEW = "bkuformpreview";
+
public static enum STRUTS_RETURNAREA_VALUES {adminRequestsInit, main, usermanagementInit};
public static final String REQUEST_OAID = "oaid";
public static final String REQUEST_USERREQUESTTOKKEN = "tokken";
+ public static final String REQUEST_FORMCUSTOM_MODULE = "module";
+ public static final String REQUEST_FORMCUSTOM_VALUE = "value";
+
public static final String BKU_ONLINE = "bkuonline";
public static final String BKU_LOCAL = "bkulocal";
public static final String BKU_HANDY = "bkuhandy";
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 13e13bcc7..2b6c326eb 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
@@ -34,6 +34,9 @@ import at.gv.egovernment.moa.util.MiscUtil;
public class ConfigurationProvider {
+ public static final String HTMLTEMPLATE_DIR = "/htmlTemplates";
+ public static final String HTMLTEMPLATE_FILE = "/loginFormFull.html";
+
private static final Logger log = Logger.getLogger(ConfigurationProvider.class);
private static final String SYSTEM_PROP_CONFIG = "moa.id.webconfig";
@@ -181,6 +184,10 @@ public class ConfigurationProvider {
return configRootDir;
}
+ public String getMOAIDInstanceURL() {
+ return props.getProperty("general.moaid.instance.url");
+ }
+
public boolean isLoginDeaktivated() {
String result = props.getProperty("general.login.deaktivate", "false");
return Boolean.parseBoolean(result);
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java
index 0d13de3fe..6c90ac89a 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java
@@ -1,12 +1,15 @@
package at.gv.egovernment.moa.id.configuration.data;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA;
import at.gv.egovernment.moa.id.commons.db.dao.config.BKUSelectionCustomizationType;
import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication;
import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType;
+import at.gv.egovernment.moa.id.util.FormBuildUtils;
import at.gv.egovernment.moa.util.MiscUtil;
public class FormularCustomization {
@@ -27,13 +30,17 @@ public class FormularCustomization {
private String appletRedirectTarget = null;
public static List<String> appletRedirectTargetList = null;
+
+ public static List<String> fontTypeList = null;
+ public String fontTypeListValue = null;
public FormularCustomization() {
appletRedirectTargetList = Arrays.asList("","_blank","_self","_parent","_top");
+ fontTypeList = Arrays.asList("","Verdana","Geneva","Arial","Helvetica","sans-serif","Times New Roman");
+ Collections.sort(fontTypeList);
}
-
-
- public void parse(OnlineApplication dbOAConfig) {
+
+ public void parse(OnlineApplication dbOAConfig, Map<String, String> map) {
AuthComponentOA auth = dbOAConfig.getAuthComponentOA();
if (auth != null) {
@@ -42,41 +49,61 @@ public class FormularCustomization {
BKUSelectionCustomizationType formcustom = templates.getBKUSelectionCustomization();
if (formcustom != null) {
- if (formcustom.isMandateLoginButton() != null)
+ if (formcustom.isMandateLoginButton() != null) {
showMandateLoginButton = formcustom.isMandateLoginButton();
+ }
- if (formcustom.isOnlyMandateLoginAllowed() != null)
+ if (formcustom.isOnlyMandateLoginAllowed() != null) {
onlyMandateAllowed = formcustom.isOnlyMandateLoginAllowed();
+ }
if (MiscUtil.isNotEmpty(formcustom.getAppletRedirectTarget()))
appletRedirectTarget = formcustom.getAppletRedirectTarget();
- if (MiscUtil.isNotEmpty(formcustom.getBackGroundColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getBackGroundColor())) {
backGroundColor = formcustom.getBackGroundColor();
+ map.put(FormBuildUtils.MAIN_BACKGROUNDCOLOR, formcustom.getBackGroundColor());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColor())) {
button_BackGroundColor = formcustom.getButtonBackGroundColor();
-
- if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColorFocus()))
+ map.put(FormBuildUtils.BUTTON_BACKGROUNDCOLOR, formcustom.getButtonBackGroundColor());
+ }
+
+ if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColorFocus())) {
button_BackGroundColorFocus = formcustom.getButtonBackGroundColorFocus();
+ map.put(FormBuildUtils.BUTTON_BACKGROUNDCOLOR_FOCUS, formcustom.getButtonBackGroundColorFocus());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getButtonFontColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getButtonFontColor())) {
button_FrontColor = formcustom.getButtonFontColor();
+ map.put(FormBuildUtils.BUTTON_COLOR, formcustom.getButtonFontColor());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getFontType()))
+ if (MiscUtil.isNotEmpty(formcustom.getFontType())) {
fontType = formcustom.getFontType();
+ map.put(FormBuildUtils.FONTFAMILY, formcustom.getFontType());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getFrontColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getFrontColor())) {
frontColor = formcustom.getFrontColor();
+ map.put(FormBuildUtils.MAIN_COLOR, formcustom.getFrontColor());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getHeaderBackGroundColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getHeaderBackGroundColor())) {
header_BackGroundColor = formcustom.getHeaderBackGroundColor();
+ map.put(FormBuildUtils.HEADER_BACKGROUNDCOLOR, formcustom.getHeaderBackGroundColor());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getHeaderFrontColor()))
+ if (MiscUtil.isNotEmpty(formcustom.getHeaderFrontColor())) {
header_FrontColor = formcustom.getHeaderFrontColor();
+ map.put(FormBuildUtils.HEADER_COLOR, formcustom.getHeaderFrontColor());
+ }
- if (MiscUtil.isNotEmpty(formcustom.getHeaderText()))
+ if (MiscUtil.isNotEmpty(formcustom.getHeaderText())) {
header_text = formcustom.getHeaderText();
+ map.put(FormBuildUtils.HEADER_TEXT, formcustom.getHeaderText());
+ }
}
}
}
@@ -281,6 +308,28 @@ public class FormularCustomization {
return appletRedirectTargetList;
}
+ /**
+ * @return the fontTypeList
+ */
+ public List<String> getFontTypeList() {
+ return fontTypeList;
+ }
+
+ /**
+ * @return the fontTypeListValue
+ */
+ public String getFontTypeListValue() {
+ return fontTypeListValue;
+ }
+
+ /**
+ * @param fontTypeListValue the fontTypeListValue to set
+ */
+ public void setFontTypeListValue(String fontTypeListValue) {
+ this.fontTypeListValue = fontTypeListValue;
+ }
+
+
}
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java
index 07c07a964..429a05242 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java
@@ -50,6 +50,7 @@ public class OAGeneralConfig {
private String aditionalAuthBlockText = null;
private String mandateProfiles = null;
+ private boolean useMandates = false;
private boolean isActive = false;
private boolean calculateHPI = false;
@@ -175,7 +176,17 @@ public class OAGeneralConfig {
Mandates mandates = oaauth.getMandates();
if (mandates != null) {
- mandateProfiles = mandates.getProfiles();
+
+ if (MiscUtil.isNotEmpty(mandates.getProfiles())) {
+ mandateProfiles = mandates.getProfiles();
+ useMandates = true;
+
+ } else {
+ mandateProfiles = new String();
+ useMandates = false;
+ }
+
+
}
TemplatesType templates = oaauth.getTemplates();
@@ -553,5 +564,23 @@ public class OAGeneralConfig {
*/
public void setHideBPKAuthBlock(boolean isHideBPKAuthBlock) {
this.isHideBPKAuthBlock = isHideBPKAuthBlock;
+ }
+
+
+ /**
+ * @return the useMandates
+ */
+ public boolean isUseMandates() {
+ return useMandates;
+ }
+
+
+ /**
+ * @param useMandates the useMandates to set
+ */
+ public void setUseMandates(boolean useMandates) {
+ this.useMandates = useMandates;
}
+
+
}
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 ca547204f..56d6ba9d7 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
@@ -1,11 +1,18 @@
package at.gv.egovernment.moa.id.configuration.struts.action;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.math.BigInteger;
+import java.net.URI;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -15,6 +22,7 @@ import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
+import at.gv.egovernment.moa.id.auth.builder.LoginFormBuilder;
import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead;
import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils;
import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentOA;
@@ -36,8 +44,10 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.TemplatesType;
import at.gv.egovernment.moa.id.commons.db.dao.config.TransformsInfoType;
import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
+import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;
import at.gv.egovernment.moa.id.configuration.Constants;
import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser;
+import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider;
import at.gv.egovernment.moa.id.configuration.data.FormularCustomization;
import at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig;
import at.gv.egovernment.moa.id.configuration.data.oa.OAPVP2Config;
@@ -55,6 +65,7 @@ import at.gv.egovernment.moa.id.configuration.validation.oa.OAPVP2ConfigValidati
import at.gv.egovernment.moa.id.configuration.validation.oa.OASAML1ConfigValidation;
import at.gv.egovernment.moa.id.configuration.validation.oa.OASSOConfigValidation;
import at.gv.egovernment.moa.id.configuration.validation.oa.OASTORKConfigValidation;
+import at.gv.egovernment.moa.id.util.FormBuildUtils;
import at.gv.egovernment.moa.id.util.Random;
import at.gv.egovernment.moa.util.MiscUtil;
@@ -90,6 +101,8 @@ ServletResponseAware {
private OASTORKConfig storkOA;
private FormularCustomization formOA = new FormularCustomization();
+ private InputStream stream;
+
//STRUTS actions
public String inital() {
HttpSession session = request.getSession();
@@ -144,7 +157,13 @@ ServletResponseAware {
generalOA.parse(onlineapplication);
ssoOA.parse(onlineapplication);
saml1OA.parse(onlineapplication);
- formOA.parse(onlineapplication);
+
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.putAll(FormBuildUtils.getDefaultMap());
+ formOA.parse(onlineapplication, map);
+
+ session.setAttribute(Constants.SESSION_BKUFORMPREVIEW, map);
List<String> errors = pvp2OA.parse(onlineapplication);
@@ -216,6 +235,7 @@ ServletResponseAware {
formID = Random.nextRandom();
session.setAttribute(Constants.SESSION_FORMID, formID);
+ session.setAttribute(Constants.SESSION_BKUFORMPREVIEW, null);
return Constants.STRUTS_OA_EDIT;
}
@@ -611,6 +631,83 @@ ServletResponseAware {
}
+ public String bkuFramePreview() {
+
+ String preview = null;
+
+ HttpSession session = request.getSession();
+ if (session == null) {
+ log.info("No http Session found.");
+ preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible");
+
+ } else {
+ InputStream input = null;
+
+ try {
+ Object mapobj = session.getAttribute(Constants.SESSION_BKUFORMPREVIEW);
+ if (mapobj != null && mapobj instanceof Map<?, ?>) {
+
+ ConfigurationProvider config = ConfigurationProvider.getInstance();
+ String templateURL = config.getConfigRootDir() +
+ ConfigurationProvider.HTMLTEMPLATE_DIR +
+ ConfigurationProvider.HTMLTEMPLATE_FILE;
+
+ File file = new File(templateURL);
+ input = new FileInputStream(file);
+
+ String contextpath = config.getMOAIDInstanceURL();
+ if (MiscUtil.isEmpty(contextpath)) {
+ log.info("NO MOA-ID instance URL configurated.");
+ throw new ConfigurationException("No MOA-ID instance configurated");
+ }
+
+ preview = LoginFormBuilder.getTemplate(input);
+ preview = preview.replace(LoginFormBuilder.CONTEXTPATH, contextpath);
+
+
+ Map<String, String> map = (Map<String, String>) mapobj;
+
+ String module = request.getParameter(Constants.REQUEST_FORMCUSTOM_MODULE);
+ String value = request.getParameter(Constants.REQUEST_FORMCUSTOM_VALUE);
+
+ synchronized (map) {
+
+ if (MiscUtil.isNotEmpty(module)) {
+ if (map.containsKey("#"+module+"#")) {
+ if (MiscUtil.isNotEmpty(value)) {
+ if (FormBuildUtils.FONTFAMILY.contains(module) ||
+ FormBuildUtils.HEADER_TEXT.contains(module) ||
+ value.startsWith("#"))
+ map.put("#"+module+"#", value);
+ else
+ map.put("#"+module+"#", "#"+value);
+
+ } else {
+ map.put("#"+module+"#",
+ FormBuildUtils.getDefaultMap().get("#"+module+"#"));
+ }
+ }
+ }
+ preview = FormBuildUtils.customiceLayoutBKUSelection(preview, true, false, map);
+ }
+
+ } else {
+ preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible");
+
+ }
+
+ } catch (Exception e) {
+ log.warn("BKUSelection Preview can not be generated.", e);
+ preview = LanguageHelper.getErrorString("error.bkuformpreview.notpossible");
+
+ }
+ }
+
+ stream = new ByteArrayInputStream(preview.getBytes());
+
+ return Constants.STRUTS_SUCCESS;
+ }
+
private String saveOAConfigToDatabase(OnlineApplication dboa, boolean newentry) {
AuthComponentOA authoa = dboa.getAuthComponentOA();
@@ -715,17 +812,31 @@ ServletResponseAware {
bkuruls.setLocalBKU(generalOA.getBkuLocalURL());
bkuruls.setOnlineBKU(generalOA.getBkuOnlineURL());
}
-
- Mandates mandates = new Mandates();
- mandates.setProfiles(generalOA.getMandateProfiles());
- authoa.setMandates(mandates);
-
+
TemplatesType templates = authoa.getTemplates();
if (templates == null) {
templates = new TemplatesType();
authoa.setTemplates(templates);
}
+ BKUSelectionCustomizationType bkuselectioncustom = templates.getBKUSelectionCustomization();
+ if (bkuselectioncustom == null) {
+ bkuselectioncustom = new BKUSelectionCustomizationType();
+ templates.setBKUSelectionCustomization(bkuselectioncustom);
+ }
+
+ Mandates mandates = new Mandates();
+ if (generalOA.isUseMandates()) {
+ mandates.setProfiles(generalOA.getMandateProfiles());
+
+ } else {
+ mandates.setProfiles(new String());
+ }
+
+ authoa.setMandates(mandates);
+ bkuselectioncustom.setMandateLoginButton(MiscUtil.isNotEmpty(generalOA.getMandateProfiles()));
+ bkuselectioncustom.setOnlyMandateLoginAllowed(formOA.isOnlyMandateAllowed());
+
if (authUser.isAdmin()) {
templates.setAditionalAuthBlockText(generalOA.getAditionalAuthBlockText());
@@ -757,14 +868,7 @@ ServletResponseAware {
if (template != null && template.size() > 0)
template.clear();
}
-
-
- BKUSelectionCustomizationType bkuselectioncustom = templates.getBKUSelectionCustomization();
- if (bkuselectioncustom == null) {
- bkuselectioncustom = new BKUSelectionCustomizationType();
- templates.setBKUSelectionCustomization(bkuselectioncustom);
- }
-
+
bkuselectioncustom.setBackGroundColor(parseColor(formOA.getBackGroundColor()));
bkuselectioncustom.setFrontColor(parseColor(formOA.getFrontColor()));
@@ -779,11 +883,8 @@ ServletResponseAware {
if (MiscUtil.isNotEmpty(formOA.getAppletRedirectTarget()))
bkuselectioncustom.setAppletRedirectTarget(formOA.getAppletRedirectTarget());
- bkuselectioncustom.setFontType(formOA.getFontType());
-
- bkuselectioncustom.setMandateLoginButton(formOA.isShowMandateLoginButton());
- bkuselectioncustom.setOnlyMandateLoginAllowed(formOA.isOnlyMandateAllowed());
-
+ bkuselectioncustom.setFontType(formOA.getFontType());
+
}
//set default transformation if it is empty
@@ -1120,6 +1221,13 @@ ServletResponseAware {
public void setFormOA(FormularCustomization formOA) {
this.formOA = formOA;
}
+
+ /**
+ * @return the stream
+ */
+ public InputStream getStream() {
+ return stream;
+ }
}
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAGeneralConfigValidation.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAGeneralConfigValidation.java
index 87ac31e89..f3f96e7f2 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAGeneralConfigValidation.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/oa/OAGeneralConfigValidation.java
@@ -131,12 +131,20 @@ public class OAGeneralConfigValidation {
//check Mandate Profiles
check = form.getMandateProfiles();
if (MiscUtil.isNotEmpty(check)) {
+
+ if (!form.isUseMandates()) {
+ log.info("MandateProfiles configured but useMandates is false.");
+ errors.add(LanguageHelper.getErrorString("validation.general.mandate.usemandate"));
+ }
+
if (ValidationHelper.containsPotentialCSSCharacter(check, true)) {
log.warn("MandateProfiles contains potentail XSS characters: " + check);
errors.add(LanguageHelper.getErrorString("validation.general.mandate.profiles",
new Object[] {ValidationHelper.getPotentialCSSCharacter(true)} ));
}
}
+
+
boolean businessservice = form.isBusinessService();