diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 14:22:04 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-06 14:22:04 +0200 |
commit | 18b4c5edd2a2d88d5efa69a1023a13926c53e8fd (patch) | |
tree | e6f92695ef12b66e9e19c7cce89c7ac56ca601af /pdf-over-gui/src/main/java | |
parent | 29fe91f5aa066a4b78fbf805ff5059bf0c78154f (diff) | |
download | pdf-over-18b4c5edd2a2d88d5efa69a1023a13926c53e8fd.tar.gz pdf-over-18b4c5edd2a2d88d5efa69a1023a13926c53e8fd.tar.bz2 pdf-over-18b4c5edd2a2d88d5efa69a1023a13926c53e8fd.zip |
YAGNI: at.asit.pdfover.signatur.SigningState.Status
Diffstat (limited to 'pdf-over-gui/src/main/java')
17 files changed, 93 insertions, 167 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index b93a458c..105b769f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -396,7 +396,7 @@ public class MainWindow { }, /* preferencesListener */ (Event arg0) -> { - if (MainWindow.this.stateMachine.getStatus().getBehavior().getEnabled(Buttons.CONFIG)) + if (MainWindow.this.stateMachine.getStatus().behavior.getEnabled(Buttons.CONFIG)) MainWindow.this.stateMachine.jumpToState(new ConfigurationUIState(MainWindow.this.stateMachine)); } ); @@ -406,8 +406,7 @@ public class MainWindow { * Update MainWindow to fit new status */ public void applyBehavior() { - MainWindowBehavior behavior = this.stateMachine.getStatus() - .getBehavior(); + MainWindowBehavior behavior = this.stateMachine.getStatus().behavior; log.debug("Updating MainWindow state for : " + this.stateMachine.getStatus().getCurrentState().toString()); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java index f2484afa..c397fa72 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java @@ -20,9 +20,7 @@ import java.net.URL; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpState; import org.apache.commons.httpclient.protocol.Protocol; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java index d5058e43..65e24c81 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUStatus.java @@ -15,8 +15,6 @@ */ package at.asit.pdfover.gui.bku.mobile; -import org.apache.commons.httpclient.Cookie; - /** * */ diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java index b2238dc9..7644de76 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InputDocumentArgument.java @@ -60,7 +60,7 @@ public class InputDocumentArgument extends Argument { throw new FileNotFoundException(signatureDocument); } - getStatus().setDocument(signatureDocumentFile); + getStatus().document = signatureDocumentFile; return argOffset + 1; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java index b34f32dc..0f3f1642 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/ClickableCanvas.java @@ -25,7 +25,6 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; /** * diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java index 14d917d0..3b03de78 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/Status.java @@ -31,23 +31,23 @@ import at.asit.pdfover.signator.SigningState; public class Status { private static final Logger log = LoggerFactory.getLogger(Status.class); - private File document = null; + public File document = null; - private SignaturePosition signaturePosition = null; + public SignaturePosition signaturePosition = null; - private BKUs bku = BKUs.NONE; + public BKUs bku = BKUs.NONE; private State currentState = null; private State previousState = null; - private SigningState signingState = null; + public SigningState signingState = null; - private SignResult signResult = null; + public SignResult signResult = null; - private MainWindowBehavior behavior; + public final MainWindowBehavior behavior; - private boolean searchForPlacehoderSignature = false; + public boolean searchForPlacehoderSignature = false; public Status() { this.behavior = new MainWindowBehavior(); @@ -58,15 +58,16 @@ public class Status { } public void setCurrentState(State currentState) { - //if (this.previousState == this.currentState) - // log.error("Changing to same state? " + this.currentState); + log.debug("Changing from " + this.currentState + " to " + currentState); if (this.previousState != this.currentState) { - //Reference to previous state will be lost - perform cleanup - log.debug("Changing from " + this.currentState + " to " + currentState); // - log.debug("Cleaning up " + this.previousState); - this.previousState.cleanUp(); + // Reference to previous state will be lost - perform cleanup + if (this.previousState != null) + { + log.debug("Cleaning up " + this.previousState); + this.previousState.cleanUp(); + } } this.previousState = this.currentState; @@ -76,56 +77,4 @@ public class Status { public State getPreviousState() { return this.previousState; } - - public void setDocument(File document) { - this.document = document; - } - - public File getDocument() { - return this.document; - } - - public void setSignaturePosition(SignaturePosition position) { - this.signaturePosition = position; - } - - public SignaturePosition getSignaturePosition() { - return this.signaturePosition; - } - - public void setBKU(BKUs bku) { - this.bku = bku; - } - - public BKUs getBKU() { - return this.bku; - } - - public MainWindowBehavior getBehavior() { - return this.behavior; - } - - public SigningState getSigningState() { - return this.signingState; - } - - public void setSigningState(SigningState state) { - this.signingState = state; - } - - public void setSignResult(SignResult signResult) { - this.signResult = signResult; - } - - public SignResult getSignResult() { - return this.signResult; - } - - public boolean isSearchForPlaceholderSignature() { - return this.searchForPlacehoderSignature; - } - - public void setSearchForPlaceholderSignature(boolean value) { - this.searchForPlacehoderSignature = value; - } } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java index 006b1ed9..dcffe2c0 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/BKUSelectionState.java @@ -74,21 +74,21 @@ public class BKUSelectionState extends State { (previousState instanceof PositioningState) || (previousState instanceof BKUSelectionState) )) { - status.setBKU(BKUs.NONE); + status.bku = BKUs.NONE; } else if(!(status.getPreviousState() instanceof BKUSelectionState)) { ConfigProvider config = getStateMachine().getConfigProvider(); - status.setBKU(config.getDefaultBKU()); + status.bku = config.getDefaultBKU(); } - if(status.getBKU() == BKUs.NONE) { + if(status.bku == BKUs.NONE) { BKUSelectionComposite selection = this.getSelectionComposite(); getStateMachine().getGUIProvider().display(selection); selection.layout(); - status.setBKU(selection.getSelected()); + status.bku = selection.getSelected(); - if(status.getBKU() == BKUs.NONE) { + if(status.bku == BKUs.NONE) { return; } } @@ -109,7 +109,7 @@ public class BKUSelectionState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java index d8ee2c63..8450629f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/ConfigurationUIState.java @@ -96,7 +96,7 @@ public class ConfigurationUIState extends State { @Override public void updateMainWindowBehavior() { // Leave the state as it is - MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.setEnabled(Buttons.CONFIG, false); behavior.setMainBarVisible(false); } 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 21a3a2ac..1ecf880c 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 @@ -63,7 +63,7 @@ public class KSState extends State { public void run() { Status status = getStateMachine().getStatus(); - SigningState signingState = status.getSigningState(); + SigningState signingState = status.signingState; ConfigProvider config = getStateMachine().getConfigProvider(); try { @@ -138,8 +138,7 @@ public class KSState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus() - .getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setActive(Buttons.OPEN, true); behavior.setActive(Buttons.POSITION, true); 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 91fae1cc..3ec134d4 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 @@ -173,7 +173,7 @@ public class LocalBKUState extends State { public void run() { Status status = getStateMachine().getStatus(); - SigningState signingState = status.getSigningState(); + SigningState signingState = status.signingState; if (!signingState.hasSignatureResponse() && this.threadException == null) { @@ -219,8 +219,7 @@ public class LocalBKUState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus() - .getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setActive(Buttons.OPEN, true); behavior.setActive(Buttons.POSITION, true); 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 6ec4302d..a2c65938 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 @@ -521,7 +521,7 @@ public class MobileBKUState extends State { */
@Override
public void run() {
- this.signingState = getStateMachine().getStatus().getSigningState();
+ this.signingState = getStateMachine().getStatus().signingState;
this.signingState.setBKUConnector(new MobileBKUConnector(this));
log.debug("Setting base64 request to " + this.handler.useBase64Request());
@@ -573,8 +573,7 @@ public class MobileBKUState extends State { */
@Override
public void updateMainWindowBehavior() {
- MainWindowBehavior behavior = getStateMachine().getStatus()
- .getBehavior();
+ MainWindowBehavior behavior = getStateMachine().getStatus().behavior;
behavior.reset();
behavior.setActive(Buttons.OPEN, true);
behavior.setActive(Buttons.POSITION, true);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java index 1e04a446..64de1640 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OpenState.java @@ -85,33 +85,33 @@ public class OpenState extends State { Status status = getStateMachine().getStatus(); if (!(status.getPreviousState() instanceof PrepareConfigurationState) && !(status.getPreviousState() instanceof OpenState)) { - status.setBKU(config.getDefaultBKU()); - status.setDocument(null); - status.setSignaturePosition(config.getDefaultSignaturePosition()); + status.bku = config.getDefaultBKU(); + status.document = null; + status.signaturePosition = config.getDefaultSignaturePosition(); /* ensure that files get closed */ status.getPreviousState().cleanUp(); } - if (status.getDocument() == null) { + if (status.document == null) { DataSourceSelectComposite selection = this.getSelectionComposite(); getStateMachine().getGUIProvider().display(selection); selection.layout(); - status.setDocument(selection.getSelected()); + status.document = selection.getSelected(); - if (status.getDocument() == null) { + if (status.document == null) { // Not selected yet return; } } - log.debug("Got Datasource: " + getStateMachine().getStatus().getDocument().getAbsolutePath()); + log.debug("Got Datasource: " + getStateMachine().getStatus().document.getAbsolutePath()); // scan for signature placeholders // - see if we want to scan for placeholders in the settings if (config.getEnablePlaceholderUsage()) { - try (PDDocument pddocument = PDDocument.load(getStateMachine().getStatus().getDocument())) { + try (PDDocument pddocument = PDDocument.load(getStateMachine().getStatus().document)) { // - scan for placeholders boolean useSignatureFields = config.getUseSignatureFields(); boolean useMarker = config.getUseMarker(); @@ -147,7 +147,7 @@ public class OpenState extends State { "select the fields", fields); int res = gui.open(); if (res != -1) { - getStateMachine().getStatus().setSearchForPlaceholderSignature(true); + getStateMachine().getStatus().searchForPlacehoderSignature = true; addPlaceholderSelectionToConfig(fields.get(res)); this.setNextState(new BKUSelectionState(getStateMachine())); } @@ -156,9 +156,9 @@ public class OpenState extends State { } } else if (result == SWT.NO) { - getStateMachine().getStatus().setSearchForPlaceholderSignature(false); + getStateMachine().getStatus().searchForPlacehoderSignature = false; } else { - status.setDocument(null); + status.document = null; return; } break; @@ -185,18 +185,17 @@ public class OpenState extends State { // - fill the position information so that we skip to // the // next stages without breaking stuff - SignaturePosition position = new SignaturePosition( + status.signaturePosition = new SignaturePosition( signaturePlaceholderData.getTablePos().getPosX(), signaturePlaceholderData.getTablePos().getPosY(), signaturePlaceholderData.getTablePos().getPage()); - status.setSignaturePosition(position); - getStateMachine().getStatus().setSearchForPlaceholderSignature(true); + getStateMachine().getStatus().searchForPlacehoderSignature = true; } else if (result == SWT.NO) { - getStateMachine().getStatus().setSearchForPlaceholderSignature(false); + getStateMachine().getStatus().searchForPlacehoderSignature = false; } else { - status.setDocument(null); + status.document = null; return; } // TODO: why does this use a different logic (via PositioningState) than the signature placeholders? @@ -257,7 +256,7 @@ public class OpenState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java index 79e6551e..bae7cb13 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/OutputState.java @@ -61,10 +61,9 @@ public class OutputState extends State { this.outputComposite.setOutputDir(config.getDefaultOutputFolder()); this.outputComposite.setSaveFilePostFix(config.getSaveFilePostFix()); this.outputComposite.setTempDir(tmpDir.getAbsolutePath()); - this.outputComposite.setInputFile(status.getDocument()); + this.outputComposite.setInputFile(status.document); - this.outputComposite.setSignedDocument(status.getSignResult() - .getSignedDocument()); + this.outputComposite.setSignedDocument(status.signResult.getSignedDocument()); // Save signed document this.outputComposite.saveDocument(); @@ -81,7 +80,7 @@ public class OutputState extends State { public void run() { Status status = getStateMachine().getStatus(); - if (status.getSignResult() == null) { + if (status.signResult == null) { ErrorDialog error = new ErrorDialog(getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.Signatur"), BUTTONS.RETRY_CANCEL); if(error.open() == SWT.RETRY) { @@ -106,7 +105,7 @@ public class OutputState extends State { @Override public void cleanUp() { - getStateMachine().getStatus().setSignResult(null); + getStateMachine().getStatus().signResult = null; if (this.outputComposite != null) this.outputComposite.dispose(); @@ -119,8 +118,7 @@ public class OutputState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus() - .getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 6e1710bf..427edb85 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -82,7 +82,7 @@ public class PositioningState extends State { private void openPDFDocument() throws IOException { closePDFDocument(); - File documentPath = getStateMachine().getStatus().getDocument(); + File documentPath = getStateMachine().getStatus().document; PDFFile pdf = null; RandomAccessFile rafile = new RandomAccessFile(documentPath, "r"); FileChannel chan = rafile.getChannel(); @@ -115,7 +115,7 @@ public class PositioningState extends State { if (this.positionComposite == null) { this.positionComposite = stateMachine.getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); - log.debug("Displaying " + stateMachine.getStatus().getDocument()); + log.debug("Displaying " + stateMachine.getStatus().document); this.positionComposite.displayDocument(document); } // Update possibly changed values @@ -150,12 +150,12 @@ public class PositioningState extends State { if (!(status.getPreviousState() instanceof PositioningState) && !(status.getPreviousState() instanceof OpenState)) { - this.previousPosition = status.getSignaturePosition(); - status.setSignaturePosition(null); + this.previousPosition = status.signaturePosition; + status.signaturePosition = null; } if ((this.document == null) || - (this.loadedDocumentPath != getStateMachine().getStatus().getDocument())) { + (this.loadedDocumentPath != getStateMachine().getStatus().document)) { log.debug("Checking PDF document for encryption"); try { openPDFDocument(); @@ -177,7 +177,7 @@ public class PositioningState extends State { } } - if (status.getSignaturePosition() == null) { + if (status.signaturePosition == null) { PositioningComposite position = null; try { position = this.getPositioningComposite(this.document); @@ -187,16 +187,16 @@ public class PositioningState extends State { getStateMachine().getGUIProvider().getMainShell(), Messages.getString("error.PositioningNotPossible"), BUTTONS.OK); dialog.open(); - status.setSignaturePosition(new SignaturePosition()); + status.signaturePosition = new SignaturePosition(); this.setNextState(new BKUSelectionState(getStateMachine())); return; } getStateMachine().getGUIProvider().display(position); - status.setSignaturePosition(position.getPosition()); + status.signaturePosition = position.getPosition(); - if(status.getSignaturePosition() != null) { + if(status.signaturePosition != null) { this.setNextState(new BKUSelectionState(getStateMachine())); } @@ -221,7 +221,7 @@ public class PositioningState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus().getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setEnabled(Buttons.CONFIG, true); behavior.setEnabled(Buttons.OPEN, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index b31ba4a9..22f66d32 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -506,10 +506,8 @@ public class PrepareConfigurationState extends State { // Create PDF Signer Status status = stateMachine.getStatus(); - status.setBKU(getStateMachine().getConfigProvider().getDefaultBKU()); - - status.setSignaturePosition(getStateMachine().getConfigProvider() - .getDefaultSignaturePosition()); + status.bku = getStateMachine().getConfigProvider().getDefaultBKU(); + status.signaturePosition = getStateMachine().getConfigProvider().getDefaultSignaturePosition(); setNextState(new OpenState(stateMachine)); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index 10d1cd9f..e00ec6e7 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -32,7 +32,6 @@ import at.asit.pdfover.commons.Messages; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; import at.asit.pdfover.gui.workflow.config.ConfigProvider; -import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.PDFFileDocumentSource; import at.asit.pdfover.signator.SignatureParameter; @@ -134,20 +133,14 @@ public class PrepareSigningState extends State { .newParameter(); } - this.state.signatureParameter - .setInputDocument(new PDFFileDocumentSource(status - .getDocument())); - this.state.signatureParameter.setSignatureDevice(status - .getBKU()); - if (status.getSignaturePosition() != null ) { - this.state.signatureParameter.setSignaturePosition(status - .getSignaturePosition()); + this.state.signatureParameter.setInputDocument(new PDFFileDocumentSource(status.document)); + this.state.signatureParameter.setSignatureDevice(status.bku); + if (status.signaturePosition != null) { + this.state.signatureParameter.setSignaturePosition(status.signaturePosition); } - if (configuration.getDefaultEmblem() != null - && !configuration.getDefaultEmblem().isEmpty()) { - this.state.signatureParameter.setEmblem(new CachedFileNameEmblem( - configuration.getDefaultEmblem())); + if (configuration.getDefaultEmblem() != null && !configuration.getDefaultEmblem().isEmpty()) { + this.state.signatureParameter.setEmblem(new CachedFileNameEmblem(configuration.getDefaultEmblem())); } if (configuration.getSignatureNote() != null @@ -156,20 +149,15 @@ public class PrepareSigningState extends State { "SIG_NOTE", configuration.getSignatureNote()); } - this.state.signatureParameter - .setSearchForPlaceholderSignatures(getStateMachine().getStatus().isSearchForPlaceholderSignature()); + this.state.signatureParameter.setSearchForPlaceholderSignatures(getStateMachine().getStatus().searchForPlacehoderSignature); - this.state.signatureParameter - .setSignatureLanguage(configuration.getSignatureLocale() - .getLanguage()); + this.state.signatureParameter.setSignatureLanguage(configuration.getSignatureLocale().getLanguage()); - this.state.signatureParameter - .setSignaturePdfACompat(configuration.getSignaturePdfACompat()); + this.state.signatureParameter.setSignaturePdfACompat(configuration.getSignaturePdfACompat()); this.state.signatureParameter.setSignatureProfile(configuration.getSignatureProfile()); - this.state.signingState = this.state.signer - .prepare(this.state.signatureParameter); + this.state.signingState = this.state.signer.prepare(this.state.signatureParameter); } catch (Exception e) { log.error("PrepareDocumentThread: ", e); @@ -240,17 +228,22 @@ public class PrepareSigningState extends State { } // We got the Request set it into status and move on to next state ... - status.setSigningState(this.signingState); - - if (status.getBKU() == BKUs.LOCAL) { - this.setNextState(new LocalBKUState(getStateMachine())); - } else if (status.getBKU() == BKUs.MOBILE) { - this.setNextState(new MobileBKUState(getStateMachine())); - } else if (status.getBKU() == BKUs.KS) { - this.setNextState(new KSState(getStateMachine())); - } else { - log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); - this.setNextState(new BKUSelectionState(getStateMachine())); + status.signingState = this.signingState; + + switch (status.bku) + { + case LOCAL: + this.setNextState(new LocalBKUState(getStateMachine())); + break; + case MOBILE: + this.setNextState(new MobileBKUState(getStateMachine())); + break; + case KS: + this.setNextState(new KSState(getStateMachine())); + break; + default: + log.error("Invalid selected BKU Value \"NONE\" in PrepareSigningState!"); + this.setNextState(new BKUSelectionState(getStateMachine())); } } @@ -270,8 +263,7 @@ public class PrepareSigningState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus() - .getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setActive(Buttons.OPEN, true); behavior.setActive(Buttons.POSITION, true); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java index afb12333..1bf901d3 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/SigningState.java @@ -57,7 +57,7 @@ public class SigningState extends State { Signer signer = this.state.getStateMachine().getPDFSigner().getPDFSigner(); Status status = this.state.getStateMachine().getStatus(); - status.setSignResult(signer.sign(status.getSigningState())); + status.signResult = signer.sign(status.signingState); } catch(Exception e) { this.state.threadException = e; } finally { @@ -84,7 +84,7 @@ public class SigningState extends State { public void run() { Status status = getStateMachine().getStatus(); - if(status.getSignResult() == null && + if(status.signResult == null && this.threadException == null) { Thread t = new Thread(new FinishSignThread(this)); t.start(); @@ -147,8 +147,7 @@ public class SigningState extends State { */ @Override public void updateMainWindowBehavior() { - MainWindowBehavior behavior = getStateMachine().getStatus() - .getBehavior(); + MainWindowBehavior behavior = getStateMachine().getStatus().behavior; behavior.reset(); behavior.setActive(Buttons.OPEN, true); behavior.setActive(Buttons.POSITION, true); |