summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2015-02-23 15:29:35 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2015-02-23 15:29:35 +0100
commit7b6860087f50b7576c31f7aa50714d3fa7a9b228 (patch)
treec2347315c5a0e4e6565f9020d3e1d7d38d94abfe
parent72cb98966c0d631ed4741bf071c621fd36f33fd6 (diff)
downloadpdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.tar.gz
pdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.tar.bz2
pdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.zip
BASE64 request handling
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java61
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java10
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java30
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java10
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java59
-rw-r--r--pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java8
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java2
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java8
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java9
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java8
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java9
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java10
-rw-r--r--pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java32
15 files changed, 108 insertions, 152 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
index f862455c..eb1b57d6 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/LocalBKUConnector.java
@@ -47,9 +47,6 @@ public class LocalBKUConnector implements BkuSlConnector {
private static final Logger log = LoggerFactory
.getLogger(LocalBKUConnector.class);
- /** Whether to use Base64 or FileUpload Request */
- private boolean useBase64Request = false;
-
/**
* HTTP Response server HEADER
*/
@@ -65,12 +62,6 @@ public class LocalBKUConnector implements BkuSlConnector {
*/
public final static String BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; //$NON-NLS-1$
- /**
- * Null-Operation SL-Request
- */
- private final static String NULL_OPERATION_REQUEST = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
- "<sl:NullOperationRequest xmlns:sl=\"http://www.buergerkarte.at/namespaces/securitylayer/1.2#\"/>"; //$NON-NLS-1$
-
/* (non-Javadoc)
* @see at.asit.pdfover.signator.BkuSlConnector#handleSLRequest(java.lang.String)
*/
@@ -78,54 +69,36 @@ public class LocalBKUConnector implements BkuSlConnector {
public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
try {
HttpClient client = BKUHelper.getHttpClient();
-
PostMethod method = new PostMethod(Constants.LOCAL_BKU_URL);
- String sl_request = NULL_OPERATION_REQUEST;
- method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
- int returnCode = client.executeMethod(method);
-
- String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
- String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
- if (server != null && server.contains("trustDeskbasic")) //$NON-NLS-1$
- this.useBase64Request = true; // TDB doesn't support MultiPart requests
-
- method = new PostMethod(Constants.LOCAL_BKU_URL);
-
- if (request.getSignatureData() != null) {
- if (this.useBase64Request)
- {
- sl_request = request.getBase64Request();
- method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
- } else {
- sl_request = request.getFileUploadRequest();
- StringPart xmlpart = new StringPart(
- "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
- new FileUploadSource(request.getSignatureData()));
-
- Part[] parts = { xmlpart, filepart };
-
- method.setRequestEntity(new MultipartRequestEntity(parts, method
- .getParams()));
- }
+ String sl_request = request.getRequest();
+ if (request.getSignatureData() == null) {
+ method.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
} else {
- method.addParameter("XMLRequest", request.getRequest()); //$NON-NLS-1$
+ StringPart xmlpart = new StringPart(
+ "XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
+ new FileUploadSource(request.getSignatureData()));
+
+ Part[] parts = { xmlpart, filepart };
+
+ method.setRequestEntity(new MultipartRequestEntity(parts, method
+ .getParams()));
}
- log.debug("SL REQUEST: " + sl_request); //$NON-NLS-1$
+ log.trace("SL REQUEST: " + sl_request); //$NON-NLS-1$
- returnCode = client.executeMethod(method);
+ int returnCode = client.executeMethod(method);
if (returnCode != HttpStatus.SC_OK) {
throw new HttpException(
method.getResponseBodyAsString());
}
- server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
+ String server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
if (server == null)
server = ""; //$NON-NLS-1$
- userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
+ String userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
if (userAgent == null)
userAgent = ""; //$NON-NLS-1$
String signatureLayout = getResponseHeader(method, BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
index 7112bd94..12eff95b 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/ATrustHandler.java
@@ -239,7 +239,7 @@ public class ATrustHandler extends MobileBKUHandler {
* @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request()
*/
@Override
- protected boolean useBase64Request() {
+ public boolean useBase64Request() {
return false;
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
index 04338f8b..0904f045 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
@@ -306,7 +306,7 @@ public class IAIKHandler extends MobileBKUHandler {
* @see at.asit.pdfover.gui.bku.mobile.MobileBKUHandler#useBase64Request()
*/
@Override
- protected boolean useBase64Request() {
+ public boolean useBase64Request() {
return false;
}
}
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
index 4644002e..429000f1 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHandler.java
@@ -75,17 +75,17 @@ public abstract class MobileBKUHandler {
PostMethod post = new PostMethod(mobileBKUUrl);
String sl_request;
if (request.getSignatureData() != null) {
+ sl_request = request.getRequest();
if (useBase64Request())
{
- sl_request = request.getBase64Request();
post.addParameter("XMLRequest", sl_request); //$NON-NLS-1$
} else {
- sl_request = request.getFileUploadRequest();
StringPart xmlpart = new StringPart(
"XMLRequest", sl_request, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
- FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
- new FileUploadSource(request.getSignatureData()));
+ FilePart filepart = new FilePart("fileupload", //$NON-NLS-1$
+ new FileUploadSource(request.getSignatureData()),
+ "application/pdf", "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
Part[] parts = { xmlpart, filepart };
@@ -168,7 +168,7 @@ public abstract class MobileBKUHandler {
* Whether to use a Base64 request
* @return true if base64 request shall be used
*/
- protected abstract boolean useBase64Request();
+ public abstract boolean useBase64Request();
/**
* Execute a post to the mobile BKU, following redirects
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
index 3962d836..dd47fe9d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/LocalBKUState.java
@@ -25,8 +25,8 @@ import org.eclipse.swt.SWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.Constants;
+import at.asit.pdfover.gui.MainWindow.Buttons;
import at.asit.pdfover.gui.MainWindowBehavior;
import at.asit.pdfover.gui.bku.BKUHelper;
import at.asit.pdfover.gui.bku.LocalBKUConnector;
@@ -36,6 +36,7 @@ import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.Status;
import at.asit.pdfover.signator.SLResponse;
+import at.asit.pdfover.signator.SigningState;
/**
* Logical state for performing the BKU Request to a local BKU
@@ -62,10 +63,11 @@ public class LocalBKUState extends State {
*/
public final static String BKU_RESPONSE_HEADER_SIGNATURE_LAYOUT = "SignatureLayout"; //$NON-NLS-1$
- at.asit.pdfover.signator.SigningState signingState;
-
Exception threadException = null;
+ /** Whether to use Base64 or FileUpload Request */
+ boolean useBase64Request = false;
+
/**
* Null-Operation SL-Request
*/
@@ -86,13 +88,16 @@ public class LocalBKUState extends State {
private final class SignLocalBKUThread implements Runnable {
private LocalBKUState state;
+ private SigningState signingState;
/**
* @param localBKUState
+ * @param signingState
*/
- public SignLocalBKUThread(LocalBKUState localBKUState) {
+ public SignLocalBKUThread(LocalBKUState localBKUState, SigningState signingState) {
this.state = localBKUState;
+ this.signingState = signingState;
}
@Override
@@ -117,6 +122,10 @@ public class LocalBKUState extends State {
server = getResponseHeader(method, BKU_RESPONSE_HEADER_SERVER);
if (server == null)
server = ""; //$NON-NLS-1$
+ else
+ if (server.contains("trustDeskbasic")) //$NON-NLS-1$
+ LocalBKUState.this.useBase64Request = true;
+
userAgent = getResponseHeader(method, BKU_RESPONSE_HEADER_USERAGENT);
if (userAgent == null)
userAgent = ""; //$NON-NLS-1$
@@ -126,7 +135,8 @@ public class LocalBKUState extends State {
log.debug("SL Response: " + response); //$NON-NLS-1$
SLResponse slResponse = new SLResponse(response, server,
userAgent, signatureLayout);
- this.state.signingState.setSignatureResponse(slResponse);
+ this.signingState.setSignatureResponse(slResponse);
+ this.signingState.setUseBase64Request(LocalBKUState.this.useBase64Request);
}
} catch (Exception e) {
log.error("SignLocalBKUThread: ", e); //$NON-NLS-1$
@@ -161,15 +171,15 @@ public class LocalBKUState extends State {
public void run() {
Status status = getStateMachine().getStatus();
- this.signingState = status.getSigningState();
+ SigningState signingState = status.getSigningState();
- if (!this.signingState.hasSignatureResponse()
+ if (!signingState.hasSignatureResponse()
&& this.threadException == null) {
- Thread t = new Thread(new SignLocalBKUThread(this));
+ Thread t = new Thread(new SignLocalBKUThread(this, signingState));
t.start();
return;
}
- this.signingState.setBKUConnector(new LocalBKUConnector());
+ signingState.setBKUConnector(new LocalBKUConnector());
if (this.threadException != null) {
ErrorDialog dialog = new ErrorDialog(
@@ -187,7 +197,7 @@ public class LocalBKUState extends State {
}
// OK
- this.setNextState(new SigningState(getStateMachine()));
+ this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
}
/*
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
index 1df8f755..6b0d6684 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java
@@ -37,6 +37,8 @@ import at.asit.pdfover.gui.controls.Dialog.BUTTONS;
import at.asit.pdfover.gui.controls.ErrorDialog;
import at.asit.pdfover.gui.utils.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
+import at.asit.pdfover.gui.workflow.config.ConfigProvider;
+import at.asit.pdfover.signator.SigningState;
/**
* Logical state for performing the BKU Request to the A-Trust Mobile BKU
@@ -67,7 +69,7 @@ public class MobileBKUState extends State {
private static final Logger log = LoggerFactory
.getLogger(MobileBKUState.class);
- at.asit.pdfover.signator.SigningState signingState;
+ SigningState signingState;
Exception threadException = null;
@@ -138,7 +140,7 @@ public class MobileBKUState extends State {
/**
* @return the signingState
*/
- public at.asit.pdfover.signator.SigningState getSigningState() {
+ public SigningState getSigningState() {
return this.signingState;
}
@@ -315,6 +317,8 @@ public class MobileBKUState extends State {
this.signingState = getStateMachine().getStatus().getSigningState();
this.signingState.setBKUConnector(new MobileBKUConnector(this));
+ log.debug("Setting base64 request to " + this.handler.useBase64Request()); //$NON-NLS-1$
+ this.signingState.setUseBase64Request(this.handler.useBase64Request());
if (this.threadException != null) {
String message = Messages.getString("error.Unexpected"); //$NON-NLS-1$
@@ -335,7 +339,7 @@ public class MobileBKUState extends State {
getStateMachine().getGUIProvider().display(
this.getWaitingComposite());
- this.setNextState(new SigningState(getStateMachine()));
+ this.setNextState(new at.asit.pdfover.gui.workflow.states.SigningState(getStateMachine()));
}
/*
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
index 9edd0a02..5fd9c756 100644
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
+++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SLRequest.java
@@ -15,19 +15,12 @@
*/
package at.asit.pdfover.signator;
-import org.apache.commons.codec.binary.Base64;
-
/**
* Security Layer Request
*/
public class SLRequest {
/**
- * The String constant to replace the SL DATAOBJECT
- */
- public static final String DATAOBJECT_STRING = "##DATAOBJECT##";
-
- /**
* The security layer request
*/
private String request;
@@ -39,7 +32,6 @@ public class SLRequest {
/**
* Set the SL request
- * The data object should contain the placeholder DATAOBJECT_STRING
* @param request the request to set
*/
protected void setRequest(String request) {
@@ -47,57 +39,6 @@ public class SLRequest {
}
/**
- * The SL request String with the document encoded in base64
- *
- * This SL Request is always a detached signature request which contains a
- * reference to the data object in base64 encoding.
- *
- * @return SL request String
- */
- public String getBase64Request() {
- String b64content = new String(Base64.encodeBase64(getSignatureData().getByteArray()));
-
- String b64request = this.request.replace(
- DATAOBJECT_STRING,
- "<sl:Base64Content>" + b64content //$NON-NLS-1$
- + "</sl:Base64Content>"); //$NON-NLS-1$
-
- return b64request;
- }
-
- /**
- * The SL request String with the document defined as file upload
- * @return SL request String
- */
- public String getFileUploadRequest() {
- String fileUploadRequest = this.request.replace(
- DATAOBJECT_STRING,
- "<sl:LocRefContent>formdata:fileupload</sl:LocRefContent>"); //$NON-NLS-1$
-
- return fileUploadRequest;
- }
-
- /**
- * The SL request String with the document referenced as an URI
- *
- * This SL Request is always a detached signature request which contains a
- * reference to the data object as an URI
- * The URI has to be provided and should be a valid reference to
- * the document provided by getSignatureData().
- *
- * @param uri The URI pointing to the signature data
- * @return SL request String
- */
- public String getURIRequest(String uri) {
- String urirequest = this.request.replace(
- DATAOBJECT_STRING,
- "<sl:LocRefContent>" + uri //$NON-NLS-1$
- + "</sl:LocRefContent>"); //$NON-NLS-1$
-
- return urirequest;
- }
-
- /**
* Set the signature data (document to be signed)
* @param signatureData the signatureData to set
*/
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java
index b86e356c..f624e5b4 100644
--- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java
+++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java
@@ -27,11 +27,17 @@ public interface SigningState {
public SLRequest getSignatureRequest();
/**
+ * Sets whether to use base64 (or FileUpload) for request data
+ * @param useBase64Request whether to use base64 for request data
+ */
+ public void setUseBase64Request(boolean useBase64Request);
+
+ /**
* Sets the Security Layer Response to the Signature Request
* @param value The Signature Response
*/
public void setSignatureResponse(SLResponse value);
-
+
/**
* Has the state a SignatureResponse set ?
* @return true if a SLResponse is set
diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java
index f274068a..221fdb28 100644
--- a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java
+++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSLRequest.java
@@ -47,7 +47,7 @@ public class PDFASSLRequest extends SLRequest {
}
// Modifing SL Request ...
- setRequest(slRequest.replace(PDFASSigner.LOC_REF, SLRequest.DATAOBJECT_STRING));
+ setRequest(slRequest.replace(PDFASSigner.LOC_REF, /*SLRequest.DATAOBJECT_STRING*/""));
setSignatureData(new ByteArrayDocumentSource(signData));
}
diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java
index 247b1afc..e61465cf 100644
--- a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java
+++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PDFASSigningState.java
@@ -170,4 +170,12 @@ public class PDFASSigningState implements SigningState {
public void setBKUConnector(BkuSlConnector connector) {
// Nothing to do here
}
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SigningState#setUseBase64Request(boolean)
+ */
+ @Override
+ public void setUseBase64Request(boolean useBase64Request) {
+ // Nothing to do here
+ }
}
diff --git a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
index 1ceb6493..407773de 100644
--- a/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
+++ b/pdf-over-signer/pdf-over-sigpdfas3/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java
@@ -114,15 +114,6 @@ public class PdfAsSignatureParameter extends SignatureParameter {
return this.genericProperties.get(key);
}
- /* (non-Javadoc)
- * @see at.asit.pdfover.signator.SignatureParameter#setSignatureLanguage(java.lang.String)
- */
- @Override
- public void setSignatureLanguage(String signatureLanguage) {
- super.setSignatureLanguage(signatureLanguage);
-// this.height = -1;
- }
-
@Override
public SignatureDimension getPlaceholderDimension() {
// return new SignatureDimension(487, 206);
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
index ff2bef77..436db5f0 100644
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
+++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java
@@ -28,6 +28,8 @@ import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException;
import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
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.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
import at.gv.egiz.sl.schema.ErrorResponseType;
@@ -111,7 +113,11 @@ public class PdfAs4BKUSLConnector extends BaseSLConnector {
String slRequestString = SLMarschaller.marshalToString(this.of.createCreateCMSSignatureRequest(pack.getRequestType()));
//log.trace(slRequestString);
- PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, pack.getSignatureData());
+ byte[] signatureData = pack.getSignatureData();
+ if (IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD.equals(parameter.getConfiguration().getValue(IConfigurationConstants.SL_REQUEST_TYPE)))
+ signatureData = PDFUtils.blackOutSignature(signatureData, pack.getByteRange());
+
+ PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, signatureData);
String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone();
element = (JAXBElement<?>) SLMarschaller
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java
index 87babd59..36a6a8a4 100644
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java
+++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SLRequest.java
@@ -41,15 +41,6 @@ public class PdfAs4SLRequest extends SLRequest {
* @throws PdfAs4SLRequestException
*/
public PdfAs4SLRequest(String slRequest, byte[] signData) throws PdfAs4SLRequestException {
-// if(!slRequest.contains(PdfAs4Signer.LOC_REF)) {
-// log.error("PDF-AS SL request doesn't contain " + PdfAs4Signer.LOC_REF);
-// log.debug("Request: " + slRequest);
-// throw new PdfAs4SLRequestException("PDF-AS SL request doesn't contain " + PdfAs4Signer.LOC_REF);
-// }
-//
-// // Modifing SL Request ...
-// setRequest(slRequest.replace(PdfAs4Signer.LOC_REF, SLRequest.DATAOBJECT_STRING));
-
setRequest(slRequest);
setSignatureData(signData == null ? null : new ByteArrayDocumentSource(signData));
}
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
index 0f42a517..efce1c6e 100644
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
+++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java
@@ -20,6 +20,7 @@ import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource;
import at.gv.egiz.pdfas.lib.api.Configuration;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.PdfAs;
import at.gv.egiz.pdfas.lib.api.PdfAsFactory;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
@@ -71,7 +72,7 @@ public class PdfAs4Signer implements Signer {
if (sigEmblem != null && !sigEmblem.trim().isEmpty()) {
config.setValue("sig_obj." + sigProfile + ".value.SIG_LABEL", sigEmblem);
}
-
+
if(sigNote != null) {
config.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote);
}
@@ -107,6 +108,13 @@ public class PdfAs4Signer implements Signer {
SignParameter param = sstate.getSignParameter();
+ Configuration config = param.getConfiguration();
+ log.debug("Use base64 request? " + sstate.getUseBase64Request());
+ config.setValue(IConfigurationConstants.SL_REQUEST_TYPE,
+ sstate.getUseBase64Request() ?
+ IConfigurationConstants.SL_REQUEST_TYPE_BASE64 :
+ IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD);
+
ISLConnector connector = new PdfAs4BKUSLConnector(sstate.getBKUConnector());
param.setPlainSigner(new PAdESSigner(connector));
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java
index b8280142..ec2efdae 100644
--- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java
+++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java
@@ -48,6 +48,8 @@ public class PdfAs4SigningState implements SigningState {
private BkuSlConnector connector;
+ private boolean useBase64Request;
+
/* (non-Javadoc)
* @see at.asit.pdfover.signator.SigningState#getSignatureRequest()
*/
@@ -56,20 +58,28 @@ public class PdfAs4SigningState implements SigningState {
return this.slrequest;
}
+ /**
+ * Sets the SL Request
+ * @param request The SL Request
+ */
+ public void setSignatureRequest(SLRequest request) {
+ this.slrequest = request;
+ }
+
/* (non-Javadoc)
- * @see at.asit.pdfover.signator.SigningState#setSignatureResponse(at.asit.pdfover.signator.SLResponse)
+ * @see at.asit.pdfover.signator.SigningState#setUseBase64Request(boolean)
*/
@Override
- public void setSignatureResponse(SLResponse response) {
- this.slresponse = response;
+ public void setUseBase64Request(boolean useBase64Request) {
+ this.useBase64Request = useBase64Request;
}
/**
- * Sets the SL Request
- * @param request The SL Request
+ * Gets whether to use base64 (or FileUpload) for request data
+ * @return whether to use base64 for request data
*/
- public void setSignatureRequest(SLRequest request) {
- this.slrequest = request;
+ public boolean getUseBase64Request() {
+ return this.useBase64Request;
}
/**
@@ -81,6 +91,14 @@ public class PdfAs4SigningState implements SigningState {
}
/* (non-Javadoc)
+ * @see at.asit.pdfover.signator.SigningState#setSignatureResponse(at.asit.pdfover.signator.SLResponse)
+ */
+ @Override
+ public void setSignatureResponse(SLResponse response) {
+ this.slresponse = response;
+ }
+
+ /* (non-Javadoc)
* @see at.asit.pdfover.signator.SigningState#hasSignatureResponse()
*/
@Override