From c0ea288869c5c21d93c59702148305eefa3f1f51 Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 13 Dec 2010 16:00:29 +0000 Subject: Minor changes to ease web -> pdf-as handling git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@706 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../egiz/pdfas/web/helper/LocalRequestHelper.java | 2 +- .../egiz/pdfas/web/helper/SignServletHelper.java | 2 +- .../gv/egiz/pdfas/api/internal/PdfAsInternal.java | 6 +++-- .../at/gv/egiz/pdfas/impl/api/CheckHelper.java | 11 ++++++++ .../impl/api/internal/PdfAsInternalObject.java | 29 ++++++++++++---------- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java index 9717662..41a565f 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/LocalRequestHelper.java @@ -86,7 +86,7 @@ public abstract class LocalRequestHelper URL loc_ref_URL = new URL(WebUtils.buildRetrieveSignatureDataURL(request, response)); String loc_ref_url = response.encodeURL(loc_ref_URL.toString()); - String sign_request = pdfAsInternal.prepareLocalSignRequest(si.signParameters, loc_ref_url, si.sdi); + String sign_request = pdfAsInternal.prepareLocalSignRequest(si.signParameters, false, loc_ref_url, si.sdi); String local_request_url = pdfAsInternal.getLocalServiceAddress(si.type, si.connector); si.localRequest = new LocalRequest(local_request_url, sign_request); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java index 3f2ac6c..925df3a 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/SignServletHelper.java @@ -317,7 +317,7 @@ public class SignServletHelper ByteArrayDataSink data = new ByteArrayDataSink(); si.signParameters.setOutput(data); - SignResult signResult = pdfAsInternal.finishLocalSign(pdfAs, si.signParameters, si.sdi, si.localBKUParams, si.xmlResponse); + SignResult signResult = pdfAsInternal.finishLocalSign(pdfAs, si.signParameters, si.sdi, si.localBKUParams, false, si.xmlResponse); si.signResult = signResult; si.output = data; si.outputAvailable = true; 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 index f3a4962..bb5b940 100644 --- a/src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java +++ b/src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java @@ -46,7 +46,7 @@ public interface PdfAsInternal { * @return the signed document + additional info * @throws PdfAsException */ - public SignResult finishLocalSign(PdfAs pdfAs, SignParameters signParameters, SignatureDetailInformation sdi, LocalBKUParams bkuParams, String xmlResponse) throws PdfAsException; + public SignResult finishLocalSign(PdfAs pdfAs, SignParameters signParameters, SignatureDetailInformation sdi, LocalBKUParams bkuParams, boolean multipart, String xmlResponse) throws PdfAsException; /** * Get the security layer address for the given connector. (zB: http://127.0.0.1:3495/http-security-layer-request) @@ -60,14 +60,16 @@ public interface PdfAsInternal { /** * Get the CreateXMLSignatureRequest for the given parameters. + * The request will use the given callback address to retrieve the data to sign. * * @param signParameters the sign parameters. {@link SignParameters#getSignatureDevice()} determines the connector to use. + * @param multipart true to select a {@link at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector} that uses multipart requests * @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; + public String prepareLocalSignRequest(SignParameters signParameters, boolean multipart, String loc_ref_url, SignatureDetailInformation sdi) throws ConnectorException; /** * Create an AnalyzeResult from raw text, instead of a PDF. 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 index d48435a..74e4b06 100644 --- a/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java +++ b/src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java @@ -42,6 +42,17 @@ public final class 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. * 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 index 747f6b0..6531678 100644 --- 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 @@ -56,6 +56,7 @@ 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; @@ -86,8 +87,8 @@ public class PdfAsInternalObject implements PdfAsInternal { /** * @see PdfAsInternal#finishLocalSign(PdfAs, SignParameters, SignatureDetailInformation, LocalBKUParams, String) */ - public SignResult finishLocalSign(PdfAs pdfAs, SignParameters signParameters, SignatureDetailInformation sdi, LocalBKUParams bkuParams, String xmlResponse) throws PdfAsException { - LocalConnector c = chooseLocalConnectorForSign(signParameters.getSignatureDevice(), signParameters.getSignatureProfileId(), "not needed"); + 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); @@ -106,18 +107,20 @@ public class PdfAsInternalObject implements PdfAsInternal { return ret; } - private LocalConnector chooseLocalConnectorForSign(String connector, String profile, String loc_ref_url) throws ConnectorException{ + 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(connector)) { - - return new LocRefDetachedMOCCAConnector(cp, loc_ref_url); - - } else if (Constants.SIGNATURE_DEVICE_BKU.equals(connector)){ - return new LocRefDetachedBKUConnector(cp, loc_ref_url); - + 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); + } } log.error("Currently only the BKU connector is fully implemented."); @@ -204,9 +207,9 @@ public class PdfAsInternalObject implements PdfAsInternal { /** * @see PdfAsInternal#prepareLocalSignRequest(SignParameters, String, SignatureDetailInformation) */ - public String prepareLocalSignRequest(SignParameters signParameters, String loc_ref_url, + 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); + 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; -- cgit v1.2.3