summaryrefslogtreecommitdiff
path: root/smcc/src/main
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-06-16 11:19:41 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2010-06-16 11:19:41 +0000
commit265b0aca555d9880361b754b6a18ce70b5be28cd (patch)
tree158387c96aa33e53beec0caab6bb938148c15587 /smcc/src/main
parent1615a1e0bea092641bd72351876f6aa6edba655e (diff)
downloadmocca-265b0aca555d9880361b754b6a18ce70b5be28cd.tar.gz
mocca-265b0aca555d9880361b754b6a18ce70b5be28cd.tar.bz2
mocca-265b0aca555d9880361b754b6a18ce70b5be28cd.zip
Refactored smart card unit tests to use Spring to configure smart card emulators.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@754 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smcc/src/main')
-rw-r--r--smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java18
-rw-r--r--smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java2
-rw-r--r--smcc/src/main/java/at/gv/egiz/smcc/util/ISO7816Utils.java2
-rw-r--r--smcc/src/main/resources/at/gv/egiz/smcc/SwissSignIDCard.properties20
4 files changed, 36 insertions, 6 deletions
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
index eea1b6ed..bb913c67 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java
@@ -166,7 +166,7 @@ public class ACOSCard extends AbstractSignatureCard implements PINMgmtSignatureC
@Override
@Exclusive
public byte[] getCertificate(KeyboxName keyboxName)
- throws SignatureCardException, InterruptedException {
+ throws SignatureCardException {
byte[] aid;
byte[] fid;
@@ -240,7 +240,13 @@ public class ACOSCard extends AbstractSignatureCard implements PINMgmtSignatureC
// READ BINARY
while(true) {
try {
- return ISO7816Utils.readTransparentFileTLV(channel, maxSize, (byte) 0x30);
+ byte[] idLink = ISO7816Utils.readTransparentFileTLV(channel, maxSize,
+ (byte) 0x30);
+ if (idLink != null) {
+ return idLink;
+ } else {
+ throw new NotActivatedException();
+ }
} catch (SecurityStatusNotSatisfiedException e) {
verifyPINLoop(channel, infPinInfo, provider);
}
@@ -299,7 +305,7 @@ public class ACOSCard extends AbstractSignatureCard implements PINMgmtSignatureC
}
// empty
- return null;
+ throw new NotActivatedException();
} catch (FileNotFoundException e) {
throw new NotActivatedException();
@@ -472,7 +478,11 @@ public class ACOSCard extends AbstractSignatureCard implements PINMgmtSignatureC
* @see at.gv.egiz.smcc.PINMgmtSignatureCard#getpinInfos()
*/
@Override
- public PinInfo[] getPinInfos() {
+ public PinInfo[] getPinInfos() throws SignatureCardException {
+
+ //check if card is activated
+ getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR);
+
if (appVersion < 2) {
return new PinInfo[] {decPinInfo, sigPinInfo, infPinInfo };
}
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
index 01d8639a..f092b3fc 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java
@@ -283,7 +283,7 @@ public class STARCOSCard extends AbstractSignatureCard implements PINMgmtSignatu
}
// empty
- return null;
+ throw new NotActivatedException();
} else if ("Status".equals(infobox)) {
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/util/ISO7816Utils.java b/smcc/src/main/java/at/gv/egiz/smcc/util/ISO7816Utils.java
index 444de316..f7a8d58b 100644
--- a/smcc/src/main/java/at/gv/egiz/smcc/util/ISO7816Utils.java
+++ b/smcc/src/main/java/at/gv/egiz/smcc/util/ISO7816Utils.java
@@ -118,7 +118,7 @@ public class ISO7816Utils {
// check expected type
int b = is.read();
- if (b == 0x00) {
+ if (b == 0x00 || b == 0xFF) {
return null;
}
if (b == -1 || expectedType != (0xFF & b)) {
diff --git a/smcc/src/main/resources/at/gv/egiz/smcc/SwissSignIDCard.properties b/smcc/src/main/resources/at/gv/egiz/smcc/SwissSignIDCard.properties
new file mode 100644
index 00000000..1a637af1
--- /dev/null
+++ b/smcc/src/main/resources/at/gv/egiz/smcc/SwissSignIDCard.properties
@@ -0,0 +1,20 @@
+# Copyright 2008 Federal Chancellery Austria and
+# Graz University of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+pin.name=PIN
+pin.length=5-12 \ No newline at end of file