diff options
10 files changed, 28 insertions, 105 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 d7d98172..2944dd07 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 @@ -54,7 +54,7 @@ public class MobileBKUConnector implements BkuSlConnector { */
@Override
public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
- PdfAs4SigningState signingState = (PdfAs4SigningState) this.state.getSigningState();
+ PdfAs4SigningState signingState = this.state.getSigningState();
signingState.setSignatureRequest(request);
MobileBKUHandler handler = this.state.handler;
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 90e4ff46..b3231cf2 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 @@ -39,7 +39,7 @@ import at.asit.pdfover.gui.utils.FileUploadSource; import at.asit.pdfover.gui.workflow.states.LocalBKUState;
import at.asit.pdfover.gui.workflow.states.MobileBKUState;
import at.asit.pdfover.signator.SLRequest;
-import at.asit.pdfover.signator.SigningState;
+import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
/**
* A mobile BKU Handler
@@ -151,7 +151,7 @@ public abstract class MobileBKUHandler { * Get the SigningState
* @return the SigningState
*/
- protected SigningState getSigningState() {
+ protected PdfAs4SigningState getSigningState() {
return state.getSigningState();
}
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 3920b4d7..a6e6c28a 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 @@ -26,7 +26,7 @@ import at.asit.pdfover.gui.workflow.states.State; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignResult; import at.asit.pdfover.signator.SignaturePosition; -import at.asit.pdfover.signator.SigningState; +import at.asit.pdfover.signer.pdfas.PdfAs4SigningState; public class Status { private static final Logger log = LoggerFactory.getLogger(Status.class); @@ -41,7 +41,7 @@ public class Status { private State previousState = null; - public SigningState signingState = null; + public PdfAs4SigningState signingState = null; public SignResult signResult = null; 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 443f54af..ad0f1863 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 @@ -37,7 +37,7 @@ import at.asit.pdfover.gui.workflow.Status; import at.asit.pdfover.gui.workflow.config.ConfigurationManager; import at.asit.pdfover.gui.workflow.config.ConfigurationDataInMemory.KeyStorePassStorageType; import at.asit.pdfover.signator.SignatureException; -import at.asit.pdfover.signator.SigningState; +import at.asit.pdfover.signer.pdfas.PdfAs4SigningState; /** * Logical state for performing the BKU Request to a local BKU @@ -78,7 +78,7 @@ public class KSState extends State { public void run() { Status status = getStateMachine().status; - SigningState signingState = status.signingState; + PdfAs4SigningState signingState = status.signingState; ConfigurationManager config = getStateMachine().configProvider; try { 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 51151338..779d39c7 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 @@ -36,7 +36,7 @@ import at.asit.pdfover.commons.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; +import at.asit.pdfover.signer.pdfas.PdfAs4SigningState; /** * Logical state for performing the BKU Request to a local BKU @@ -88,14 +88,14 @@ public class LocalBKUState extends State { private final class SignLocalBKUThread implements Runnable { private LocalBKUState state; - private SigningState signingState; + private PdfAs4SigningState signingState; /** * @param localBKUState * @param signingState */ - public SignLocalBKUThread(LocalBKUState localBKUState, SigningState signingState) { + public SignLocalBKUThread(LocalBKUState localBKUState, PdfAs4SigningState signingState) { this.state = localBKUState; this.signingState = signingState; } @@ -173,7 +173,7 @@ public class LocalBKUState extends State { public void run() { Status status = getStateMachine().status; - SigningState signingState = status.signingState; + PdfAs4SigningState signingState = status.signingState; if (!signingState.hasSignatureResponse() && this.threadException == null) { 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 fc4025c0..e74ba969 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 @@ -24,6 +24,8 @@ import java.util.TimerTask; // Imports
import at.asit.pdfover.gui.exceptions.ATrustConnectionException;
import at.asit.pdfover.signator.SignatureException;
+import at.asit.pdfover.signer.pdfas.PdfAs4SigningState;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.slf4j.Logger;
@@ -49,7 +51,6 @@ import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.commons.Messages;
import at.asit.pdfover.gui.workflow.StateMachine;
import at.asit.pdfover.gui.workflow.config.ConfigurationManager;
-import at.asit.pdfover.signator.SigningState;
/**
* Logical state for performing the BKU Request to the A-Trust Mobile BKU
@@ -57,7 +58,7 @@ import at.asit.pdfover.signator.SigningState; public class MobileBKUState extends State {
static final Logger log = LoggerFactory.getLogger(MobileBKUState.class);
- SigningState signingState;
+ PdfAs4SigningState signingState;
public Exception threadException = null;
@@ -155,7 +156,7 @@ public class MobileBKUState extends State { /**
* @return the signingState
*/
- public SigningState getSigningState() {
+ public PdfAs4SigningState getSigningState() {
return this.signingState;
}
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 e6a10aa6..26fd0cab 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 @@ -36,6 +36,7 @@ import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.PDFFileDocumentSource; import at.asit.pdfover.signer.pdfas.PdfAs4SignatureParameter; import at.asit.pdfover.signer.pdfas.PdfAs4Signer; +import at.asit.pdfover.signer.pdfas.PdfAs4SigningState; /** * User waiting state, wait for PDF Signator library to prepare document for @@ -180,7 +181,7 @@ public class PrepareSigningState extends State { return this.waitingComposite; } - at.asit.pdfover.signator.SigningState signingState = null; + PdfAs4SigningState signingState = null; Exception threadException = null; 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 deleted file mode 100644 index 58263e08..00000000 --- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/SigningState.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.signator; - -/** - * The state of the pdf signing library - */ -public interface SigningState { - - /** - * Gets the Security Layer Request to create the signature - * @return The Signature Request - */ - 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 - */ - public boolean hasSignatureResponse(); - - /** - * Set the BKU connector - * @param connector the BKU connector - */ - public void setBKUConnector(BkuSlConnector connector); - - /** - * Set the KeyStore signer - * @param file KeyStore filename - * @param alias KeyStore alias - * @param kspassword KeyStore password - * @param keypassword KeyStore private key password - * @param type KeyStore type - * @throws SignatureException - */ - public void setKSSigner(String file, String alias, String kspassword, - String keypassword, String type) throws SignatureException; - -} 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 9959dcdf..9adf99aa 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 @@ -11,7 +11,6 @@ import at.asit.pdfover.signator.SignResult; import at.asit.pdfover.signator.SignResultImpl; import at.asit.pdfover.signator.SignatureException; import at.asit.pdfover.signator.SignaturePosition; -import at.asit.pdfover.signator.SigningState; import at.gv.egiz.pdfas.common.exceptions.PDFASError; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.lib.api.ByteArrayDataSource; @@ -41,7 +40,7 @@ public class PdfAs4Signer { protected static final String LOC_REF = "<sl:LocRefContent>" + URL_TEMPLATE + "</sl:LocRefContent>"; - public static SigningState prepare(PdfAs4SignatureParameter parameter) throws SignatureException { + public static PdfAs4SigningState prepare(PdfAs4SignatureParameter parameter) throws SignatureException { if (parameter == null) { throw new SignatureException("Incorrect SignatureParameter!"); @@ -85,35 +84,29 @@ public class PdfAs4Signer { return state; } - public static SignResult sign(SigningState state) throws SignatureException { + public static SignResult sign(PdfAs4SigningState state) throws SignatureException { try { - PdfAs4SigningState sstate = null; - - if (PdfAs4SigningState.class.isInstance(state)) { - sstate = PdfAs4SigningState.class.cast(state); - } - - if (sstate == null) { + if (state == null) { throw new SignatureException("Incorrect SigningState!"); } // Retrieve objects PdfAs pdfas = PdfAs4Helper.getPdfAs(); - SignParameter param = sstate.getSignParameter(); + SignParameter param = state.getSignParameter(); Configuration config = param.getConfiguration(); config.setValue(IConfigurationConstants.SL_REQUEST_TYPE, - sstate.getUseBase64Request() ? + state.getUseBase64Request() ? IConfigurationConstants.SL_REQUEST_TYPE_BASE64 : IConfigurationConstants.SL_REQUEST_TYPE_UPLOAD); IPlainSigner signer; - if (sstate.hasBKUConnector()) { - ISLConnector connector = new PdfAs4BKUSLConnector(sstate.getBKUConnector()); + if (state.hasBKUConnector()) { + ISLConnector connector = new PdfAs4BKUSLConnector(state.getBKUConnector()); signer = new PAdESSigner(connector); - } else if (sstate.hasKSSigner()) { - signer = sstate.getKSSigner(); + } else if (state.hasKSSigner()) { + signer = state.getKSSigner(); } else { throw new SignatureException("SigningState doesn't have a signer"); } @@ -137,7 +130,7 @@ public class PdfAs4Signer { result.setSignaturePosition(sp); } - result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray())); + result.setSignedDocument(new ByteArrayDocumentSource(state.getOutput().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 f0aff1c8..0fe32b25 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 @@ -22,7 +22,6 @@ import at.asit.pdfover.signator.BkuSlConnector; import at.asit.pdfover.signator.SLRequest; import at.asit.pdfover.signator.SLResponse; import at.asit.pdfover.signator.SignatureException; -import at.asit.pdfover.signator.SigningState; import at.gv.egiz.pdfas.common.exceptions.PDFASError; import at.gv.egiz.pdfas.lib.api.sign.IPlainSigner; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; @@ -31,7 +30,7 @@ import at.gv.egiz.pdfas.sigs.pades.PAdESSignerKeystore; /** * Signing State for PDFAS Wrapper */ -public class PdfAs4SigningState implements SigningState { +public class PdfAs4SigningState { /** * The Signature Layer request @@ -59,7 +58,6 @@ public class PdfAs4SigningState implements SigningState { /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#getSignatureRequest() */ - @Override public SLRequest getSignatureRequest() { return this.slrequest; } @@ -75,7 +73,6 @@ public class PdfAs4SigningState implements SigningState { /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#setUseBase64Request(boolean) */ - @Override public void setUseBase64Request(boolean useBase64Request) { this.useBase64Request = useBase64Request; } @@ -99,7 +96,6 @@ 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; } @@ -107,7 +103,6 @@ public class PdfAs4SigningState implements SigningState { /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#hasSignatureResponse() */ - @Override public boolean hasSignatureResponse() { return this.slresponse != null; } @@ -143,7 +138,6 @@ public class PdfAs4SigningState implements SigningState { /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#setBKUConnector(at.asit.pdfover.signator.BkuSlConnector) */ - @Override public void setBKUConnector(BkuSlConnector connector) { this.bkuconnector = connector; } @@ -151,7 +145,6 @@ public class PdfAs4SigningState implements SigningState { /* (non-Javadoc) * @see at.asit.pdfover.signator.SigningState#setKSSigner(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ - @Override public void setKSSigner(String file, String alias, String kspassword, String keypassword, String type) throws SignatureException { try { |