summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-gui/src/main')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java217
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java1
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties2
-rw-r--r--pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties2
4 files changed, 150 insertions, 72 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
index df883496..bcf6108d 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java
@@ -16,6 +16,9 @@
package at.asit.pdfover.gui.composites;
// Imports
+import java.awt.Desktop;
+import java.net.URI;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -46,7 +49,7 @@ import at.asit.pdfover.gui.workflow.states.State;
* Composite for entering the TAN for the mobile BKU
*/
public class MobileBKUEnterTANComposite extends StateComposite {
-
+
/**
*
*/
@@ -60,19 +63,21 @@ public class MobileBKUEnterTANComposite extends StateComposite {
@Override
public void widgetSelected(SelectionEvent e) {
String tan = MobileBKUEnterTANComposite.this.txt_tan.getText();
-
+
tan = tan.trim();
-
- if(MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
- MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue")); //$NON-NLS-1$
+
+ if (MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
return;
}
-
- if(tan.length() > 6) {
- MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.TanTooLong")); //$NON-NLS-1$
+
+ if (tan.length() > 6) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.TanTooLong")); //$NON-NLS-1$
return;
}
-
+
MobileBKUEnterTANComposite.this.tan = tan;
MobileBKUEnterTANComposite.this.setUserAck(true);
MobileBKUEnterTANComposite.this.state.updateStateMachine();
@@ -84,16 +89,32 @@ public class MobileBKUEnterTANComposite extends StateComposite {
**/
static final Logger log = LoggerFactory
.getLogger(MobileBKUEnterTANComposite.class);
-
+
Text txt_tan;
-
- boolean userAck = false;
+ boolean userAck = false;
private Label lblRefVal;
String refVal;
-
+
+ String signatureData;
+
+ /**
+ * @return the signatureData
+ */
+ public String getSignatureData() {
+ return this.signatureData;
+ }
+
+ /**
+ * @param signatureData
+ * the signatureData to set
+ */
+ public void setSignatureData(String signatureData) {
+ this.signatureData = signatureData;
+ }
+
String tan;
private Label lblTries;
@@ -111,16 +132,17 @@ public class MobileBKUEnterTANComposite extends StateComposite {
/**
* Set how many tries are left
+ *
* @param tries
*/
public void setTries(int tries) {
- this.lblTries.setText(
- tries == 1 ? Messages.getString("tanEnter.try") : //$NON-NLS-1$
+ this.lblTries.setText(tries == 1 ? Messages.getString("tanEnter.try") : //$NON-NLS-1$
String.format(Messages.getString("tanEnter.tries"), tries)); //$NON-NLS-1$
}
-
+
/**
* Sets the message
+ *
* @param msg
*/
public void setMessage(String msg) {
@@ -128,9 +150,10 @@ public class MobileBKUEnterTANComposite extends StateComposite {
this.lblTries.redraw();
this.lblTries.getParent().layout(true, true);
}
-
+
/**
- * @param userAck the userAck to set
+ * @param userAck
+ * the userAck to set
*/
public void setUserAck(boolean userAck) {
this.userAck = userAck;
@@ -144,19 +167,20 @@ public class MobileBKUEnterTANComposite extends StateComposite {
}
/**
- * @param refVal the reference value to set
+ * @param refVal
+ * the reference value to set
*/
public void setRefVal(String refVal) {
this.refVal = refVal.trim();
-
- if(this.refVal != null) {
+
+ if (this.refVal != null) {
this.lblRefVal.setText(this.refVal);
} else {
this.lblRefVal.setText(""); //$NON-NLS-1$
}
-
+
}
-
+
/**
* @return the tan
*/
@@ -165,12 +189,13 @@ public class MobileBKUEnterTANComposite extends StateComposite {
}
/**
- * @param tan the tan to set
+ * @param tan
+ * the tan to set
*/
public void setTan(String tan) {
this.tan = tan;
-
- if(this.tan == null) {
+
+ if (this.tan == null) {
this.txt_tan.setText(""); //$NON-NLS-1$
} else {
this.txt_tan.setText(this.tan);
@@ -178,29 +203,58 @@ public class MobileBKUEnterTANComposite extends StateComposite {
}
/**
+ * Selection Listener for open button
+ */
+ private final class ShowSignatureDataListener extends SelectionAdapter {
+ /**
+ * Empty constructor
+ */
+ public ShowSignatureDataListener() {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ String signatureData = MobileBKUEnterTANComposite.this
+ .getSignatureData();
+ if (signatureData != null && !signatureData.equals("")) { //$NON-NLS-1$
+ log.debug("Trying to open " + signatureData); //$NON-NLS-1$
+ if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop().browse(new URI(signatureData));
+ } else {
+ log.error("SWT Desktop is not supported on this platform!"); //$NON-NLS-1$
+ }
+ }
+ } catch (Exception ex) {
+ log.error("OpenSelectionListener: ", ex); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
* Create the composite.
+ *
* @param parent
* @param style
- * @param state
+ * @param state
*/
public MobileBKUEnterTANComposite(Composite parent, int style, State state) {
super(parent, style, state);
setLayout(new FormLayout());
-
+
final Composite containerComposite = new Composite(this, SWT.NATIVE);
containerComposite.addPaintListener(new PaintListener() {
-
+
@Override
public void paintControl(PaintEvent e) {
Rectangle clientArea = containerComposite.getClientArea();
-
- //e.gc.setForeground();
- e.gc.setForeground(new Color(getDisplay(),0x6B, 0xA5, 0xD9));
+
+ // e.gc.setForeground();
+ e.gc.setForeground(new Color(getDisplay(), 0x6B, 0xA5, 0xD9));
e.gc.setLineWidth(3);
e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.drawRoundRectangle(clientArea.x,
- clientArea.y, clientArea.width - 2, clientArea.height - 2,
- 10, 10);
+ e.gc.drawRoundRectangle(clientArea.x, clientArea.y,
+ clientArea.width - 2, clientArea.height - 2, 10, 10);
}
});
containerComposite.setLayout(new FormLayout());
@@ -210,23 +264,24 @@ public class MobileBKUEnterTANComposite extends StateComposite {
fd_containerComposite.left = new FormAttachment(50, -200);
fd_containerComposite.right = new FormAttachment(50, 200);
containerComposite.setLayoutData(fd_containerComposite);
-
-
+
this.lblRefValLabel = new Label(containerComposite, SWT.NATIVE);
this.lblRefValLabel.setAlignment(SWT.RIGHT);
FormData fd_lblRefValLabel = new FormData();
- //fd_lblRefValLabel.left = new FormAttachment(0, 20);
+ // fd_lblRefValLabel.left = new FormAttachment(0, 20);
fd_lblRefValLabel.right = new FormAttachment(50, -10);
- //fd_lblRefValLabel.top = new FormAttachment(30, -15);
+ // fd_lblRefValLabel.top = new FormAttachment(30, -15);
fd_lblRefValLabel.bottom = new FormAttachment(50, -10);
this.lblRefValLabel.setLayoutData(fd_lblRefValLabel);
- this.lblRefValLabel.setText(Messages.getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
-
+ this.lblRefValLabel.setText(Messages
+ .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
+
Label lbl_image = new Label(containerComposite, SWT.NATIVE);
-
- ImageData data = new ImageData(this.getClass().getResourceAsStream("/img/handy.gif"));//$NON-NLS-1$
- Image mobile = new Image(getDisplay(), data);
-
+
+ ImageData data = new ImageData(this.getClass().getResourceAsStream(
+ "/img/handy.gif"));//$NON-NLS-1$
+ Image mobile = new Image(getDisplay(), data);
+
FormData fd_lbl_image = new FormData();
fd_lbl_image.top = new FormAttachment(50, -1 * (data.width / 2));
fd_lbl_image.bottom = new FormAttachment(50, data.width / 2);
@@ -234,26 +289,26 @@ public class MobileBKUEnterTANComposite extends StateComposite {
fd_lbl_image.width = data.width;
lbl_image.setLayoutData(fd_lbl_image);
lbl_image.setImage(mobile);
-
+
this.lblRefVal = new Label(containerComposite, SWT.NATIVE);
FormData fd_lblRefVal = new FormData();
fd_lblRefVal.left = new FormAttachment(50, 10);
fd_lblRefVal.right = new FormAttachment(100, -20);
- //fd_lblRefVal.top = new FormAttachment(30, -15);
+ // fd_lblRefVal.top = new FormAttachment(30, -15);
fd_lblRefVal.bottom = new FormAttachment(50, -10);
this.lblRefVal.setLayoutData(fd_lblRefVal);
this.lblRefVal.setText(""); //$NON-NLS-1$
-
+
this.lblTan = new Label(containerComposite, SWT.NATIVE);
this.lblTan.setAlignment(SWT.RIGHT);
FormData fd_lblTan = new FormData();
- //fd_lblTan.left = new FormAttachment(0, 20);
+ // fd_lblTan.left = new FormAttachment(0, 20);
fd_lblTan.right = new FormAttachment(50, -10);
fd_lblTan.top = new FormAttachment(50, 10);
- //fd_lblTan.bottom = new FormAttachment(50, 15);
+ // fd_lblTan.bottom = new FormAttachment(50, 15);
this.lblTan.setLayoutData(fd_lblTan);
this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
-
+
this.txt_tan = new Text(containerComposite, SWT.BORDER | SWT.NATIVE);
FormData fd_text = new FormData();
fd_text.left = new FormAttachment(50, 10);
@@ -261,9 +316,9 @@ public class MobileBKUEnterTANComposite extends StateComposite {
fd_text.top = new FormAttachment(50, 10);
this.txt_tan.setEditable(true);
this.txt_tan.setLayoutData(fd_text);
-
+
this.txt_tan.addTraverseListener(new TraverseListener() {
-
+
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
@@ -271,37 +326,50 @@ public class MobileBKUEnterTANComposite extends StateComposite {
}
}
});
-
+
this.txt_tan.addModifyListener(new ModifyListener() {
-
+
@Override
public void modifyText(ModifyEvent e) {
-
+
String text = MobileBKUEnterTANComposite.this.txt_tan.getText();
//log.debug("Current TAN: " + text); //$NON-NLS-1$
- if(text.length() > 3 && MobileBKUEnterTANComposite.this.getRefVal().startsWith(text.trim())) {
- MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue")); //$NON-NLS-1$
- }
+ if (text.length() > 3
+ && MobileBKUEnterTANComposite.this.getRefVal()
+ .startsWith(text.trim())) {
+ MobileBKUEnterTANComposite.this.setMessage(Messages
+ .getString("error.EnteredReferenceValue")); //$NON-NLS-1$
+ }
}
});
-
+
Button btn_ok = new Button(containerComposite, SWT.NATIVE);
+
+ Button lnk_sig_data = new Button(containerComposite, SWT.NATIVE | SWT.RESIZE);
+
+ FormData fd_lnk_data = new FormData();
+ fd_lnk_data.right = new FormAttachment(100, -20);
+ fd_lnk_data.bottom = new FormAttachment(100, -20);
+ lnk_sig_data.setEnabled(true);
+ lnk_sig_data.setLayoutData(fd_lnk_data);
+ lnk_sig_data.addSelectionListener(new ShowSignatureDataListener());
+ lnk_sig_data.setText(Messages.getString("mobileBKU.show")); //$NON-NLS-1$
+ lnk_sig_data.setToolTipText(Messages.getString("mobileBKU.show_tooltip")); //$NON-NLS-1$
this.lblTries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE);
FormData fd_lbl_tries = new FormData();
- //fd_lbl_tries.left = new FormAttachment(15, 5);
+ // fd_lbl_tries.left = new FormAttachment(15, 5);
fd_lbl_tries.right = new FormAttachment(btn_ok, -10);
- //fd_lbl_tries.top = new FormAttachment(70, -15);
+ // fd_lbl_tries.top = new FormAttachment(70, -15);
fd_lbl_tries.bottom = new FormAttachment(100, -20);
this.lblTries.setLayoutData(fd_lbl_tries);
-
-
+
FormData fd_btn_ok = new FormData();
- //fd_btn_ok.left = new FormAttachment(95, 0);
- fd_btn_ok.right = new FormAttachment(100, -20);
- fd_btn_ok.left = new FormAttachment(100, -70);
- fd_btn_ok.bottom = new FormAttachment(100,-20);
-
+ // fd_btn_ok.left = new FormAttachment(95, 0);
+ fd_btn_ok.right = new FormAttachment(lnk_sig_data, -10);
+ //fd_btn_ok.left = new FormAttachment(100, -70);
+ fd_btn_ok.bottom = new FormAttachment(100, -20);
+
btn_ok.setLayoutData(fd_btn_ok);
btn_ok.setText(Messages.getString("common.Ok")); //$NON-NLS-1$
btn_ok.addSelectionListener(new OkSelectionListener());
@@ -313,7 +381,9 @@ public class MobileBKUEnterTANComposite extends StateComposite {
// Disable the check that prevents subclassing of SWT components
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see at.asit.pdfover.gui.composites.StateComposite#doLayout()
*/
@Override
@@ -321,12 +391,15 @@ public class MobileBKUEnterTANComposite extends StateComposite {
// Nothing to do
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see at.asit.pdfover.gui.composites.StateComposite#reloadResources()
*/
@Override
public void reloadResources() {
- this.lblRefValLabel.setText(Messages.getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
+ this.lblRefValLabel.setText(Messages
+ .getString("tanEnter.ReferenceValue")); //$NON-NLS-1$
this.lblTan.setText(Messages.getString("tanEnter.TAN")); //$NON-NLS-1$
}
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 827dcf70..4b7a3f3e 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
@@ -283,6 +283,7 @@ public class MobileBKUState extends State {
} else {
tan.setRefVal(mobileStatus.getRefVal());
+ tan.setSignatureData(mobileStatus.getSignatureDataURL());
if (mobileStatus.getTanTries() < mobileStatus.getMaxTanTries()
&& mobileStatus.getTanTries() > 0) {
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
index 8ed7b808..f4b7898e 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties
@@ -100,6 +100,8 @@ main.signature=Signing
main.title=PDF-Over
mobileBKU.number=Number:
mobileBKU.password=Password:
+mobileBKU.show=Show
+mobileBKU.show_tooltip=Show signature data
output.file_ask_overwrite=File %s already exists, do you want to overwrite it?
output.link_open_message=You can open the signed file <a>here</a>
output.link_save_message=You can save the signed file
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
index 7cd6bc59..7bcbef5b 100644
--- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
+++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties
@@ -100,6 +100,8 @@ main.signature=Signatur
main.title=PDF-Over
mobileBKU.number=Nummer:
mobileBKU.password=Passwort:
+mobileBKU.show=Show
+mobileBKU.show_tooltip=Zeigt die Signaturdaten an
output.file_ask_overwrite=Datei %s existiert bereits, wollen Sie sie überschreiben?
output.link_open_message=Sie können das signierte Dokument <a>hier</a> öffnen
output.link_save_message=Sie können das signierte Dokument speichern