aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-14 13:31:07 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-14 13:31:07 +0200
commit49f389e3e943dd9e1e4c9271a9e03a1ba9201b2d (patch)
tree84a2db7ff8d6c6f6aad19a2109a9f4462affd2ef /pdf-as-lib/src/main/java/at/gv/egiz
parent08c97191ccc476ac318935f09866b3f099cc2ef1 (diff)
downloadpdf-as-4-49f389e3e943dd9e1e4c9271a9e03a1ba9201b2d.tar.gz
pdf-as-4-49f389e3e943dd9e1e4c9271a9e03a1ba9201b2d.tar.bz2
pdf-as-4-49f389e3e943dd9e1e4c9271a9e03a1ba9201b2d.zip
added Fileupload SL Request option
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java3
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/BaseSLConnector.java132
2 files changed, 57 insertions, 78 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
index 4b3eefb2..fa8857a9 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
@@ -85,4 +85,7 @@ public interface IConfigurationConstants {
public static final String MOC_SIGN_URL = "moc.sign.url";
public static final String MOBILE_SIGN_URL = "mobile.sign.url";
+ public static final String SL_REQUEST_TYPE = "sl.request.type";
+ public static final String SL_REQUEST_TYPE_BASE64 = "b64";
+ public static final String SL_REQUEST_TYPE_UPLOAD = "upload";
}
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 a5036005..349a1485 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
@@ -33,6 +33,7 @@ import at.gv.egiz.pdfas.common.utils.PDFUtils;
import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.sl.schema.Base64OptRefContentType;
+import at.gv.egiz.sl.schema.Base64XMLLocRefOptRefContentType;
import at.gv.egiz.sl.schema.CMSDataObjectRequiredMetaType;
import at.gv.egiz.sl.schema.CreateCMSSignatureRequestType;
import at.gv.egiz.sl.schema.ExcludedByteRangeType;
@@ -42,7 +43,8 @@ import at.gv.egiz.sl.schema.InfoboxReadRequestType;
import at.gv.egiz.sl.schema.MetaInfoType;
import at.gv.egiz.sl.schema.ObjectFactory;
-public abstract class BaseSLConnector implements ISLConnector, IConfigurationConstants {
+public abstract class BaseSLConnector implements ISLConnector,
+ IConfigurationConstants {
private static final Logger logger = LoggerFactory
.getLogger(BaseSLConnector.class);
@@ -58,7 +60,8 @@ public abstract class BaseSLConnector implements ISLConnector, IConfigurationCon
protected ObjectFactory of = new ObjectFactory();
- public InfoboxReadRequestType createInfoboxReadRequest(SignParameter parameter) {
+ public InfoboxReadRequestType createInfoboxReadRequest(
+ SignParameter parameter) {
InfoboxReadRequestType request = new InfoboxReadRequestType();
request.setInfoboxIdentifier("Certificates");
InfoboxReadParamsAssocArrayType readData = new InfoboxReadParamsAssocArrayType();
@@ -71,87 +74,60 @@ public abstract class BaseSLConnector implements ISLConnector, IConfigurationCon
return request;
}
- public RequestPackage createCMSRequest(byte[] signatureData, int[] byteRange, SignParameter parameter)
- throws PDFIOException {
- //if (base64) {
- byte[] data = PDFUtils.blackOutSignature(signatureData, byteRange);
+ public RequestPackage createCMSRequest(byte[] signatureData,
+ int[] byteRange, SignParameter parameter) throws PDFIOException {
+ boolean base64 = true;
+ String requestType = parameter.getConfiguration().getValue(
+ SL_REQUEST_TYPE);
+ if (requestType != null) {
+ if (requestType.equals(SL_REQUEST_TYPE_BASE64)) {
+ base64 = true;
+ } else if (requestType.equals(SL_REQUEST_TYPE_UPLOAD)) {
+ base64 = true;
+ }
+ }
+ byte[] data = PDFUtils.blackOutSignature(signatureData, byteRange);
+ RequestPackage pack = new RequestPackage();
+ int[] exclude_range = PDFUtils.buildExcludeRange(byteRange);
+ logger.info("Exclude Byte Range: " + exclude_range[0] + " "
+ + exclude_range[1]);
- int[] exclude_range = PDFUtils.buildExcludeRange(byteRange);
- logger.info("Exclude Byte Range: " + exclude_range[0] + " "
- + exclude_range[1]);
+ // == MetaInfoType
+ MetaInfoType metaInfoType = new MetaInfoType();
+ metaInfoType.setMimeType(PDF_MIME_TYPE);
- // == MetaInfoType
- MetaInfoType metaInfoType = new MetaInfoType();
- metaInfoType.setMimeType(PDF_MIME_TYPE);
+ // == Base64OptRefContentType
+ Base64OptRefContentType base64OptRefContentType = new Base64OptRefContentType();
- // == Base64OptRefContentType
- Base64OptRefContentType base64OptRefContentType = new Base64OptRefContentType();
+ if (base64) {
base64OptRefContentType.setBase64Content(data);
-
- // == CMSDataObjectRequiredMetaType
- CMSDataObjectRequiredMetaType cmsDataObjectRequiredMetaType = new CMSDataObjectRequiredMetaType();
- cmsDataObjectRequiredMetaType.setMetaInfo(metaInfoType);
- cmsDataObjectRequiredMetaType.setContent(base64OptRefContentType);
- if (byteRange.length > 0) {
- ExcludedByteRangeType excludeByteRange = new ExcludedByteRangeType();
- excludeByteRange.setFrom(new BigInteger(String
- .valueOf(exclude_range[0])));
- excludeByteRange.setTo(new BigInteger(String
- .valueOf(exclude_range[1])));
- cmsDataObjectRequiredMetaType
- .setExcludedByteRange(excludeByteRange);
- }
-
- // == CreateCMSSignatureRequestType
- CreateCMSSignatureRequestType request = new CreateCMSSignatureRequestType();
- request.setKeyboxIdentifier(SecureSignatureKeypair);
- request.setDataObject(cmsDataObjectRequiredMetaType);
- request.setStructure(DETACHED);
-
- RequestPackage pack = new RequestPackage();
-
- pack.setRequestType(request);
- return pack;
- /*} else {
- RequestPackage pack = new RequestPackage();
+ } else {
+ base64OptRefContentType.setReference("formdata:fileupload");
pack.setSignatureData(signatureData);
pack.setByteRange(byteRange);
-
- int[] exclude_range = PDFUtils.buildExcludeRange(byteRange);
- logger.info("Exclude Byte Range: " + exclude_range[0] + " "
- + exclude_range[1]);
-
- // == MetaInfoType
- MetaInfoType metaInfoType = new MetaInfoType();
- metaInfoType.setMimeType(PDF_MIME_TYPE);
-
- // == File RefContentType
- Base64XMLLocRefOptRefContentType base64OptRefContentType = new Base64XMLLocRefOptRefContentType();
- base64OptRefContentType.setLocRefContent("formdata:fileupload");
-
- DataObjectInfoType cmsObject = new DataObjectInfoType();
- cmsObject.setDataObject(base64OptRefContentType);
- // == CMSDataObjectRequiredMetaType
- CMSDataObjectRequiredMetaType cmsDataObjectRequiredMetaType = new CMSDataObjectRequiredMetaType();
- cmsDataObjectRequiredMetaType.setMetaInfo(metaInfoType);
- cmsDataObjectRequiredMetaType.setContent(value);
- if (byteRange.length > 0) {
- ExcludedByteRangeType excludeByteRange = new ExcludedByteRangeType();
- excludeByteRange.setFrom(new BigInteger(String
- .valueOf(exclude_range[0])));
- excludeByteRange.setTo(new BigInteger(String
- .valueOf(exclude_range[1])));
- cmsObject.
- .setExcludedByteRange(excludeByteRange);
- }
-
- // == CreateCMSSignatureRequestType
- CreateCMSSignatureRequestType request = new CreateCMSSignatureRequestType();
- request.setKeyboxIdentifier(SecureSignatureKeypair);
- request.setDataObject(cmsDataObjectRequiredMetaType);
- request.setStructure(DETACHED);
- pack.setRequestType(request);
- return pack;
- }*/
+ }
+
+ // == CMSDataObjectRequiredMetaType
+ CMSDataObjectRequiredMetaType cmsDataObjectRequiredMetaType = new CMSDataObjectRequiredMetaType();
+ cmsDataObjectRequiredMetaType.setMetaInfo(metaInfoType);
+ cmsDataObjectRequiredMetaType.setContent(base64OptRefContentType);
+ if (byteRange.length > 0) {
+ ExcludedByteRangeType excludeByteRange = new ExcludedByteRangeType();
+ excludeByteRange.setFrom(new BigInteger(String
+ .valueOf(exclude_range[0])));
+ excludeByteRange.setTo(new BigInteger(String
+ .valueOf(exclude_range[1])));
+ cmsDataObjectRequiredMetaType
+ .setExcludedByteRange(excludeByteRange);
+ }
+
+ // == CreateCMSSignatureRequestType
+ CreateCMSSignatureRequestType request = new CreateCMSSignatureRequestType();
+ request.setKeyboxIdentifier(SecureSignatureKeypair);
+ request.setDataObject(cmsDataObjectRequiredMetaType);
+ request.setStructure(DETACHED);
+
+ pack.setRequestType(request);
+ return pack;
}
}