diff options
8 files changed, 40 insertions, 145 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java index 2944dd07..34b53173 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java @@ -55,7 +55,7 @@ public class MobileBKUConnector implements BkuSlConnector { @Override
public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
PdfAs4SigningState signingState = this.state.getSigningState();
- signingState.setSignatureRequest(request);
+ signingState.signatureRequest = request;
MobileBKUHandler handler = this.state.handler;
@@ -112,9 +112,9 @@ public class MobileBKUConnector implements BkuSlConnector { } while(this.state.status.errorMessage != null);
// Check if response is already available
- if (signingState.hasSignatureResponse()) {
- SLResponse response = signingState.getSignatureResponse();
- signingState.setSignatureResponse(null);
+ if (signingState.signatureResponse != null) {
+ SLResponse response = signingState.signatureResponse;
+ signingState.signatureResponse = null;
return response;
}
@@ -200,7 +200,7 @@ public class MobileBKUConnector implements BkuSlConnector { throw new SignatureException(new IllegalStateException());
} while (this.state.status.tanTries == -2);
- return signingState.getSignatureResponse();
+ return signingState.signatureResponse;
}
private boolean consumeCancelError() {
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 d6febeaa..d0d7e50e 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 @@ -258,12 +258,12 @@ public class ATrustHandler extends MobileBKUHandler { // credentials ok! InfoboxReadResponse
state.rememberCredentialsIfNecessary();
log.debug("Credentials accepted - Response given");
- getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null);
return;
} else if (responseData.contains("undecided.aspx?sid=")) {
// skip intermediate page
log.debug("Page Undecided");
- getSigningState().setSignatureResponse(new SLResponse(responseData, getStatus().server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null);
status.errorMessage = "waiting...";
return;
}else {
@@ -339,8 +339,7 @@ public class ATrustHandler extends MobileBKUHandler { responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) {
// success !!
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, getStatus().server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null);
} else {
try {
String tries = MobileBKUHelper.extractSubstring(
@@ -465,8 +464,7 @@ public class ATrustHandler extends MobileBKUHandler { responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) {
// success !!
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, getStatus().server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, getStatus().server, null, null);
return true;
}
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 bf5c865f..e908ec3c 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 @@ -158,8 +158,7 @@ public class IAIKHandler extends MobileBKUHandler { if (responseData.contains("sl:InfoboxReadResponse")) {
// credentials ok! InfoboxReadResponse
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, status.server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, status.server, null, null);
return;
}
@@ -288,8 +287,7 @@ public class IAIKHandler extends MobileBKUHandler { status.errorMessage = null;
if (responseData.contains("sl:CreateCMSSignatureResponse xmlns:sl")) {
// success
- getSigningState().setSignatureResponse(
- new SLResponse(responseData, status.server, null, null));
+ getSigningState().signatureResponse = new SLResponse(responseData, status.server, null, null);
} else {
try {
String errorMessage = MobileBKUHelper.extractContentFromTagWithParam(
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java index ad0f1863..1d2074c7 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/KSState.java @@ -180,7 +180,7 @@ public class KSState extends State { else if (config.getKeyStorePassStorageType() == KeyStorePassStorageType.MEMORY) config.setKeyStoreKeyPassOverlay(keyPass); - signingState.setKSSigner(file, alias, storePass, keyPass, type); + signingState.setKeystoreSigner(file, alias, storePass, keyPass, type); } catch (SignatureException e) { log.error("Error loading keystore", e); if (askShouldRetry("error.KeyStore")) 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 779d39c7..6e3922dc 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 @@ -137,8 +137,8 @@ public class LocalBKUState extends State { log.debug("SL Response: " + response); SLResponse slResponse = new SLResponse(response, server, userAgent, signatureLayout); - this.signingState.setSignatureResponse(slResponse); - this.signingState.setUseBase64Request(LocalBKUState.this.useBase64Request); + this.signingState.signatureResponse = slResponse; + this.signingState.useBase64Request = LocalBKUState.this.useBase64Request; } } catch (Exception e) { log.error("SignLocalBKUThread: ", e); @@ -175,13 +175,13 @@ public class LocalBKUState extends State { PdfAs4SigningState signingState = status.signingState; - if (!signingState.hasSignatureResponse() + if ((signingState.signatureResponse == null) && this.threadException == null) { Thread t = new Thread(new SignLocalBKUThread(this, signingState)); t.start(); return; } - signingState.setBKUConnector(new LocalBKUConnector()); + signingState.bkuConnector = new LocalBKUConnector(); if (this.threadException != null) { ErrorDialog dialog = new ErrorDialog( 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 e74ba969..bb1be5d0 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 @@ -557,9 +557,9 @@ public class MobileBKUState extends State { public void run() {
this.signingState = getStateMachine().status.signingState;
- this.signingState.setBKUConnector(new MobileBKUConnector(this));
+ this.signingState.bkuConnector = new MobileBKUConnector(this);
log.debug("Setting base64 request to " + this.handler.useBase64Request());
- this.signingState.setUseBase64Request(this.handler.useBase64Request());
+ this.signingState.useBase64Request = this.handler.useBase64Request();
if (this.threadException != null) {
displayError(this.threadException);
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; } } |