summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
diff options
context:
space:
mode:
authorTobias Kellner <tobias.kellner@iaik.tugraz.at>2014-11-27 20:57:33 +0100
committerTobias Kellner <tobias.kellner@iaik.tugraz.at>2014-11-27 20:57:33 +0100
commit9e50f1a103a37d9dcfbeb5ea45bcf6c6c0c0f6dd (patch)
tree03355244de7f50fc75f0ccffb51cd0073ba92340 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
parent896fbe4a5643bf8c29968f8514a1c14fd51c4d9e (diff)
downloadpdf-over-9e50f1a103a37d9dcfbeb5ea45bcf6c6c0c0f6dd.tar.gz
pdf-over-9e50f1a103a37d9dcfbeb5ea45bcf6c6c0c0f6dd.tar.bz2
pdf-over-9e50f1a103a37d9dcfbeb5ea45bcf6c6c0c0f6dd.zip
Implement PDF-AS 4 changes
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java128
1 files changed, 128 insertions, 0 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
new file mode 100644
index 00000000..f08c885e
--- /dev/null
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/MobileBKUConnector.java
@@ -0,0 +1,128 @@
+/*
+ * 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.gui.bku;
+
+// Imports
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.asit.pdfover.gui.bku.mobile.MobileBKUHandler;
+import at.asit.pdfover.gui.workflow.states.MobileBKUState;
+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.signer.pdfas.PdfAs4SigningState;
+
+/**
+ *
+ */
+public class MobileBKUConnector implements BkuSlConnector {
+ /**
+ * SLF4J Logger instance
+ **/
+ private static final Logger log = LoggerFactory
+ .getLogger(MobileBKUConnector.class);
+
+ private MobileBKUState state;
+
+ /**
+ *
+ * @param state
+ */
+ public MobileBKUConnector(MobileBKUState state) {
+ this.state = state;
+ }
+
+ /* (non-Javadoc)
+ * @see at.asit.pdfover.signator.BkuSlConnector#handleSLRequest(java.lang.String)
+ */
+ @Override
+ public SLResponse handleSLRequest(SLRequest request) throws SignatureException {
+ PdfAs4SigningState signingState = (PdfAs4SigningState) this.state.getSigningState();
+ signingState.setSignatureRequest(request);
+
+ MobileBKUHandler handler = this.state.getHandler();
+
+ do {
+ // Post SL Request
+ try {
+ String responseData = handler.postSLRequest(this.state.getURL(), request);
+
+ // Now we have received some data lets check it:
+ log.debug("Response from mobile BKU: " + responseData); //$NON-NLS-1$
+
+ handler.handleSLRequestResponse(responseData);
+ } catch (Exception ex) {
+ log.error("Error in PostSLRequestThread", ex); //$NON-NLS-1$
+ this.state.setThreadException(ex);
+ this.state.displayError(ex);
+ throw new SignatureException(ex);
+ }
+
+ do {
+ // Check if credentials are available, get them from user if not
+ this.state.checkCredentials();
+
+ // Post credentials
+ try {
+ String responseData = handler.postCredentials();
+
+ // Now we have received some data lets check it:
+ log.debug("Response from mobile BKU: " + responseData); //$NON-NLS-1$
+
+ handler.handleCredentialsResponse(responseData);
+ } catch (Exception ex) {
+ log.error("Error in PostCredentialsThread", ex); //$NON-NLS-1$
+ this.state.setThreadException(ex);
+ this.state.displayError(ex);
+ throw new SignatureException(ex);
+ }
+ } while(this.state.getStatus().getErrorMessage() != null);
+
+ // Check if response is already available
+ if (signingState.hasSignatureResponse()) {
+ SLResponse response = signingState.getSignatureResponse();
+ signingState.setSignatureResponse(null);
+ return response;
+ }
+
+ do {
+ // Get TAN
+ this.state.checkTAN();
+
+ // Post TAN
+ try {
+ String responseData = handler.postTAN();
+
+ // Now we have received some data lets check it:
+ log.debug("Response from mobile BKU: " + responseData); //$NON-NLS-1$
+
+ handler.handleTANResponse(responseData);
+ } catch (Exception ex) {
+ log.error("Error in PostTanThread", ex); //$NON-NLS-1$
+ this.state.setThreadException(ex);
+ this.state.displayError(ex);
+ throw new SignatureException(ex);
+ }
+ } while (this.state.getStatus().getErrorMessage() != null);
+ if (this.state.getStatus().getTanTries() == -1)
+ throw new SignatureException(new IllegalStateException());
+ } while (this.state.getStatus().getTanTries() == -2);
+
+ return signingState.getSignatureResponse();
+ }
+}