summaryrefslogtreecommitdiff
path: root/BKUCommonGUI/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-12 20:48:57 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-11-12 20:48:57 +0000
commit68651bf67987905980734f5c2199f337a232f427 (patch)
treed3875d79cf555488824ca5e4455433c8e13ccd5d /BKUCommonGUI/src/main/java/at/gv/egiz
parent68941b57df2caeead67a5bede2ef5a635d07db32 (diff)
downloadmocca-68651bf67987905980734f5c2199f337a232f427.tar.gz
mocca-68651bf67987905980734f5c2199f337a232f427.tar.bz2
mocca-68651bf67987905980734f5c2199f337a232f427.zip
Added support for enforcing a PIN length in a CHANGE REFERENCE DATA to match the recommended PIN length via Applet parameter.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@541 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUCommonGUI/src/main/java/at/gv/egiz')
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java4
-rw-r--r--BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java94
2 files changed, 54 insertions, 44 deletions
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
index 34f278fb..20fe4f56 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/BKUGUIImpl.java
@@ -593,7 +593,7 @@ public class BKUGUIImpl implements BKUGUIFacade {
pinField = new JPasswordField();
pinField.setText("");
- pinField.setDocument(new PINDocument(pinSpec, okButton));
+ pinField.setDocument(new PINDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(), pinSpec.getRexepPattern(), okButton));
pinField.setActionCommand(okCommand);
pinField.addActionListener(new ActionListener() {
@@ -1031,7 +1031,7 @@ public class BKUGUIImpl implements BKUGUIFacade {
pinField = new JPasswordField();
pinField.setText("");
- pinField.setDocument(new PINDocument(pinSpec, signButton));
+ pinField.setDocument(new PINDocument(pinSpec.getMinLength(), pinSpec.getMaxLength(), pinSpec.getRexepPattern(), signButton));
pinField.setActionCommand(signCommand);
pinField.addActionListener(new ActionListener() {
diff --git a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
index 13aaf870..96032dc1 100644
--- a/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
+++ b/BKUCommonGUI/src/main/java/at/gv/egiz/bku/gui/PinDocument.java
@@ -16,7 +16,6 @@
*/
package at.gv.egiz.bku.gui;
-import at.gv.egiz.smcc.PINSpec;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
@@ -31,49 +30,60 @@ import javax.swing.text.PlainDocument;
*/
class PINDocument extends PlainDocument {
- protected PINSpec pinSpec;
- protected Pattern pinPattern;
- protected JButton enterButton;
- protected Document compareTo;
- protected Document oldPin;
+ private static final long serialVersionUID = 1L;
+
+ protected Pattern pinPattern;
+ protected int minLength;
+ protected int maxLength;
- public PINDocument(PINSpec pinSpec, JButton enterButton) {
- this.pinSpec = pinSpec;
- if (pinSpec.getRexepPattern() != null) {
- pinPattern = Pattern.compile(pinSpec.getRexepPattern());
- } else {
- pinPattern = Pattern.compile(".");
- }
- this.enterButton = enterButton;
- }
+ protected JButton enterButton;
+ protected Document compareTo;
+ protected Document oldPin;
- /**
- *
- * @param pinSpec
- * @param enterButton
- * @param compareTo enable enterButton iff this pinDocument's pin equals to compareTo's pin. may be null
- */
- public PINDocument(PINSpec pinSpec, JButton enterButton, Document compareTo) {
- this(pinSpec, enterButton);
- this.compareTo = compareTo;
- }
+ public PINDocument(int minLength, int maxLength, String pattern, JButton enterButton) {
+ if (pattern != null) {
+ pinPattern = Pattern.compile(pattern);
+ } else {
+ pinPattern = Pattern.compile(".");
+ }
+ this.minLength = minLength;
+ this.maxLength = maxLength;
+ this.enterButton = enterButton;
+ }
- /**
- *
- * @param pinSpec
- * @param enterButton may be null
- * @param compareTo enable enterButton iff this pinDocument's pin equals to compareTo's pin. may be null
- * @param oldPin enable enterButton iff oldPin meets the pinSpec pin length requirements, may be null
- */
- public PINDocument(PINSpec pinSpec, JButton enterButton, Document compareTo, Document oldPin) {
- this(pinSpec, enterButton);
- this.compareTo = compareTo;
- this.oldPin = oldPin;
- }
+ /**
+ * @param pinSpec
+ * @param enterButton
+ * @param compareTo
+ * enable enterButton if this pinDocument's pin equals to
+ * compareTo's pin. may be null
+ */
+ public PINDocument(int minLength, int maxLength, String pattern, JButton enterButton, Document compareTo) {
+ this(minLength, maxLength, pattern, enterButton);
+ this.compareTo = compareTo;
+ }
+
+ /**
+ * @param pinSpec
+ * @param enterButton
+ * may be null
+ * @param compareTo
+ * enable enterButton if this pinDocument's pin equals to
+ * compareTo's pin. may be null
+ * @param oldPin
+ * enable enterButton if oldPin meets the pinSpec pin length
+ * requirements, may be null
+ */
+ public PINDocument(int minLength, int maxLength, String pattern,
+ JButton enterButton, Document compareTo, Document oldPin) {
+ this(minLength, maxLength, pattern, enterButton);
+ this.compareTo = compareTo;
+ this.oldPin = oldPin;
+ }
@Override
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
- if (pinSpec.getMaxLength() < 0 || pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ if (maxLength < 0 || maxLength >= (getLength() + str.length())) {
boolean matches = true;
for (int i = 0; i < str.length(); i++) {
Matcher m = pinPattern.matcher(str.substring(i, i + 1));
@@ -87,8 +97,8 @@ class PINDocument extends PlainDocument {
}
if (enterButton != null) {
enterButton.setEnabled(
- (oldPin == null || oldPin.getLength() >= pinSpec.getMinLength()) &&
- getLength() >= pinSpec.getMinLength() &&
+ (oldPin == null || oldPin.getLength() >= minLength) &&
+ getLength() >= minLength &&
compare());
}
}
@@ -98,8 +108,8 @@ class PINDocument extends PlainDocument {
super.remove(offs, len);
if (enterButton != null) {
enterButton.setEnabled(
- (oldPin == null || oldPin.getLength() >= pinSpec.getMinLength()) &&
- getLength() >= pinSpec.getMinLength() &&
+ (oldPin == null || oldPin.getLength() >= minLength) &&
+ getLength() >= minLength &&
compare());
}
}