aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java')
-rw-r--r--id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java178
1 files changed, 178 insertions, 0 deletions
diff --git a/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java b/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java
new file mode 100644
index 000000000..71093a4d3
--- /dev/null
+++ b/id/server/moa-id-frontend-resources/src/main/java/at/gv/egovernment/moa/id/auth/frontend/utils/FormBuildUtils.java
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, 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.egovernment.moa.id.auth.frontend.utils;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+public class FormBuildUtils {
+
+ private static Map<String, String> defaultmap = null;
+
+ public static String PARAM_MAIN_BACKGROUNDCOLOR = "MAIN_BACKGOUNDCOLOR";
+ public static String PARAM_MAIN_COLOR = "MAIN_COLOR";
+ public static String PARAM_HEADER_BACKGROUNDCOLOR = "HEADER_BACKGROUNDCOLOR";
+ public static String PARAM_HEADER_COLOR = "HEADER_COLOR";
+ public static String PARAM_BUTTON_BACKGROUNDCOLOR = "BUTTON_BACKGROUNDCOLOR";
+ public static String PARAM_BUTTON_BACKGROUNDCOLOR_FOCUS = "BUTTON_BACKGROUNDCOLOR_FOCUS";
+ public static String PARAM_BUTTON_COLOR = "BUTTON_COLOR";
+ public static String PARAM_FONTFAMILY = "FONTTYPE";
+ public static String PARAM_HEADER_TEXT = "HEADER_TEXT";
+ public static String PARAM_REDIRECTTARGET = "REDIRECTTARGET";
+ public static String PARAM_APPLET_HEIGHT = "APPLETHEIGHT";
+ public static String PARAM_APPLET_WIDTH = "APPLETWIDTH";
+
+ private static String PARAM_MANDATEVISIBLE = "MANDATEVISIBLE";
+ private static String PARAM_MANDATECHECKED = "MANDATECHECKED";
+
+ private static String PARAM_STORKVISIBLE = "STORKVISIBLE";
+
+ private static final String TEMPLATEVISIBLE = " display: none";
+ private static final String TEMPLATEDISABLED = "disabled=\"true\"";
+ private static final String TEMPLATECHECKED = "checked=\"true\"";
+ private static final String TEMPLATE_ARIACHECKED = "aria-checked=";
+
+
+ static {
+ if (defaultmap == null) {
+ defaultmap = new HashMap<String, String>();
+ defaultmap.put(PARAM_MAIN_BACKGROUNDCOLOR, "#F7F8F7");
+ defaultmap.put(PARAM_MAIN_COLOR, "#000000");
+
+ defaultmap.put(PARAM_HEADER_BACKGROUNDCOLOR, "#C3D2E2");
+ defaultmap.put(PARAM_HEADER_COLOR, "#000000");
+ defaultmap.put(PARAM_HEADER_TEXT, "Login");
+
+ defaultmap.put(PARAM_BUTTON_BACKGROUNDCOLOR, "#EBEBEB");
+ defaultmap.put(PARAM_BUTTON_BACKGROUNDCOLOR_FOCUS, "#EBEBEB");
+ defaultmap.put(PARAM_BUTTON_COLOR, "#000000");
+
+ defaultmap.put(PARAM_FONTFAMILY, "Verdana,Geneva,Arial,sans-serif");
+
+ defaultmap.put(PARAM_REDIRECTTARGET, "_top");
+ }
+ }
+
+ public static void customiceLayoutBKUSelection(Map<String, Object> params, IOAAuthParameters oaParam) {
+
+ if (oaParam.isShowMandateCheckBox())
+ params.put(PARAM_MANDATEVISIBLE, "");
+ else
+ params.put(PARAM_MANDATEVISIBLE, TEMPLATEVISIBLE);
+
+ if (oaParam.isOnlyMandateAllowed()) {
+ params.put(PARAM_MANDATECHECKED, TEMPLATECHECKED + " " +
+ TEMPLATEDISABLED + " " +TEMPLATE_ARIACHECKED + "\"true\"");
+
+ } else
+ params.put(PARAM_MANDATECHECKED, TEMPLATE_ARIACHECKED + "\"false\"");
+
+ if (oaParam.isShowStorkLogin())
+ params.put(PARAM_STORKVISIBLE, "");
+ else
+ params.put(PARAM_STORKVISIBLE, TEMPLATEVISIBLE);
+
+ //add more SP specific infos
+ setFormCustomizatenFromSP(params, oaParam);
+
+ //format parameter-value for fontss
+ String fonttype = (String) params.get(PARAM_FONTFAMILY);
+ if (MiscUtil.isNotEmpty(fonttype)) {
+ String[] fonttypeList = fonttype.split(",");
+ String fonttypeformated = "\"" + fonttypeList[0].trim().replace("\"", "") + "\"";
+
+ for (int i=1; i<fonttypeList.length; i++) {
+ fonttypeformated += ",\"" + fonttypeList[i].trim().replace("\"", "") + "\"";
+ }
+
+ params.put(PARAM_FONTFAMILY, fonttypeformated);
+ }
+
+ }
+
+ public static Map<String, String> getDefaultMap() {
+ return defaultmap;
+ }
+
+ /**
+ * @param value
+ * @return
+ */
+ public static void defaultLayoutBKUSelection(Map<String, Object> params) {
+ params.put(PARAM_MANDATEVISIBLE, TEMPLATEVISIBLE);
+ params.put(PARAM_MANDATECHECKED, TEMPLATE_ARIACHECKED + "\"false\"");
+ params.put(PARAM_STORKVISIBLE, TEMPLATEVISIBLE);
+
+ params.putAll(getDefaultMap());
+ }
+
+ /* (non-Javadoc)
+ * @see at.gv.egovernment.moa.id.config.auth.IOAAuthParameters#getFormCustomizaten()
+ */
+ private static void setFormCustomizatenFromSP(Map<String, Object> params, IOAAuthParameters spConfig) {
+ params.putAll(FormBuildUtils.getDefaultMap());
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BACKGROUNDCOLOR)))
+ params.put(FormBuildUtils.PARAM_MAIN_BACKGROUNDCOLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BACKGROUNDCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACKGROUNDCOLOR)))
+ params.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACKGROUNDCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACLGROUNDCOLORFOCUS)))
+ params.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR_FOCUS, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONBACLGROUNDCOLORFOCUS));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONFRONTCOLOR)))
+ params.put(FormBuildUtils.PARAM_BUTTON_COLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_BUTTONFRONTCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FONTTYPE)))
+ params.put(FormBuildUtils.PARAM_FONTFAMILY, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FONTTYPE));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FRONTCOLOR)))
+ params.put(FormBuildUtils.PARAM_MAIN_COLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_FRONTCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERBACKGROUNDCOLOR)))
+ params.put(FormBuildUtils.PARAM_HEADER_BACKGROUNDCOLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERBACKGROUNDCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERFRONTCOLOR)))
+ params.put(FormBuildUtils.PARAM_HEADER_COLOR, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERFRONTCOLOR));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERTEXT)))
+ params.put(FormBuildUtils.PARAM_HEADER_TEXT, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_HEADERTEXT));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETREDIRECTTARGET)))
+ params.put(FormBuildUtils.PARAM_REDIRECTTARGET, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETREDIRECTTARGET));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETHEIGHT)))
+ params.put(FormBuildUtils.PARAM_APPLET_HEIGHT, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETHEIGHT));
+
+ if (MiscUtil.isNotEmpty(spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETWIDTH)))
+ params.put(FormBuildUtils.PARAM_APPLET_WIDTH, spConfig.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_AUTH_TEMPLATES_CUSTOMIZATION_APPLETWIDTH));
+
+ }
+
+}