aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2013-01-09 15:41:29 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2013-01-09 15:41:29 +0000
commit535a04fa05f739ec16dd81666e3b0f82dfbd442d (patch)
tree0804f301c1a9ceb303a8441b7b29244fc8eb7ff0 /src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java
parent1efaf6fd5619dfa95c9d7e8c71eda4c2ffba4998 (diff)
downloadpdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.tar.gz
pdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.tar.bz2
pdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.zip
pdf-as-lib maven project files moved to pdf-as-lib
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@926 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java515
1 files changed, 0 insertions, 515 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java
deleted file mode 100644
index 783512c..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/SignatureTypes.java
+++ /dev/null
@@ -1,515 +0,0 @@
-/**
- * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
- * 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: SignatureTypes.java,v 1.5 2006/10/31 08:18:56 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.sig;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.log4j.Logger;
-
-import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
-import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
-import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
-import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
-import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException;
-import at.knowcenter.wag.exactparser.ByteArrayUtils;
-
-public class SignatureTypes
-{
-
-// 03.11.2010 changed by exthex - commented unneeded setDefaultStyles method to reduce confusion
-
- /**
- * The settings key prefix for signature definitions. <code>"sig_obj."</code>
- */
- public static final String SIG_OBJ = "sig_obj.";
-
- /**
- * The settings key prefix for signature object types
- */
- public static final String TYPES = SIG_OBJ + "types";
-
- /**
- * The settings key prefix for the default signature object type
- */
- public static final String DEFAULT_TYPE = SIG_OBJ + "type.default";
-
- /**
- * The settings key postfix for the type description
- */
- public static final String SIG_DESCR = "description";
-
- /**
- * The state value activating an signature definition
- */
- private static final String STATE_ON = "on";
-
- // /**
- // * The state value de activating an signature definition
- // */
- // private static final String STATE_OFF = "off";
-
- /**
- * The settings key prefix for the signature table object definition
- */
- public static final String TABLE = "table.";
-
- /**
- * The settings key sub prefix getting the main table definition
- */
- public static final String MAIN_TABLE = "main";
-
- /**
- * The settings value refering to a table
- */
- public final static String TYPE_TABLE = "TABLE";
-
- /**
- * The settings value refering to an image
- */
- public final static String TYPE_IMAGE = "i";
-
- /**
- * The settings value refering to a text caption
- */
- public final static String TYPE_CAPTION = "c";
-
- /**
- * The settings value refering to a text value
- */
- public final static String TYPE_VALUE = "v";
-
- /**
- * The settings key sub prefix getting the width of columns for a table
- * definition
- */
- public final static String COLS_WITH = "ColsWidth";
-
- /**
- * The settings key sub prefix getting the style definition
- */
- public final static String STYLE = "Style";
-
-// /**
-// * The default style definition for images.
-// */
-// private Style defaultImageStyle_ = new Style();
-//
-// /**
-// * The default style definition for captions.
-// */
-// private Style defaultCaptionStyle_ = new Style();
-//
-// /**
-// * The default style definition for values.
-// */
-// private Style defaultValueStyle_ = new Style();
-
- /**
- * Standard key get/set the singature name
- */
- public static final String SIG_NAME = "SIG_NAME";
-
- /**
- * Standard key get/set the signature date
- */
- public static final String SIG_DATE = "SIG_DATE";
-
- /**
- * Standard key get/set the signator issuer
- */
- public static final String SIG_ISSUER = "SIG_ISSUER";
-
- /**
- * Standard key get/set the siganture value
- */
- public static final String SIG_VALUE = "SIG_VALUE";
-
- /**
- * Standard key get/set the normalisation method used
- */
- public static final String SIG_NORM = "SIG_NORM";
-
- /**
- * Standard key get/set the signation id's used by BKU signated documents
- */
- public static final String SIG_ID = "SIG_ID";
-
- /**
- * The EGIZ Algorithm "Kennzeichnung".
- */
- public static final String SIG_KZ = "SIG_KZ";
-
- /**
- * Standard key get/set the reference to the signature label (image mark)
- */
- public static final String SIG_LABEL = "SIG_LABEL";
-
- /**
- * Standard key get/set the serial number of the signature
- */
- public static final String SIG_NUMBER = "SIG_NUMBER";
-
- // public static final String SIG_TYPE = "SIG_TYPE";
- /**
- * Standard key get/set the signature meta informations
- */
- public static final String SIG_META = "SIG_META";
-
- /**
- * Standard key get/set the signature algorithm (sign + hash)
- */
- public static final String SIG_ALG = "SIG_ALG";
-
- /**
- * Standard key get/set the signature note
- * added by rpiazzi
- */
- public static final String SIG_NOTE = "SIG_NOTE";
-
-
- /**
- * Standard key get/set the signature subject
- * Added to be able to define static signator name within config file
- * added by rpiazzi
- */
- public static final String SIG_SUBJECT = "SIG_SUBJECT";
-
- /**
- * The logger definition.
- */
- private static final Logger logger_ = ConfigLogger.getLogger(SignatureTypes.class);
-
- // /**
- // * The normalizer reference
- // */
- // private Normalizer normalizer_ = null;
-
- /**
- * The settings reader reference
- */
- private SettingsReader settings_ = null;
-
-
- // /**
- // * The reference to the settings property tree
- // */
- // private PropertyTree pTree_ = null;
-
- // /**
- // * The current signature type used reading and analysing the property tree
- // */
- // private String sigType_ = null;
-
- // /**
- // * List of all keys used in the current signature definition
- // */
- // private ArrayList sigKeys_ = null;
-
- /**
- * Array of required signature keys
- */
- // public static String[] REQUIRED_SIG_KEYS = new String[]{SIG_NAME, SIG_DATE,
- // SIG_ISSUER, SIG_VALUE, SIG_NUMBER, SIG_ID};
- public static String[] REQUIRED_SIG_KEYS = new String[] { SIG_DATE,
- SIG_ISSUER, SIG_VALUE, SIG_NUMBER, SIG_ID, SIG_KZ };
-
- /**
- * Tells, if the given key is a required key.
- * <p>
- * Note that the SIG_KZ is a required key.
- * </p>
- * @param key The key to be tested if it is a required key.
- * @return Returns true, if the key is required, false otherwise.
- */
- public static boolean isRequiredKey (String key)
- {
- if (key.equals(SIG_KZ))
- {
- return true;
- }
-
- for (int i = 0; i < REQUIRED_SIG_KEYS.length; i++)
- {
- if (key.equals(REQUIRED_SIG_KEYS[i]))
- {
- return true;
- }
- }
- return false;
- }
-
- public static String[] ALL_SIG_KEYS = new String[] { SIG_NAME, SIG_DATE,
- SIG_ISSUER, SIG_VALUE, SIG_NORM, SIG_ID, SIG_LABEL, SIG_NUMBER, SIG_META , SIG_ALG, SIG_NOTE};
-
- public static byte [][] ALL_SIG_BREV = new byte[][] { { 'n', 'a', 'm' },
- { 'd', 'a', 't' }, { 'i', 's', 's' }, { 'v', 'a', 'l' },
- { 'n', 'o', 'r' }, { 's', 'i', 'd' }, { 'l', 'a', 'b' },
- { 's', 'n', 'r' }, { 'm', 'e', 't' }, { 'a', 'l', 'g' } };
-
- // /**
- // * Sorted representation of keys defined in rows
- // */
- // private ArrayList sortedSigKeys_ = new ArrayList();
-
- // /**
- // * Reference from signature key to there corresponding value
- // */
- // private Hashtable sigEntries_ = new Hashtable(8);
-
-// /**
-// * A list of all configured signature type definitions
-// */
-// private List signatureTypeDefinitions_ = new Vector();
-
- /**
- * A type-name to type-definition map
- */
- private Map typeDefMap_ = new HashMap();
-
- // /**
- // * A map of required keys used to reconstruct a signature block
- // */
- // private static HashMap requiredSigKeys_ = new HashMap();
-
- /**
- * A plain list of signature type names
- */
-// ArrayList typeList_ = new ArrayList(4);
-
- /**
- * Used as singleton to read the singnature type definitions only one times of
- * a session
- */
- private static SignatureTypes instance_ = null;
-
- /**
- * This is the private constructor method to provide a singleton instance of
- * this class. It inits a normalizer, the settings reader, read the default
- * styles and load the configured signature types.
- *
- * @throws SignatureTypesException
- * @see SettingsReader
- */
- private SignatureTypes() throws SignatureTypesException
- {
- try
- {
- loadSettings();
- }
- catch (SettingsException e)
- {
- throw new SignatureTypesException(e);
- }
-// setDefaultStyles();
- loadSignatureTypes();
- }
-
- /**
- * This static method returns the stored instance of this class. If the
- * singleton does not exist, this method creates a new singleton and gives
- * this instance back to the caller.
- *
- * @return the stored instance of this class
- * @throws SignatureTypesException
- */
- public static SignatureTypes getInstance() throws SignatureTypesException
- {
- if (instance_ == null)
- {
- instance_ = new SignatureTypes();
- }
- return instance_;
- }
-
- /**
- * Reloads the instance.
- * @throws SignatureTypesException
- */
- public static void createInstance() throws SignatureTypesException
- {
- instance_ = null;
- getInstance();
- }
-
- /**
- * This method load the signature definitions
- *
- * @throws SettingsException
- *
- * @throws SettingsException
- * ErrorCode:101
- */
- private void loadSettings() throws SettingsException
- {
- if (settings_ == null)
- {
- settings_ = SettingsReader.getInstance();
- }
- // pTree_ = settings_.getPTree();
- }
-
-// /**
-// * This method set the default styles for images, captions and values.
-// */
-// private void setDefaultStyles()
-// {
-// defaultImageStyle_.setPadding(3);
-// defaultImageStyle_.setHAlign(Style.CENTER);
-// defaultImageStyle_.setVAlign(Style.MIDDLE);
-// defaultImageStyle_.setBgColor(new Color(255, 255, 255));
-//
-// defaultCaptionStyle_.setHAlign(Style.CENTER);
-// defaultCaptionStyle_.setVAlign(Style.MIDDLE);
-//
-// defaultValueStyle_.setVAlign(Style.MIDDLE);
-// }
-
- /**
- * This method load the configured signature types. It stores the definition
- * representations only if the type is set to ON. It stores the type
- * definition object, the definition map and the simple type name list.
- */
- private void loadSignatureTypes()
- {
- if (settings_ != null)
- {
- ArrayList types = settings_.getKeys(TYPES);
- for (int type_idx = 0; type_idx < types.size(); type_idx++)
- {
- String type = (String) types.get(type_idx);
- addSignatureType(type);
- }
- }
- }
-
- public void removeSignatureType(String typeName) {
- this.typeDefMap_.remove(typeName);
- }
-
- /**
- * Create and add {@link SignatureTypeDefinition} from its name
- * @param typeName
- */
- public void addSignatureType(String typeName) {
-
- if (STATE_ON.equals(settings_.getSetting(TYPES + "." + typeName, null)))
- {
- SignatureTypeDefinition sig_type_def;
- try
- {
- sig_type_def = new SignatureTypeDefinition(settings_, typeName);
- //signatureTypeDefinitions_.add(sig_type_def);
- typeDefMap_.put(typeName, sig_type_def);
- //typeList_.add(type);
- }
- catch (SignatureException e)
- {
- logger_.error(e.getMessage(), e);
- }
- }
- }
-
- /**
- * @return a arrayList (String) of signature types names
- */
- public Set getSignatureTypes()
- {
- return this.typeDefMap_.keySet();
- }
-
- /**
- * @return a list of signature type definitions
- */
- public List getSignatureTypeDefinitions()
- {
- return new ArrayList(this.typeDefMap_.values());
- }
-
- /**
- * This method returns the corresponding signature type definition to a given
- * type key
- *
- * @param type
- * the key to get the signature type definition
- * @return the stored signature type definition
- */
- public SignatureTypeDefinition getSignatureTypeDefinition(String type)
- {
- return (SignatureTypeDefinition) typeDefMap_.get(type);
- }
-
- public static String convertBrevToType (final byte [] brev)
- {
- for (int i = 0; i < ALL_SIG_BREV.length; i++)
- {
- if (ByteArrayUtils.compareByteArrays(ALL_SIG_BREV[i], 0, brev))
- {
- return ALL_SIG_KEYS[i];
- }
- }
- return null;
- }
-
- public static byte [] convertTypeToBrev (final String type)
- {
- for (int i = 0; i < ALL_SIG_KEYS.length; i++)
- {
- if (ALL_SIG_KEYS.equals(type))
- {
- return ALL_SIG_BREV[i];
- }
- }
- return null;
- }
-
- public static boolean isRequredSigTypeKey(String name) {
- return ArrayUtils.contains(REQUIRED_SIG_KEYS, name);
- }
-
- /**
- * The standard toString method. Used for testing only.
- *
- * @return the string representation of the class
- */
- public String toString()
- {
- String strg = "";
- for (Iterator it = this.typeDefMap_.values().iterator(); it.hasNext();) {
- SignatureTypeDefinition std = (SignatureTypeDefinition) it.next();
-
- strg += "----------TYPE:" + std.getType() + "----------\n";
- strg += std.toString();
- }
- return strg;
- }
-
-} \ No newline at end of file