/**
* Copyright (c) 2006 by Know-Center, Graz, Austria
*
* This software is the confidential and proprietary information of Know-Center,
* Graz, Austria. You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license agreement you entered
* into with Know-Center.
*
* KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
* NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
* LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES.
*
* $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_MODE = "mode";
public static final String FIELD_PREVIEW = "preview";
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_BINARY = "binary";
public static final String VALUE_MODE_TEXTUAL = "textual";
public static final String VALUE_MODE_DETACHED = "detached";
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 = "source-is-file";
public static final String VALUE_SOURCE_FREETEXT = "source-is-freetext";
public static final String FIELD_FREETEXT = "freetext";
// end add
/**
* 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);
}
}
}