diff options
Diffstat (limited to 'id/server/idserverlib/src/main/java/at')
3 files changed, 54 insertions, 24 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/LoginFormBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/LoginFormBuilder.java index 729af48f7..a00ae4ccf 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/LoginFormBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/LoginFormBuilder.java @@ -7,9 +7,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.net.URI; +import java.net.URISyntaxException; import org.apache.commons.io.IOUtils; +import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.id.protocols.saml1.SAML1Protocol; @@ -29,32 +31,42 @@ public class LoginFormBuilder { private static String BKU_ONLINE = "#ONLINE#"; private static String BKU_HANDY = "#HANDY#"; private static String BKU_LOCAL = "#LOCAL#"; - private static String CONTEXTPATH = "#CONTEXTPATH#"; + public static String CONTEXTPATH = "#CONTEXTPATH#"; private static String MOASESSIONID = "#SESSIONID#"; private static String SERVLET = CONTEXTPATH+"/GenerateIframeTemplate"; - private static String getTemplate() { + public static String getTemplate() { + String pathLocation =""; + InputStream input = null; + + try { + String rootconfigdir = AuthConfigurationProvider.getInstance().getRootConfigFileDir(); + pathLocation = rootconfigdir + HTMLTEMPLATESDIR + HTMLTEMPLATEFULL; + File file = new File(new URI(pathLocation)); + input = new FileInputStream(file); + + } catch (ConfigurationException e) { + Logger.warn("MOA-ID configuration can not be loaded."); + + } catch (Exception e) { + + } + + return getTemplate(input); + + } + + public static String getTemplate(InputStream input) { String template = null; - InputStream input = null; try { - String pathLocation; - - String rootconfigdir = AuthConfigurationProvider.getInstance().getRootConfigFileDir(); - pathLocation = rootconfigdir + HTMLTEMPLATESDIR + HTMLTEMPLATEFULL; - - try { - File file = new File(new URI(pathLocation)); - input = new FileInputStream(file); - - } catch (FileNotFoundException e) { + if (input == null) { Logger.warn("No LoginFormTempaltes found. Use Generic Templates from package."); - pathLocation = "resources/templates/" + HTMLTEMPLATEFULL; - + String pathLocation = "resources/templates/" + HTMLTEMPLATEFULL; input = Thread.currentThread() .getContextClassLoader() .getResourceAsStream(pathLocation); @@ -82,7 +94,7 @@ public class LoginFormBuilder { } return template; } - + public static String buildLoginForm(String modul, String action, OAAuthParameter oaParam, String contextpath, String moaSessionID) { String value = getTemplate(); @@ -99,10 +111,12 @@ public class LoginFormBuilder { value = value.replace(CONTEXTPATH, contextpath); value = value.replace(MOASESSIONID, moaSessionID); - value = FormBuildUtils.customiceLayoutBKUSelection(value, oaParam); + value = FormBuildUtils.customiceLayoutBKUSelection(value, + oaParam.isShowMandateCheckBox(), + oaParam.isOnlyMandateAllowed(), + oaParam.getFormCustomizaten()); } return value; } - } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/SendAssertionFormBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/SendAssertionFormBuilder.java index 1617ef796..b763afd65 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/SendAssertionFormBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/SendAssertionFormBuilder.java @@ -98,7 +98,10 @@ public class SendAssertionFormBuilder { value = value.replace(OANAME, oaParam.getFriendlyName()); value = value.replace(CONTEXTPATH, contextpath); - value = FormBuildUtils.customiceLayoutBKUSelection(value, oaParam); + value = FormBuildUtils.customiceLayoutBKUSelection(value, + oaParam.isShowMandateCheckBox(), + oaParam.isOnlyMandateAllowed(), + oaParam.getFormCustomizaten()); } return value; diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/FormBuildUtils.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/FormBuildUtils.java index 533957cc8..e8af82872 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/FormBuildUtils.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/FormBuildUtils.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.Set; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; +import at.gv.egovernment.moa.util.MiscUtil; public class FormBuildUtils { @@ -43,21 +44,22 @@ public class FormBuildUtils { defaultmap.put(BUTTON_BACKGROUNDCOLOR_FOCUS, "#EBEBEB"); defaultmap.put(BUTTON_COLOR, "#000000"); - defaultmap.put(FONTFAMILY, "Verdana, Geneva, Arial, sans-serif"); + defaultmap.put(FONTFAMILY, "Verdana,Geneva,Arial,sans-serif"); defaultmap.put(REDIRECTTARGET, "_top"); } } - public static String customiceLayoutBKUSelection(String value, OAAuthParameter oaParam) { + public static String customiceLayoutBKUSelection(String value, boolean isShowMandateCheckbox, + boolean isOnlyMandateAllowed, Map<String, String> map) { - if (oaParam.isShowMandateCheckBox()) + if (isShowMandateCheckbox) value = value.replace(MANDATEVISIBLE, ""); else value = value.replace(MANDATEVISIBLE, TEMPLATEVISIBLE); - if (oaParam.isOnlyMandateAllowed()) { + if (isOnlyMandateAllowed) { value = value.replace(MANDATECHECKED, TEMPLATECHECKED + " " + TEMPLATEDISABLED + " " + TEMPLATE_ARIACHECKED + "\"true\""); @@ -65,7 +67,18 @@ public class FormBuildUtils { } else value = value.replace(MANDATECHECKED, TEMPLATE_ARIACHECKED + "\"false\""); - Map<String, String> map = oaParam.getFormCustomizaten(); + String fonttype = map.get(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("\"", "") + "\""; + } + + map.put(FONTFAMILY, fonttypeformated); + } + Set<String> elements = map.keySet(); for (String element: elements) { value = value.replace(element, map.get(element)); |