From 265b0aca555d9880361b754b6a18ce70b5be28cd Mon Sep 17 00:00:00 2001 From: mcentner Date: Wed, 16 Jun 2010 11:19:41 +0000 Subject: 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 --- smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 18 ++++++++++++++---- smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java | 2 +- .../main/java/at/gv/egiz/smcc/util/ISO7816Utils.java | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'smcc/src/main/java/at/gv/egiz') 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)) { -- cgit v1.2.3