From 73c30d3a15a33d02f7ea675e267b39310913ba4d Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 6 Dec 2010 17:02:56 +0000 Subject: Necessary changes for separation of pdf-as-web and rest of the project git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@680 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../gv/egiz/pdfas/api/internal/LocalBKUParams.java | 41 ++++++ .../gv/egiz/pdfas/api/internal/PdfAsInternal.java | 138 +++++++++++++++++++++ .../gv/egiz/pdfas/api/internal/SignatureEntry.java | 131 +++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 src/main/java/at/gv/egiz/pdfas/api/internal/LocalBKUParams.java create mode 100644 src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java create mode 100644 src/main/java/at/gv/egiz/pdfas/api/internal/SignatureEntry.java (limited to 'src/main/java/at/gv/egiz/pdfas/api/internal') diff --git a/src/main/java/at/gv/egiz/pdfas/api/internal/LocalBKUParams.java b/src/main/java/at/gv/egiz/pdfas/api/internal/LocalBKUParams.java new file mode 100644 index 0000000..114788c --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/api/internal/LocalBKUParams.java @@ -0,0 +1,41 @@ +package at.gv.egiz.pdfas.api.internal; + + +/** + * Parameter container for local BKUs. (BKU, Mocca) + * + * @author exthex + * + */ +public class LocalBKUParams { + + private String server; + private String userAgent; + private String signatureLayout; + + public LocalBKUParams(String server, String userAgent, String signatureLayout) { + this.server = server; + this.userAgent = userAgent; + this.signatureLayout = signatureLayout; + } + + public String getServer() { + return server; + } + public void setServer(String server) { + this.server = server; + } + public String getUserAgent() { + return userAgent; + } + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + public String getSignatureLayout() { + return signatureLayout; + } + public void setSignatureLayout(String signatureLayout) { + this.signatureLayout = signatureLayout; + } + +} diff --git a/src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java b/src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java new file mode 100644 index 0000000..f3a4962 --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java @@ -0,0 +1,138 @@ +package at.gv.egiz.pdfas.api.internal; + +import java.util.Map; + +import at.gv.egiz.pdfas.api.PdfAs; +import at.gv.egiz.pdfas.api.analyze.AnalyzeResult; +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.VerifyResult; +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; + +/** + * The methods of this interface are used by the pdf-as-web project and are not for external use.
+ * Using this API is inadvisable as its functionality might change without notice from release to release. + * + * @author exthex + * + */ +public interface PdfAsInternal { + + /** + * Check if a BKU with the given parameters is supported. + * + * @param bkuParams + * @throws ConnectorException if the BKU is not supported + * @throws SettingsException if the BKU is not supported + */ + public void verifyBKUSupport(LocalBKUParams bkuParams) throws ConnectorException, SettingsException; + + /** + * Finish the sign process. + * + * @param pdfAs + * @param signParameters + * @param sdi This info will most likely come from a {@link PdfAs#prepareSign(SignParameters)} call + * @param bkuParams + * @param xmlResponse the SecurityLayer response from the BKU + * @return the signed document + additional info + * @throws PdfAsException + */ + public SignResult finishLocalSign(PdfAs pdfAs, SignParameters signParameters, SignatureDetailInformation sdi, LocalBKUParams bkuParams, String xmlResponse) throws PdfAsException; + + /** + * Get the security layer address for the given connector. (zB: http://127.0.0.1:3495/http-security-layer-request) + * + * @param profile + * @param device + * @return + * @throws SettingsException + */ + public String getLocalServiceAddress(String profile, String device) throws SettingsException; + + /** + * Get the CreateXMLSignatureRequest for the given parameters. + * + * @param signParameters the sign parameters. {@link SignParameters#getSignatureDevice()} determines the connector to use. + * @param loc_ref_url the URL where to retrieve the PDF to sign + * @param sdi {@link SignatureDetailInformation#getSignatureData()} provides the data to be signed. + * @return + * @throws ConnectorException + */ + public String prepareLocalSignRequest(SignParameters signParameters, String loc_ref_url, SignatureDetailInformation sdi) throws ConnectorException; + + /** + * Create an AnalyzeResult from raw text, instead of a PDF. + * + * @param rawText + * @param sigValues the signature values + * @return + * @throws SignatureException + * @throws SettingsException + * @throws SignatureTypesException + * @throws NormalizeException + */ + public AnalyzeResult analyzeFromRawText(String rawText, Map sigValues) throws SignatureException, SettingsException, SignatureTypesException, NormalizeException; + + /** + * Create the SecurityLayer VerifyXMLSignatureRequest for the given parameters. + * + * @param sigInfo + * @param connector + * @param profile + * @param loc_ref_url + * @return + * @throws SignatureException + * @throws ConnectorException + */ + public String prepareLocalVerifyRequest(SignatureInformation sigInfo, String connector, String profile, String loc_ref_url) throws SignatureException, ConnectorException; + + /** + * Parse the given xml_response - must be a VerifyXMLSignatureResponse - from the BKU or Mocca and generates a VerifyResult from it. + * + * @param sigInfo + * @param connector + * @param profile + * @param loc_ref_url + * @param xmlResponse + * @return + * @throws SignatureException + * @throws ConnectorException + */ + public VerifyResult finishLocalVerify(SignatureInformation sigInfo, String connector, String profile, String loc_ref_url, String xmlResponse) throws SignatureException, ConnectorException; + + /** + * Get the {@link SignatureEntry} corresponding to a given {@link SignatureInformation} + * + * @param key + * @param sigInfo + * @return + */ + public SignatureEntry getSignatureEntryFromSignatureInformation(String key, SignatureInformation sigInfo); + + /** + * Get the signed text for a given sigInfo.
+ * If this signature is not text based this method will return null. + * + * @param sigInfo + * @return + */ + public String getSignedText(SignatureInformation sigInfo); + + /** + * Get a map of all connectors available for web. + * The key is the connector id, the value is the description. + * + * @return + * @throws ConnectorFactoryException + */ + public Map getConnectorsAvailableForWeb() throws ConnectorFactoryException; +} diff --git a/src/main/java/at/gv/egiz/pdfas/api/internal/SignatureEntry.java b/src/main/java/at/gv/egiz/pdfas/api/internal/SignatureEntry.java new file mode 100644 index 0000000..3b039ab --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/api/internal/SignatureEntry.java @@ -0,0 +1,131 @@ +/* + * + * Copyright (c) 2006 by Know-Center, Graz, Austria + * + * + * This software is the confidential and proprietary information of Know-Center, + * Graz, Austria. You shall not disclose such Confidential Information and shall + * use it only in accordance with the terms of the license agreement you entered + * into with Know-Center. + * + * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE + * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, + * OR NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES + * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING + * THIS SOFTWARE OR ITS DERIVATIVES. + * + * $Id: SignatureEntry.java,v 1.3 2006/08/25 17:09:41 wprinz Exp $ + */ +package at.gv.egiz.pdfas.api.internal; + +import java.io.Serializable; + +/** + * A container for signature entries. + * Copied to internal api from {@link at.knowcenter.wag.egov.egiz.sig.SignatureEntry} + * + * @author exthex + * @see at.knowcenter.wag.egov.egiz.sig.SignatureEntry + */ +public class SignatureEntry implements Serializable { + + /** + * SVUID. + */ + private static final long serialVersionUID = -1L; + + /** + * The signature key. + */ + private String key_ = null; + /** + * The signature caption for the key found or set in the signature text. + */ + private String caption_ = null; + /** + * The signature value for the key found or set in the signature text. + */ + private String value_ = null; + + /** + * The empty constructor. + */ + public SignatureEntry() { + } + + /** + * A new SignatureEntry init with the key. + * + * @param key + */ + public SignatureEntry(String key) { + key_ = key; + } + + /** + * Returns the caption off the current key. + * + * @return Returns the caption. + */ + public String getCaption() { + return caption_; + } + + /** + * Set the caption of the current key. + * + * @param caption The caption to set. + */ + public void setCaption(String caption) { + caption_ = caption; + } + + /** + * Return the current key. + * + * @return Returns the key. + */ + public String getKey() { + return key_; + } + + /** + * Set the current key. + * + * @param key The key to set. + */ + public void setKey(String key) { + key_ = key; + } + + /** + * Return the value of the current key. + * + * @return Returns the value. + */ + public String getValue() { + return value_; + } + + /** + * Set the value of the current key. + * + * @param value The value to set. + */ + public void setValue(String value) { + value_ = value; + } + + /** + * The toString method, used for tests or debugging. + */ + public String toString() { + String the_string = ""; + the_string += "\n Key:" + key_; + the_string += "\nCaption:" + caption_; + the_string += "\n Value:" + value_; +// the_string += "\nStart I:" + startIndex_; + return the_string; + } +} \ No newline at end of file -- cgit v1.2.3