/* * 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.builder; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang.StringEscapeUtils; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.gui.IVelocityGUIBuilderConfiguration; import at.gv.egiz.eaaf.core.api.gui.ModifyableGuiBuilderConfiguration; import at.gv.egiz.eaaf.core.impl.gui.AbstractGUIFormBuilderConfiguration; /** * This class builds MOA-ID GUI forms from default resource paths * * @author tlenz * */ public class DefaultGUIFormBuilderConfiguration extends AbstractGUIFormBuilderConfiguration implements ModifyableGuiBuilderConfiguration, IVelocityGUIBuilderConfiguration { public static final String VIEW_REDIRECT = "redirectForm.html"; public static final String VIEW_ERRORMESSAGE = "error_message.html"; public static final String VIEW_SINGLELOGOUT = "slo_template.html"; public static final String VIEW_SSO_SESSION_TRANSFER = "sso_transfer_template.html"; private IRequest pendingReq; private Map customParameters = null; /** * @param authURL PublicURLPrefix of the IDP but never null * @param viewName Name of the template (with suffix) but never null * @param formSubmitEndpoint EndPoint on which the form should be submitted, * or null if the form must not submitted */ public DefaultGUIFormBuilderConfiguration(String authURL, String viewName, String formSubmitEndpoint) { super(authURL, viewName, formSubmitEndpoint); } /** * @param Current processed pending-request DAO but never null * @param viewName Name of the template (with suffix) but never null * @param formSubmitEndpoint EndPoint on which the form should be submitted, * or null if the form must not submitted */ public DefaultGUIFormBuilderConfiguration(IRequest pendingReq, String viewName, String formSubmitEndpoint) { super(pendingReq.getAuthURL(), viewName, formSubmitEndpoint); this.pendingReq = pendingReq; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.builder.ModifyableGuiBuilderConfiguration#putCustomParameterWithOutEscaption(java.lang.String, java.lang.Object) */ @Override public void putCustomParameterWithOutEscaption(String group, String key, Object value) { if (customParameters == null) customParameters = new HashMap(); customParameters.put(key, value); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.builder.ModifyableGuiBuilderConfiguration#putCustomParameter(java.lang.String, java.lang.String) */ @Override public void putCustomParameter(String group, String key, String value) { if (customParameters == null) customParameters = new HashMap(); customParameters.put(key, StringEscapeUtils.escapeHtml(value)); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.builder.IGUIBuilderConfiguration#getViewParameters() */ @Override public void putSpecificViewParameters() { if (pendingReq != null) { setViewParameter(null, PARAM_PENDINGREQUESTID, StringEscapeUtils.escapeHtml(pendingReq.getPendingRequestId())); setViewParameter(null, PARAM_PENDINGREQUESTID_DEPRECATED, StringEscapeUtils.escapeHtml(pendingReq.getPendingRequestId())); } //add additional custom parameters if (customParameters != null) { for (Entry el : customParameters.entrySet()) setViewParameter(null, el.getKey(), el.getValue()); } } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.AbstractGUIFormBuilder#getTemplate(java.lang.String) */ @Override public InputStream getTemplate(String viewName) { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.AbstractGUIFormBuilder#getContentType() */ @Override public String getDefaultContentType() { return null; } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.frontend.AbstractGUIFormBuilder#getClasspathTemplateDir() */ @Override public String getClasspathTemplateDir() { return null; } @Override protected final String getFromGroup() { return null; } }