diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-02-20 12:03:32 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-02-20 12:04:54 +0100 |
commit | ab7a38ff2956d427b598704e9309912593ff1d87 (patch) | |
tree | 91e1151e07aaddd404c756fd13a7782c05783e49 /pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons | |
parent | 6f6a16cdd2a49f7b50e8b0d2b75ef768a323eee7 (diff) | |
download | pdf-as-4-ab7a38ff2956d427b598704e9309912593ff1d87.tar.gz pdf-as-4-ab7a38ff2956d427b598704e9309912593ff1d87.tar.bz2 pdf-as-4-ab7a38ff2956d427b598704e9309912593ff1d87.zip |
Added license text
Diffstat (limited to 'pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons')
6 files changed, 973 insertions, 835 deletions
diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java index 568787b4..136e0d70 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/Constants.java @@ -1,190 +1,213 @@ -/**
- * <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.
- */
-package at.gv.egiz.pdfas.api.commons;
-
-
-/**
- * Contains commonly used constants.
- *
- * @author wprinz
- */
-@Deprecated
-public final class Constants
-{
-
- /**
- * Hidden default constructor.
- */
- private Constants()
- {
- // empty
- }
-
- /**
- * A binary signature.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_TYPE_BINARY = "binary";
-
- /**
- * A textual signature.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_TYPE_TEXTUAL = "textual";
-
- /**
- * The default signature type (one of "textual", "binary", "detachedtextual").
- */
- public static final String DEFAULT_SIGNATURE_TYPE = SIGNATURE_TYPE_BINARY;
-
- /**
- * A "detached" textual signature.
- *
- * <p>
- * The document text is signed, but instead of returning the pdf with the signature block,
- * the sign result XML of the connector is returned.
- * </p>
- */
- public static final String SIGNATURE_TYPE_DETACHEDTEXTUAL = "detachedtextual";
-
- /**
- * The signature device moa.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_MOA = "moa";
-
- /**
- * The signature device bku.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_BKU = "bku";
-
- /**
- * The signature device a1.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_A1 = "a1";
-
- /**
- * The signature device MOCCA (online bku).
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_MOC = "moc";
-
- /**
- * Added by rpiazzi
- * The signature device MOBILE.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_MOBILE = "mobile";
-
- /**
- * Added by rpiazzi
- * The signature device MOBILETEST for the test version of the MOBILE CCS.
- * This value should not be modified due to external dependencies!
- */
- public static final String SIGNATURE_DEVICE_MOBILETEST = "mobiletest";
-
- /**
- * Only binary signatures are verified.
- */
- public static final String VERIFY_MODE_BINARY_ONLY = "binaryOnly";
-
- /**
- * Binary and textual signatures are verified with time optimization.
- *
- * <p>
- * This mode of operation tries to minimize the numbers of text extractions,
- * which are very time intensive, at the cost of some rare cases, in which some
- * signatures may not be found.
- * </p>
- */
- public static final String VERIFY_MODE_SEMI_CONSERVATIVE = "semiConservative";
-
- /**
- * Binary and textual signatures are verified.
- */
- public static final String VERIFY_MODE_FULL_CONSERVATIVE = "fullConservative";
-
- /**
- * All signatures are verified.
- */
- public static final int VERIFY_ALL = -1;
-
- /**
- * The system property that may be used to declare the pdf-as configuration folder.
- */
- public static final String CONFIG_DIR_SYSTEM_PROPERTY = "pdf-as.work-dir";
-
- /**
- * The zip file containing the default configuration.
- */
- public static final String DEFAULT_CONFIGURATION_ZIP_RESOURCE = "DefaultConfiguration.zip";
-
- /**
- * The configuration folder for pdf-as within the user's home folder.
- */
- public static final String USERHOME_CONFIG_FOLDER = "PDF-AS";
-
- /**
- * The name of the directory, where temporary files are stored.
- */
- public static final String TEMP_DIR_NAME = "pdfastmp";
-
- public static final String BKU_HEADER_SIGNATURE_LAYOUT = "SignatureLayout";
-
- public static final String ADOBE_SIG_FILTER = "Adobe.PDF-AS";
-
- /**
- * Strict matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, an exception will be thrown.
- */
- public static final int PLACEHOLDER_MATCH_MODE_STRICT = 0;
-
- /**
- * A moderate matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, the first placeholder without an id will be taken.<br/>
- * If there is no such placeholder, the signature will be placed as usual, according to the pos parameter of the signature profile used.
- */
- public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1;
-
- /**
- * A more lenient matching mode for placeholder extraction.<br/>
- * If the placeholder with the given id is not found in the document, the first found placeholder will be taken, regardless if it has an id set, or not.<br/>
- * If there is no placeholder at all, the signature will be placed as usual, according to the pos parameter of the signature profile used.
- */
- public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2;
-
- /**
- * Identifier for QR based placeholders.
- */
- public static final String QR_PLACEHOLDER_IDENTIFIER = "PDF-AS-POS";
-
- /**
- * The name of a logger used for statistical logging.
- */
- public static final String STATISTIC_LOGGER_NAME = "statistic";
-
-}
-
+/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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. + */ +package at.gv.egiz.pdfas.api.commons; + + +/** + * Contains commonly used constants. + * + * @author wprinz + */ +@Deprecated +public final class Constants +{ + + /** + * Hidden default constructor. + */ + private Constants() + { + // empty + } + + /** + * A binary signature. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_TYPE_BINARY = "binary"; + + /** + * A textual signature. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_TYPE_TEXTUAL = "textual"; + + /** + * The default signature type (one of "textual", "binary", "detachedtextual"). + */ + public static final String DEFAULT_SIGNATURE_TYPE = SIGNATURE_TYPE_BINARY; + + /** + * A "detached" textual signature. + * + * <p> + * The document text is signed, but instead of returning the pdf with the signature block, + * the sign result XML of the connector is returned. + * </p> + */ + public static final String SIGNATURE_TYPE_DETACHEDTEXTUAL = "detachedtextual"; + + /** + * The signature device moa. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_MOA = "moa"; + + /** + * The signature device bku. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_BKU = "bku"; + + /** + * The signature device a1. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_A1 = "a1"; + + /** + * The signature device MOCCA (online bku). + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_MOC = "moc"; + + /** + * Added by rpiazzi + * The signature device MOBILE. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_MOBILE = "mobile"; + + /** + * Added by rpiazzi + * The signature device MOBILETEST for the test version of the MOBILE CCS. + * This value should not be modified due to external dependencies! + */ + public static final String SIGNATURE_DEVICE_MOBILETEST = "mobiletest"; + + /** + * Only binary signatures are verified. + */ + public static final String VERIFY_MODE_BINARY_ONLY = "binaryOnly"; + + /** + * Binary and textual signatures are verified with time optimization. + * + * <p> + * This mode of operation tries to minimize the numbers of text extractions, + * which are very time intensive, at the cost of some rare cases, in which some + * signatures may not be found. + * </p> + */ + public static final String VERIFY_MODE_SEMI_CONSERVATIVE = "semiConservative"; + + /** + * Binary and textual signatures are verified. + */ + public static final String VERIFY_MODE_FULL_CONSERVATIVE = "fullConservative"; + + /** + * All signatures are verified. + */ + public static final int VERIFY_ALL = -1; + + /** + * The system property that may be used to declare the pdf-as configuration folder. + */ + public static final String CONFIG_DIR_SYSTEM_PROPERTY = "pdf-as.work-dir"; + + /** + * The zip file containing the default configuration. + */ + public static final String DEFAULT_CONFIGURATION_ZIP_RESOURCE = "DefaultConfiguration.zip"; + + /** + * The configuration folder for pdf-as within the user's home folder. + */ + public static final String USERHOME_CONFIG_FOLDER = "PDF-AS"; + + /** + * The name of the directory, where temporary files are stored. + */ + public static final String TEMP_DIR_NAME = "pdfastmp"; + + public static final String BKU_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; + + public static final String ADOBE_SIG_FILTER = "Adobe.PDF-AS"; + + /** + * Strict matching mode for placeholder extraction.<br/> + * If the placeholder with the given id is not found in the document, an exception will be thrown. + */ + public static final int PLACEHOLDER_MATCH_MODE_STRICT = 0; + + /** + * A moderate matching mode for placeholder extraction.<br/> + * If the placeholder with the given id is not found in the document, the first placeholder without an id will be taken.<br/> + * If there is no such placeholder, the signature will be placed as usual, according to the pos parameter of the signature profile used. + */ + public static final int PLACEHOLDER_MATCH_MODE_MODERATE = 1; + + /** + * A more lenient matching mode for placeholder extraction.<br/> + * If the placeholder with the given id is not found in the document, the first found placeholder will be taken, regardless if it has an id set, or not.<br/> + * If there is no placeholder at all, the signature will be placed as usual, according to the pos parameter of the signature profile used. + */ + public static final int PLACEHOLDER_MATCH_MODE_LENIENT = 2; + + /** + * Identifier for QR based placeholders. + */ + public static final String QR_PLACEHOLDER_IDENTIFIER = "PDF-AS-POS"; + + /** + * The name of a logger used for statistical logging. + */ + public static final String STATISTIC_LOGGER_NAME = "statistic"; + +} + diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java index 369bff87..ff967077 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureLifetimeEnum.java @@ -1,73 +1,96 @@ -/**
- * <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.
- */
-package at.gv.egiz.pdfas.api.commons;
-
-import java.io.Serializable;
-
-/**
- * Pseudo enum defining lifetime models for {@link DynamicSignatureProfile}s.
- *
- * @author exthex
- *
- */
-@Deprecated
-public final class DynamicSignatureLifetimeEnum implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private int value;
-
- /**
- * Automatic lifetime bound to one sign process
- */
- public static final DynamicSignatureLifetimeEnum AUTO = new DynamicSignatureLifetimeEnum(1);
-
- /**
- * Manual lifetime making YOU responsible for calling {@link DynamicSignatureProfile#dispose()}.
- */
- public static final DynamicSignatureLifetimeEnum MANUAL = new DynamicSignatureLifetimeEnum(2);
-
- private DynamicSignatureLifetimeEnum(int val) {
- this.value = val;
- }
-
- public int hashCode() {
- return value;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- DynamicSignatureLifetimeEnum other = (DynamicSignatureLifetimeEnum) obj;
- if (value != other.value)
- return false;
- return true;
- }
-
-
-
-}
+/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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. + */ +package at.gv.egiz.pdfas.api.commons; + +import java.io.Serializable; + +/** + * Pseudo enum defining lifetime models for {@link DynamicSignatureProfile}s. + * + * @author exthex + * + */ +@Deprecated +public final class DynamicSignatureLifetimeEnum implements Serializable { + private static final long serialVersionUID = 1L; + + private int value; + + /** + * Automatic lifetime bound to one sign process + */ + public static final DynamicSignatureLifetimeEnum AUTO = new DynamicSignatureLifetimeEnum(1); + + /** + * Manual lifetime making YOU responsible for calling {@link DynamicSignatureProfile#dispose()}. + */ + public static final DynamicSignatureLifetimeEnum MANUAL = new DynamicSignatureLifetimeEnum(2); + + private DynamicSignatureLifetimeEnum(int val) { + this.value = val; + } + + public int hashCode() { + return value; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DynamicSignatureLifetimeEnum other = (DynamicSignatureLifetimeEnum) obj; + if (value != other.value) + return false; + return true; + } + + + +} diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java index 9620d2fe..535ea18c 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfile.java @@ -1,126 +1,149 @@ -/**
- * <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.
- */
-package at.gv.egiz.pdfas.api.commons;
-
-import at.gv.egiz.pdfas.api.PdfAs;
-import at.gv.egiz.pdfas.api.sign.SignParameters;
-
-/**
- * A dynamic signature profile. It is used to define a signature profile like the ones from pdf-as/config.properties at runtime.
- * After creation via {@link PdfAs} you can set properties via {@link #setPropertyRaw(String, String)}
- * or {@link #setFieldValue(String, String)}.<br>
- * You have to call {@link #apply()} to use the profile. The identifying name (e.g. for {@link SignParameters#setSignatureProfileId(String)}
- * can be obtained via {@link #getName()}.<br>
- * Depending on the {@link DynamicSignatureLifetimeEnum} the profile can be alive and usable till you {@link #dispose()} it manually.
- * <p>
- * Sample usage:<br>
- * <pre>
- SignParameters sp = new SignParameters();
- . . .
- sp.setSignatureType(Constants.SIGNATURE_TYPE_TEXTUAL);
- sp.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA);
-
- // create a new dynamic profile based on SIGNATURBLOCK_DE (every property is copied) with manual lifetime
- DynamicSignatureProfile dsp = pdfAs.createDynamicSignatureProfile("myUniqueName", "SIGNATURBLOCK_DE",
- DynamicSignatureLifetimeEnum.MANUAL);
-
- // set something
- dsp.setPropertyRaw("key.SIG_META", "Statement");
- dsp.setPropertyRaw("value.SIG_META", "respect to the man in the icecream van ${subject.EMAIL}");
- dsp.setPropertyRaw("value.SIG_LABEL", "./images/signatur-logo_en.png");
- dsp.setPropertyRaw("table.main.Style.halign", "right");
-
- // mandatory: apply the profile, you have to apply again after changes (overriding your previous setting)
- dsp.apply();
- sp.setSignatureProfileId(dsp.getName());
-
- // execute PDF-AS
- pdfAs.sign(sp);
-
- . . .
-
- // your profile is saved and you can obtain it again anytime later:
- dsp = pdfAs.loadDynamicSignatureProfile("myUniqueName");
- // use it for another sign.
- // dont forget to dispose() sometimes because it was manual lifetime
- System.out.println(dsp.getName());
- * </pre>
- * </p>
- *
- * @author exthex
- *
- */
-@Deprecated
-public interface DynamicSignatureProfile {
-
- /**
- * Get the name of the dynamic signature profile. Equals the <b>SignatureProfileId</b>
- * @return
- */
- public abstract String getName();
-
- /**
- * Set a field value for the profile. Use {@link #setPropertyRaw(String, String)} for setting any property.<br>
- * For example to set <code>sig_obj.MEIN_DYN_SIGNATURBLOCK.value.SIG_META</code> just use <code>SIG_META</code> as fieldName.
- * @param fieldName the name of the field
- * @param value the value to set
- */
- public abstract void setFieldValue(String fieldName, String value);
-
- /**
- * Get a field value from the profile. See {@link #setFieldValue(String, String)}
- * @param fieldName
- * @return
- */
- public abstract String getFieldValue(String fieldName);
-
- /**
- * Set any property for the signature profile.
- * Uses the same keys as the property file without the "prefix" for the profile.
- * For example to set <code>sig_obj.MEIN_DYN_SIGNATURBLOCK.key.SIG_META</code> use <code>key.SIG_META</code>
- * @param key property key
- * @param val property value
- */
- public void setPropertyRaw(String key, String val);
-
- /**
- * Get any property from the signature profile. See {@link #setPropertyRaw(String, String)} for details.
- * @param key
- * @return
- */
- public String getPropertyRaw(String key);
-
- /**
- * Apply the signature profile. Call this after all properties are set and you want to use the profile. It is then added
- * to the globally available signature profiles. Depending on the lifetime model {@link DynamicSignatureLifetimeEnum} you
- * have to {@link #dispose()} it manually when not needed anymore.
- */
- public abstract void apply();
-
- /**
- * Disposes the signature profile from the global store. Call this for {@link DynamicSignatureLifetimeEnum#MANUAL} only.
- */
- public abstract void dispose();
-
-}
\ No newline at end of file +/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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. + */ +package at.gv.egiz.pdfas.api.commons; + +import at.gv.egiz.pdfas.api.PdfAs; +import at.gv.egiz.pdfas.api.sign.SignParameters; + +/** + * A dynamic signature profile. It is used to define a signature profile like the ones from pdf-as/config.properties at runtime. + * After creation via {@link PdfAs} you can set properties via {@link #setPropertyRaw(String, String)} + * or {@link #setFieldValue(String, String)}.<br> + * You have to call {@link #apply()} to use the profile. The identifying name (e.g. for {@link SignParameters#setSignatureProfileId(String)} + * can be obtained via {@link #getName()}.<br> + * Depending on the {@link DynamicSignatureLifetimeEnum} the profile can be alive and usable till you {@link #dispose()} it manually. + * <p> + * Sample usage:<br> + * <pre> + SignParameters sp = new SignParameters(); + . . . + sp.setSignatureType(Constants.SIGNATURE_TYPE_TEXTUAL); + sp.setSignatureDevice(Constants.SIGNATURE_DEVICE_MOA); + + // create a new dynamic profile based on SIGNATURBLOCK_DE (every property is copied) with manual lifetime + DynamicSignatureProfile dsp = pdfAs.createDynamicSignatureProfile("myUniqueName", "SIGNATURBLOCK_DE", + DynamicSignatureLifetimeEnum.MANUAL); + + // set something + dsp.setPropertyRaw("key.SIG_META", "Statement"); + dsp.setPropertyRaw("value.SIG_META", "respect to the man in the icecream van ${subject.EMAIL}"); + dsp.setPropertyRaw("value.SIG_LABEL", "./images/signatur-logo_en.png"); + dsp.setPropertyRaw("table.main.Style.halign", "right"); + + // mandatory: apply the profile, you have to apply again after changes (overriding your previous setting) + dsp.apply(); + sp.setSignatureProfileId(dsp.getName()); + + // execute PDF-AS + pdfAs.sign(sp); + + . . . + + // your profile is saved and you can obtain it again anytime later: + dsp = pdfAs.loadDynamicSignatureProfile("myUniqueName"); + // use it for another sign. + // dont forget to dispose() sometimes because it was manual lifetime + System.out.println(dsp.getName()); + * </pre> + * </p> + * + * @author exthex + * + */ +@Deprecated +public interface DynamicSignatureProfile { + + /** + * Get the name of the dynamic signature profile. Equals the <b>SignatureProfileId</b> + * @return + */ + public abstract String getName(); + + /** + * Set a field value for the profile. Use {@link #setPropertyRaw(String, String)} for setting any property.<br> + * For example to set <code>sig_obj.MEIN_DYN_SIGNATURBLOCK.value.SIG_META</code> just use <code>SIG_META</code> as fieldName. + * @param fieldName the name of the field + * @param value the value to set + */ + public abstract void setFieldValue(String fieldName, String value); + + /** + * Get a field value from the profile. See {@link #setFieldValue(String, String)} + * @param fieldName + * @return + */ + public abstract String getFieldValue(String fieldName); + + /** + * Set any property for the signature profile. + * Uses the same keys as the property file without the "prefix" for the profile. + * For example to set <code>sig_obj.MEIN_DYN_SIGNATURBLOCK.key.SIG_META</code> use <code>key.SIG_META</code> + * @param key property key + * @param val property value + */ + public void setPropertyRaw(String key, String val); + + /** + * Get any property from the signature profile. See {@link #setPropertyRaw(String, String)} for details. + * @param key + * @return + */ + public String getPropertyRaw(String key); + + /** + * Apply the signature profile. Call this after all properties are set and you want to use the profile. It is then added + * to the globally available signature profiles. Depending on the lifetime model {@link DynamicSignatureLifetimeEnum} you + * have to {@link #dispose()} it manually when not needed anymore. + */ + public abstract void apply(); + + /** + * Disposes the signature profile from the global store. Call this for {@link DynamicSignatureLifetimeEnum#MANUAL} only. + */ + public abstract void dispose(); + +} diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java index 71317a52..4bf896b6 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/DynamicSignatureProfileImpl.java @@ -1,228 +1,251 @@ -/**
- * <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.
- */
-package at.gv.egiz.pdfas.api.commons;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import at.gv.egiz.pdfas.api.PdfAs;
-import at.gv.egiz.pdfas.common.settings.ISettings;
-import at.gv.egiz.pdfas.lib.api.Configuration;
-import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
-
-// TODO exception types?
-/**
- * Implementation class of the {@link DynamicSignatureProfile}. Don't use this class directly. Use {@link PdfAs} to create and the
- * {@link DynamicSignatureProfile} interface for manipulation.
- * @author exthex
- *
- */
-@Deprecated
-public class DynamicSignatureProfileImpl implements DynamicSignatureProfile {
- private String name;
- private Properties newProps = new Properties();
- private int dynamicTypeCounter = 0;
- private static Map<String, DynamicSignatureProfile> profiles =
- new HashMap<String, DynamicSignatureProfile>();
- private static ThreadLocal<DynamicSignatureProfile> localProfiles = new ThreadLocal<DynamicSignatureProfile>();
- private DynamicSignatureLifetimeEnum lifeMode;
- private Configuration configuration;
-
- private DynamicSignatureProfileImpl(DynamicSignatureLifetimeEnum mode, String name,
- Configuration configuration) {
- if (name != null) {
- this.name = name;
- } else {
- this.name = createDynamicTypeName();
- }
- this.configuration = configuration;
- this.lifeMode = mode;
- }
-
- public static DynamicSignatureProfileImpl createFromParent(String myUniqueName, String parentProfile,
- DynamicSignatureLifetimeEnum mode, Configuration configuration) {
- DynamicSignatureProfileImpl res = new DynamicSignatureProfileImpl(mode, myUniqueName, configuration);
- res.initFromParent(parentProfile);
- return res;
- }
-
- private void store() {
- if (lifeMode.equals(DynamicSignatureLifetimeEnum.MANUAL)) {
- profiles.put(this.getName(), this);
- } else if (lifeMode.equals(DynamicSignatureLifetimeEnum.AUTO)) {
- localProfiles.set(this);
- }
- }
-
- private void remove() {
- if (lifeMode.equals(DynamicSignatureLifetimeEnum.MANUAL)) {
- profiles.remove(this);
- } else if (lifeMode.equals(DynamicSignatureLifetimeEnum.AUTO)) {
- localProfiles.set(null);
- }
- }
-
- public static void disposeLocalProfile() {
- DynamicSignatureProfileImpl profile = (DynamicSignatureProfileImpl) localProfiles.get();
- if (profile != null) {
- profile.dispose();
- }
- }
-
- public static DynamicSignatureProfileImpl createEmptyProfile(String myUniqueName, DynamicSignatureLifetimeEnum mode,
- Configuration configuration) {
- return new DynamicSignatureProfileImpl(mode, myUniqueName, configuration);
- }
-
- public static DynamicSignatureProfileImpl loadProfile(String name) {
- return (DynamicSignatureProfileImpl) profiles.get(name);
- }
-
- private synchronized String createDynamicTypeName() {
- return "dynprofile__#" + this.dynamicTypeCounter++;
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#getName()
- */
- public String getName() {
- return name;
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#setName(String)
- */
- public void setName(String uniqueName) {
- this.name = uniqueName;
- }
-
- public void setPropertyRaw(String key, String val) {
- this.newProps.setProperty(localPropName(key), val);
- }
-
- public String getPropertyRaw(String key) {
- return this.newProps.getProperty(localPropName(key));
- }
-
- private void assertPropExists(String key) {
- if (!this.newProps.containsKey(localPropName(key))) {
- throw new RuntimeException("property '" + key + "'not existing, cannot add one");
- }
- }
-
- private String localPropName(String key) {
- return "sig_obj." + this.name + "." + key;
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#setFieldValue(java.lang.String, java.lang.String)
- */
- public void setFieldValue(String fieldName, String value) {
- if (SignatureTypes.isRequredSigTypeKey(fieldName)) {
- throw new RuntimeException("cannot set value for pre defined signature field names");
- }
-
- String key = "value." +fieldName;
- assertPropExists(key);
- setPropertyRaw(key, value);
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#getFieldValue(java.lang.String)
- */
- public String getFieldValue(String fieldName) {
- return getPropertyRaw("value."+fieldName);
- }
-
- private void initFromParent(String parentProfile) {
- try {
- ISettings cfg = null;
-
- cfg = (ISettings)configuration;
- String parentKey = "sig_obj." + parentProfile + ".";
- Map<String, String> properties = cfg.getValuesPrefix(parentKey);
- //Properties props = cfg.getProperties();
- // DTI: props.keys() does not support default properties, therefore we should better use props.propertyNames()
-// for (Enumeration e = props.keys(); e.hasMoreElements();) {
- /*for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
- String oldKey = (String) e.nextElement();
- if (oldKey.startsWith("sig_obj." + parentProfile + ".")) {
- String newKey = StringUtils.replace(oldKey, parentProfile, name);
- String val = props.getProperty(oldKey);
- this.newProps.put(newKey, val);
- }
- }*/
-
- Iterator<String> keyIt = properties.keySet().iterator();
-
- while(keyIt.hasNext()) {
- String oldKey = keyIt.next();
- String newKey = oldKey.replaceAll(parentProfile, name);
- String val = properties.get(oldKey);
- this.newProps.put(newKey, val);
- }
-
- this.newProps.put("sig_obj.types." + name, "on");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#register()
- */
- public synchronized void apply() {
- try {
- Configuration cfg = this.configuration;
- for (Enumeration<Object> e = newProps.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- cfg.setValue(key, newProps.getProperty(key));
- }
-
- store();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#dispose()
- */
- public synchronized void dispose() {
- try {
- Configuration cfg = this.configuration;
- for (Enumeration<Object> e = newProps.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- cfg.setValue(key, null);
- }
- remove();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
+/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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. + */ +package at.gv.egiz.pdfas.api.commons; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; + +import at.gv.egiz.pdfas.api.PdfAs; +import at.gv.egiz.pdfas.common.settings.ISettings; +import at.gv.egiz.pdfas.lib.api.Configuration; +import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; + +// TODO exception types? +/** + * Implementation class of the {@link DynamicSignatureProfile}. Don't use this class directly. Use {@link PdfAs} to create and the + * {@link DynamicSignatureProfile} interface for manipulation. + * @author exthex + * + */ +@Deprecated +public class DynamicSignatureProfileImpl implements DynamicSignatureProfile { + private String name; + private Properties newProps = new Properties(); + private int dynamicTypeCounter = 0; + private static Map<String, DynamicSignatureProfile> profiles = + new HashMap<String, DynamicSignatureProfile>(); + private static ThreadLocal<DynamicSignatureProfile> localProfiles = new ThreadLocal<DynamicSignatureProfile>(); + private DynamicSignatureLifetimeEnum lifeMode; + private Configuration configuration; + + private DynamicSignatureProfileImpl(DynamicSignatureLifetimeEnum mode, String name, + Configuration configuration) { + if (name != null) { + this.name = name; + } else { + this.name = createDynamicTypeName(); + } + this.configuration = configuration; + this.lifeMode = mode; + } + + public static DynamicSignatureProfileImpl createFromParent(String myUniqueName, String parentProfile, + DynamicSignatureLifetimeEnum mode, Configuration configuration) { + DynamicSignatureProfileImpl res = new DynamicSignatureProfileImpl(mode, myUniqueName, configuration); + res.initFromParent(parentProfile); + return res; + } + + private void store() { + if (lifeMode.equals(DynamicSignatureLifetimeEnum.MANUAL)) { + profiles.put(this.getName(), this); + } else if (lifeMode.equals(DynamicSignatureLifetimeEnum.AUTO)) { + localProfiles.set(this); + } + } + + private void remove() { + if (lifeMode.equals(DynamicSignatureLifetimeEnum.MANUAL)) { + profiles.remove(this); + } else if (lifeMode.equals(DynamicSignatureLifetimeEnum.AUTO)) { + localProfiles.set(null); + } + } + + public static void disposeLocalProfile() { + DynamicSignatureProfileImpl profile = (DynamicSignatureProfileImpl) localProfiles.get(); + if (profile != null) { + profile.dispose(); + } + } + + public static DynamicSignatureProfileImpl createEmptyProfile(String myUniqueName, DynamicSignatureLifetimeEnum mode, + Configuration configuration) { + return new DynamicSignatureProfileImpl(mode, myUniqueName, configuration); + } + + public static DynamicSignatureProfileImpl loadProfile(String name) { + return (DynamicSignatureProfileImpl) profiles.get(name); + } + + private synchronized String createDynamicTypeName() { + return "dynprofile__#" + this.dynamicTypeCounter++; + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#getName() + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#setName(String) + */ + public void setName(String uniqueName) { + this.name = uniqueName; + } + + public void setPropertyRaw(String key, String val) { + this.newProps.setProperty(localPropName(key), val); + } + + public String getPropertyRaw(String key) { + return this.newProps.getProperty(localPropName(key)); + } + + private void assertPropExists(String key) { + if (!this.newProps.containsKey(localPropName(key))) { + throw new RuntimeException("property '" + key + "'not existing, cannot add one"); + } + } + + private String localPropName(String key) { + return "sig_obj." + this.name + "." + key; + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#setFieldValue(java.lang.String, java.lang.String) + */ + public void setFieldValue(String fieldName, String value) { + if (SignatureTypes.isRequredSigTypeKey(fieldName)) { + throw new RuntimeException("cannot set value for pre defined signature field names"); + } + + String key = "value." +fieldName; + assertPropExists(key); + setPropertyRaw(key, value); + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#getFieldValue(java.lang.String) + */ + public String getFieldValue(String fieldName) { + return getPropertyRaw("value."+fieldName); + } + + private void initFromParent(String parentProfile) { + try { + ISettings cfg = null; + + cfg = (ISettings)configuration; + String parentKey = "sig_obj." + parentProfile + "."; + Map<String, String> properties = cfg.getValuesPrefix(parentKey); + //Properties props = cfg.getProperties(); + // DTI: props.keys() does not support default properties, therefore we should better use props.propertyNames() +// for (Enumeration e = props.keys(); e.hasMoreElements();) { + /*for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { + String oldKey = (String) e.nextElement(); + if (oldKey.startsWith("sig_obj." + parentProfile + ".")) { + String newKey = StringUtils.replace(oldKey, parentProfile, name); + String val = props.getProperty(oldKey); + this.newProps.put(newKey, val); + } + }*/ + + Iterator<String> keyIt = properties.keySet().iterator(); + + while(keyIt.hasNext()) { + String oldKey = keyIt.next(); + String newKey = oldKey.replaceAll(parentProfile, name); + String val = properties.get(oldKey); + this.newProps.put(newKey, val); + } + + this.newProps.put("sig_obj.types." + name, "on"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#register() + */ + public synchronized void apply() { + try { + Configuration cfg = this.configuration; + for (Enumeration<Object> e = newProps.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + cfg.setValue(key, newProps.getProperty(key)); + } + + store(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /* (non-Javadoc) + * @see at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile#dispose() + */ + public synchronized void dispose() { + try { + Configuration cfg = this.configuration; + for (Enumeration<Object> e = newProps.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + cfg.setValue(key, null); + } + remove(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java index 2f5c7d97..413be0ad 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java @@ -1,130 +1,153 @@ -/**
- * <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: SignatureHolder.java,v 1.3 2006/10/11 07:57:58 wprinz Exp $
- */
-package at.gv.egiz.pdfas.api.commons;
-
-import java.security.cert.X509Certificate;
-import java.util.Date;
-import java.util.List;
-
-import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
-import at.gv.egiz.pdfas.api.io.DataSource;
-
-/**
- * Holds the information of one found signature block, which is the signed data
- * and the corresponding signature information.
- *
- * @author wprinz
- */
-@Deprecated
-public interface SignatureInformation
-{
- /**
- * Returns the type of this signature (binary/textual).
- *
- * <p>
- * May be {@link Constants#SIGNATURE_TYPE_BINARY} or
- * {@link Constants#SIGNATURE_TYPE_TEXTUAL}.
- * </p>
- *
- * @return Returns the type of this signature (binary/textual).
- */
- public String getSignatureType();
-
- /**
- * Returns the DataSource providing the data that was signed.
- *
- * <p>
- * Note that this is the signed data as sent to the verification device by
- * PDF-AS. The verification device (e.g. MOA) may perform several other
- * transformations on the data before feeding it to the signature hash
- * function. To get the actual hashed data use the ReturnHashInputData mechanism (which is very slow).
- * </p>
- *
- * @return Returns the DataSource providing the data that was signed.
- *
- * @see at.gv.egiz.pdfas.api.verify.VerifyParameters#setReturnHashInputData(boolean)
- * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getHashInputData()
- *
- */
- public DataSource getSignedData();
-
- /**
- * Returns the certificate of the signer.
- *
- * <p>
- * Information like subject name, issuer name or serial number can be
- * retrieved form this certificate.
- * </p>
- *
- * @return Returns the certificate of the signer.
- */
- public X509Certificate getSignerCertificate();
-
- /**
- * Returns the signing time, which is the time when the signature was created.
- *
- * @return Returns the signing time, which is the time when the signature was
- * created.
- */
- public Date getSigningTime();
-
- /**
- * Returns additional, internal information about the found signature.
- *
- * <p>
- * Note that this provides a way for developers to gather core information
- * about the signature. What information is returned strongly depends on the
- * core implementation.
- * </p>
- *
- * @return Returns additional, internal information about the signature. Null
- * means that no additional information is available.
- */
- public Object getInternalSignatureInformation();
-
- /**
- * Returns the embedded /TimeStamp value (b64 encoded) from the signature if available.
- * @return
- */
- public String getTimeStampValue();
-
- /**
- * Returns a list<{@link NonTextObjectInfo}> of non textual objects in the pdf document.
- * Only available for textual signatures. Show this to the user who signed the textual content only!
- * @return List<{@link NonTextObjectInfo} or <tt>null</tt> of not available (binary signature)
- */
- public List getNonTextualObjects();
-
- public void setNonTextualObjects(List nonTextualObjects);
-
- /**
- * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
- * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
- */
- public boolean hasNonTextualObjects();
-
-
-}
\ No newline at end of file +/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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: SignatureHolder.java,v 1.3 2006/10/11 07:57:58 wprinz Exp $ + */ +package at.gv.egiz.pdfas.api.commons; + +import java.security.cert.X509Certificate; +import java.util.Date; +import java.util.List; + +import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo; +import at.gv.egiz.pdfas.api.io.DataSource; + +/** + * Holds the information of one found signature block, which is the signed data + * and the corresponding signature information. + * + * @author wprinz + */ +@Deprecated +public interface SignatureInformation +{ + /** + * Returns the type of this signature (binary/textual). + * + * <p> + * May be {@link Constants#SIGNATURE_TYPE_BINARY} or + * {@link Constants#SIGNATURE_TYPE_TEXTUAL}. + * </p> + * + * @return Returns the type of this signature (binary/textual). + */ + public String getSignatureType(); + + /** + * Returns the DataSource providing the data that was signed. + * + * <p> + * Note that this is the signed data as sent to the verification device by + * PDF-AS. The verification device (e.g. MOA) may perform several other + * transformations on the data before feeding it to the signature hash + * function. To get the actual hashed data use the ReturnHashInputData mechanism (which is very slow). + * </p> + * + * @return Returns the DataSource providing the data that was signed. + * + * @see at.gv.egiz.pdfas.api.verify.VerifyParameters#setReturnHashInputData(boolean) + * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getHashInputData() + * + */ + public DataSource getSignedData(); + + /** + * Returns the certificate of the signer. + * + * <p> + * Information like subject name, issuer name or serial number can be + * retrieved form this certificate. + * </p> + * + * @return Returns the certificate of the signer. + */ + public X509Certificate getSignerCertificate(); + + /** + * Returns the signing time, which is the time when the signature was created. + * + * @return Returns the signing time, which is the time when the signature was + * created. + */ + public Date getSigningTime(); + + /** + * Returns additional, internal information about the found signature. + * + * <p> + * Note that this provides a way for developers to gather core information + * about the signature. What information is returned strongly depends on the + * core implementation. + * </p> + * + * @return Returns additional, internal information about the signature. Null + * means that no additional information is available. + */ + public Object getInternalSignatureInformation(); + + /** + * Returns the embedded /TimeStamp value (b64 encoded) from the signature if available. + * @return + */ + public String getTimeStampValue(); + + /** + * Returns a list<{@link NonTextObjectInfo}> of non textual objects in the pdf document. + * Only available for textual signatures. Show this to the user who signed the textual content only! + * @return List<{@link NonTextObjectInfo} or <tt>null</tt> of not available (binary signature) + */ + public List getNonTextualObjects(); + + public void setNonTextualObjects(List nonTextualObjects); + + /** + * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not. + * @return <code>true</code> if non textual objects have been found, <code>false</code> if not. + */ + public boolean hasNonTextualObjects(); + + +} diff --git a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java index def2d820..f23ce5a0 100644 --- a/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java +++ b/pdf-as-legacy/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureProfile.java @@ -1,88 +1,111 @@ -/**
- * <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.
- */
-package at.gv.egiz.pdfas.api.commons;
-
-import java.util.Properties;
-
-import at.knowcenter.wag.egov.egiz.sig.SignatureTypes.State;
-
-/**
- * Definition of a signature profile.
- *
- * @author wprinz
- */
-@Deprecated
-public interface SignatureProfile {
-
- // TODO: implement full profile support
-
- /**
- * Returns the profile id.
- *
- * @return Returns the profile id.
- */
- public String getProfileId();
-
- /**
- * Returns the MOA KeyIdentifier.
- *
- * @return Returns the MOA KeyIdentifier.
- */
- public String getMOAKeyIdentifier();
-
- /**
- * Returns the entries relevant to the search algorithm for signature blocks.<br/>
- * e.g. properties starting with <code>sig_obj.PROFILE.key.</code> and
- * properties of the form <code>sig_obj.PROFILE.table.TABLENAME.NUMBER</code>
- * where <code>PROFILE</code> is the name of the current profile,
- * <code>TABLENAME</code> is the name of a table and <code>NUMBER</code>
- * is the number of the specific row within the table <code>TABLENAME</code>.
- *
- * @return The entries relevant to the signature block search algorithm as
- * Java properties.
- */
- public Properties getSignatureBlockEntries();
-
- /**
- * Returns the profile description.
- *
- * @return The profile description.
- */
- public String getProfileDescription();
-
- /**
- * True only if this is the default profile according to config.
- * @return
- */
- public boolean isDefault();
-
- /**
- * Returns the state of the signature profile. Signature profiles may be restricted to signature (
- * {@link State#SIGN_ONLY}) or to verification ({@link State#VERIFY_ONLY}).
- *
- * @return The state of the profile.
- */
- public State getState();
-
-}
+/******************************************************************************* + * <copyright> Copyright 2014 by E-Government Innovation Center EGIZ, 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. + ******************************************************************************/ +/** + * <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. + */ +package at.gv.egiz.pdfas.api.commons; + +import java.util.Properties; + +import at.knowcenter.wag.egov.egiz.sig.SignatureTypes.State; + +/** + * Definition of a signature profile. + * + * @author wprinz + */ +@Deprecated +public interface SignatureProfile { + + // TODO: implement full profile support + + /** + * Returns the profile id. + * + * @return Returns the profile id. + */ + public String getProfileId(); + + /** + * Returns the MOA KeyIdentifier. + * + * @return Returns the MOA KeyIdentifier. + */ + public String getMOAKeyIdentifier(); + + /** + * Returns the entries relevant to the search algorithm for signature blocks.<br/> + * e.g. properties starting with <code>sig_obj.PROFILE.key.</code> and + * properties of the form <code>sig_obj.PROFILE.table.TABLENAME.NUMBER</code> + * where <code>PROFILE</code> is the name of the current profile, + * <code>TABLENAME</code> is the name of a table and <code>NUMBER</code> + * is the number of the specific row within the table <code>TABLENAME</code>. + * + * @return The entries relevant to the signature block search algorithm as + * Java properties. + */ + public Properties getSignatureBlockEntries(); + + /** + * Returns the profile description. + * + * @return The profile description. + */ + public String getProfileDescription(); + + /** + * True only if this is the default profile according to config. + * @return + */ + public boolean isDefault(); + + /** + * Returns the state of the signature profile. Signature profiles may be restricted to signature ( + * {@link State#SIGN_ONLY}) or to verification ({@link State#VERIFY_ONLY}). + * + * @return The state of the profile. + */ + public State getState(); + +} |