From 2be4c7f179bb50c1b9103f16912310afd4be2686 Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 7 Apr 2009 09:13:14 +0000 Subject: [maven-release-plugin] copy for tag mocca-1.1.0 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/tags/mocca-1.1.0@330 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../java/at/gv/egiz/smcc/ccid/DefaultReader.java | 162 +++------------------ 1 file changed, 22 insertions(+), 140 deletions(-) (limited to 'smcc/src/main/java/at/gv/egiz/smcc/ccid/DefaultReader.java') 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; -// } - - } -- cgit v1.2.3