From e497e79c707d335ebb0610e9bc993a180098db55 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:32:03 +0000 Subject: Rename ATrustHelper, refVal git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@370 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../pdfover/gui/cliarguments/PasswordArgument.java | 4 +- .../gui/cliarguments/PhoneNumberArgument.java | 4 +- .../composites/MobileBKUEnterNumberComposite.java | 6 +- .../gui/composites/MobileBKUEnterTANComposite.java | 95 ++++++------- .../gui/workflow/ConfigurationContainerImpl.java | 4 +- .../gui/workflow/states/MobileBKUState.java | 2 +- .../workflow/states/mobilebku/ATrustHelper.java | 148 --------------------- .../workflow/states/mobilebku/MobileBKUHelper.java | 148 +++++++++++++++++++++ .../workflow/states/mobilebku/MobileBKUStatus.java | 14 +- .../states/mobilebku/PostCredentialsThread.java | 18 +-- .../states/mobilebku/PostSLRequestThread.java | 8 +- 11 files changed, 226 insertions(+), 225 deletions(-) delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHelper.java create mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHelper.java (limited to 'pdf-over-gui/src/main/java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java index b32a4edd..1f90cda2 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PasswordArgument.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.exceptions.InitializationException; import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; /** * CLI Argument to provide Mobile BKU password @@ -52,7 +52,7 @@ public class PasswordArgument extends CLIArgument { String password = args[argOffset + 1]; - ATrustHelper.validatePassword(password); + MobileBKUHelper.validatePassword(password); getConfiguration().setDefaultMobilePasswordOverlay(password); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java index eccebb21..a6a1cb79 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/PhoneNumberArgument.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.exceptions.InitializationException; import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; /** * CLI Argument to provide Mobile BKU phone number to use @@ -55,7 +55,7 @@ public class PhoneNumberArgument extends CLIArgument { String number = args[argOffset + 1]; - number = ATrustHelper.normalizeMobileNumber(number); + number = MobileBKUHelper.normalizeMobileNumber(number); getConfiguration().setDefaultMobileNumberOverlay(number); 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 index 4c706c2d..1f4ef4d1 100644 --- 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 @@ -39,7 +39,7 @@ import at.asit.pdfover.gui.exceptions.InvalidNumberException; import at.asit.pdfover.gui.exceptions.InvalidPasswordException; import at.asit.pdfover.gui.utils.Messages; import at.asit.pdfover.gui.workflow.states.State; -import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; /** * Composite for entering the phone number for the mobile BKU @@ -62,7 +62,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { .getText(); - number = ATrustHelper.normalizeMobileNumber(number); + number = MobileBKUHelper.normalizeMobileNumber(number); MobileBKUEnterNumberComposite.this.setMobileNumber(number); @@ -71,7 +71,7 @@ public class MobileBKUEnterNumberComposite extends StateComposite { String password = MobileBKUEnterNumberComposite.this.txt_password .getText(); - ATrustHelper.validatePassword(password); + MobileBKUHelper.validatePassword(password); MobileBKUEnterNumberComposite.this.mobilePassword = password; MobileBKUEnterNumberComposite.this.setUserAck(true); 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 f0f5cb78..df883496 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 @@ -63,7 +63,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { tan = tan.trim(); - if(MobileBKUEnterTANComposite.this.vergleichswert.startsWith(tan)) { + if(MobileBKUEnterTANComposite.this.refVal.startsWith(tan)) { MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue")); //$NON-NLS-1$ return; } @@ -89,6 +89,19 @@ public class MobileBKUEnterTANComposite extends StateComposite { boolean userAck = false; + + private Label lblRefVal; + + String refVal; + + String tan; + + private Label lblTries; + + private Label lblRefValLabel; + + private Label lblTan; + /** * @return the userAck */ @@ -101,7 +114,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { * @param tries */ public void setTries(int tries) { - this.lbl_tries.setText( + this.lblTries.setText( tries == 1 ? Messages.getString("tanEnter.try") : //$NON-NLS-1$ String.format(Messages.getString("tanEnter.tries"), tries)); //$NON-NLS-1$ } @@ -111,9 +124,9 @@ public class MobileBKUEnterTANComposite extends StateComposite { * @param msg */ public void setMessage(String msg) { - this.lbl_tries.setText(msg); - this.lbl_tries.redraw(); - this.lbl_tries.getParent().layout(true, true); + this.lblTries.setText(msg); + this.lblTries.redraw(); + this.lblTries.getParent().layout(true, true); } /** @@ -123,35 +136,23 @@ public class MobileBKUEnterTANComposite extends StateComposite { this.userAck = userAck; } - private Label lblvergleich; - - String vergleichswert; - - String tan; - - private Label lbl_tries; - - private Label lblVergleichswert; - - private Label lblTan; - /** - * @return the vergleichswert + * @return the reference value */ - public String getVergleichswert() { - return this.vergleichswert; + public String getRefVal() { + return this.refVal; } /** - * @param vergleichswert the vergleichswert to set + * @param refVal the reference value to set */ - public void setVergleichswert(String vergleichswert) { - this.vergleichswert = vergleichswert.trim(); + public void setRefVal(String refVal) { + this.refVal = refVal.trim(); - if(this.vergleichswert != null) { - this.lblvergleich.setText(this.vergleichswert); + if(this.refVal != null) { + this.lblRefVal.setText(this.refVal); } else { - this.lblvergleich.setText(""); //$NON-NLS-1$ + this.lblRefVal.setText(""); //$NON-NLS-1$ } } @@ -211,15 +212,15 @@ public class MobileBKUEnterTANComposite extends StateComposite { containerComposite.setLayoutData(fd_containerComposite); - this.lblVergleichswert = new Label(containerComposite, SWT.NATIVE); - this.lblVergleichswert.setAlignment(SWT.RIGHT); - FormData fd_lblVergleichswert = new FormData(); - //fd_lblVergleichswert.left = new FormAttachment(0, 20); - fd_lblVergleichswert.right = new FormAttachment(50, -10); - //fd_lblVergleichswert.top = new FormAttachment(30, -15); - fd_lblVergleichswert.bottom = new FormAttachment(50, -10); - this.lblVergleichswert.setLayoutData(fd_lblVergleichswert); - this.lblVergleichswert.setText(Messages.getString("tanEnter.ReferenceValue")); //$NON-NLS-1$ + 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.right = new FormAttachment(50, -10); + //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$ Label lbl_image = new Label(containerComposite, SWT.NATIVE); @@ -234,14 +235,14 @@ public class MobileBKUEnterTANComposite extends StateComposite { lbl_image.setLayoutData(fd_lbl_image); lbl_image.setImage(mobile); - this.lblvergleich = new Label(containerComposite, SWT.NATIVE); - FormData fd_lblvergleich = new FormData(); - fd_lblvergleich.left = new FormAttachment(50, 10); - fd_lblvergleich.right = new FormAttachment(100, -20); - //fd_lblvergleich.top = new FormAttachment(30, -15); - fd_lblvergleich.bottom = new FormAttachment(50, -10); - this.lblvergleich.setLayoutData(fd_lblvergleich); - this.lblvergleich.setText(""); //$NON-NLS-1$ + 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.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); @@ -278,7 +279,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { String text = MobileBKUEnterTANComposite.this.txt_tan.getText(); //log.debug("Current TAN: " + text); //$NON-NLS-1$ - if(text.length() > 3 && MobileBKUEnterTANComposite.this.getVergleichswert().startsWith(text.trim())) { + if(text.length() > 3 && MobileBKUEnterTANComposite.this.getRefVal().startsWith(text.trim())) { MobileBKUEnterTANComposite.this.setMessage(Messages.getString("error.EnteredReferenceValue")); //$NON-NLS-1$ } } @@ -286,13 +287,13 @@ public class MobileBKUEnterTANComposite extends StateComposite { Button btn_ok = new Button(containerComposite, SWT.NATIVE); - this.lbl_tries = new Label(containerComposite, SWT.WRAP | SWT.NATIVE); + 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.right = new FormAttachment(btn_ok, -10); //fd_lbl_tries.top = new FormAttachment(70, -15); fd_lbl_tries.bottom = new FormAttachment(100, -20); - this.lbl_tries.setLayoutData(fd_lbl_tries); + this.lblTries.setLayoutData(fd_lbl_tries); FormData fd_btn_ok = new FormData(); @@ -325,7 +326,7 @@ public class MobileBKUEnterTANComposite extends StateComposite { */ @Override public void reloadResources() { - this.lblVergleichswert.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/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java index 219ac99b..cb2a1ee8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigurationContainerImpl.java @@ -32,7 +32,7 @@ import at.asit.pdfover.gui.exceptions.InvalidEmblemFile; import at.asit.pdfover.gui.exceptions.InvalidNumberException; import at.asit.pdfover.gui.exceptions.InvalidPortException; import at.asit.pdfover.gui.utils.Messages; -import at.asit.pdfover.gui.workflow.states.mobilebku.ATrustHelper; +import at.asit.pdfover.gui.workflow.states.mobilebku.MobileBKUHelper; import at.asit.pdfover.signator.BKUs; import at.asit.pdfover.signator.SignaturePosition; @@ -148,7 +148,7 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { return; } try { - this.mobileNumber = ATrustHelper.normalizeMobileNumber(number); + this.mobileNumber = MobileBKUHelper.normalizeMobileNumber(number); } catch (InvalidNumberException e) { throw new InvalidNumberException(Messages.getString("error.InvalidPhoneNumber")); //$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 bc831766..71e68d36 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 @@ -251,7 +251,7 @@ public class MobileBKUState extends State { postTanThread.start(); } else { - tan.setVergleichswert(mobileStatus.getVergleichswert()); + tan.setRefVal(mobileStatus.getRefVal()); if (mobileStatus.getTanTries() < MobileBKUStatus.MOBILE_MAX_TAN_TRIES && mobileStatus.getTanTries() > 0) { diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHelper.java deleted file mode 100644 index ee984e96..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/ATrustHelper.java +++ /dev/null @@ -1,148 +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.gui.workflow.states.mobilebku; - -// Imports -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.exceptions.InvalidNumberException; -import at.asit.pdfover.gui.exceptions.InvalidPasswordException; -import at.asit.pdfover.gui.exceptions.PasswordTooLongException; -import at.asit.pdfover.gui.exceptions.PasswordTooShortException; - -/** - * - */ -public class ATrustHelper { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory - .getLogger(ATrustHelper.class); - - /** - * 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$ - - /** - * Extracts a substring from data starting after start and ending with end - * - * @param data - * the whole data string - * @param start - * the start marker - * @param end - * the end marker - * @return the substring - * @throws Exception - */ - public static String extractTag(String data, String start, String end) - throws Exception { - int startidx = data.indexOf(start); - if (startidx > 0) { - startidx = startidx + start.length(); - int endidx = data.indexOf(end, startidx); - if (endidx > startidx) { - return data.substring(startidx, endidx); - } - log.error("extracting Tag: end tag not valid!: " + start + " ... " + end); //$NON-NLS-1$//$NON-NLS-2$ - throw new Exception("end tag not available!"); //$NON-NLS-1$ - } - log.error("extracting Tag: start tag not valid!: " + start + " ... " + end); //$NON-NLS-1$//$NON-NLS-2$ - throw new Exception("start tag not available!"); //$NON-NLS-1$ - } - - /** - * Validates the Mobile phone number - * - * @param number - * @return the normalized Phone number - * @throws InvalidNumberException - */ - public static String normalizeMobileNumber(String number) - throws InvalidNumberException { - // Verify number and normalize - - // Compile and use regular expression - Pattern pattern = Pattern.compile(NUMBER_REGEX); - Matcher matcher = pattern.matcher(number); - - if (!matcher.find()) { - throw new InvalidNumberException(); - } - - if (matcher.groupCount() != 6) { - throw new InvalidNumberException(); - } - - String countryCode = matcher.group(1); - - String normalNumber = matcher.group(6); - - if (countryCode.equals("10301")) { //$NON-NLS-1$ - // A-Trust Testnumber! Don't change - return number; - } - - countryCode = countryCode.replace("00", "+"); //$NON-NLS-1$ //$NON-NLS-2$ - - if (countryCode.equals("0")) { //$NON-NLS-1$ - countryCode = "+43"; //$NON-NLS-1$ - } - - return countryCode + normalNumber; - } - - /** - * Validate given Password for Mobile BKU - * - * @param password - * @throws InvalidPasswordException - */ - public static void validatePassword(String password) - throws InvalidPasswordException { - if (password.length() < 6 || password.length() > 20) { - if (password.length() < 6) { - throw new PasswordTooShortException(); - } - throw new PasswordTooLongException(); - } - } - - /** - * Removes file extension from URL - * - * @param query - * the url string - * @return the stripped url - */ - public static String stripQueryString(String query) { - int pathidx = query.lastIndexOf('/'); - if (pathidx > 0) { - return query.substring(0, pathidx); - } - return query; - } -} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHelper.java new file mode 100644 index 00000000..cbb234cb --- /dev/null +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUHelper.java @@ -0,0 +1,148 @@ +/* + * 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.workflow.states.mobilebku; + +// Imports +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.gui.exceptions.InvalidNumberException; +import at.asit.pdfover.gui.exceptions.InvalidPasswordException; +import at.asit.pdfover.gui.exceptions.PasswordTooLongException; +import at.asit.pdfover.gui.exceptions.PasswordTooShortException; + +/** + * + */ +public class MobileBKUHelper { + /** + * SLF4J Logger instance + **/ + private static final Logger log = LoggerFactory + .getLogger(MobileBKUHelper.class); + + /** + * 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$ + + /** + * Extracts a substring from data starting after start and ending with end + * + * @param data + * the whole data string + * @param start + * the start marker + * @param end + * the end marker + * @return the substring + * @throws Exception + */ + public static String extractTag(String data, String start, String end) + throws Exception { + int startidx = data.indexOf(start); + if (startidx > 0) { + startidx = startidx + start.length(); + int endidx = data.indexOf(end, startidx); + if (endidx > startidx) { + return data.substring(startidx, endidx); + } + log.error("extracting Tag: end tag not valid!: " + start + " ... " + end); //$NON-NLS-1$//$NON-NLS-2$ + throw new Exception("end tag not available!"); //$NON-NLS-1$ + } + log.error("extracting Tag: start tag not valid!: " + start + " ... " + end); //$NON-NLS-1$//$NON-NLS-2$ + throw new Exception("start tag not available!"); //$NON-NLS-1$ + } + + /** + * Validates the Mobile phone number + * + * @param number + * @return the normalized Phone number + * @throws InvalidNumberException + */ + public static String normalizeMobileNumber(String number) + throws InvalidNumberException { + // Verify number and normalize + + // Compile and use regular expression + Pattern pattern = Pattern.compile(NUMBER_REGEX); + Matcher matcher = pattern.matcher(number); + + if (!matcher.find()) { + throw new InvalidNumberException(); + } + + if (matcher.groupCount() != 6) { + throw new InvalidNumberException(); + } + + String countryCode = matcher.group(1); + + String normalNumber = matcher.group(6); + + if (countryCode.equals("10301")) { //$NON-NLS-1$ + // A-Trust Testnumber! Don't change + return number; + } + + countryCode = countryCode.replace("00", "+"); //$NON-NLS-1$ //$NON-NLS-2$ + + if (countryCode.equals("0")) { //$NON-NLS-1$ + countryCode = "+43"; //$NON-NLS-1$ + } + + return countryCode + normalNumber; + } + + /** + * Validate given Password for Mobile BKU + * + * @param password + * @throws InvalidPasswordException + */ + public static void validatePassword(String password) + throws InvalidPasswordException { + if (password.length() < 6 || password.length() > 20) { + if (password.length() < 6) { + throw new PasswordTooShortException(); + } + throw new PasswordTooLongException(); + } + } + + /** + * Removes file extension from URL + * + * @param query + * the url string + * @return the stripped url + */ + public static String stripQueryString(String query) { + int pathidx = query.lastIndexOf('/'); + if (pathidx > 0) { + return query.substring(0, pathidx); + } + return query; + } +} diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUStatus.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUStatus.java index fd8ded4e..78dad7a5 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUStatus.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/MobileBKUStatus.java @@ -58,7 +58,7 @@ public class MobileBKUStatus { String baseURL; - String vergleichswert; + String refVal; String errorMessage; @@ -109,17 +109,17 @@ public class MobileBKUStatus { } /** - * @return the vergleichswert + * @return the reference value */ - public String getVergleichswert() { - return this.vergleichswert; + public String getRefVal() { + return this.refVal; } /** - * @param vergleichswert the vergleichswert to set + * @param refVal the reference value to set */ - public void setVergleichswert(String vergleichswert) { - this.vergleichswert = vergleichswert; + public void setRefVal(String refVal) { + this.refVal = refVal; } /** diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostCredentialsThread.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostCredentialsThread.java index a2269d21..45656404 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostCredentialsThread.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostCredentialsThread.java @@ -129,28 +129,28 @@ public class PostCredentialsThread implements Runnable { String eventValidation = status.getEventvalidation(); String sessionID = status.getSessionID(); - String vergleichswert = null; + String refVal = null; - status.setVergleichswert(null); + status.setRefVal(null); status.setErrorMessage(null); if(responseData.contains("signature.aspx?sid=")) { //$NON-NLS-1$ // credentials ok! TAN eingabe - sessionID = ATrustHelper.extractTag(responseData, "signature.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ - viewState = ATrustHelper.extractTag(responseData, "id=\"__VIEWSTATE\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + sessionID = MobileBKUHelper.extractTag(responseData, "signature.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + viewState = MobileBKUHelper.extractTag(responseData, "id=\"__VIEWSTATE\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ - eventValidation = ATrustHelper.extractTag(responseData, "id=\"__EVENTVALIDATION\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + eventValidation = MobileBKUHelper.extractTag(responseData, "id=\"__EVENTVALIDATION\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ - vergleichswert = ATrustHelper.extractTag(responseData, "id='vergleichswert'>Vergleichswert:", ""); //$NON-NLS-1$//$NON-NLS-2$ + refVal = MobileBKUHelper.extractTag(responseData, "id='vergleichswert'>Vergleichswert:", ""); //$NON-NLS-1$//$NON-NLS-2$ - status.setVergleichswert(vergleichswert); + status.setRefVal(refVal); this.state.setCommunicationState(MobileBKUCommunicationState.POST_TAN); } else { // error seite // extract error text! - String errorMessage = ATrustHelper.extractTag(responseData, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ + String errorMessage = MobileBKUHelper.extractTag(responseData, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ this.state.getStatus().setErrorMessage(errorMessage); @@ -159,7 +159,7 @@ public class PostCredentialsThread implements Runnable { } log.info("sessionID: " + sessionID); //$NON-NLS-1$ - log.info("Vergleichswert: " + vergleichswert); //$NON-NLS-1$ + log.info("Vergleichswert: " + refVal); //$NON-NLS-1$ log.info("viewState: " + viewState); //$NON-NLS-1$ log.info("eventValidation: " + eventValidation); //$NON-NLS-1$ diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java index ecd1d98a..4de8f6fc 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/mobilebku/PostSLRequestThread.java @@ -146,7 +146,7 @@ public class PostSLRequestThread implements Runnable { String responseData = null; this.state.getStatus().setBaseURL( - ATrustHelper.stripQueryString(url)); + MobileBKUHelper.stripQueryString(url)); // Follow redirects do { @@ -188,13 +188,13 @@ public class PostSLRequestThread implements Runnable { // Extract infos: - String sessionID = ATrustHelper.extractTag(responseData, + String sessionID = MobileBKUHelper.extractTag(responseData, "identification.aspx?sid=", "\""); //$NON-NLS-1$ //$NON-NLS-2$ - String viewState = ATrustHelper.extractTag(responseData, + String viewState = MobileBKUHelper.extractTag(responseData, "id=\"__VIEWSTATE\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ - String eventValidation = ATrustHelper.extractTag(responseData, + String eventValidation = MobileBKUHelper.extractTag(responseData, "id=\"__EVENTVALIDATION\" value=\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$ log.info("sessionID: " + sessionID); //$NON-NLS-1$ -- cgit v1.2.3