/******************************************************************************* * 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.builder; public class LoginConfirmationBuilder { /** private static String NL contains the NewLine representation in Java*/ private static final String nl = "\n"; private static final String OA_URL_TAG = ""; private static final String FORM_METHOD_TAG = ""; private static final String ATTR_NAME_TAG = ""; private static final String ATTR_VALUE_TAG = ""; private static final String ATTR_TEMP_TAG = ""; private static final String OA_TAG = ""; private static final String NAME_TAG = ""; private static final String METHOD_GET = "GET"; private static final String METHOD_POST = "POST"; private static final String ATTR_TEMPLATE = " " + nl; /** default HTML template */ private static final String DEFAULT_HTML_TEMPLATE = "" + nl + "" + nl + "" + nl + "Anmeldung mit Bürgerkarte" + nl + "" + nl + "" + nl + "

Wollen Sie sich als "+NAME_TAG+" bei "+OA_TAG+ " anmelden?

" + nl + "
" + nl + ATTR_TEMP_TAG + " " + nl + "
" + nl + "" + nl + ""; private String template; public LoginConfirmationBuilder(){ init(METHOD_GET); } public LoginConfirmationBuilder(String method) { init(method); } public void init(String method) { if(method.equals(METHOD_POST)) { template = DEFAULT_HTML_TEMPLATE.replace(FORM_METHOD_TAG, METHOD_POST); } else { template = DEFAULT_HTML_TEMPLATE.replace(FORM_METHOD_TAG, METHOD_GET); } } public void addParameter(String name, String value) { String attr_template = ATTR_TEMPLATE + ATTR_TEMP_TAG; //Logger.info("Attr Template: " + attr_template); attr_template = attr_template.replace(ATTR_NAME_TAG, name); //Logger.info("Attr Template: " + attr_template); attr_template = attr_template.replace(ATTR_VALUE_TAG, value); //Logger.info("Attr Template: " + attr_template); template = template.replace(ATTR_TEMP_TAG, attr_template); //Logger.info("Template: " + template); } public String finish(String oaURL, String userName, String oa) { template = template.replace(NAME_TAG, userName); template = template.replace(OA_TAG, oa); template = template.replace(OA_URL_TAG, oaURL); return template.replace(ATTR_TEMP_TAG, ""); } }