diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-04-07 08:37:53 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-04-07 08:37:53 +0000 |
commit | ac3d1788dfa8db5dd8de5a99764b439dd5ec54db (patch) | |
tree | 9dc65bae1994432caf35d0d05b2f08393fc9ff45 /smcc/src/main/java/at/gv | |
parent | 78728a96af022bae87e4d0d11855f420736d87b7 (diff) | |
download | mocca-ac3d1788dfa8db5dd8de5a99764b439dd5ec54db.tar.gz mocca-ac3d1788dfa8db5dd8de5a99764b439dd5ec54db.tar.bz2 mocca-ac3d1788dfa8db5dd8de5a99764b439dd5ec54db.zip |
MOCCA-1.1 final
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@327 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smcc/src/main/java/at/gv')
7 files changed, 142 insertions, 173 deletions
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 b9c68b06..e622f65a 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java @@ -700,9 +700,9 @@ public class STARCOSCard extends AbstractSignatureCard { // ^-------- System bit units is bit // ^^^^--- PIN length is at the 4th position bit //TODO compare ints, not bytes - byte wPINMaxExtraDigitL = // Max=12 digits (Gemplus support max 8) - (reader.getwPINMaxExtraDigitL() < (byte) 0x12) ? - reader.getwPINMaxExtraDigitL() : (byte) 0x12; + byte wPINMaxExtraDigitL = // Max=12 digits + (reader.getwPINMaxExtraDigitL() < (byte) 0x0c) ? + reader.getwPINMaxExtraDigitL() : (byte) 0x0c; byte wPINMaxExtraDigitH = // Min=4/6 digits TODO card/ss pin (min: 4/6) (reader.getwPINMaxExtraDigitH() > (byte) 0x04) ? reader.getwPINMaxExtraDigitH() : (byte) 0x04; @@ -757,8 +757,8 @@ public class STARCOSCard extends AbstractSignatureCard { byte bInsertionOffsetOld = (byte) 0x00; // insertion position offset in bytes byte bInsertionOffsetNew = (byte) 0x08; // (add 1 from bmFormatString b3) byte wPINMaxExtraDigitL = - (reader.getwPINMaxExtraDigitL() < (byte) 0x12) ? - reader.getwPINMaxExtraDigitL() : (byte) 0x12; + (reader.getwPINMaxExtraDigitL() < (byte) 0x0c) ? + reader.getwPINMaxExtraDigitL() : (byte) 0x0c; byte wPINMaxExtraDigitH = // Min=4/6 digits TODO card/ss pin (min: 4/6) (reader.getwPINMaxExtraDigitH() > (byte) 0x04) ? reader.getwPINMaxExtraDigitH() : (byte) 0x04; diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/CherrySmartBoardXX44.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/CherrySmartBoardXX44.java new file mode 100644 index 00000000..a7e45765 --- /dev/null +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/CherrySmartBoardXX44.java @@ -0,0 +1,42 @@ +/* + * 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. + */ +package at.gv.egiz.smcc.ccid; + +import javax.smartcardio.Card; +import javax.smartcardio.CardTerminal; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class CherrySmartBoardXX44 extends DefaultReader { + + protected static final Log log = LogFactory.getLog(CherrySmartBoardXX44.class); + + public static final byte wPINMaxExtraDigitH = 0x01; + + public CherrySmartBoardXX44(Card icc, CardTerminal ct) { + super(icc, ct); + } + + @Override + public byte getwPINMaxExtraDigitH() { + return wPINMaxExtraDigitH; + } +} diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/DefaultReader.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/DefaultReader.java index 9b1787a0..b203ae52 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ccid/DefaultReader.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/DefaultReader.java @@ -20,8 +20,6 @@ import at.gv.egiz.smcc.*; import at.gv.egiz.smcc.util.SMCCHelper; import java.util.HashMap; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.smartcardio.Card; import javax.smartcardio.CardException; import javax.smartcardio.CardTerminal; @@ -34,6 +32,12 @@ import org.apache.commons.logging.LogFactory; */ public class DefaultReader implements CCID { + public static final byte bEntryValidationCondition = 0x02; // validation key pressed + public static final byte bTimeOut = 0x3c; // 60sec (= max on ReinerSCT) + public static final byte bTimeOut2 = 0x00; // default (attention with SCM) + public static final byte wPINMaxExtraDigitH = 0x00; // min pin length zero digits + public static final byte wPINMaxExtraDigitL = 0x0c; // max pin length 12 digits + protected final static Log log = LogFactory.getLog(DefaultReader.class); private static int CTL_CODE(int code) { @@ -60,9 +64,17 @@ public class DefaultReader implements CCID { if (icc == null || ct == null) { throw new NullPointerException("no card or card terminal provided"); } + log.info("Initializing " + ct.getName()); + this.icc = icc; this.ct = ct; - features = queryFeatures(); + features = queryFeatures(); + + log.debug("setting pin timeout: " + getbTimeOut()); + log.debug("setting pin timeout (after key pressed): " + getbTimeOut2()); + log.debug("setting pin entry validation condition: " + getbEntryValidationCondition()); + log.debug("setting min pin length: " + getwPINMaxExtraDigitH()); + log.debug("setting max pin length: " + getwPINMaxExtraDigitL()); } /** @@ -103,11 +115,10 @@ public class DefaultReader implements CCID { // control code value for supported feature (in big endian) for (int i = 0; i < resp.length; i += 6) { Byte feature = new Byte(resp[i]); - int ioctlBigEndian = ((0xff & resp[i + 2]) << 24) | + Integer ioctl = new Integer((0xff & resp[i + 2]) << 24) | ((0xff & resp[i + 3]) << 16) | ((0xff & resp[i + 4]) << 8) | (0xff & resp[i + 5]); - Integer ioctl = new Integer(ioctlBigEndian); if (log.isInfoEnabled()) { log.info("CCID supports " + FEATURES[feature.intValue()] + ": " + Integer.toHexString(ioctl.intValue())); @@ -131,54 +142,29 @@ public class DefaultReader implements CCID { return false; } -// protected byte[] transmitControlCommand(Byte feature, byte[] ctrlCommand) -// throws CardException { -// try { -// if (!features.containsKey(feature)) { -// throw new CardException(FEATURES[feature.intValue()] + " not supported"); -// } -// int ioctl = features.get(feature); -// if (log.isTraceEnabled()) { -// log.trace("CtrlCommand (" + Integer.toHexString(ioctl) + -// ") " + SMCCHelper.toString(ctrlCommand)); -// } -// byte[] resp = icc.transmitControlCommand(ioctl, ctrlCommand); -// if (log.isTraceEnabled()) { -// log.trace("CtrlCommand Response " + SMCCHelper.toString(resp)); -// } -// return resp; -// } catch (CardException ex) { -// log.error(ex.getMessage()); -// throw new SignatureCardException("Failed to transmit CtrlCommand for " + -// FEATURES[feature.intValue()]); -// } -// } - - @Override public byte getbTimeOut() { - return (byte) 0x3c; // (max 1min on ReinerSCT), - // 0x00=default, 0x1e = 30sec + return bTimeOut; } @Override public byte getbTimeOut2() { - return (byte) 0x00; // default + return bTimeOut2; } @Override public byte getwPINMaxExtraDigitL() { - return (byte) 0x12; // signed int + return wPINMaxExtraDigitL; } @Override public byte getwPINMaxExtraDigitH() { - return (byte) 0x00; + return wPINMaxExtraDigitH; } @Override public byte getbEntryValidationCondition() { - return (byte) 0x02; // validation key pressed + return bEntryValidationCondition; } void verifyPinStart(byte[] PIN_VERIFY) throws CardException { @@ -275,9 +261,6 @@ public class DefaultReader implements CCID { throw new CardException("FEATURE_GET_KEY_PRESSED not supported"); } int ioctl = features.get(FEATURE_GET_KEY_PRESSED); -// if (log.isTraceEnabled()) { -// log.trace("GET_KEY_PRESSED (" + Integer.toHexString(ioctl) + ")"); -// } byte[] resp = icc.transmitControlCommand(ioctl, new byte[0]); if (resp != null && resp.length == 1) { // if (log.isTraceEnabled()) { @@ -349,7 +332,7 @@ public class DefaultReader implements CCID { throw new CardException("unexpected response to GET_KEY_PRESSED: " + Integer.toHexString(resp)); } - } while (true); //resp != (byte) 0x0d); + } while (true); return verifyPinFinish(); } @@ -404,7 +387,6 @@ public class DefaultReader implements CCID { } /** - * NOT SUPPORTED FOR ACOS ON OMNIKEY CardMan 3621 * * @param PIN_MODIFY * @return @@ -426,104 +408,4 @@ public class DefaultReader implements CCID { } return resp; } - - -//[TRACE] SmartCardIO - terminal 'PC/SC terminal OMNIKEY CardMan 3621 0' card inserted : PC/SC card in OMNIKEY CardMan 3621 0, protocol T=1, state OK -//[TRACE] DefaultReader - GET_FEATURE_REQUEST 313520 on OMNIKEY CardMan 3621 0 -//[TRACE] DefaultReader - Response TLV [01:04:00:31:30:00:02:04:00:31:2f:d4:03:04:00:31:30:04:04:04:00:31:2f:dc:05:04:00:31:2f:e0:0a:04 -//00:31:30:08] -//[INFO] DefaultReader - CCID supports FEATURE_VERIFY_PIN_START: 313000 -//[INFO] DefaultReader - CCID supports FEATURE_VERIFY_PIN_FINISH: ffffffd4 -//[INFO] DefaultReader - CCID supports FEATURE_MODIFY_PIN_START: 313004 -//[INFO] DefaultReader - CCID supports FEATURE_MODIFY_PIN_FINISH: ffffffdc -//[INFO] DefaultReader - CCID supports FEATURE_GET_KEY_PRESSED: ffffffe0 -//[INFO] DefaultReader - CCID supports FEATURE_IFD_PIN_PROPERTIES: 313008 -//[TRACE] AbstractSignatureCard - Setting IFS (information field size) to 254 - - - // protected byte ifdGetKeyPressed() throws CardException { -// if (ifdSupportsFeature(FEATURE_VERIFY_PIN_DIRECT)) { -// -// Long controlCode = (Long) IFD_IOCTL.get(new Byte((byte) 0x05)); -// -// byte key = 0x00; -// while (key == 0x00) { -// -// byte[] resp = card_.transmitControlCommand(controlCode.intValue(), new byte[] {}); -// -// if (resp != null && resp.length > 0) { -// key = resp[0]; -// } -// } -// -// System.out.println("Key: " + key); -// -// } -// -// return 0x00; -// } -// -// protected byte[] ifdVerifyPINFinish() throws CardException { -// if (ifdSupportsFeature(FEATURE_VERIFY_PIN_DIRECT)) { -// -// Long controlCode = (Long) IFD_IOCTL.get(new Byte((byte) 0x02)); -// -// byte[] resp = card_.transmitControlCommand(controlCode.intValue(), new byte[] {}); -// -// System.out.println("CommandResp: " + toString(resp)); -// -// return resp; -// -// } -// -// return null; -// } - - - /** - * assumes ifdSupportsVerifyPIN() == true - * @param pinVerifyStructure - * @return - * @throws javax.smartcardio.CardException - */ -// protected byte[] ifdVerifyPIN(byte[] pinVerifyStructure) throws CardException { -// -//// Long ctrlCode = (Long) ifdFeatures.get(FEATURE_IFD_PIN_PROPERTIES); -//// if (ctrlCode != null) { -//// if (log.isTraceEnabled()) { -//// log.trace("PIN_PROPERTIES CtrlCode " + Integer.toHexString(ctrlCode.intValue())); -//// } -//// byte[] resp = card_.transmitControlCommand(ctrlCode.intValue(), new byte[] {}); -//// -//// if (log.isTraceEnabled()) { -//// log.trace("PIN_PROPERTIES Response " + SMCCHelper.toString(resp)); -//// } -//// } -// -// -// Long ctrlCode = (Long) ifdFeatures.get(FEATURE_VERIFY_PIN_DIRECT); -// if (ctrlCode == null) { -// throw new NullPointerException("no CtrlCode for FEATURE_VERIFY_PIN_DIRECT"); -// } -// -// if (log.isTraceEnabled()) { -// log.trace("VERIFY_PIN_DIRECT CtrlCode " + Integer.toHexString(ctrlCode.intValue()) + -// ", PIN_VERIFY_STRUCTURE " + SMCCHelper.toString(pinVerifyStructure)); -// } -// byte[] resp = card_.transmitControlCommand(ctrlCode.intValue(), pinVerifyStructure); -// -// if (log.isTraceEnabled()) { -// log.trace("VERIFY_PIN_DIRECT Response " + SMCCHelper.toString(resp)); -// } -// return resp; -// } - -// protected Long getControlCode(Byte feature) { -// if (ifdFeatures != null) { -// return ifdFeatures.get(feature); -// } -// return null; -// } - - } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/GemplusGemPCPinpad.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/GemplusGemPCPinpad.java index 903b11fc..ff6d004b 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ccid/GemplusGemPCPinpad.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/GemplusGemPCPinpad.java @@ -22,7 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * + * bTimeOut = 15sec (too short, leave value from DefaultRearder), + * however, max is something near 40sec * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ public class GemplusGemPCPinpad extends DefaultReader { @@ -31,20 +32,6 @@ public class GemplusGemPCPinpad extends DefaultReader { public GemplusGemPCPinpad(Card icc, CardTerminal ct) { super(icc, ct); - log.info("Initializing Gemplus GemPC Pinpad reader"); - log.info("Gemplus GemPC Pinpad allows PINs to have 4-8 digits"); - - } - - @Override - public byte getbTimeOut() { - return (byte) 0x3c; // 0x00 default = 15sec - // max 40sec (?) - } - - @Override - public byte getbTimeOut2() { - return (byte) 0x00; // 0x00 default = 15sec } @Override @@ -56,10 +43,4 @@ public class GemplusGemPCPinpad extends DefaultReader { public byte getwPINMaxExtraDigitH() { return (byte) 0x04; } - - @Override - public byte getbEntryValidationCondition() { - return (byte) 0x02; // validation key pressed - } - } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/OMNIKEYCardMan3621.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/OMNIKEYCardMan3621.java index 35dd4f99..d8a6b40d 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ccid/OMNIKEYCardMan3621.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/OMNIKEYCardMan3621.java @@ -28,12 +28,17 @@ import org.apache.commons.logging.LogFactory; * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> */ public class OMNIKEYCardMan3621 extends DefaultReader { + + public static final byte wPINMaxExtraDigitH = 0x01; protected static final Log log = LogFactory.getLog(OMNIKEYCardMan3621.class); - + public OMNIKEYCardMan3621(Card icc, CardTerminal ct) { super(icc, ct); - log.warn("This card reader does not support ACOS cards."); - log.debug("TODO: fall back to software pin entry"); + } + + @Override + public byte getwPINMaxExtraDigitH() { + return wPINMaxExtraDigitH; } } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/ReaderFactory.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/ReaderFactory.java index 07c16c3e..1e3bdce2 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ccid/ReaderFactory.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/ReaderFactory.java @@ -27,10 +27,18 @@ import javax.smartcardio.CardTerminal; public class ReaderFactory { public static CCID getReader(Card icc, CardTerminal ct) { - if ("Gemplus GemPC Pinpad 00 00".equals(ct.getName())) { - return new GemplusGemPCPinpad(icc, ct); - } else if ("OmniKey CardMan 3621 00 00".equals(ct.getName())) { - return new OMNIKEYCardMan3621(icc, ct); + String name = ct.getName(); + if (name != null) { + name = name.toLowerCase(); + if(name.startsWith("gemplus gempc pinpad")) { + return new GemplusGemPCPinpad(icc, ct); + } else if (name.startsWith("omnikey cardman 3621")) { + return new OMNIKEYCardMan3621(icc, ct); + } else if (name.startsWith("scm microsystems inc. sprx32 usb smart card reader")) { + return new SCMMicrosystemsSPRx32(icc, ct); + } else if (name.startsWith("cherry smartboard xx44")) { + return new CherrySmartBoardXX44(icc, ct); + } } return new DefaultReader(icc, ct); } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/SCMMicrosystemsSPRx32.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/SCMMicrosystemsSPRx32.java new file mode 100644 index 00000000..133bc350 --- /dev/null +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/SCMMicrosystemsSPRx32.java @@ -0,0 +1,51 @@ +/* + * 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. + */ +package at.gv.egiz.smcc.ccid; + +import javax.smartcardio.Card; +import javax.smartcardio.CardTerminal; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * bTimeOut: spr532 (win driver) interprets 0x00 as zero sec + * instead of default + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class SCMMicrosystemsSPRx32 extends DefaultReader { + + public static final byte bTimeOut = 0x3c; + public static final byte bTimeOut2 = 0x0f; + + protected final static Log log = LogFactory.getLog(SCMMicrosystemsSPRx32.class); + + public SCMMicrosystemsSPRx32(Card icc, CardTerminal ct) { + super(icc, ct); + } + + @Override + public byte getbTimeOut() { + return bTimeOut; + } + + @Override + public byte getbTimeOut2() { + return bTimeOut2; + } + +} |