diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2015-02-23 15:29:35 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2015-02-23 15:29:35 +0100 |
commit | 7b6860087f50b7576c31f7aa50714d3fa7a9b228 (patch) | |
tree | c2347315c5a0e4e6565f9020d3e1d7d38d94abfe /pdf-over-signer/pdf-over-sigpdfas4/src/main | |
parent | 72cb98966c0d631ed4741bf071c621fd36f33fd6 (diff) | |
download | pdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.tar.gz pdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.tar.bz2 pdf-over-7b6860087f50b7576c31f7aa50714d3fa7a9b228.zip |
BASE64 request handling
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src/main')
4 files changed, 41 insertions, 18 deletions
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 |