summaryrefslogtreecommitdiff
path: root/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-08-06 14:01:01 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-08-06 14:01:01 +0000
commit974087a04d2fb9b03a72b66c090afe65e5a818dc (patch)
tree04c20ab8a9b4c6abab720e294868d450fe9585d3 /smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
parenta6575ed68434ead1b2ebdfe1563d9cd11a2d4007 (diff)
downloadmocca-974087a04d2fb9b03a72b66c090afe65e5a818dc.tar.gz
mocca-974087a04d2fb9b03a72b66c090afe65e5a818dc.tar.bz2
mocca-974087a04d2fb9b03a72b66c090afe65e5a818dc.zip
FIX [462] PINMgmtSignatureCard changePIN silently ignores wrong pin entry [63cX]
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@414 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smcc/src/test/java/at/gv/egiz/smcc/CardTest.java')
-rw-r--r--smcc/src/test/java/at/gv/egiz/smcc/CardTest.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
index 298e26a5..f72820e1 100644
--- a/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
+++ b/smcc/src/test/java/at/gv/egiz/smcc/CardTest.java
@@ -76,6 +76,73 @@ public abstract class CardTest {
}
+ public class TestWrongPINProvider implements PINProvider {
+
+ int provided = 0;
+ int numWrongTries = 0;
+
+ char[] pin;
+
+ public TestWrongPINProvider(char[] pin, int numWrongTries) {
+ super();
+ this.pin = pin;
+ this.numWrongTries = numWrongTries;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+ if (provided >= numWrongTries) {
+ throw new CancelledException("Number of wrong tries reached: " + provided);
+ } else {
+ provided++;
+ return pin;
+ }
+ }
+
+ public int getProvided() {
+ return provided;
+ }
+ }
+
+ public class TestWrongChangePINProvider implements ChangePINProvider {
+
+ int provided = 0;
+ int numWrongTries = 0;
+
+ char[] pin;
+ char[] oldPin;
+
+ /** emulate ChangePinProvider */
+ public TestWrongChangePINProvider(char[] oldPin, char[] newPin, int numWrongTries) {
+ super();
+ this.pin = newPin;
+ this.oldPin = oldPin;
+ this.numWrongTries = numWrongTries;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+ return pin;
+ }
+
+ public int getProvided() {
+ return provided;
+ }
+
+ @Override
+ public char[] provideOldPIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+ if (provided >= numWrongTries) {
+ throw new CancelledException("Number of wrong tries reached: " + provided);
+ } else {
+ provided++;
+ return oldPin;
+ }
+ }
+ }
+
public CardTest() {
super();
}