aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/internal/PdfAsInternal.java6
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/CheckHelper.java11
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java29
3 files changed, 31 insertions, 15 deletions
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
@@ -44,6 +44,17 @@ public final class CheckHelper
/**
* 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}
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;