aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/sl
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/sl')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java18
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISLConnector.java9
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnector.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java13
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java5
6 files changed, 34 insertions, 21 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
index afceb96f..204fd727 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BKUSLConnector.java
@@ -46,6 +46,7 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
import at.gv.egiz.pdfas.common.utils.PDFUtils;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
import at.gv.egiz.sl.schema.ErrorResponseType;
import at.gv.egiz.sl.schema.InfoboxReadRequestType;
@@ -69,7 +70,7 @@ public class BKUSLConnector extends BaseSLConnector {
return builder.build();
}
- private String performHttpRequestToBKU(String xmlRequest, RequestPackage pack)
+ private String performHttpRequestToBKU(String xmlRequest, RequestPackage pack, SignParameter parameter)
throws ClientProtocolException, IOException, IllegalStateException {
CloseableHttpClient client = null;
try {
@@ -81,6 +82,13 @@ public class BKUSLConnector extends BaseSLConnector {
entityBuilder.addTextBody(XMLREQUEST, xmlRequest,
ContentType.TEXT_XML);
+ if(parameter != null) {
+ String transactionId = parameter.getTransactionId();
+ if(transactionId != null) {
+ entityBuilder.addTextBody("TransactionId_", transactionId);
+ }
+ }
+
if(pack != null && pack.getSignatureData() != null) {
entityBuilder.addBinaryBody("fileupload",
PDFUtils.blackOutSignature(pack.getSignatureData(), pack.getByteRange()));
@@ -115,7 +123,7 @@ public class BKUSLConnector extends BaseSLConnector {
}
public InfoboxReadResponseType sendInfoboxReadRequest(
- InfoboxReadRequestType request) throws PdfAsException {
+ InfoboxReadRequestType request, SignParameter parameter) throws PdfAsException {
JAXBElement<?> element = null;
String slRequest;
try {
@@ -123,7 +131,7 @@ public class BKUSLConnector extends BaseSLConnector {
.createInfoboxReadRequest(request));
logger.trace(slRequest);
- String slResponse = performHttpRequestToBKU(slRequest, null);
+ String slResponse = performHttpRequestToBKU(slRequest, null, parameter);
element = (JAXBElement<?>) SLMarschaller
.unmarshalFromString(slResponse);
@@ -154,7 +162,7 @@ public class BKUSLConnector extends BaseSLConnector {
}
public CreateCMSSignatureResponseType sendCMSRequest(
- RequestPackage pack) throws PdfAsException {
+ RequestPackage pack, SignParameter parameter) throws PdfAsException {
JAXBElement<?> element = null;
String slRequest;
try {
@@ -162,7 +170,7 @@ public class BKUSLConnector extends BaseSLConnector {
.createCreateCMSSignatureRequest(pack.getRequestType()));
logger.debug(slRequest);
- String slResponse = performHttpRequestToBKU(slRequest, pack);
+ String slResponse = performHttpRequestToBKU(slRequest, pack, parameter);
element = (JAXBElement<?>) SLMarschaller
.unmarshalFromString(slResponse);
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java
index 5321ed51..99cdb9f8 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
import at.gv.egiz.pdfas.common.utils.PDFUtils;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.sl.schema.Base64OptRefContentType;
import at.gv.egiz.sl.schema.Base64XMLLocRefContentType;
import at.gv.egiz.sl.schema.Base64XMLLocRefOptRefContentType;
@@ -60,7 +61,7 @@ public abstract class BaseSLConnector implements ISLConnector {
protected ObjectFactory of = new ObjectFactory();
- public InfoboxReadRequestType createInfoboxReadRequest() {
+ public InfoboxReadRequestType createInfoboxReadRequest(SignParameter parameter) {
InfoboxReadRequestType request = new InfoboxReadRequestType();
request.setInfoboxIdentifier("Certificates");
InfoboxReadParamsAssocArrayType readData = new InfoboxReadParamsAssocArrayType();
@@ -73,7 +74,7 @@ public abstract class BaseSLConnector implements ISLConnector {
return request;
}
- public RequestPackage createCMSRequest(byte[] signatureData, int[] byteRange)
+ public RequestPackage createCMSRequest(byte[] signatureData, int[] byteRange, SignParameter parameter)
throws PDFIOException {
//if (base64) {
byte[] data = PDFUtils.blackOutSignature(signatureData, byteRange);
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISLConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISLConnector.java
index 120f2f73..1a2f8f79 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISLConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISLConnector.java
@@ -25,14 +25,15 @@ package at.gv.egiz.sl.util;
import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
import at.gv.egiz.sl.schema.InfoboxReadRequestType;
import at.gv.egiz.sl.schema.InfoboxReadResponseType;
public interface ISLConnector {
- public InfoboxReadRequestType createInfoboxReadRequest();
- public InfoboxReadResponseType sendInfoboxReadRequest(InfoboxReadRequestType request) throws PdfAsException;
- public RequestPackage createCMSRequest(byte[] signatureData, int[] byteRange) throws PDFIOException;
- public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack) throws PdfAsException;
+ public InfoboxReadRequestType createInfoboxReadRequest(SignParameter parameter);
+ public InfoboxReadResponseType sendInfoboxReadRequest(InfoboxReadRequestType request, SignParameter parameter) throws PdfAsException;
+ public RequestPackage createCMSRequest(byte[] signatureData, int[] byteRange, SignParameter parameter) throws PDFIOException;
+ public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack, SignParameter parameter) throws PdfAsException;
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnector.java
index e39398a6..fdb95f49 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnector.java
@@ -25,8 +25,9 @@ package at.gv.egiz.sl.util;
import iaik.x509.X509Certificate;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
public interface ISignatureConnector {
- public X509Certificate getCertificate() throws PdfAsException;
- public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException;
+ public X509Certificate getCertificate(SignParameter parameter) throws PdfAsException;
+ public byte[] sign(byte[] input, int[] byteRange, SignParameter parameter) throws PdfAsException;
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
index 1b9fad2a..b564c215 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsSignatureException;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.pdfas.lib.impl.verify.VerifyResultImpl;
import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
import at.gv.egiz.sl.schema.InfoboxAssocArrayPairType;
@@ -58,13 +59,13 @@ public class ISignatureConnectorSLWrapper implements ISignatureConnector {
this.connector = connector;
}
- public X509Certificate getCertificate() throws PdfAsException {
+ public X509Certificate getCertificate(SignParameter parameter) throws PdfAsException {
X509Certificate certificate = null;
try {
InfoboxReadRequestType request = connector
- .createInfoboxReadRequest();
+ .createInfoboxReadRequest(parameter);
InfoboxReadResponseType response = connector
- .sendInfoboxReadRequest(request);
+ .sendInfoboxReadRequest(request, parameter);
Iterator<InfoboxAssocArrayPairType> iterator = response
.getAssocArrayData().getPair().iterator();
@@ -83,11 +84,11 @@ public class ISignatureConnectorSLWrapper implements ISignatureConnector {
return certificate;
}
- public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException {
+ public byte[] sign(byte[] input, int[] byteRange, SignParameter parameter) throws PdfAsException {
RequestPackage pack = connector.createCMSRequest(
- input, byteRange);
+ input, byteRange, parameter);
CreateCMSSignatureResponseType response = connector
- .sendCMSRequest(pack);
+ .sendCMSRequest(pack, parameter);
try {
SignedData signedData = new SignedData(new ByteArrayInputStream(
response.getCMSSignature()));
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java
index 9c5c720a..73de30cf 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/MOAConnector.java
@@ -58,6 +58,7 @@ import at.gv.egiz.pdfas.common.exceptions.PdfAsMOAException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException;
import at.gv.egiz.pdfas.common.settings.ISettings;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
public class MOAConnector implements ISignatureConnector {
@@ -125,7 +126,7 @@ public class MOAConnector implements ISignatureConnector {
this.keyIdentifier = config.getValue(MOA_SIGN_KEY_ID);
}
- public X509Certificate getCertificate() throws PdfAsException {
+ public X509Certificate getCertificate(SignParameter parameter) throws PdfAsException {
return this.certificate;
}
@@ -134,7 +135,7 @@ public class MOAConnector implements ISignatureConnector {
return builder.build();
}
- public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException {
+ public byte[] sign(byte[] input, int[] byteRange, SignParameter parameter) throws PdfAsException {
CloseableHttpClient client = null;
try {
client = buildHttpClient();