From 535a04fa05f739ec16dd81666e3b0f82dfbd442d Mon Sep 17 00:00:00 2001 From: tknall Date: Wed, 9 Jan 2013 15:41:29 +0000 Subject: 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 --- .../at/gv/egiz/pdfas/impl/api/CheckHelper.java | 284 ------- .../at/gv/egiz/pdfas/impl/api/PdfAsObject.java | 865 --------------------- .../java/at/gv/egiz/pdfas/impl/api/PosHelper.java | 99 --- .../pdfas/impl/api/analyze/AnalyzeResultImpl.java | 116 --- .../pdfas/impl/api/commons/DataSinkAdapter.java | 103 --- .../impl/api/commons/DataSourceApiAdapter.java | 105 --- .../impl/api/commons/PdfDataSourceAdapter.java | 72 -- .../api/commons/SignatureInformationAdapter.java | 133 ---- .../impl/api/commons/SignatureProfileImpl.java | 158 ---- .../api/commons/TextBasedDataSourceApiAdapter.java | 92 --- .../impl/api/commons/TextDataSourceAdapter.java | 72 -- .../impl/api/internal/PdfAsInternalObject.java | 362 --------- .../api/sign/ActualSignaturePositionAdapter.java | 93 --- .../egiz/pdfas/impl/api/sign/SignResultImpl.java | 115 --- .../api/sign/SignatureDetailInformationImpl.java | 190 ----- .../pdfas/impl/api/verify/SignatureCheckImpl.java | 71 -- .../pdfas/impl/api/verify/VerifyResultAdapter.java | 205 ----- .../pdfas/impl/api/verify/VerifyResultsImpl.java | 60 -- 18 files changed, 3195 deletions(-) delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/PosHelper.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/sign/ActualSignaturePositionAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignResultImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignatureDetailInformationImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/verify/SignatureCheckImpl.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java (limited to 'src/main/java/at/gv/egiz/pdfas/impl/api') diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java b/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java deleted file mode 100644 index ee2166e..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java +++ /dev/null @@ -1,284 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.io.DataSource; -import at.gv.egiz.pdfas.api.sign.SignParameters; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning; -import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters; -import at.gv.egiz.pdfas.api.verify.VerifyParameters; -import at.gv.egiz.pdfas.framework.signator.SignatorInformation; -import at.gv.egiz.pdfas.impl.api.sign.SignatureDetailInformationImpl; -import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; -import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException; -import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; - -/** - * Contains check methods frequently used by the {@link PdfAsObject} to check - * input parameters. - * - * @author wprinz - * - */ -public final class CheckHelper -{ - /** - * The log. - */ - private static Log log = LogFactory.getLog(CheckHelper.class); - - /** - * Hidden default constructor. - */ - private CheckHelper() - { - // empty block - } - - /** - * Checks the SignParameters for integrity. - * This is a shortcut to {@link CheckHelper#checkSignParameters(SignParameters, false)} - * - * @param sp - * The {@link SignParameters} - */ - public static void checkSignParameters(SignParameters sp){ - checkSignParameters(sp, false); - } - - /** - * Checks the SignParameters for integrity. - * - * @param sp - * The {@link SignParameters} - * @param allowAllDevices if true, no check for non local BKUs will be done - */ - public static void checkSignParameters(SignParameters sp, boolean allowAllDevices) - { - if (sp == null) - { - throw new IllegalArgumentException("The signParameters must not be null."); - } - - checkDocument(sp.getDocument()); - if (sp.getOutput() == null) - { - throw new IllegalArgumentException("The output DataSink must not be null."); - } - checkSignatureType(sp.getSignatureType()); - if (!allowAllDevices) - checkSignatureDevice(sp.getSignatureDevice()); - if (sp.getSignatureProfileId() != null) - { - checkProfileId(sp.getSignatureProfileId()); - } - if (sp.getSignaturePositioning() != null) - { - checkSignaturePositioning(sp.getSignaturePositioning()); - } - checkSignatureKeyIdentifier(sp.getSignatureKeyIdentifier(), sp.getSignatureDevice()); - checkTimestampHandler(sp); - } - - /** - * Checks the VerifyParameters for integrity. - * - * @param vp - * The {@link VerifyParameters} - */ - public static void checkVerifyParameters(VerifyParameters vp) - { - if (vp == null) - { - throw new IllegalArgumentException("The verifyParameters must not be null."); - } - - checkDocument(vp.getDocument()); - checkVerifyMode(vp.getVerifyMode()); - checkSignatureDevice(vp.getSignatureDevice()); - if (vp.getSignatureToVerify() < Constants.VERIFY_ALL) - { - throw new IllegalArgumentException("The signatureToVerify parameter is incorrect. " + vp.getSignatureToVerify()); - } - } - - /** - * Checks the AnalyzeParameters for integrity. - * - * @param ap - * The {@link AnalyzeParameters} - */ - public static void checkAnalyzeParameters(AnalyzeParameters ap) - { - if (ap == null) - { - throw new IllegalArgumentException("The analyzeParameters must not be null."); - } - - checkDocument(ap.getDocument()); - checkVerifyMode(ap.getVerifyMode()); - } - - /** - * Checks the VerifyAfterAnalysisParameters for integrity. - * - * @param vaap - * The {@link VerifyAfterAnalysisParameters} - */ - public static void checkVerifyAfterAnalysisParameters(VerifyAfterAnalysisParameters vaap) - { - if (vaap == null) - { - throw new IllegalArgumentException("The analyzeParameters must not be null."); - } - - if (vaap.getAnalyzeResult() == null) - { - throw new IllegalArgumentException("The analyzeResult must not be null."); - } - checkSignatureDevice(vaap.getSignatureDevice()); - } - - protected static void checkDocument(DataSource document) - { - if (document == null) - { - throw new IllegalArgumentException("The document DataSource must not be null."); - } - } - - protected static void checkSignatureType(String signatureType) - { - if (signatureType == null) - { - throw new IllegalArgumentException("The signatureType must not be null."); - } - if (!(signatureType.equals(Constants.SIGNATURE_TYPE_BINARY) || signatureType.equals(Constants.SIGNATURE_TYPE_TEXTUAL) || signatureType.equals(Constants.SIGNATURE_TYPE_DETACHEDTEXTUAL))) - { - throw new IllegalArgumentException("The signatureType must be one of the Constants.SIGNATURE_TYPE_* constants. " + signatureType); - } - } - - protected static void checkTimestampHandler(SignParameters params) { - if (params.getTimeStamperImpl() != null && !Constants.SIGNATURE_TYPE_BINARY.equals(params.getSignatureType())) { - throw new IllegalArgumentException("timestamping is only allowed for binary signatures "); - } - } - - protected static void checkProfileId(String profileId) - { - if (profileId == null) - { - throw new IllegalArgumentException("The profileId must not be null."); - } - try - { - if (!SignatureTypes.getInstance().getSignatureTypes().contains(profileId)) - { - throw new IllegalArgumentException("The profileId \"" + profileId + "\" must be defined (code or configuration file.)"); - } - } - catch (SignatureTypesException e) - { - String msg = "Error while checking the profileId parameter - cannot get list of valid profiles. " + profileId; - log.error(msg, e); - throw new IllegalArgumentException(msg); - } - } - - protected static void checkSignaturePositioning(SignaturePositioning signaturePositioning) - { - if (signaturePositioning == null) - { - throw new IllegalArgumentException("The signaturePosition must not be null."); - } - try - { - PosHelper.formTablePos(signaturePositioning); - } - catch (PDFDocumentException e) - { - String msg = "The signaturePosition is not valid. Please check the provided parameters."; - log.error(msg, e); - throw new IllegalArgumentException(msg); - } - } - - protected static void checkSignatureKeyIdentifier (String signatureKeyIdentifier, String signatureDevice) - { - if (signatureKeyIdentifier != null && !Constants.SIGNATURE_DEVICE_MOA.equals(signatureDevice)) - { - log.warn("A signatureKeyIdentifier (" + signatureKeyIdentifier + ") was provided although the signatureDevice (" + signatureDevice + ") is not moa. Currently only the moa signature device evaluates the signatureKeyIdentifier parameter."); - } - } - - protected static void checkVerifyMode(String verifyMode) - { - if (verifyMode == null) - { - throw new IllegalArgumentException("The verifyMode must not be null."); - } - if (!(verifyMode.equals(Constants.VERIFY_MODE_BINARY_ONLY) || verifyMode.equals(Constants.VERIFY_MODE_SEMI_CONSERVATIVE) || verifyMode.equals(Constants.VERIFY_MODE_FULL_CONSERVATIVE))) - { - throw new IllegalArgumentException("The verifyMode must be one of the Constants.VERIFY_MODE_* constants. " + verifyMode); - } - } - - protected static void checkSignatureDevice(String signatureDevice) - { - if (signatureDevice == null) - { - throw new IllegalArgumentException("The signatureDevice must not be null."); - } - if (!(signatureDevice.equals(Constants.SIGNATURE_DEVICE_BKU) || signatureDevice.equals(Constants.SIGNATURE_DEVICE_MOA))) - { - throw new IllegalArgumentException("The signatureDevice must be one of the Constants.SIGNATURE_DEVICE_* constants. " + signatureDevice); - } - } - - protected static void checkSignParametersForSignAfterPrepare(SignParameters signParameters, boolean allowAllDevices) { - checkSignParameters(signParameters, allowAllDevices); - checkProfileId(signParameters.getSignatureProfileId()); - } - - public static void checkSignatorInformation(SignatorInformation signatorInfo) { - if (signatorInfo.getSignSignatureObject() == null) - { - throw new IllegalArgumentException("The signatorInformation.getSignSignatureObject() must not be null."); - } - } - - public static void checkSignatureDetailInformation(SignatureDetailInformation signatureDetailInformation) { - if (!(signatureDetailInformation instanceof SignatureDetailInformationImpl)){ - throw new IllegalArgumentException("SignatureDetailInformation is of unsupported type. Must be " + SignatureDetailInformationImpl.class.getName()); - } - - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java deleted file mode 100644 index eda94c0..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java +++ /dev/null @@ -1,865 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api; - -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Vector; - -import org.apache.commons.lang.math.NumberUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; -import at.gv.egiz.pdfas.api.analyze.AnalyzeResult; -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.commons.DynamicSignatureLifetimeEnum; -import at.gv.egiz.pdfas.api.commons.DynamicSignatureProfile; -import at.gv.egiz.pdfas.api.commons.DynamicSignatureProfileImpl; -import at.gv.egiz.pdfas.api.commons.SignatureInformation; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.sign.SignParameters; -import at.gv.egiz.pdfas.api.sign.SignResult; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters; -import at.gv.egiz.pdfas.api.verify.VerifyAfterReconstructXMLDsigParameters; -import at.gv.egiz.pdfas.api.verify.VerifyParameters; -import at.gv.egiz.pdfas.api.verify.VerifyResult; -import at.gv.egiz.pdfas.api.verify.VerifyResults; -import at.gv.egiz.pdfas.api.xmldsig.ExtendedSignatureInformation; -import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigAfterAnalysisParameters; -import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigParameters; -import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigResult; -import at.gv.egiz.pdfas.api.xmldsig.XMLDsigData; -import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser; -import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.gv.egiz.pdfas.exceptions.framework.PlaceholderExtractionException; -import at.gv.egiz.pdfas.framework.ConnectorParameters; -import at.gv.egiz.pdfas.framework.DataSourceHolder; -import at.gv.egiz.pdfas.framework.config.SettingsHelper; -import at.gv.egiz.pdfas.framework.input.ExtractionStage; -import at.gv.egiz.pdfas.framework.input.PdfDataSource; -import at.gv.egiz.pdfas.framework.signator.Signator; -import at.gv.egiz.pdfas.framework.signator.SignatorInformation; -import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters; -import at.gv.egiz.pdfas.impl.api.analyze.AnalyzeResultImpl; -import at.gv.egiz.pdfas.impl.api.commons.DataSinkAdapter; -import at.gv.egiz.pdfas.impl.api.commons.PdfDataSourceAdapter; -import at.gv.egiz.pdfas.impl.api.commons.SignatureInformationAdapter; -import at.gv.egiz.pdfas.impl.api.commons.SignatureProfileImpl; -import at.gv.egiz.pdfas.impl.api.commons.TextDataSourceAdapter; -import at.gv.egiz.pdfas.impl.api.sign.ActualSignaturePositionAdapter; -import at.gv.egiz.pdfas.impl.api.sign.SignResultImpl; -import at.gv.egiz.pdfas.impl.api.sign.SignatureDetailInformationImpl; -import at.gv.egiz.pdfas.impl.api.verify.VerifyResultAdapter; -import at.gv.egiz.pdfas.impl.api.verify.VerifyResultsImpl; -import at.gv.egiz.pdfas.impl.input.DelimitedPdfDataSource; -import at.gv.egiz.pdfas.impl.vfilter.VerificationFilterParametersImpl; -import at.gv.egiz.pdfas.impl.xmldsig.XMLDsigReconstructor; -import at.gv.egiz.pdfas.placeholder.SignaturePlaceholderContext; -import at.gv.egiz.pdfas.placeholder.SignaturePlaceholderData; -import at.gv.egiz.pdfas.placeholder.SignaturePlaceholderExtractor; -import at.gv.egiz.pdfas.utils.ConfigUtils; -import at.knowcenter.wag.egov.egiz.PdfAS; -import at.knowcenter.wag.egov.egiz.PdfASID; -import at.knowcenter.wag.egov.egiz.cfg.OverridePropertyHolder; -import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; -import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; -import at.knowcenter.wag.egov.egiz.exceptions.OutOfMemoryException; -import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; -import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; -import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; -import at.knowcenter.wag.egov.egiz.exceptions.SignatorFactoryException; -import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; -import at.knowcenter.wag.egov.egiz.framework.SignatorFactory; -import at.knowcenter.wag.egov.egiz.pdf.AdobeSignatureHelper; -import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.NoSignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.ObjectExtractor; -import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.TablePos; -import at.knowcenter.wag.egov.egiz.pdf.TextualSignatureHolder; -import at.knowcenter.wag.egov.egiz.sig.SignatureData; -import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl; -import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; -import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition; -import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; -import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; - -/** - * Implementation of the {@link PdfAs} interface. - * - * @author wprinz - */ -public class PdfAsObject implements PdfAs -{ -//23.11.2010 changed by exthex - added methods for reconstructXMLDsig - - /** - * The log. - */ - private static Log log = LogFactory.getLog(PdfAsObject.class); - - private static final String ENABLE_PLACEHOLDER_SEARCH_KEY = "enable_placeholder_search"; - - /** - * Configuration key for minimal signature block width threshold. Any width below this certain value will lead to a warning log entry." - */ - private static final String SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY = "signature_block_width_warning_threshold"; - - /** - * Minimal signature block width. If a width below that value is defined (by parameter, by placeholder or by configuration) a warning log entry is created. - */ - public static final float DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD = 150; - - - /** - * This constructor is for internal use only - use - * {@link at.gv.egiz.pdfas.PdfAsFactory} instead. - * Note: IAIK JCE and IAIK ECC security providers are automatically registered. - * - * @param workDirectory - * The work directory. - * @throws PdfAsException - * Thrown, if the configuration cannot be processed. - */ - public PdfAsObject(File workDirectory) throws PdfAsException - { - this(workDirectory, SettingsReader.REGISTER_IAIK_PROVIDERS_ON_DEFAULT); - } - - /** - * This constructor is for internal use only - use - * {@link at.gv.egiz.pdfas.PdfAsFactory} instead. - * - * @param workDirectory - * The work directory. - * @param registerProvider true: automatically registers IAIK JCE and ECC Provider; - * false: providers will NOT be automatically registered, providers - * needed have to be registered by the API user - * @throws PdfAsException - * Thrown, if the configuration cannot be processed. - */ - public PdfAsObject(File workDirectory, boolean registerProvider) throws PdfAsException - { - String path = workDirectory != null ? workDirectory.getPath() : null; - SettingsReader.initialize(path, path); - reloadConfig(registerProvider); - } - - /** - * This constructor is for internal use only - use - * {@link at.gv.egiz.pdfas.PdfAsFactory} instead. - * Note: IAIK JCE and IAIK ECC security providers are automatically registered. - * - * @throws PdfAsException - * Thrown, if the configuration cannot be processed. - */ - public PdfAsObject() throws PdfAsException - { - this(null); - } - - /** - * @see at.gv.egiz.pdfas.api.PdfAs#reloadConfig() - */ - public void reloadConfig() throws PdfAsException - { - ConfigUtils.initializeLogger(); - SettingsReader.createInstance(); - SignatureTypes.createInstance(); - } - - /** - * @param registerProvider true: automatically registers IAIK JCE and ECC Provider; - * false: providers will NOT be automatically registered, providers - * needed have to be registered by the API user - * @see at.gv.egiz.pdfas.api.PdfAs#reloadConfig() - */ - private void reloadConfig(boolean registerProvider) throws PdfAsException - { - ConfigUtils.initializeLogger(); - SettingsReader.createInstance(registerProvider); - SignatureTypes.createInstance(); - } - - /** - * @see at.gv.egiz.pdfas.api.PdfAs#getProfileInformation() - */ - public List getProfileInformation() throws PdfAsException - { - log.debug("Collecting profile information."); - final String MOA_SIGN_KEY_IDENTIFIER_KEY = "moa.sign.KeyIdentifier"; - - SettingsReader settings = SettingsReader.getInstance(); - final String defaultMoaKeyIdentifiert = settings.getSetting(MOA_SIGN_KEY_IDENTIFIER_KEY, null); - - SignatureTypes types = SignatureTypes.getInstance(); - List profiles = types.getSignatureTypeDefinitions(); - - List profileInformation = new ArrayList(profiles.size()); - - String default_type = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE); - - Iterator it = profiles.iterator(); - while (it.hasNext()) - { - SignatureTypeDefinition profile = (SignatureTypeDefinition) it.next(); - - final String profileId = profile.getType(); - log.debug("Processing profile \"" + profileId + "\"."); - final String moaKeyIdentifier = settings.getSetting("sig_obj." + profileId + "." + MOA_SIGN_KEY_IDENTIFIER_KEY, defaultMoaKeyIdentifiert); - final String profileDescription = settings.getSetting("sig_obj." + profileId + "." + SignatureTypes.SIG_DESCR, null); - - boolean isDefault = (default_type != null && default_type.equals(profileId)); - // modified by tknall - SignatureProfileImpl signatureProfile = new SignatureProfileImpl(profileId, profileDescription, moaKeyIdentifier, isDefault); - - // start - added by tknall - - // signature entries relevant to the search algorithm - Properties signatureEntries = new Properties(); - - // search for table entries - String parentPropertyKey = "sig_obj." + profileId + ".table"; - log.debug("Looking for subkeys of \"" + parentPropertyKey + "\"."); - Vector keysVector = settings.getSettingKeys(parentPropertyKey); - if (keysVector != null) { - Iterator keyIt = keysVector.iterator(); - while (keyIt.hasNext()) { - String subKey = (String) keyIt.next(); - if (subKey != null && subKey.length() > 0) { - String fullKey = parentPropertyKey + "." + subKey; - String value = settings.getValueFromKey(fullKey); - int lastIndex = fullKey.lastIndexOf("."); - if (lastIndex != -1) { - String endsWith = fullKey.substring(lastIndex + 1); - if (value != null && value.length() > 0) { - if (NumberUtils.isDigits(endsWith)) { - signatureEntries.setProperty(fullKey, value); - } else { - log.debug("Ignoring table entry \"" + fullKey + "\" because it does not end with a digit. Therefore it is not relevant for the seach algorithm."); - } - } else { - log.warn("Problem detected with key \"" + fullKey + "\". The value is empty."); - } - } - } - } - } - - // search for table entries - parentPropertyKey = "sig_obj." + profileId + ".key"; - log.debug("Looking for subkeys of \"" + parentPropertyKey + "\"."); - keysVector = settings.getSettingKeys(parentPropertyKey); - if (keysVector != null) { - Iterator keyIt = keysVector.iterator(); - while (keyIt.hasNext()) { - String subKey = (String) keyIt.next(); - if (subKey != null && subKey.length() > 0) { - String fullKey = parentPropertyKey + "." + subKey; - String value = settings.getValueFromKey(fullKey); - if (value != null && value.length() > 0) { - signatureEntries.setProperty(fullKey, value); - } else { - log.warn("Problem detected with key \"" + fullKey + "\". The value is empty."); - } - } - } - } - - // set properties - signatureProfile.setSignatureBlockEntries(signatureEntries); - - // stop - added by tknall - - profileInformation.add(signatureProfile); - } - - return profileInformation; - } - - /** - * @see at.gv.egiz.pdfas.api.PdfAs#sign(at.gv.egiz.pdfas.api.sign.SignParameters) - */ - public SignResult sign(SignParameters signParameters) throws PdfAsException - { - CheckHelper.checkSignParameters(signParameters, false); - - try { - SignatureDetailInformation signatorInfo = prepareSign(signParameters); - - return sign(signParameters, signatorInfo); - - } catch (java.lang.OutOfMemoryError e) { - throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e); - } - - } - - /** - * @see at.gv.egiz.pdfas.api.PdfAs#verify(at.gv.egiz.pdfas.api.verify.VerifyParameters) - */ - public VerifyResults verify(VerifyParameters verifyParameters) throws PdfAsException - { - CheckHelper.checkVerifyParameters(verifyParameters); - - AnalyzeParameters ap = new AnalyzeParameters(); - fillAnalyzeParametersWithVerifyParameters(ap, verifyParameters); - AnalyzeResult analyzeResult = analyze(ap); - - if (verifyParameters.getSignatureToVerify() != Constants.VERIFY_ALL) - { - if (verifyParameters.getSignatureToVerify() >= analyzeResult.getSignatures().size()) - { - throw new SignatureException(312, "The selected signature to be verified doesn't exist. " + verifyParameters.getSignatureToVerify()); - } - - Object stv = analyzeResult.getSignatures().get(verifyParameters.getSignatureToVerify()); - List selectedSignature = new ArrayList(1); - selectedSignature.add(stv); - analyzeResult = new AnalyzeResultImpl(selectedSignature); - } - - VerifyAfterAnalysisParameters vaap = new VerifyAfterAnalysisParameters(); - vaap.setAnalyzeResult(analyzeResult); - fillVerifyAfterAnalysisParametersWithVerifyParameters(vaap, verifyParameters); - VerifyResults res = verify(vaap); - - return res; - - } - - - /** - * Copies all adequate parameters from the {@link VerifyParameters} to the - * {@link AnalyzeParameters}. - * - * @param ap - * The {@link AnalyzeParameters}. - * @param vp - * The {@link VerifyParameters}. - */ - protected void fillAnalyzeParametersWithVerifyParameters(AnalyzeParameters ap, VerifyParameters vp) - { - ap.setDocument(vp.getDocument()); - ap.setVerifyMode(vp.getVerifyMode()); - ap.setReturnNonTextualObjects(vp.isReturnNonTextualObjects()); - } - - protected void fillAnalyzeParametersWithReconstructXMLDsigParameters(AnalyzeParameters ap, ReconstructXMLDsigParameters rxp) - { - ap.setDocument(rxp.getDocument()); - ap.setVerifyMode(rxp.getVerifyMode()); - ap.setReturnNonTextualObjects(rxp.isReturnNonTextualObjects()); - } - - /** - * Copies all adequate parameters from the {@link VerifyParameters} to the - * {@link VerifyAfterAnalysisParameters}. - * - * @param vaap - * The {@link VerifyAfterAnalysisParameters}. - * @param vp - * The {@link VerifyParameters}. - */ - protected void fillVerifyAfterAnalysisParametersWithVerifyParameters(VerifyAfterAnalysisParameters vaap, VerifyParameters vp) - { - vaap.setSignatureDevice(vp.getSignatureDevice()); - vaap.setVerificationTime(vp.getVerificationTime()); - vaap.setReturnHashInputData(vp.isReturnHashInputData()); - } - - - protected void fillReconstructXMLDsigAfterAnalysisParametersWithVerifyAfterAnalysisParameters( - ReconstructXMLDsigAfterAnalysisParameters reconstructParams, - VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) { - reconstructParams.setAnalyzeResult(verifyAfterAnalysisParameters.getAnalyzeResult()); - reconstructParams.setSignatureDevice(verifyAfterAnalysisParameters.getSignatureDevice()); - } - - /** - * @see at.gv.egiz.pdfas.api.PdfAs#analyze(at.gv.egiz.pdfas.api.analyze.AnalyzeParameters) - */ - public AnalyzeResult analyze(AnalyzeParameters analyzeParameters) throws PdfAsException - { - CheckHelper.checkAnalyzeParameters(analyzeParameters); - - VerificationFilterParameters parametersConfig = SettingsHelper.readVerificationFilterParametersFromSettings(); - boolean binaryOnly = parametersConfig.extractBinarySignaturesOnly(); - if (analyzeParameters.getVerifyMode().equals(Constants.VERIFY_MODE_BINARY_ONLY)) - { - binaryOnly = true; - } - boolean assumeOnlySB = parametersConfig.assumeOnlySignatureUpdateBlocks(); - if (analyzeParameters.getVerifyMode().equals(Constants.VERIFY_MODE_SEMI_CONSERVATIVE)) - { - assumeOnlySB = true; - } - if (analyzeParameters.getVerifyMode().equals(Constants.VERIFY_MODE_FULL_CONSERVATIVE)) - { - assumeOnlySB = false; - } - VerificationFilterParameters parameters = new VerificationFilterParametersImpl(binaryOnly, assumeOnlySB, parametersConfig.scanForOldSignatures()); - - at.gv.egiz.pdfas.framework.input.DataSource inputDataSource = null; - if (analyzeParameters.getDocument().getMimeType().equals("application/pdf")) - { - inputDataSource = new PdfDataSourceAdapter(analyzeParameters.getDocument()); - } - else - { - try - { - inputDataSource = new TextDataSourceAdapter(analyzeParameters.getDocument()); - } - catch (UnsupportedEncodingException e) - { - throw new PresentableException(ErrorCode.DOCUMENT_CANNOT_BE_READ, "The characterEncoding is not supported." + analyzeParameters.getDocument().getCharacterEncoding(), e); - } - } - assert inputDataSource != null; - - try { - ExtractionStage es = new ExtractionStage(); - DataSourceHolder dsh = new DataSourceHolder(inputDataSource); - List signature_holders = es.extractSignatureHolders(dsh, parameters); - - - // List sigInfs = new ArrayList(signature_holders.size()); - List sigInfs = new ArrayList(); - List noSigs = new ArrayList(); - Iterator it = signature_holders.iterator(); - while (it.hasNext()) - { - SignatureHolder sh = (SignatureHolder)it.next(); - - if(sh instanceof NoSignatureHolder) { - noSigs.add(sh); - } else { - - SignatureInformation si = new SignatureInformationAdapter(sh); - sigInfs.add(si); - if (analyzeParameters.isReturnNonTextualObjects()) { - si.setNonTextualObjects(doExtractNonTexualObjects(sh, (PdfDataSource) dsh.getDataSource())); - } - - } - } - return new AnalyzeResultImpl(sigInfs, noSigs, parameters.hasBeenCorrected()); - } catch (java.lang.OutOfMemoryError e) { - throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e); - } - - } - - private List doExtractNonTexualObjects(SignatureHolder sh, PdfDataSource pdfDataSource) { - if (sh == null) return null; - if (sh instanceof BinarySignatureHolder) { - BinarySignatureHolder bsh = (BinarySignatureHolder)sh; - return ObjectExtractor.extractNonTextInfo(bsh.getSignedPdf()); - } else if (sh instanceof TextualSignatureHolder) { - TextualSignatureHolder tsh = (TextualSignatureHolder)sh; - if (tsh.getUiBlockEndPos() == 0) { - log.warn("uiblockendpos not available. Extract objects from final pdf document"); - return ObjectExtractor.extractNonTextInfo(pdfDataSource); - } - DelimitedPdfDataSource dpds = new DelimitedPdfDataSource(pdfDataSource, tsh.getUiBlockEndPos()); - return ObjectExtractor.extractNonTextInfo(dpds); - } else { - return null; - } - } - -/** - * @see at.gv.egiz.pdfas.api.PdfAs#verify(at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters) - */ - public VerifyResults verify(VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) throws PdfAsException - { - CheckHelper.checkVerifyAfterAnalysisParameters(verifyAfterAnalysisParameters); - - List signatures = verifyAfterAnalysisParameters.getAnalyzeResult().getSignatures(); - - // added by tknall - if (signatures == null || signatures.isEmpty()) { - throw new PDFDocumentException(ErrorCode.DOCUMENT_NOT_SIGNED, "PDF document not signed."); //$NON-NLS-1$ - } - - ReconstructXMLDsigAfterAnalysisParameters rxaap = new ReconstructXMLDsigAfterAnalysisParameters(); - fillReconstructXMLDsigAfterAnalysisParametersWithVerifyAfterAnalysisParameters(rxaap, verifyAfterAnalysisParameters); - ReconstructXMLDsigResult reconstructResult = reconstructXMLDSIG(rxaap); - - VerifyAfterReconstructXMLDsigParameters varxp = new VerifyAfterReconstructXMLDsigParameters(); - fillVerifyAfterReconstructXMLDsigParametersWithVerifyAfterAnalysisParameters(varxp, verifyAfterAnalysisParameters); - varxp.setReconstructXMLDsigResult(reconstructResult); - - return verify(varxp); - - } - - protected void fillVerifyAfterReconstructXMLDsigParametersWithVerifyAfterAnalysisParameters( - VerifyAfterReconstructXMLDsigParameters varxp, - VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) { - varxp.setReturnHashInputData(verifyAfterAnalysisParameters.isReturnHashInputData()); - varxp.setSignatureDevice(verifyAfterAnalysisParameters.getSignatureDevice()); - varxp.setVerificationTime(verifyAfterAnalysisParameters.getVerificationTime()); - varxp.setVerifySignatureIndex(verifyAfterAnalysisParameters.getVerifySignatureIndex()); - } - - /** - * @see PdfAs#reconstructXMLDSIG(ReconstructXMLDsigParameters) - */ - public ReconstructXMLDsigResult reconstructXMLDSIG( - ReconstructXMLDsigParameters reconstructXMLDsigParameters) - throws PdfAsException { - - AnalyzeParameters analyzeParameters = new AnalyzeParameters(); - fillAnalyzeParametersWithReconstructXMLDsigParameters(analyzeParameters, reconstructXMLDsigParameters); - AnalyzeResult ar = analyze(analyzeParameters); - - ReconstructXMLDsigAfterAnalysisParameters rxaap = new ReconstructXMLDsigAfterAnalysisParameters(); - rxaap.setSignatureDevice(reconstructXMLDsigParameters.getSignatureDevice()); - rxaap.setAnalyzeResult(ar); - - return reconstructXMLDSIG(rxaap); - } - - /** - * @see PdfAs#reconstructXMLDSIG(ReconstructXMLDsigAfterAnalysisParameters) - */ - public ReconstructXMLDsigResult reconstructXMLDSIG( - ReconstructXMLDsigAfterAnalysisParameters reconstructXMLDsigParameters) - throws PdfAsException { - - AnalyzeResult ar = reconstructXMLDsigParameters.getAnalyzeResult(); - List extendedSignatureInfos = new Vector(); - for (int i = 0; i < ar.getSignatures().size(); i++) - { - SignatureInformation si = (SignatureInformation)ar.getSignatures().get(i); - XMLDsigData dsigData; - try { - dsigData = XMLDsigReconstructor.reconstruct(si, reconstructXMLDsigParameters.getSignatureDevice()); - extendedSignatureInfos.add(new ExtendedSignatureInformation(si, dsigData)); - } catch (ConnectorException e) { - // don't care for connector exceptions because of mutli signs. they are handled during verify - extendedSignatureInfos.add(new ExtendedSignatureInformation(si, null)); - } - - } - return new ReconstructXMLDsigResult(extendedSignatureInfos, reconstructXMLDsigParameters.getSignatureDevice()); - } - - /** - * @see PdfAs#verify(VerifyAfterReconstructXMLDsigParameters) - */ - public VerifyResults verify( - VerifyAfterReconstructXMLDsigParameters verifyAfterReconstructXMLDsigParameters) - throws PdfAsException { - - try { - List extSignatures = verifyAfterReconstructXMLDsigParameters.getReconstructXMLDsigResult().getExtendedSignatures(); - String signatureDevice = verifyAfterReconstructXMLDsigParameters.getSignatureDevice(); - if (signatureDevice == null){ - signatureDevice = verifyAfterReconstructXMLDsigParameters.getReconstructXMLDsigResult().getDevice(); - } - List results = PdfAS.verifyExtendedSignatureHolders(extSignatures, - signatureDevice, - verifyAfterReconstructXMLDsigParameters.isReturnHashInputData(), - verifyAfterReconstructXMLDsigParameters.getVerificationTime(), verifyAfterReconstructXMLDsigParameters.getVerifySignatureIndex()); - - List vrs = new ArrayList(results.size()); - - int verifySignatureIndex = verifyAfterReconstructXMLDsigParameters.getVerifySignatureIndex(); - if (verifySignatureIndex < 0) - { - for (int i = 0; i < extSignatures.size(); i++) - { - SignatureResponse response = (SignatureResponse) results.get(i); - ExtendedSignatureInformation extSigInfo = (ExtendedSignatureInformation)extSignatures.get(i); - SignatureHolder holder = (SignatureHolder) extSigInfo.getSignatureInformation().getInternalSignatureInformation(); - - VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime(), extSigInfo.getXmlDsigData()); - vr.setNonTextualObjects( extSigInfo.getSignatureInformation().getNonTextualObjects()); - - vrs.add(vr); - } - }else{ - SignatureResponse response = (SignatureResponse) results.get(0); - ExtendedSignatureInformation extSigInfo = (ExtendedSignatureInformation)extSignatures.get(verifySignatureIndex); - SignatureHolder holder = (SignatureHolder) extSigInfo.getSignatureInformation().getInternalSignatureInformation(); - - VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime(), extSigInfo.getXmlDsigData()); - vr.setNonTextualObjects( extSigInfo.getSignatureInformation().getNonTextualObjects()); - - vrs.add(vr); - } - - VerifyResultsImpl verifyResults = new VerifyResultsImpl(vrs); - return verifyResults; - } catch (java.lang.OutOfMemoryError e) { - throw new OutOfMemoryException(ErrorCode.OUT_OF_MEMORY_ERROR, "Insufficient memory allocated to virtual machine. Start Java with parameters \"-Xms128m -Xmx786m -XX:MaxPermSize=256m\".", e); - } - } - - public DynamicSignatureProfile createDynamicSignatureProfile(String parentProfile, DynamicSignatureLifetimeEnum mode) { - return DynamicSignatureProfileImpl.createFromParent(null, parentProfile, mode); - } - - public DynamicSignatureProfile createEmptyDynamicSignatureProfile(DynamicSignatureLifetimeEnum mode) { - return DynamicSignatureProfileImpl.createEmptyProfile(null, mode); - } - - public DynamicSignatureProfile loadDynamicSignatureProfile(String name) { - return DynamicSignatureProfileImpl.loadProfile(name); - } - - public DynamicSignatureProfile createDynamicSignatureProfile(String myUniqueName, - String parentProfile, DynamicSignatureLifetimeEnum mode) { - return DynamicSignatureProfileImpl.createFromParent(myUniqueName, parentProfile, mode); - } - - public DynamicSignatureProfile createEmptyDynamicSignatureProfile(String myUniqueName, - DynamicSignatureLifetimeEnum mode) { - return DynamicSignatureProfileImpl.createEmptyProfile(myUniqueName, mode); - } - - /** - * @see PdfAs#prepareSign(SignParameters) - */ - public SignatureDetailInformation prepareSign(SignParameters signParameters) throws PdfAsException { - CheckHelper.checkSignParameters(signParameters, true); - - if (signParameters.getProfileOverrideProperties() != null) { - OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties()); - } - - signParameters.setDocument(PdfAS.applyStrictMode(signParameters.getDocument())); - - SettingsReader settings = SettingsReader.getInstance(); - String defaultProfile = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE); - - SignaturePlaceholderData spd = getSignaturePlaceholder(signParameters, defaultProfile); - if (spd != null){ - if (spd.getProfile() != null) - signParameters.setSignatureProfileId(spd.getProfile()); - if (spd.getType() != null) - signParameters.setSignatureType(spd.getType()); - if (spd.getKey() != null) - signParameters.setSignatureKeyIdentifier(spd.getKey()); - // check again, we might have destroyed something - CheckHelper.checkSignParameters(signParameters, true); - } - - if (signParameters.getSignatureProfileId() == null) - { - signParameters.setSignatureProfileId(defaultProfile); - } - - boolean fromPlaceholder = false; - boolean fromSignParameters = false; - boolean fromConfig = false; - TablePos pos = null; - if (spd != null && spd.getTablePos() != null){ - // position and width is determined by placeholder image - fromPlaceholder = true; - pos = spd.getTablePos(); - } else { - // position and width is determined by api sign parameters - pos = PosHelper.formTablePos(signParameters.getSignaturePositioning()); - if (pos != null) { - fromSignParameters = true; - } - } - - TablePos effectivePos = pos; - if (effectivePos == null) { - String pos_string = settings.getSetting(SignatureTypes.SIG_OBJ + signParameters.getSignatureProfileId() + ".pos", null); - if (pos_string != null) { - // position and width is determined by profile configuration - effectivePos = PdfAS.parsePositionFromPosString(pos_string); - fromConfig = true; - } - } - if (effectivePos != null) { - // check if width is lower than the smallest meaningful width - String thresholdString = AdobeSignatureHelper.getDefaultableConfigProperty(signParameters.getSignatureProfileId(), SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY, String.valueOf(DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD)); - float threshold = DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD; - try { - threshold = Float.parseFloat(thresholdString); - } catch (NumberFormatException e) { - if (log.isDebugEnabled()) { - log.debug("Unable to parse threshold value (\"" + thresholdString + "\") of configuration value \"" + SIGNATURE_BLOCK_WIDTH_THRESHOLD_FOR_WARNING_KEY + "\". Using default value: " + DEFAULT_SIGNATURE_BLOCK_WIDTH_THRESHOLD); - } - } - if (!effectivePos.isWauto() && effectivePos.getWidth() < threshold) { - String msg = "The {0} for the signature block is very small ({1}). The signature block might not get placed correcty."; - String[] arguments = new String[]{ "given width", "" + effectivePos.getWidth()}; - // very small, warn user - if (fromPlaceholder) { - arguments[0] = "width given by the placeholder image"; - } else if (fromSignParameters) { - arguments[0] = "width defined by the sign parameters"; - } else if (fromConfig) { - arguments[0] = "width defined by the profile " + signParameters.getSignatureProfileId(); - } - log.warn(MessageFormat.format(msg, arguments)); - } - } - - Signator signator = createSignator(signParameters.getSignatureType()); - - SignatorInformation signatorInfo = signator.prepareSign( - new PdfDataSourceAdapter(signParameters.getDocument()), - signParameters.getSignatureProfileId(), - pos, - signParameters.getTimeStamperImpl()); - - SignatureDetailInformationImpl ret = new SignatureDetailInformationImpl(); - ret.setSignatorInformation(signatorInfo); - return ret; - - } - - private SignaturePlaceholderData getSignaturePlaceholder(SignParameters signParameters, - String defaultProfile) throws SettingsException, PDFDocumentException, PlaceholderExtractionException { - SignaturePlaceholderData spd = null; - SignaturePlaceholderContext.setSignaturePlaceholderData(null); - - SettingsReader settings = SettingsReader.getInstance(); - - // check sig_obj.PROFILEID.enable_placeholder_search - String profile = signParameters.getSignatureProfileId(); - if (profile == null) - profile = defaultProfile; - String key = SignatureTypes.SIG_OBJ + profile + "." + ENABLE_PLACEHOLDER_SEARCH_KEY; - String configFileActivedString = settings.getValueFromKey(key); - - if (configFileActivedString == null){ - // check global enable_placeholder_search - configFileActivedString = settings.getValueFromKey(ENABLE_PLACEHOLDER_SEARCH_KEY); - } - - Boolean configFileActived = null; - if (configFileActivedString != null) - configFileActived = Boolean.valueOf(configFileActivedString); - - Boolean signParamsActivated = signParameters.isCheckForPlaceholder(); - - boolean enableSearch; - - if (signParamsActivated != null) - { - enableSearch = signParamsActivated.booleanValue(); - } else { - if (configFileActived != null) - enableSearch = configFileActived.booleanValue(); - else - enableSearch = false; - } - - if (enableSearch) - { - spd = SignaturePlaceholderExtractor.extract( - signParameters.getDocument().createInputStream(), - signParameters.getPlaceholderId(), - signParameters.getPlaceholderMatchMode()); - } - return spd; - } - - private Signator createSignator(String signatureType) throws SignatorFactoryException { - PdfASID signatorId = null; - if (signatureType.equals(Constants.SIGNATURE_TYPE_BINARY)) - { - signatorId = SignatorFactory.MOST_RECENT_BINARY_SIGNATOR_ID; - } - if (signatureType.equals(Constants.SIGNATURE_TYPE_TEXTUAL)) - { - signatorId = SignatorFactory.MOST_RECENT_TEXTUAL_SIGNATOR_ID; - } - if (signatureType.equals(Constants.SIGNATURE_TYPE_DETACHEDTEXTUAL)) - { - signatorId = SignatorFactory.MOST_RECENT_DETACHEDTEXT_SIGNATOR_ID; - } - - return at.gv.egiz.pdfas.framework.SignatorFactory.createSignator(signatorId); - - } - - public SignResult sign(SignParameters signParameters, SignatureDetailInformation signatorInfo) - throws PdfAsException { - CheckHelper.checkSignParametersForSignAfterPrepare(signParameters, false); - - if (signParameters.getProfileOverrideProperties() != null) { - OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties()); - } - - String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice()); - - ConnectorParameters cp = new ConnectorParameters(); - cp.setProfileId(signParameters.getSignatureProfileId()); - cp.setSignatureKeyIdentifier(signParameters.getSignatureKeyIdentifier()); - Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp); - - SignatureData sd = new SignatureDataImpl(new PdfDataSourceAdapter(signatorInfo.getSignatureData()), signatorInfo.getSignatureData().getMimeType()); - SignSignatureObject sso = PdfAS.sign(sd, c, signParameters.getTimeStamperImpl()); - ((SignatureDetailInformationImpl)signatorInfo).setSignSignatureObject(sso); - - return finishSign(signParameters, signatorInfo); - } - - public SignResult finishSign(SignParameters signParameters, SignatureDetailInformation signatureDetailInformation) - throws PdfAsException { - try { - CheckHelper.checkSignParametersForSignAfterPrepare(signParameters, true); - CheckHelper.checkSignatureDetailInformation(signatureDetailInformation); - - if (signParameters.getProfileOverrideProperties() != null) { - OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties()); - } - - Signator signator = createSignator(signParameters.getSignatureType()); - - SignatorInformation signatorInfo = ((SignatureDetailInformationImpl)signatureDetailInformation).getSignatorInfo(); - signator.finishSign(signatorInfo, new DataSinkAdapter(signParameters.getOutput())); - - return new SignResultImpl( - signParameters.getOutput(), - signatorInfo.getSignSignatureObject().getX509Certificate(), - new ActualSignaturePositionAdapter(signatorInfo.getActualTablePos()), - signatorInfo.getNonTextualObjects()); - } finally { - OverridePropertyHolder.removeProperties(); - DynamicSignatureProfileImpl.disposeLocalProfile(); - } - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PosHelper.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PosHelper.java deleted file mode 100644 index cfb811e..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/PosHelper.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api; - -import at.gv.egiz.pdfas.api.sign.pos.SignaturePositioning; -import at.gv.egiz.pdfas.api.sign.pos.axis.AbsoluteAxisAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.axis.AutoAxisAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.axis.AxisAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.page.AbsolutePageAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.page.AutoPageAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.page.NewPageAlgorithm; -import at.gv.egiz.pdfas.api.sign.pos.page.PageAlgorithm; -import at.knowcenter.wag.egov.egiz.PdfAS; -import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException; -import at.knowcenter.wag.egov.egiz.pdf.TablePos; - -/** - * @author wprinz - * - */ -public final class PosHelper -{ - /** - * Hidden default constructor. - */ - private PosHelper() - { - // empty block - } - - public static TablePos formTablePos(SignaturePositioning signaturePositioning) throws PDFDocumentException - { - if (signaturePositioning == null) - { - return null; - } - - String positioningString = formPositioningString(signaturePositioning); - TablePos pos = PdfAS.parsePositionFromPosString(positioningString); - - return pos; - } - - protected static String formPositioningString(SignaturePositioning sp) - { - String x_algo = formAxisAlgoString(sp.getXAlgorithm()); - String y_algo = formAxisAlgoString(sp.getYAlgorithm()); - String w_algo = formAxisAlgoString(sp.getWidthAlgorithm()); - String p_algo = formPageAlgoString(sp.getPageAlgorithm()); - String positioning = "x:" + x_algo + ";y:" + y_algo + ";w:" + w_algo + ";p:" + p_algo + ";f:" + sp.getFooterLine(); - return positioning; - } - - protected static String formAxisAlgoString(AxisAlgorithm algorithm) - { - if (algorithm instanceof AutoAxisAlgorithm) - { - return "auto"; - } - AbsoluteAxisAlgorithm aaa = (AbsoluteAxisAlgorithm) algorithm; - return Float.toString(aaa.getAbsoluteValue()); - } - - protected static String formPageAlgoString(PageAlgorithm algorithm) - { - if (algorithm instanceof AutoPageAlgorithm) - { - return "auto"; - } - if (algorithm instanceof NewPageAlgorithm) - { - return "new"; - } - AbsolutePageAlgorithm apa = (AbsolutePageAlgorithm) algorithm; - return Integer.toString(apa.getPage()); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java deleted file mode 100644 index 5e25ced..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.analyze; - -import java.util.List; - -import at.gv.egiz.pdfas.api.analyze.AnalyzeResult; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; - -/** - * Holds the result of an analyzation. - * - * @author wprinz - */ -public class AnalyzeResultImpl implements AnalyzeResult -{ - /** - * The found signatures. - */ - protected List signatures = null; - - /** - * The found non-signature update blocks. - */ - protected List noSignatures = null; - - protected boolean hasBeenCorrected = false; - - - /** - * Constructor. - * - * @param signatures - * The found signatures. - * @param noSignatures - * The found non-signature update blocks. - */ - public AnalyzeResultImpl(List signatures, List noSignatures, boolean hasBeenCorrected) - { - if (signatures == null) - { - throw new IllegalArgumentException("The list of found signatures must not be null."); - } - - this.signatures = signatures; - this.noSignatures = noSignatures; - this.hasBeenCorrected = hasBeenCorrected; - } - - - /** - * Constructor. - * - * @param signatures - * The found signatures. - */ - public AnalyzeResultImpl(List signatures) - { - if (signatures == null) - { - throw new IllegalArgumentException("The list of found signatures must not be null."); - } - - this.signatures = signatures; - } - - /** - * @see at.gv.egiz.pdfas.api.analyze.AnalyzeResult#getSignatures() - */ - public List getSignatures() throws PdfAsException - { - return this.signatures; - } - - public List getNoSignatures() { - - return this.noSignatures; - } - - /** - * Tells if the document has been corrected before verification. The correction maybe done - * after a first failing parse to repair a document (if enabled in the configuration - * correct_document_on_verify_if_necessary). The correction can only work for textual - * signatures. Binary signatures are lost anyhow. - * @return - */ - public boolean hasBeenCorrected() { - return hasBeenCorrected; - } - - public void setHasBeenCorrected(boolean hasBeenCorrected) { - this.hasBeenCorrected = hasBeenCorrected; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java deleted file mode 100644 index 2aee44f..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSinkAdapter.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.IOException; -import java.io.OutputStream; - -import at.gv.egiz.pdfas.api.io.DataSink; - -/** - * Adapter that converts an API DataSink to a framework DataSink. - * - * @author wprinz - */ -public class DataSinkAdapter implements at.gv.egiz.pdfas.framework.output.DataSink -{ - /** - * The API DataSink to be adapted to a framework DataSink. - */ - protected at.gv.egiz.pdfas.api.io.DataSink apiDataSink = null; - - /** - * Constructor. - * - * @param apiDataSink - * The API DataSink to be adapted to a framework DataSink. - */ - public DataSinkAdapter(DataSink apiDataSink) - { - this.apiDataSink = apiDataSink; - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#createOutputStream(java.lang.String) - */ - public OutputStream createOutputStream(String mimeType) - { - try - { - return this.apiDataSink.createOutputStream(mimeType); - } - catch (IOException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#createOutputStream(java.lang.String, - * java.lang.String) - */ - public OutputStream createOutputStream(String mimeType, String characterEncoding) - { - try - { - return this.apiDataSink.createOutputStream(mimeType, characterEncoding); - } - catch (IOException e) - { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#getCharacterEncoding() - */ - public String getCharacterEncoding() - { - return this.apiDataSink.getCharacterEncoding(); - } - - /** - * @see at.gv.egiz.pdfas.framework.output.DataSink#getMimeType() - */ - public String getMimeType() - { - return this.apiDataSink.getMimeType(); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java deleted file mode 100644 index 8db3fcf..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/DataSourceApiAdapter.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.InputStream; - -import at.gv.egiz.pdfas.framework.input.PdfDataSource; -import at.gv.egiz.pdfas.framework.input.TextDataSource; - -/** - * Adapter that converts a framework DataSource to an API PdfDataSource. - * - * @author wprinz - */ -public class DataSourceApiAdapter implements at.gv.egiz.pdfas.api.io.DataSource -{ - /** - * The framework DataSource to be adapted to an API DataSource. - */ - protected at.gv.egiz.pdfas.framework.input.DataSource frameworkDataSource = null; - - /** - * Constructor. - * - * @param frameworkDataSource - * The framework DataSource to be adapted to an API DataSource. - */ - public DataSourceApiAdapter(at.gv.egiz.pdfas.framework.input.DataSource frameworkDataSource) - { - this.frameworkDataSource = frameworkDataSource; - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#createInputStream() - */ - public InputStream createInputStream() - { - return this.frameworkDataSource.createInputStream(); - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#getAsByteArray() - */ - public byte[] getAsByteArray() - { - return this.frameworkDataSource.getAsByteArray(); - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#getLength() - */ - public int getLength() - { - return this.frameworkDataSource.getLength(); - } - - public String getCharacterEncoding() - { - if (this.frameworkDataSource instanceof PdfDataSource) - { - return null; - } - if (this.frameworkDataSource instanceof TextDataSource) - { - return "UTF-8"; - } - return null; - } - - public String getMimeType() - { - if (this.frameworkDataSource instanceof PdfDataSource) - { - return "application/pdf"; - } - if (this.frameworkDataSource instanceof TextDataSource) - { - return "text/plain"; - } - - return null; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java deleted file mode 100644 index 6336071..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/PdfDataSourceAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.InputStream; - -/** - * Adapter that converts an API DataSource to a framework PdfDataSource. - * - * @author wprinz - */ -public class PdfDataSourceAdapter implements at.gv.egiz.pdfas.framework.input.PdfDataSource -{ - /** - * The API DataSource to be adapted to a framework PdfDataSource. - */ - protected at.gv.egiz.pdfas.api.io.DataSource apiDataSource = null; - - /** - * Constructor. - * @param apiDataSource The API DataSource to be adapted to a framework PdfDataSource. - */ - public PdfDataSourceAdapter(at.gv.egiz.pdfas.api.io.DataSource apiDataSource) - { - this.apiDataSource = apiDataSource; - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#createInputStream() - */ - public InputStream createInputStream() - { - return this.apiDataSource.createInputStream(); - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#getAsByteArray() - */ - public byte[] getAsByteArray() - { - return this.apiDataSource.getAsByteArray(); - } - - /** - * @see at.gv.egiz.pdfas.framework.input.DataSource#getLength() - */ - public int getLength() - { - return this.apiDataSource.getLength(); - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java deleted file mode 100644 index 34c706b..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.security.cert.X509Certificate; -import java.util.Date; -import java.util.List; - -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.commons.SignatureInformation; -import at.gv.egiz.pdfas.api.io.DataSource; -import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.EGIZDate; -import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; - -/** - * Adapter that converts a framework SignatureHolder to an API - * SignatureInformation. - * - * @author wprinz - */ -public class SignatureInformationAdapter implements SignatureInformation -{ - /** - * The framework SignatureHolder to be adapted to an API SignatureInformation. - */ - protected SignatureHolder signatureHolder = null; - - protected String timeStamp = null; - - protected List nonTextualObjects = null; - - /** - * Constructor. - * - * @param signatureHolder - * The framework SignatureHolder to be adapted to an API - * SignatureInformation. - */ - public SignatureInformationAdapter(SignatureHolder signatureHolder) - { - this.signatureHolder = signatureHolder; - if (signatureHolder instanceof BinarySignatureHolder) { - this.timeStamp = ((BinarySignatureHolder)signatureHolder).getSignatureObject().getTimeStamp(); - } - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignedData() - */ - public DataSource getSignedData() - { - return new DataSourceApiAdapter(this.signatureHolder.getDataSource()); - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getInternalSignatureInformation() - */ - public Object getInternalSignatureInformation() - { - return this.signatureHolder; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignatureType() - */ - public String getSignatureType() - { - if (this.signatureHolder.getSignatureObject().isBinary()) - { - return Constants.SIGNATURE_TYPE_BINARY; - } - return Constants.SIGNATURE_TYPE_TEXTUAL; - } - - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignerCertificate() - */ - public X509Certificate getSignerCertificate() - { - return this.signatureHolder.getSignatureObject().getX509Cert().getX509Certificate(); - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSigningTime() - */ - public Date getSigningTime() - { - String date_value = this.signatureHolder.getSignatureObject().getSignationDate(); - Date date = EGIZDate.parseDateFromString(date_value); - return date; - } - - public String getTimeStampValue() { - return this.timeStamp; - } - - public List getNonTextualObjects() { - return this.nonTextualObjects; - } - - public boolean hasNonTextualObjects() { - return this.nonTextualObjects != null && this.nonTextualObjects.size() > 0; - } - - public void setNonTextualObjects(List nonTextualObjects) { - this.nonTextualObjects = nonTextualObjects; - } - - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java deleted file mode 100644 index 35d8c17..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureProfileImpl.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.util.Properties; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import at.gv.egiz.pdfas.api.commons.SignatureProfile; - -/** - * Holds the data of a signature profile. - * - * @author wprinz - */ -public class SignatureProfileImpl implements SignatureProfile { - - /** - * The profile identifier. - */ - protected String profileId = null; - - /** - * The MOA key identifiert of this profile. - */ - protected String moaKeyIdentifier = null; - - /** - * Properties containing the layout settings relevant to the search algorithm - * for signature blocks. - */ - protected Properties signatureBlockEntries; - - /** - * Short description of the profile. - */ - protected String profileDescription; - - /** - * true if this is the default profile, false otherwise. - */ - protected boolean defaultProfile = false; - - /** - * Constructor. - * - * @param profileId - * The profile identifier. - * @param moaKeyIdentifier - * The MOA key identifier of this profile. - */ - public SignatureProfileImpl(String profileId, String moaKeyIdentifier) { - this.profileId = profileId; - this.moaKeyIdentifier = moaKeyIdentifier; - this.signatureBlockEntries = new Properties(); - } - - /** - * Constructor. - * - * @param profileId - * The profile identifier. - * @param profileDescription - * The profile description. - * @param moaKeyIdentifier - * The MOA key identifier of this profile. - * @param isDefault - */ - public SignatureProfileImpl(String profileId, String profileDescription, String moaKeyIdentifier, boolean isDefault) { - this.profileId = profileId; - this.moaKeyIdentifier = moaKeyIdentifier; - this.profileDescription = profileDescription; - this.signatureBlockEntries = new Properties(); - this.defaultProfile = isDefault; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getProfileId() - */ - public String getProfileId() { - return this.profileId; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getMOAKeyIdentifier() - */ - public String getMOAKeyIdentifier() { - return this.moaKeyIdentifier; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureProfile#getSignatureBlockEntries() - */ - public Properties getSignatureBlockEntries() { - return this.signatureBlockEntries; - } - - /** - * Sets the entries relevant to the search algorithm for signature blocks.
- * e.g. properties starting with sig_obj.PROFILE.key. and - * properties of the form sig_obj.PROFILE.table.TABLENAME.NUMBER - * where PROFILE is the name of the current profile, - * TABLENAME is the name of a table and NUMBER - * is the number of the specific row within the table TABLENAME. - * - * @param signatureBlockEntries - * The entries relevant to the signature block search algorithm as - * Java properties. - */ - public void setSignatureBlockEntries(Properties signatureBlockEntries) { - this.signatureBlockEntries = signatureBlockEntries; - } - - /** - * Returns the profile description. - * @return The profile description. - */ - public String getProfileDescription() { - return this.profileDescription; - } - - public String toString() { - return new ToStringBuilder(this) - .append("profileId", this.profileId) - .append("profileDescription", this.profileDescription) - .append("moaKeyIdentifier", this.moaKeyIdentifier) - .toString(); - } - - /** - * - */ - public boolean isDefault() { - return this.defaultProfile; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java deleted file mode 100644 index 5685490..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextBasedDataSourceApiAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.InputStream; - -import at.gv.egiz.pdfas.api.io.TextBased; -import at.gv.egiz.pdfas.framework.input.TextDataSource; - -/** - * Adapter that converts a framework DataSource to an API PdfDataSource. - * - * @author wprinz - */ -public class TextBasedDataSourceApiAdapter implements at.gv.egiz.pdfas.api.io.DataSource, TextBased -{ - /** - * The framework DataSource to be adapted to an API DataSource. - */ - protected TextDataSource frameworkDataSource = null; - - /** - * Constructor. - * - * @param frameworkDataSource - * The framework DataSource to be adapted to an API DataSource. - */ - public TextBasedDataSourceApiAdapter(TextDataSource frameworkDataSource) - { - this.frameworkDataSource = frameworkDataSource; - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#createInputStream() - */ - public InputStream createInputStream() - { - return this.frameworkDataSource.createInputStream(); - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#getAsByteArray() - */ - public byte[] getAsByteArray() - { - return this.frameworkDataSource.getAsByteArray(); - } - - /** - * @see at.gv.egiz.pdfas.api.io.DataSource#getLength() - */ - public int getLength() - { - return this.frameworkDataSource.getLength(); - } - - public String getCharacterEncoding() - { - return "UTF-8"; - } - - public String getMimeType() - { - return "text/plain"; - } - - public String getText() { - return this.frameworkDataSource.getText(); - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java deleted file mode 100644 index 39f88e2..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/TextDataSourceAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.commons; - -import java.io.UnsupportedEncodingException; - -import at.gv.egiz.pdfas.api.io.TextBased; -import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl; - -/** - * Adapter that converts an API DataSource to a framework TextDataSource. - * - * @author wprinz - */ -public class TextDataSourceAdapter extends TextDataSourceImpl -{ - /** - * The API DataSource to be adapted to a framework TextDataSource. - */ - protected at.gv.egiz.pdfas.api.io.DataSource apiDataSource = null; - - /** - * Constructor. - * - * @param apiDataSource - * The API DataSource to be adapted to a framework TextDataSource. - * @throws UnsupportedEncodingException - */ - public TextDataSourceAdapter(at.gv.egiz.pdfas.api.io.DataSource apiDataSource) throws UnsupportedEncodingException - { - super(null); - this.apiDataSource = apiDataSource; - - if (this.apiDataSource instanceof TextBased) - { - TextBased tb = (TextBased) this.apiDataSource; - this.text = tb.getText(); - } - else - { - byte[] data = this.apiDataSource.getAsByteArray(); - String characterEncoding = this.apiDataSource.getCharacterEncoding(); - if (characterEncoding == null) - { - throw new UnsupportedEncodingException("The characterEncoding must not be null. Specify a correct encoding."); - } - this.text = new String(data, characterEncoding); - } - assert this.text != null; - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java deleted file mode 100644 index b817ea9..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java +++ /dev/null @@ -1,362 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.internal; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Vector; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.pdfas.api.PdfAs; -import at.gv.egiz.pdfas.api.analyze.AnalyzeResult; -import at.gv.egiz.pdfas.api.commons.Constants; -import at.gv.egiz.pdfas.api.commons.SignatureInformation; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.internal.LocalBKUParams; -import at.gv.egiz.pdfas.api.internal.PdfAsInternal; -import at.gv.egiz.pdfas.api.internal.SignatureEntry; -import at.gv.egiz.pdfas.api.sign.SignParameters; -import at.gv.egiz.pdfas.api.sign.SignResult; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.api.verify.VerifyResult; -import at.gv.egiz.pdfas.exceptions.ErrorCode; -import at.gv.egiz.pdfas.framework.ConnectorParameters; -import at.gv.egiz.pdfas.framework.input.TextDataSource; -import at.gv.egiz.pdfas.impl.api.CheckHelper; -import at.gv.egiz.pdfas.impl.api.analyze.AnalyzeResultImpl; -import at.gv.egiz.pdfas.impl.api.commons.PdfDataSourceAdapter; -import at.gv.egiz.pdfas.impl.api.commons.SignatureInformationAdapter; -import at.gv.egiz.pdfas.impl.api.sign.SignatureDetailInformationImpl; -import at.gv.egiz.pdfas.impl.api.verify.VerifyResultAdapter; -import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl; -import at.knowcenter.wag.egov.egiz.PdfAS; -import at.knowcenter.wag.egov.egiz.PdfASID; -import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; -import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; -import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException; -import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException; -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.egov.egiz.framework.SignatorFactory; -import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.TextualSignatureHolder; -import at.knowcenter.wag.egov.egiz.sig.ConnectorFactory; -import at.knowcenter.wag.egov.egiz.sig.ConnectorInformation; -import at.knowcenter.wag.egov.egiz.sig.SignatureData; -import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl; -import at.knowcenter.wag.egov.egiz.sig.SignatureObject; -import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; -import at.knowcenter.wag.egov.egiz.sig.SignatureTypes; -import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUHelper; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.EnvelopedBase64BKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.LocRefDetachedBKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.MultipartDetachedBKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.OldEnvelopingBase64BKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; -import at.knowcenter.wag.egov.egiz.sig.connectors.mocca.LocRefDetachedMOCCAConnector; -import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter; -import at.knowcenter.wag.egov.egiz.sig.signaturelayout.SignatureLayoutHandlerFactory; -import at.knowcenter.wag.egov.egiz.sig.signatureobject.SignatureObjectHelper; - -/** - * @see PdfAsInternal - * - * @author exthex - * - */ -public class PdfAsInternalObject implements PdfAsInternal { - /** - * The log. - */ - private static Log log = LogFactory.getLog(CheckHelper.class); - - /** - * @see PdfAsInternal#verifyBKUSupport(LocalBKUParams) - */ - public void verifyBKUSupport(LocalBKUParams bkuParams) throws ConnectorException, SettingsException { - String bkuIdentifier = BKUHelper.getBKUIdentifier(bkuParams); - SignatureLayoutHandlerFactory.verifyBKUSupport(bkuIdentifier); - } - - /** - * @see PdfAsInternal#finishLocalSign(PdfAs, SignParameters, SignatureDetailInformation, LocalBKUParams, String) - */ - public SignResult finishLocalSign(PdfAs pdfAs, SignParameters signParameters, SignatureDetailInformation sdi, LocalBKUParams bkuParams, boolean multipart, String xmlResponse) throws PdfAsException { - LocalConnector c = chooseLocalConnectorForSign(signParameters.getSignatureDevice(), signParameters.getSignatureProfileId(), "not needed", multipart); - SignSignatureObject sso = c.analyzeSignResponse(buildResponseProperties(bkuParams, xmlResponse)); - ((SignatureDetailInformationImpl)sdi).setSignSignatureObject(sso); - - return pdfAs.finishSign(signParameters, sdi); - } - - private Properties buildResponseProperties(LocalBKUParams bkuParams, String xmlResponse) { - Properties ret = new Properties(); - if (bkuParams.getServer() != null) - ret.setProperty(BKUPostConnection.BKU_SERVER_HEADER_KEY, bkuParams.getServer()); - if (bkuParams.getUserAgent() != null) - ret.setProperty(BKUPostConnection.BKU_USER_AGENT_HEADER_KEY, bkuParams.getUserAgent()); - if (bkuParams.getSignatureLayout() != null) - ret.setProperty(BKUPostConnection.BKU_SIGNATURE_LAYOUT_HEADER_KEY, bkuParams.getSignatureLayout()); - ret.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xmlResponse); - return ret; - } - - private LocalConnector chooseLocalConnectorForSign(String device, String profile, String loc_ref_url, boolean multipart) throws ConnectorException{ - ConnectorParameters cp = new ConnectorParameters(); - cp.setProfileId(profile); - - if (Constants.SIGNATURE_DEVICE_MOC.equals(device)) { - if (!multipart) { - return new LocRefDetachedMOCCAConnector(cp, loc_ref_url); - } - } else if (Constants.SIGNATURE_DEVICE_BKU.equals(device)){ - if (multipart) { - return new MultipartDetachedBKUConnector(cp); - } else { - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - } - } else if (Constants.SIGNATURE_DEVICE_MOBILE.equals(device)){ - if (multipart) { - return new MultipartDetachedBKUConnector(cp); - } else { - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - } - } else if (Constants.SIGNATURE_DEVICE_MOBILETEST.equals(device)){ - if (multipart) { - return new MultipartDetachedBKUConnector(cp); - } else { - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - } - } - - - log.error("Currently only the BKU connector is fully implemented."); - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - } - - private LocalConnector chooseLocalConnectorForVerify(String connector, - PdfASID sig_kz, String sig_id, String profile, String loc_ref_url) throws ConnectorException - { - log.debug("Choosing LocalConnector for verification..."); - - log.debug("connector type = " + connector); - log.debug("sig_kz = " + sig_kz); - log.debug("sig_id = " + sig_id); - - if (!connector.equals("bku")) - { - log.error("Currently only the BKU connector is fully implemented."); - } - - if (sig_kz == null) - { - log.debug("sig_kz is null -> must be old signature -> choosing old Base64 connector."); - - return new OldEnvelopingBase64BKUConnector(profile); - } - - log.debug("sig_kz is not null -> must be one of the newer ... base64, base64 hotfix, or detached"); - - if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_0_0)) - { - log.debug("sig_kz version is 1.0.0 -> choosing base64 (old or hotfix)"); - - if (sig_id == null) - { - log.debug("sig_id is null, which means that it is a MOA signature -> choose a hotfix base64 connector (thus it is moa - it doesn't matter)."); - - return new EnvelopedBase64BKUConnector(profile); - } - - String[] sig_id_parts = sig_id.split("@"); - if (sig_id_parts.length == 2) - { - log.debug("sig_id has 2 @-separated parts -> choosing old base64 connector"); - - return new OldEnvelopingBase64BKUConnector(profile); - } - if (sig_id_parts[0].equals(HotfixIdFormatter.SIG_ID_PREFIX)) - { - log.debug("sig_id prefix is hotfix -> choosing hotfix base64 connector"); - - return new EnvelopedBase64BKUConnector(profile); - } - - throw new ConnectorException(300, "The SIG_KZ version is 1.0.0, but SIG_ID is neither MOA nor Old base64 nor Hotfix base64 ???'"); - } - if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_1_0) || sig_kz.getVersion().equals(SignatorFactory.VERSION_1_2_0)) - { - log.debug("sig_kz version is 1.1.0/1.2.0 -> choosing detached (loc ref) connector."); - - ConnectorParameters cp = new ConnectorParameters(); - cp.setProfileId(profile); - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - } - - throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE, "The SIG_KZ version '" + sig_kz.getVersion() + "' is unknown."); - } - - /** - * @see PdfAsInternal#getLocalServiceAddress(String, String) - */ - public String getLocalServiceAddress(String profile, String device) throws SettingsException { - SettingsReader settings = SettingsReader.getInstance(); - - String key = device + ".sign.url"; - String value = settings.getValueFromKey("sig_obj." + profile + "." + key); //$NON-NLS-1$//$NON-NLS-2$ - if (value == null) - { - value = settings.getValueFromKey(key); - } - return value; - } - - /** - * @see PdfAsInternal#prepareLocalSignRequest(SignParameters, String, SignatureDetailInformation) - */ - public String prepareLocalSignRequest(SignParameters signParameters, boolean multipart, String loc_ref_url, - SignatureDetailInformation sdi) throws ConnectorException { - LocalConnector c = chooseLocalConnectorForSign(signParameters.getSignatureDevice(), signParameters.getSignatureProfileId(), loc_ref_url, multipart); - SignatureData sd = new SignatureDataImpl(new PdfDataSourceAdapter(sdi.getSignatureData()), sdi.getSignatureData().getMimeType(), sdi.getSignatureData().getCharacterEncoding()); - String sign_request = c.prepareSignRequest(sd); - return sign_request; - } - - /** - * @see PdfAsInternal#analyzeFromRawText(String, Map) - */ - public AnalyzeResult analyzeFromRawText(String rawText, Map sigValues) throws SignatureException, SettingsException, SignatureTypesException, NormalizeException { - String normalizedText = PdfAS.normalizeText(rawText); - - SignatureObject signature_object = new SignatureObject(); - - String default_type = SettingsReader.getInstance().getValueFromKey(SignatureTypes.DEFAULT_TYPE); - signature_object.setSigType(default_type); - signature_object.initByType(); - - Iterator sigKeys = sigValues.keySet().iterator(); - while (sigKeys.hasNext()){ - String key = (String)sigKeys.next(); - signature_object.setSigValue(key, (String)sigValues.get(key)); - } - - TextDataSource tds = new TextDataSourceImpl(normalizedText); - SignatureHolder new_holder = new TextualSignatureHolder(tds, signature_object); - - SignatureInformation si = new SignatureInformationAdapter(new_holder); - List signatures = new Vector(); - signatures.add(si); - AnalyzeResult ret = new AnalyzeResultImpl(signatures); - return ret; - } - - /** - * @see PdfAsInternal#prepareLocalVerifyRequest(SignatureInformation, String, String, String) - */ - public String prepareLocalVerifyRequest(SignatureInformation sigInfo, String connector, String profile, String loc_ref_url) throws SignatureException, ConnectorException { - - SignatureHolder holder = (SignatureHolder)sigInfo.getInternalSignatureInformation(); - SignatureObject s = holder.getSignatureObject(); - - SignatureData sd = PdfAS.convertSignatureHolderToSignatureData(holder); - - SignSignatureObject so = SignatureObjectHelper.convertSignatureObjectToSignSignatureObject(s); - - LocalConnector local_conn = chooseLocalConnectorForVerify(connector, s.getKZ(), so.id, profile, loc_ref_url); - - String request_string = local_conn.prepareVerifyRequest(sd, so, null); - return request_string; - } - - /** - * @see PdfAsInternal#finishLocalVerify(SignatureInformation, String, String, String, String) - */ - public VerifyResult finishLocalVerify(SignatureInformation sigInfo, String connector, String profile, String loc_ref_url, String xmlResponse) throws SignatureException, ConnectorException { - SignatureHolder holder = (SignatureHolder)sigInfo.getInternalSignatureInformation(); - SignatureObject s = holder.getSignatureObject(); - - SignSignatureObject so = SignatureObjectHelper.convertSignatureObjectToSignSignatureObject(s); - - LocalConnector local_conn = chooseLocalConnectorForVerify(connector, s.getKZ(), so.id, profile, loc_ref_url); - - Properties props = new Properties(); - props.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xmlResponse); - SignatureResponse sigResponse = local_conn.analyzeVerifyResponse(props); - return new VerifyResultAdapter(sigResponse, holder, null, null); // timestamp and xmldsig not needed here - } - - /** - * @see PdfAsInternal#getSignatureEntryFromSignatureInformation(String, SignatureInformation) - */ - public SignatureEntry getSignatureEntryFromSignatureInformation(String key, - SignatureInformation sigInfo) { - - SignatureHolder holder = (SignatureHolder)sigInfo.getInternalSignatureInformation(); - SignatureObject s = holder.getSignatureObject(); - at.knowcenter.wag.egov.egiz.sig.SignatureEntry internalEntry = s.getSigEntry(key); - if (internalEntry == null) - return null; - SignatureEntry ret = new SignatureEntry(key); - ret.setCaption(internalEntry.getCaption()); - ret.setValue(internalEntry.getValue()); - return ret; - } - - /** - * @see PdfAsInternal#getSignedText(SignatureInformation) - */ - public String getSignedText(SignatureInformation sigInfo) { - SignatureHolder holder = (SignatureHolder)sigInfo.getInternalSignatureInformation(); - if (holder instanceof TextualSignatureHolder) - return ((TextualSignatureHolder)holder).getSignedText(); - return null; - } - - /** - * @see PdfAsInternal#getConnectorsAvailableForWeb() - */ - public Map getConnectorsAvailableForWeb() throws ConnectorFactoryException { - ConnectorInformation ci[] = ConnectorFactory.getConnectorInformationArray(); - - Map ret = new HashMap(); - for (int i = 0; i < ci.length; i++) - { - String id = ci[i].getIdentifier(); - if (ConnectorFactory.isAvailableForWeb(id)) - { - ret.put(id, ci[i].getDescription()); - } - } - return ret; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/ActualSignaturePositionAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/sign/ActualSignaturePositionAdapter.java deleted file mode 100644 index 1cc5699..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/ActualSignaturePositionAdapter.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.sign; - -import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition; -import at.knowcenter.wag.egov.egiz.pdf.ActualTablePos; - -/** - * Adapter that converts from a framework ActualTablePos to an API - * ActualSignaturePosition. - * - * @author wprinz - * - */ -public class ActualSignaturePositionAdapter implements SignaturePosition -{ - /** - * The framework ActualTablePos. - */ - protected ActualTablePos atp = null; - - /** - * Constructor. - * - * @param actualTablePos - * The framework ActualTablePos. - */ - public ActualSignaturePositionAdapter(ActualTablePos actualTablePos) - { - this.atp = actualTablePos; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.pos.SignaturePosition#getPage() - */ - public int getPage() - { - return this.atp.page; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.pos.SignaturePosition#getX() - */ - public float getX() - { - return this.atp.x; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.pos.SignaturePosition#getY() - */ - public float getY() - { - return this.atp.y; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.pos.SignaturePosition#getWidth() - */ - public float getWidth() - { - return this.atp.width; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.pos.SignaturePosition#getHeight() - */ - public float getHeight() - { - return this.atp.height; - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignResultImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignResultImpl.java deleted file mode 100644 index 163d1d2..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignResultImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.sign; - -import java.security.cert.X509Certificate; -import java.util.List; - -import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo; -import at.gv.egiz.pdfas.api.io.DataSink; -import at.gv.egiz.pdfas.api.sign.SignResult; -import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition; - -/** - * Implementation of the SignResult interface. - * - * @author wprinz - */ -public class SignResultImpl implements SignResult -{ - /** - * The filled output DataSink. - */ - protected DataSink outputDocument = null; - - /** - * The signer certificate. - */ - protected X509Certificate signerCertificate = null; - - /** - * The signature position. - */ - protected SignaturePosition signaturePosition = null; - - /** - * List {@link NonTextObjectInfo} - */ - protected List nonTextObjects; - - /** - * Constructor. - * - * @param outputDocument - * The filled output DataSink. - * @param signerCertificate - * The signer certificate. - * @param signaturePosition - * The signature position. - */ - public SignResultImpl(DataSink outputDocument, X509Certificate signerCertificate, SignaturePosition signaturePosition, List nonTextObjects) - { - this.outputDocument = outputDocument; - this.signerCertificate = signerCertificate; - this.signaturePosition = signaturePosition; - this.nonTextObjects = nonTextObjects; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.SignResult#getOutputDocument() - */ - public DataSink getOutputDocument() - { - return this.outputDocument; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.SignResult#getSignaturePosition() - */ - public SignaturePosition getSignaturePosition() - { - return this.signaturePosition; - } - - /** - * @see at.gv.egiz.pdfas.api.sign.SignResult#getSignerCertificate() - */ - public X509Certificate getSignerCertificate() - { - return this.signerCertificate; - } - - - /** - * List {@link NonTextObjectInfo} - */ - public List getNonTextualObjects() { - return this.nonTextObjects; - } - - public boolean hasNonTextualObjects() { - return this.nonTextObjects != null && this.nonTextObjects.size() > 0; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignatureDetailInformationImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignatureDetailInformationImpl.java deleted file mode 100644 index 18b88ed..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/sign/SignatureDetailInformationImpl.java +++ /dev/null @@ -1,190 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.sign; - -import java.security.cert.X509Certificate; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import at.gv.egiz.pdfas.api.io.DataSource; -import at.gv.egiz.pdfas.api.sign.SignatureDetailInformation; -import at.gv.egiz.pdfas.api.sign.pos.SignaturePosition; -import at.gv.egiz.pdfas.framework.input.TextDataSource; -import at.gv.egiz.pdfas.framework.signator.SignatorInformation; -import at.gv.egiz.pdfas.impl.api.commons.DataSourceApiAdapter; -import at.gv.egiz.pdfas.impl.api.commons.TextBasedDataSourceApiAdapter; -import at.knowcenter.wag.egov.egiz.pdf.EGIZDate; -import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; - -/** - * - * @author exthex - * - */ -public class SignatureDetailInformationImpl implements SignatureDetailInformation { - - private DataSource signatureData; - private SignaturePosition signaturePosition; - private List nonTextualObjects; - private String dateString; - private Date signDate; - private String issuer; - private Map issuerDNMap; - private String name; - private String serialNumber; - private String sigAlgorithm; - private String sigID; - private String sigKZ; - private String signatureValue; - private String sigTimeStamp; - private Map subjectDNMap; - private X509Certificate x509Certificate; - private boolean textual; - private Properties responseProperties; - private SignatorInformation signatorInfo; - - public DataSource getSignatureData() { - return this.signatureData; - } - - public SignaturePosition getSignaturePosition() { - return this.signaturePosition; - } - - public List getNonTextualObjects() { - return this.nonTextualObjects; - } - - public Date getSignDate() { - return this.signDate; - } - - public String getIssuer() { - return this.issuer; - } - - public Map getIssuerDNMap() { - return this.issuerDNMap; - } - - public String getSubjectName() { - return this.name; - } - - public String getSerialNumber() { - return this.serialNumber; - } - - public String getSigAlgorithm() { - return this.sigAlgorithm; - } - - public String getSigID() { - return this.sigID; - } - - public String getSigKZ() { - return this.sigKZ; - } - - public String getSignatureValue() { - return this.signatureValue; - } - - public String getSigTimeStamp() { - return this.sigTimeStamp; - } - - public Map getSubjectDNMap() { - return this.subjectDNMap; - } - - public X509Certificate getX509Certificate() { - return this.x509Certificate; - } - - public boolean isTextual() { - return textual; - } - - public boolean isBinary() { - return !textual; - } - - public void setSignSignatureObject(SignSignatureObject sso) { - this.dateString = sso.getDate(); - if (this.dateString != null){ - this.signDate = EGIZDate.parseDateFromString(this.dateString); - } - this.issuer = sso.getIssuer(); - this.issuerDNMap = sso.getIssuerDNMap(); - this.name = sso.getName(); //extracted from x509Certificate - this.serialNumber = sso.getSerialNumber(); //extracted from x509Certificate - this.sigAlgorithm = sso.getSigAlgorithm(); - this.sigID = sso.getSigID(); - this.sigKZ = sso.getSigKZ(); - this.signatureValue = sso.getSignatureValue(); - this.sigTimeStamp = sso.getSigTimeStamp(); - this.subjectDNMap = sso.getSubjectDNMap(); - this.x509Certificate = sso.getX509Certificate(); - this.responseProperties = sso.response_properties; - if (this.signatorInfo != null){ - this.signatorInfo.setSignSignatureObject(sso); - } - } - - public SignSignatureObject getSignSignatureObject() { - SignSignatureObject ret = new SignSignatureObject(); - ret.date = this.dateString; - ret.id = this.sigID; - ret.issuer = this.issuer; - ret.issuerDNMap = this.issuerDNMap; - ret.kz = this.sigKZ; - ret.response_properties = this.responseProperties; - ret.sigAlgorithm = this.sigAlgorithm; - ret.signatureValue = this.signatureValue; - ret.sigTimeStamp = this.sigTimeStamp; - ret.subjectDNMap = this.subjectDNMap; - ret.x509Certificate = this.x509Certificate; - - return ret; - } - - public SignatorInformation getSignatorInfo() { - return this.signatorInfo; - } - - public void setSignatorInformation(SignatorInformation signatorInformation){ - this.signatorInfo = signatorInformation; - this.signaturePosition = new ActualSignaturePositionAdapter(signatorInformation.getActualTablePos()); - this.nonTextualObjects = signatorInformation.getNonTextualObjects(); - at.gv.egiz.pdfas.framework.input.DataSource dataSource = signatorInformation.getSignatureData().getDataSource(); - if (dataSource instanceof TextDataSource) - this.signatureData = new TextBasedDataSourceApiAdapter((TextDataSource)dataSource); - else - this.signatureData = new DataSourceApiAdapter(dataSource); - } -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/SignatureCheckImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/SignatureCheckImpl.java deleted file mode 100644 index 84df2a5..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/SignatureCheckImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.verify; - -import at.gv.egiz.pdfas.api.verify.SignatureCheck; - -/** - * @author wprinz - */ -public class SignatureCheckImpl implements SignatureCheck -{ - /** - * The check code. - */ - protected int code = -1; - - /** - * The check code message. - */ - protected String message = null; - - - - /** - * @param code The check code. - * @param message The check code message. - */ - public SignatureCheckImpl(int code, String message) - { - this.code = code; - this.message = message; - } - - /** - * @see at.gv.egiz.pdfas.api.verify.SignatureCheck#getCode() - */ - public int getCode() - { - return this.code; - } - - /** - * @see at.gv.egiz.pdfas.api.verify.SignatureCheck#getMessage() - */ - public String getMessage() - { - return this.message; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java deleted file mode 100644 index 09d247d..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.verify; - -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; -import at.gv.egiz.pdfas.api.verify.SignatureCheck; -import at.gv.egiz.pdfas.api.verify.VerifyResult; -import at.gv.egiz.pdfas.api.xmldsig.XMLDsigData; -import at.gv.egiz.pdfas.impl.api.commons.SignatureInformationAdapter; -import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException; -import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder; -import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder; -import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; - - -/** - * Implements the VerifyResult interface. - * - * @author wprinz - */ -public class VerifyResultAdapter extends SignatureInformationAdapter implements VerifyResult -{ - protected SignatureResponse sigRes = null; - - /** - * The log. - */ - private static final Log logger_ = LogFactory.getLog(VerifyResultAdapter.class); - - protected Date vTime = null; - - private String timestamp; - - private XMLDsigData xmlDsigData; - - - /** - * Constructor. - * - * @param sigRes - * The SignatureResponse. - * @param sh - * The SignatureHolder. - * @param verificationTime - * The time of verification. This is directly returned by {@link #getVerificationTime()} - * @param xmlDsigData - */ - public VerifyResultAdapter(SignatureResponse sigRes, SignatureHolder sh, Date verificationTime, XMLDsigData xmlDsigData) - { - super(sh); - this.sigRes = sigRes; - this.vTime = verificationTime; - this.xmlDsigData = xmlDsigData; - if (sh instanceof BinarySignatureHolder) { - this.timestamp = ((BinarySignatureHolder)sh).getSignatureObject().getTimeStamp(); - } - // [tknall] start: missing time of verification fixed - if (this.vTime == null) { - // verification time not been set (= null) therefore signingtime equals verificationtime - this.vTime = super.getSigningTime(); - } - // [tknall] stop: missing time of verification fixed - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getCertificateCheck() - */ - public SignatureCheck getCertificateCheck() - { - return new SignatureCheckImpl(Integer.parseInt(this.sigRes.getCertificateCheckCode()), this.sigRes.getCertificateCheckInfo()); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getManifestCheckCode() - */ - public SignatureCheck getManifestCheckCode() - { - return new SignatureCheckImpl(Integer.parseInt(this.sigRes.getSignatureManifestCheckCode()), this.sigRes.getSignatureManifestCheckInfo()); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getValueCheckCode() - */ - public SignatureCheck getValueCheckCode() - { - return new SignatureCheckImpl(Integer.parseInt(this.sigRes.getSignatureCheckCode()), this.sigRes.getSignatureCheckInfo()); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getVerificationTime() - */ - public Date getVerificationTime() - { - return this.vTime; - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#isQualifiedCertificate() - */ - public boolean isQualifiedCertificate() - { - return this.sigRes.isQualifiedCertificate(); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getPublicProperties() - */ - public List getPublicProperties() - { - try - { - return this.sigRes.getPublicProperties(); - } - catch (SettingNotFoundException e) - { - logger_.error(e.getMessage(), e); - return new ArrayList(); - } - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getInternalSignatureInformation() - */ - public Object getInternalSignatureInformation() - { - return null; - } - - /** - * @see at.gv.egiz.pdfas.api.commons.SignatureInformation#getSignerCertificate() - */ - public X509Certificate getSignerCertificate() - { - // TODO this should be the same as the signature holder's cert. - return this.sigRes.getCertificate().getX509Certificate(); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getHashInputData() - */ - public String getHashInputData() - { - return this.sigRes.getHashInputData(); - } - - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#getPublicAuthorityCode() - */ - public String getPublicAuthorityCode() { - return this.sigRes.getPublicAuthorityCode(); - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResult#isPublicAuthority() - */ - public boolean isPublicAuthority() { - return this.sigRes.isPublicAuthority(); - } - - public PdfAsException getVerificationException() { - return this.sigRes.getVerificationImpossibleEx(); - } - - public boolean isVerificationDone() { - return this.sigRes.getVerificationImpossibleEx() == null; - } - - /** - * @see VerifyResult#getReconstructedXMLDsig() - */ - public XMLDsigData getReconstructedXMLDsig() { - return this.xmlDsigData; - } - -} diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java deleted file mode 100644 index c5ce3ba..0000000 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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. - */ -package at.gv.egiz.pdfas.impl.api.verify; - -import java.util.List; - -import at.gv.egiz.pdfas.api.verify.VerifyResults; - -/** - * @author wprinz - */ -public class VerifyResultsImpl implements VerifyResults -{ - /** - * The results. - */ - protected List results = null; - - /** - * Constructor. - * - * @param results - * The results. - */ - public VerifyResultsImpl(List results) - { - this.results = results; - } - - /** - * @see at.gv.egiz.pdfas.api.verify.VerifyResults#getResults() - */ - public List getResults() - { - return this.results; - } - - -} -- cgit v1.2.3