diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:54:34 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 18:54:34 +0000 |
commit | 6d3b9d99b0e708d2516caf0f098c58c8a9585114 (patch) | |
tree | f27b4c144e19021b04b68a04b01abd92aefbee76 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites | |
parent | 7b9387fd576cea39d5a430312536d3723fdfeeed (diff) | |
download | pdf-over-6d3b9d99b0e708d2516caf0f098c58c8a9585114.tar.gz pdf-over-6d3b9d99b0e708d2516caf0f098c58c8a9585114.tar.bz2 pdf-over-6d3b9d99b0e708d2516caf0f098c58c8a9585114.zip |
Mobile BKU first working (currently set to work with test mobile BKU from A-Trust
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@31 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites')
4 files changed, 578 insertions, 8 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java index 893b0e87..8b8f5b10 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/BKUSelectionComposite.java @@ -27,8 +27,8 @@ import org.eclipse.swt.widgets.Composite; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.asit.pdfover.gui.workflow.states.BKUSelectionState.BKUs; import at.asit.pdfover.gui.workflow.states.State; +import at.asit.pdfover.signator.BKUs; /** * diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java index 38b0f877..93486894 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ErrorComposite.java @@ -65,6 +65,7 @@ public class ErrorComposite extends StateComposite { } private Exception exception; + private Label lbl_message; /** @@ -73,6 +74,7 @@ public class ErrorComposite extends StateComposite { */ public void setException(Exception exception) { this.exception = exception; + this.lbl_message.setText(this.exception.getMessage()); } /** @@ -86,14 +88,14 @@ public class ErrorComposite extends StateComposite { this.setLayout(new FormLayout()); - Label lbl_message = new Label(this, SWT.NATIVE | SWT.RESIZE); + this.lbl_message = new Label(this, SWT.WRAP | SWT.NATIVE | SWT.RESIZE); FormData fd_lbl_message = new FormData(); fd_lbl_message.left = new FormAttachment(10, 0); fd_lbl_message.right = new FormAttachment(90, 0); - fd_lbl_message.top = new FormAttachment(40, 0); - fd_lbl_message.bottom = new FormAttachment(50, 0); - lbl_message.setLayoutData(fd_lbl_message); - lbl_message.setText(this.exception.getMessage()); + fd_lbl_message.top = new FormAttachment(10, 0); + fd_lbl_message.bottom = new FormAttachment(80, 0); + this.lbl_message.setLayoutData(fd_lbl_message); + //lbl_message.setText(this.exception.getMessage()); Button btn_ok = new Button(this, SWT.NATIVE | SWT.RESIZE); btn_ok.setText("OK"); @@ -101,8 +103,8 @@ public class ErrorComposite extends StateComposite { FormData fd_btn_ok = new FormData(); fd_btn_ok.left = new FormAttachment(45, 0); fd_btn_ok.right = new FormAttachment(55, 0); - fd_btn_ok.top = new FormAttachment(70, 0); - fd_btn_ok.bottom = new FormAttachment(75, 0); + fd_btn_ok.top = new FormAttachment(85, 0); + fd_btn_ok.bottom = new FormAttachment(95, 0); btn_ok.setLayoutData(fd_btn_ok); btn_ok.addSelectionListener(new OkSelectionListener()); } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java new file mode 100644 index 00000000..45c0881b --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterNumberComposite.java @@ -0,0 +1,325 @@ +/* + * 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.composites; + +// Imports +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.workflow.states.State; +import org.eclipse.swt.custom.StackLayout; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; + +/** + * + */ +public class MobileBKUEnterNumberComposite extends StateComposite { + /** + * + */ + private final class OkSelectionListener implements SelectionListener { + + /** + * Regular expression for mobile phone numbers: + * this allows the entrance of mobile numbers in the following formats: + * + * +(countryCode)99999999999 + * 00(countryCode)99999999999 + * 099999999999 + * 1030199999999999 (A-Trust Test bku) + */ + private static final String NUMBER_REGEX = "^((\\+[\\d]{2})|(00[\\d]{2})|(0)|(10301))([1-9][\\d]+)$"; //$NON-NLS-1$ + + /** + * + */ + public OkSelectionListener() { + // Nothing to do here + } + + @Override + public void widgetSelected(SelectionEvent e) { + + try { + String number = MobileBKUEnterNumberComposite.this.txt_number + .getText(); + + // Verify number and normalize + + // Compile and use regular expression + Pattern pattern = Pattern.compile(NUMBER_REGEX); + Matcher matcher = pattern.matcher(number); + + if (!matcher.find()) { + MobileBKUEnterNumberComposite.this + .setErrorMessage("Given phone number is invalid! Example: +43664123456789"); + return; + } + + if (matcher.groupCount() != 6) { + MobileBKUEnterNumberComposite.this + .setErrorMessage("Given phone number is invalid! Example: +43664123456789"); + return; + } + + String countryCode = matcher.group(1); + + String normalNumber = matcher.group(6); + + if (countryCode.equals("10301")) { //$NON-NLS-1$ + // A-Trust Testnumber! + } else { + + countryCode = countryCode.replace("00", "+"); //$NON-NLS-1$ //$NON-NLS-2$ + + if (countryCode.equals("0")) { //$NON-NLS-1$ + countryCode = "+43"; //$NON-NLS-1$ + } + + number = countryCode + normalNumber; + } + MobileBKUEnterNumberComposite.this.setMobileNumber(number); + + MobileBKUEnterNumberComposite.this.mobileNumber = number; + + String password = MobileBKUEnterNumberComposite.this.txt_password + .getText(); + + // TODO: Logic to verify password + + if (password.length() < 6 || password.length() > 20) { + if (password.length() < 6) { + MobileBKUEnterNumberComposite.this + .setErrorMessage("Given password is too short!"); + } else { + MobileBKUEnterNumberComposite.this + .setErrorMessage("Given password is too long!"); + } + return; + } + + MobileBKUEnterNumberComposite.this.mobilePassword = password; + MobileBKUEnterNumberComposite.this.setUserAck(true); + } catch (Exception ex) { + log.error("Validating input for Mobile BKU failed!", ex); //$NON-NLS-1$ + // TODO: NOT VALID + MobileBKUEnterNumberComposite.this + .setErrorMessage("Given phone number is invalid! Example: +43664123456789"); + return; + } + MobileBKUEnterNumberComposite.this.state.updateStateMachine(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Nothing to do! + } + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MobileBKUEnterNumberComposite.class); + + String mobileNumber; + + String mobilePassword; + + Text txt_number; + + Text txt_password; + + String errorMessage = null; + + boolean userAck = false; + + /** + * @return the userAck + */ + public boolean isUserAck() { + return this.userAck; + } + + /** + * @param userAck + * the userAck to set + */ + public void setUserAck(boolean userAck) { + this.userAck = userAck; + } + + private Label lbl_error; + + /** + * @return the errorMessage + */ + public String getErrorMessage() { + return this.errorMessage; + } + + /** + * @param errorMessage + * the errorMessage to set + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + + if (this.errorMessage != null) { + this.lbl_error.setText(this.errorMessage); + } else { + this.lbl_error.setText(""); //$NON-NLS-1$ + } + } + + /** + * Create the composite. + * + * @param parent + * @param style + * @param state + */ + public MobileBKUEnterNumberComposite(Composite parent, int style, + State state) { + super(parent, style, state); + setLayout(new FormLayout()); + + this.txt_number = new Text(this, SWT.SINGLE | SWT.NATIVE | SWT.BORDER); + FormData fd_number = new FormData(); + fd_number.top = new FormAttachment(30, -15); + fd_number.bottom = new FormAttachment(30, 15); + fd_number.left = new FormAttachment(50, 0); + fd_number.right = new FormAttachment(85, 0); + this.txt_number.setLayoutData(fd_number); + this.txt_number.setEditable(true); + + Label lbl_number = new Label(this, SWT.NATIVE); + lbl_number.setText("Nummer:"); + FormData fd_lbl_number = new FormData(); + fd_lbl_number.top = new FormAttachment(30, -15); + fd_lbl_number.bottom = new FormAttachment(30, 15); + fd_lbl_number.left = new FormAttachment(15, 0); + fd_lbl_number.right = new FormAttachment(45, 0); + lbl_number.setLayoutData(fd_lbl_number); + + this.txt_password = new Text(this, SWT.SINGLE | SWT.PASSWORD + | SWT.BORDER | SWT.NATIVE); + FormData fd_password = new FormData(); + fd_password.top = new FormAttachment(50, -15); + fd_password.bottom = new FormAttachment(50, 15); + fd_password.left = new FormAttachment(50, 0); + fd_password.right = new FormAttachment(85, 0); + this.txt_password.setLayoutData(fd_password); + this.txt_password.setEditable(true); + + Label lbl_password = new Label(this, SWT.NATIVE); + lbl_password.setText("Passwort:"); + FormData fd_lbl_password = new FormData(); + fd_lbl_password.top = new FormAttachment(50, -15); + fd_lbl_password.bottom = new FormAttachment(50, 15); + fd_lbl_password.left = new FormAttachment(15, 0); + fd_lbl_password.right = new FormAttachment(45, 0); + lbl_password.setLayoutData(fd_lbl_password); + + this.lbl_error = new Label(this, SWT.WRAP | SWT.NATIVE); + FormData fd_lbl_error = new FormData(); + fd_lbl_error.top = new FormAttachment(70, -15); + fd_lbl_error.bottom = new FormAttachment(70, 15); + fd_lbl_error.left = new FormAttachment(15, 0); + fd_lbl_error.right = new FormAttachment(85, 0); + this.lbl_error.setLayoutData(fd_lbl_error); + + Button btn_ok = new Button(this, SWT.NATIVE); + btn_ok.setText("Ok"); + FormData fd_btn_ok = new FormData(); + fd_btn_ok.top = new FormAttachment(87, 0); + fd_btn_ok.bottom = new FormAttachment(95, 0); + fd_btn_ok.left = new FormAttachment(75, 0); + fd_btn_ok.right = new FormAttachment(95, 0); + btn_ok.setLayoutData(fd_btn_ok); + btn_ok.addSelectionListener(new OkSelectionListener()); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + /* + * (non-Javadoc) + * + * @see at.asit.pdfover.gui.composites.StateComposite#doLayout() + */ + @Override + public void doLayout() { + // Nothing to do here till now + } + + /** + * @return the mobileNumber + */ + public String getMobileNumber() { + return this.mobileNumber; + } + + /** + * @param mobileNumber + * the mobileNumber to set + */ + public void setMobileNumber(String mobileNumber) { + this.mobileNumber = mobileNumber; + + if (this.mobileNumber != null) { + this.txt_number.setText(this.mobileNumber); + } else { + this.txt_number.setText(""); //$NON-NLS-1$ + } + } + + /** + * @return the mobilePassword + */ + public String getMobilePassword() { + return this.mobilePassword; + } + + /** + * @param mobilePassword + * the mobilePassword to set + */ + public void setMobilePassword(String mobilePassword) { + this.mobilePassword = mobilePassword; + + if (this.mobilePassword != null) { + this.txt_password.setText(this.mobilePassword); + } else { + this.txt_password.setText(""); //$NON-NLS-1$ + } + } + +} 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 new file mode 100644 index 00000000..0a23b947 --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/MobileBKUEnterTANComposite.java @@ -0,0 +1,243 @@ +/* + * 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.composites; + +// Imports +import org.eclipse.swt.widgets.Composite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.workflow.states.State; + +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormAttachment; + +/** + * + */ +public class MobileBKUEnterTANComposite extends StateComposite { + /** + * + */ + private final class OkSelectionListener implements SelectionListener { + /** + * + */ + public OkSelectionListener() { + // Nothing to do + } + + @Override + public void widgetSelected(SelectionEvent e) { + String tan = MobileBKUEnterTANComposite.this.txt_tan.getText(); + + tan = tan.trim(); + + if(MobileBKUEnterTANComposite.this.vergleichswert.startsWith(tan)) { + MobileBKUEnterTANComposite.this.setMessage("Sie haben den Vergleichswert eingegeben!"); + return; + } + + if(tan.length() > 6) { + MobileBKUEnterTANComposite.this.setMessage("Eingabe zu lange für TAN"); + return; + } + + // TODO: Check TAN! + + MobileBKUEnterTANComposite.this.tan = tan; + MobileBKUEnterTANComposite.this.setUserAck(true); + MobileBKUEnterTANComposite.this.state.updateStateMachine(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // Nothing to do + } + } + + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MobileBKUEnterTANComposite.class); + + Text txt_tan; + + boolean userAck = false; + + /** + * @return the userAck + */ + public boolean isUserAck() { + return this.userAck; + } + + public void setTries(int tries) { + this.lbl_tries.setText(tries + " tries left!"); + } + + public void setMessage(String msg) { + this.lbl_tries.setText(msg); + } + + /** + * @param userAck the userAck to set + */ + public void setUserAck(boolean userAck) { + this.userAck = userAck; + } + + private Label lblvergleich; + + String vergleichswert; + + String tan; + + private Label lbl_tries; + + /** + * @return the vergleichswert + */ + public String getVergleichswert() { + return this.vergleichswert; + } + + /** + * @param vergleichswert the vergleichswert to set + */ + public void setVergleichswert(String vergleichswert) { + this.vergleichswert = vergleichswert.trim(); + + if(this.vergleichswert != null) { + this.lblvergleich.setText(this.vergleichswert); + } else { + this.lblvergleich.setText(""); + } + + } + + /** + * @return the tan + */ + public String getTan() { + return this.tan; + } + + /** + * @param tan the tan to set + */ + public void setTan(String tan) { + this.tan = tan; + + if(this.tan == null) { + this.txt_tan.setText(""); //$NON-NLS-1$ + } else { + this.txt_tan.setText(this.tan); + } + } + + /** + * Create the composite. + * @param parent + * @param style + * @param state + */ + public MobileBKUEnterTANComposite(Composite parent, int style, State state) { + super(parent, style, state); + setLayout(new FormLayout()); + + Label lblVergleichswert = new Label(this, SWT.NATIVE); + FormData fd_lblVergleichswert = new FormData(); + fd_lblVergleichswert.left = new FormAttachment(15, 0); + fd_lblVergleichswert.right = new FormAttachment(50, 0); + fd_lblVergleichswert.top = new FormAttachment(30, -15); + fd_lblVergleichswert.bottom = new FormAttachment(30, 15); + lblVergleichswert.setLayoutData(fd_lblVergleichswert); + lblVergleichswert.setText("Vergleichswert"); + + this.lblvergleich = new Label(this, SWT.NATIVE); + FormData fd_lblvergleich = new FormData(); + fd_lblvergleich.left = new FormAttachment(50, 0); + fd_lblvergleich.right = new FormAttachment(85, 0); + fd_lblvergleich.top = new FormAttachment(30, -15); + fd_lblvergleich.bottom = new FormAttachment(30, 15); + this.lblvergleich.setLayoutData(fd_lblvergleich); + this.lblvergleich.setText("New Label"); //$NON-NLS-1$ + + Label lblTan = new Label(this, SWT.NATIVE); + FormData fd_lblTan = new FormData(); + fd_lblTan.left = new FormAttachment(15, 5); + fd_lblTan.right = new FormAttachment(50, -5); + fd_lblTan.top = new FormAttachment(50, -15); + fd_lblTan.bottom = new FormAttachment(50, 15); + lblTan.setLayoutData(fd_lblTan); + lblTan.setText("TAN:"); + + this.txt_tan = new Text(this, SWT.BORDER | SWT.NATIVE); + FormData fd_text = new FormData(); + fd_text.left = new FormAttachment(50, 0); + fd_text.right = new FormAttachment(85, 0); + fd_text.top = new FormAttachment(50, -15); + fd_text.left = new FormAttachment(50, 15); + this.txt_tan.setEditable(true); + this.txt_tan.setLayoutData(fd_text); + + this.lbl_tries = new Label(this, SWT.WRAP | SWT.NATIVE); + FormData fd_lbl_tries = new FormData(); + fd_lbl_tries.left = new FormAttachment(15, 5); + fd_lbl_tries.right = new FormAttachment(85, -5); + fd_lbl_tries.top = new FormAttachment(70, -15); + fd_lbl_tries.bottom = new FormAttachment(70, 15); + this.lbl_tries.setLayoutData(fd_lbl_tries); + + Button btn_ok = new Button(this, SWT.NATIVE); + FormData fd_btn_ok = new FormData(); + fd_btn_ok.left = new FormAttachment(15, 0); + fd_btn_ok.right = new FormAttachment(95, 0); + fd_btn_ok.top = new FormAttachment(85); + fd_btn_ok.bottom = new FormAttachment(95); + + btn_ok.setLayoutData(fd_btn_ok); + btn_ok.setText("Ok"); + btn_ok.addSelectionListener(new OkSelectionListener()); + + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.composites.StateComposite#doLayout() + */ + @Override + public void doLayout() { + // TODO Auto-generated method stub + + } + +} |