diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-02 14:56:46 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-08-02 14:56:46 +0200 |
commit | 832cf5d3353a5fef867d177b32681b1295497626 (patch) | |
tree | 7fc89dddd2247933a9da569fa05df124ece46e76 /pdf-over-signer | |
parent | 9144df55ff7eac00f7633da6b8e4b58bab923d1f (diff) | |
download | pdf-over-832cf5d3353a5fef867d177b32681b1295497626.tar.gz pdf-over-832cf5d3353a5fef867d177b32681b1295497626.tar.bz2 pdf-over-832cf5d3353a5fef867d177b32681b1295497626.zip |
YAGNI: SigningState setters/getters
Diffstat (limited to 'pdf-over-signer')
-rw-r--r-- | pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 18 | ||||
-rw-r--r-- | pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java | 127 |
2 files changed, 22 insertions, 123 deletions
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index 9adf99aa..5993a3a9 100644 --- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -79,8 +79,8 @@ public class PdfAs4Signer { param.getConfiguration().setValue(IConfigurationConstants.PLACEHOLDER_SEARCH_ENABLED, IConfigurationConstants.TRUE); } - state.setSignParameter(param); - state.setOutput(output); + state.signParameter = param; + state.output = output; return state; } @@ -93,20 +93,20 @@ public class PdfAs4Signer { // Retrieve objects PdfAs pdfas = PdfAs4Helper.getPdfAs(); - SignParameter param = state.getSignParameter(); + SignParameter param = state.signParameter; Configuration config = param.getConfiguration(); config.setValue(IConfigurationConstants.SL_REQUEST_TYPE, - state.getUseBase64Request() ? + state.useBase64Request ? IConfigurationConstants.SL_REQUEST_TYPE_BASE64 : IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD); IPlainSigner signer; - if (state.hasBKUConnector()) { - ISLConnector connector = new PdfAs4BKUSLConnector(state.getBKUConnector()); + if (state.bkuConnector != null) { + ISLConnector connector = new PdfAs4BKUSLConnector(state.bkuConnector); signer = new PAdESSigner(connector); - } else if (state.hasKSSigner()) { - signer = state.getKSSigner(); + } else if (state.hasKeystoreSigner()) { + signer = state.getKeystoreSigner(); } else { throw new SignatureException("SigningState doesn't have a signer"); } @@ -130,7 +130,7 @@ public class PdfAs4Signer { result.setSignaturePosition(sp); } - result.setSignedDocument(new ByteArrayDocumentSource(state.getOutput().toByteArray())); + result.setSignedDocument(new ByteArrayDocumentSource(state.output.toByteArray())); return result; } catch (PdfAsException | PDFASError e) { throw new SignatureException(e); diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java index 0fe32b25..7d0ea318 100644 --- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java +++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SigningState.java @@ -35,151 +35,50 @@ public class PdfAs4SigningState { /** * The Signature Layer request */ - private SLRequest slrequest; + public SLRequest signatureRequest; /** * The Signature Layer response */ - private SLResponse slresponse; + public SLResponse signatureResponse; /** * The Sign Parameters */ - private SignParameter parameter; + public SignParameter signParameter; - private ByteArrayOutputStream output; + public ByteArrayOutputStream output; - private BkuSlConnector bkuconnector = null; + public BkuSlConnector bkuConnector = null; - private IPlainSigner kssigner = null; + private IPlainSigner keystoreSigner = null; - private boolean useBase64Request; - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SigningState#getSignatureRequest() - */ - public SLRequest getSignatureRequest() { - 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#setUseBase64Request(boolean) - */ - public void setUseBase64Request(boolean useBase64Request) { - this.useBase64Request = useBase64Request; - } - - /** - * Gets whether to use base64 (or FileUpload) for request data - * @return whether to use base64 for request data - */ - public boolean getUseBase64Request() { - return this.useBase64Request; - } - - /** - * Gets the SL Response - * @return The SL Response object - */ - public SLResponse getSignatureResponse() { - return this.slresponse; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SigningState#setSignatureResponse(at.asit.pdfover.signator.SLResponse) - */ - public void setSignatureResponse(SLResponse response) { - this.slresponse = response; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse() - */ - public boolean hasSignatureResponse() { - return this.slresponse != null; - } - - /** - * @return the output - */ - public ByteArrayOutputStream getOutput() { - return this.output; - } - - /** - * @param output the output to set - */ - public void setOutput(ByteArrayOutputStream output) { - this.output = output; - } - - /** - * @return the parameter - */ - public SignParameter getSignParameter() { - return this.parameter; - } - - /** - * @param parameter the parameter to set - */ - public void setSignParameter(SignParameter parameter) { - this.parameter = parameter; - } - - /* (non-Javadoc) - * @see at.asit.pdfover.signator.SigningState#setBKUConnector(at.asit.pdfover.signator.BkuSlConnector) - */ - public void setBKUConnector(BkuSlConnector connector) { - this.bkuconnector = connector; - } + public boolean useBase64Request; /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#setKSSigner(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ - public void setKSSigner(String file, String alias, String kspassword, + public void setKeystoreSigner(String file, String alias, String kspassword, String keypassword, String type) throws SignatureException { try { - this.kssigner = new PAdESSignerKeystore(file, alias, kspassword, keypassword, type); + this.keystoreSigner = new PAdESSignerKeystore(file, alias, kspassword, keypassword, type); } catch (PDFASError e) { throw new SignatureException(e); } } /** - * @return whether a BKU connector was set - */ - public boolean hasBKUConnector() { - return this.bkuconnector != null; - } - - /** - * @return the BKU connector - */ - public BkuSlConnector getBKUConnector() { - return this.bkuconnector; - } - - /** * @return whether a KS signer was set */ - public boolean hasKSSigner() { - return this.kssigner != null; + public boolean hasKeystoreSigner() { + return this.keystoreSigner != null; } /** * @return the KS signer */ - public IPlainSigner getKSSigner() { - return this.kssigner; + public IPlainSigner getKeystoreSigner() { + return this.keystoreSigner; } } |