/**
* Copyright 2006 by Know-Center, Graz, Austria
* PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
* joint initiative of the Federal Chancellery Austria 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.
*
* $Id: FormFields.java,v 1.4 2006/10/11 07:39:13 wprinz Exp $
*/
package at.gv.egiz.pdfas.web;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import at.gv.egiz.pdfas.api.PdfAs;
import at.gv.egiz.pdfas.api.commons.SignatureProfile;
import at.gv.egiz.pdfas.api.internal.PdfAsInternal;
import at.gv.egiz.pdfas.web.helper.ApiHelper;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException;
import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
/**
* Helper class that provides methods and constants for creating and dealing
* with the various form fields.
*
* @author wprinz
*/
public abstract class FormFields
{
public static final String FIELD_UPLOAD = "upload";
public static final String FIELD_CONNECTOR = "connector";
public static final String FIELD_PREVIEW = "preview";
public static final String FIELD_MODE = "mode";
//rpiazzi added
public static final String FIELD_MODE_BINARY = "mode-binary";
public static final String FIELD_MODE_TEXTUAL = "mode-textual";
//public static final String FIELD_MODE_INACTIVE = "modeinactive";
public static final String FIELD_SIGNATURE_TYPE_DE = "sig_type_de";
public static final String FIELD_SIGNATURE_TYPE_EN = "sig_type_en";
public static final String VALUE_SIGNATURE_TYPE_DE = "SIGNATURBLOCK_DE";
public static final String VALUE_SIGNATURE_TYPE_EN = "SIGNATURBLOCK_EN";
public static final String FIELD_HEIGHT_SIGNDIV = "height_sign_div";
public static final String FIELD_CONNECTOR_SMARTCARD = "smartcard";
public static final String FIELD_CONNECTOR_MOBILE = "mobile";
public static final String FIELD_CONNECTOR_LOCALBKU = "localbku";
public static final String FIELD_NOTE_ENABLED = "note_enabled";
public static final String FIELD_SIGPOS_X = "sig-pos-x";
public static final String FIELD_SIGPOS_W = "sig-pos-w";
//end added
public static final String FIELD_RAW_DOCUMENT_TEXT = "raw_document_text";
public static final String FIELD_SIGNATURE_TYPE = "sig_type";
// tknall: PDF/A-1b enabled
public static final String FIELD_PDFA_ENABLED = "pdfa_enabled";
public static final String FIELD_VERIFY_WHICH = "verify_which";
public static final String FIELD_SIGNED_TEXT = "signed_text";
public static final String FIELD_DOWNLOAD = "download";
public static final String VALUE_TRUE = "true";
public static final String VALUE_FALSE = "false";
public static final String VALUE_MODE_DETACHED = "detached";
public static final String VALUE_MODE_BINARY = "binary";
public static final String VALUE_MODE_TEXTUAL = "textual";
public static final String VALUE_VERIFY_WHICH_ALL = "all";
public static final String VALUE_DOWNLOAD_INLINE = "inline";
public static final String VALUE_DOWNLOAD_ATTACHMENT = "attachment";
protected static final String STYLE_CLASS_FIELD = "field";
// tzefferer: added fields for URL requests
public static final String FIELD_FILENAME = "filename";
public static final String FIELD_PDF_URL = "pdf-url";
public static final String FIELD_PDF_ID = "pdf-id";
public static final String FIELD_PDFAS_SESSION_ID = "pdfas-session-id";
public static final String FIELD_FILE_LENGTH = "num-bytes";
public static final String FIELD_INVOKE_APP_URL = "invoke-app-url";
public static final String FIELD_INVOKE_APP_ERROR_URL = "invoke-app-error-url";
public static final String FIELD_SESSION_ID = "session-id";
public static final String FIELD_SIGPOS_Y = "sig-pos-y";
public static final String FIELD_SIGPOS_P = "sig-pos-p";
public static final String FIELD_SOURCE = "source_filefreetext";
public static final String VALUE_SOURCE_FILE = "sourcefile";
public static final String VALUE_SOURCE_FREETEXT = "sourcefreetext";
public static final String FIELD_SOURCE_FREETEXT = "freetext";
public static final String FIELD_SOURCE_FILE = "file";
public static final String FIELD_MOBILETEST_ENABLED = "mobiletestenabled";
public static final String FIELD_ORIGINAL_DIGEST = "origdigest";
/**
* The settings key prefix for signature definitions. "sig_obj."
*/
public static final String SIG_OBJ = "sig_obj.";
/**
* The settings key postfix for the type description
*/
public static final String SIG_DESCR = "description";
/**
* Generates the HTML snippet of a FIELD_CONNECTOR select box that allows to
* choose a connector.
*
* @return Returns the HTML snippet.
* @throws SettingsException
* Forwarded exception.
* @throws ConnectorFactoryException
* Forwarded exception.
*/
public static String generateConnectorSelectBox(ServletContext sc) throws ConnectorFactoryException
{
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
writer.println("");
return sw.toString();
}
/**
* Generates a HTML snippet of a FIELD_SIGNATURE_TYPE select box that allows
* to choose the signature type.
*
* @return Returns the HTML snippet.
* @throws ServletException
* Forwarded exception.
*/
public static String generateTypeSelectBox(ServletContext sc) throws ServletException
{
try
{
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
PdfAs pdfAs = ApiHelper.getPdfAsFromContext(sc);
List profiles = pdfAs.getProfileInformation();
writer.println("");
return sw.toString();
}
catch (Exception e)
{
throw new ServletException(e);
}
}
}