/*******************************************************************************
* Copyright 2017 Graz University of Technology
* EAAF-Core Components has been developed in a cooperation between EGIZ,
* A-SIT+, A-SIT, and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.2 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:
* https://joinup.ec.europa.eu/news/understanding-eupl-v12
*
* 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.egiz.eaaf.core.impl.gui;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import at.gv.egiz.eaaf.core.api.gui.IGUIBuilderConfiguration;
/**
* @author tlenz
*
*/
public abstract class AbstractGUIFormBuilderConfiguration implements IGUIBuilderConfiguration {
public static final String PARAM_AUTHCONTEXT = "contextPath";
public static final String PARAM_FORMSUBMITENDPOINT = "submitEndpoint";
public static final String PARAM_PENDINGREQUESTID = "pendingReqID";
private String authURL = null;
private String viewName = null;
private String formSubmitEndpoint = null;
/**
* @param authURL IDP PublicURL-Prefix which should be used, 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 AbstractGUIFormBuilderConfiguration(String authURL, String viewName, String formSubmitEndpoint) {
if (viewName.startsWith("/"))
this.viewName = viewName.substring(1);
else
this.viewName = viewName;
if (authURL.endsWith("/"))
this.authURL = authURL.substring(0, authURL.length() - 1);
else
this.authURL = authURL;
if (StringUtils.isNotEmpty(formSubmitEndpoint)) {
if (formSubmitEndpoint.startsWith("/"))
this.formSubmitEndpoint = formSubmitEndpoint;
else
this.formSubmitEndpoint = "/" + formSubmitEndpoint;
}
}
/**
* Define the parameters, which should be evaluated in the template
* IMPORTANT: external HTML escapetion is required, because it is NOT done internally during the building process
*
* @return Map of parameters, which should be added to template
*/
abstract protected Map getSpecificViewParameters();
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.auth.frontend.builder.IGUIBuilderConfiguration#getViewName()
*/
@Override
public final String getViewName() {
return this.viewName;
}
/* (non-Javadoc)
* @see at.gv.egovernment.moa.id.auth.frontend.builder.IGUIBuilderConfiguration#getViewParameters()
*/
@Override
public final Map getViewParameters() {
//get parameters from detail implementation
Map specParams = getSpecificViewParameters();
if (specParams == null)
specParams = new HashMap();
//add generic parameters
specParams.put(PARAM_AUTHCONTEXT, this.authURL);
if (this.formSubmitEndpoint != null)
specParams.put(PARAM_FORMSUBMITENDPOINT, this.formSubmitEndpoint);
return specParams;
}
}