diff options
Diffstat (limited to 'smcc/src/main')
6 files changed, 92 insertions, 8 deletions
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java index 7dd3ee78..f0f8b8c8 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java @@ -455,7 +455,7 @@ public abstract class AbstractSignatureCard implements SignatureCard { @Override public void init(Card card, CardTerminal cardTerminal) { this.card_ = card; - this.reader = ReaderFactory.getReader(card, cardTerminal); + this.reader = ReaderFactory.getInstance().getReader(card, cardTerminal); ATR atr = card.getATR(); byte[] atrBytes = atr.getBytes(); if (atrBytes.length >= 6) { diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java index 2ed1fe64..da084e0d 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java @@ -483,6 +483,11 @@ public class SWCard implements SignatureCard { public byte[] modifyPinDirect(byte[] PIN_MODIFY) throws CardException { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public void setDisablePinpad(boolean disable) { + throw new UnsupportedOperationException("Not supported yet."); + } }; } } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ccid/CCID.java b/smcc/src/main/java/at/gv/egiz/smcc/ccid/CCID.java index 56ebaffe..2972f3b8 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ccid/CCID.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ccid/CCID.java @@ -62,6 +62,8 @@ public interface CCID { Card connect() throws CardException; + void setDisablePinpad(boolean disable); + boolean hasFeature(Byte feature); /** 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 0de6bb17..580b9379 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 @@ -55,6 +55,7 @@ public class DefaultReader implements CCID { protected Card icc; protected CardTerminal ct; + protected boolean disablePinpad = false; /** * supported features and respective control codes @@ -78,6 +79,11 @@ public class DefaultReader implements CCID { log.debug("setting max pin length: " + getwPINMaxExtraDigitL()); } + @Override + public void setDisablePinpad(boolean disable) { + disablePinpad = disable; + } + /** * * @return the card terminals name @@ -137,7 +143,7 @@ public class DefaultReader implements CCID { @Override public boolean hasFeature(Byte feature) { - if (features != null) { + if (features != null && !disablePinpad) { return features.containsKey(feature); } return false; 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 ae21e5e0..5b94de05 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 @@ -17,8 +17,11 @@ package at.gv.egiz.smcc.ccid; +import at.gv.egiz.smcc.conf.SMCCConfiguration; import javax.smartcardio.Card; import javax.smartcardio.CardTerminal; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * @@ -26,9 +29,33 @@ import javax.smartcardio.CardTerminal; */ public class ReaderFactory { - public static CCID getReader(Card icc, CardTerminal ct) { + protected final static Log log = LogFactory.getLog(ReaderFactory.class); + + protected SMCCConfiguration configuration; + private static ReaderFactory instance; + + private ReaderFactory() { + } + + public static ReaderFactory getInstance() { + if (instance == null) { + instance = new ReaderFactory(); + } + return instance; + } + + /** + * @param configuration the configuration to set + */ + public void setConfiguration(SMCCConfiguration configuration) { + this.configuration = configuration; + } + + public CCID getReader(Card icc, CardTerminal ct) { + CCID reader; String name = ct.getName(); if (name != null) { + log.info("creating reader " + name); name = name.toLowerCase(); //ReinerSCT: http://support.reiner-sct.de/downloads/LINUX // http://www.linux-club.de/viewtopic.php?f=61&t=101287&start=0 @@ -36,15 +63,26 @@ public class ReaderFactory { //new (CCID): 0C4B/0300 Reiner-SCT cyberJack pinpad(a) 00 00 //display: REINER SCT CyberJack 00 00 if(name.startsWith("gemplus gempc pinpad")) { - return new GemplusGemPCPinpad(icc, ct); + reader = new GemplusGemPCPinpad(icc, ct); } else if (name.startsWith("omnikey cardman 3621")) { - return new OMNIKEYCardMan3621(icc, ct); + reader = new OMNIKEYCardMan3621(icc, ct); } else if (name.startsWith("scm microsystems inc. sprx32 usb smart card reader")) { - return new SCMMicrosystemsSPRx32(icc, ct); + reader = new SCMMicrosystemsSPRx32(icc, ct); } else if (name.startsWith("cherry smartboard xx44")) { - return new CherrySmartBoardXX44(icc, ct); + reader = new CherrySmartBoardXX44(icc, ct); + } else { + log.info("no suitable implementation found, using default"); + reader = new DefaultReader(icc, ct); } + } else { + reader = new DefaultReader(icc, ct); + } + + if (configuration != null) { + String disablePinpad = configuration.getProperty(SMCCConfiguration.DISABLE_PINPAD_P); + log.debug("setting disablePinpad to " + Boolean.parseBoolean(disablePinpad)); + reader.setDisablePinpad(Boolean.parseBoolean(disablePinpad)); } - return new DefaultReader(icc, ct); + return reader; } } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/conf/SMCCConfiguration.java b/smcc/src/main/java/at/gv/egiz/smcc/conf/SMCCConfiguration.java new file mode 100644 index 00000000..8ea49ca6 --- /dev/null +++ b/smcc/src/main/java/at/gv/egiz/smcc/conf/SMCCConfiguration.java @@ -0,0 +1,33 @@ +/* + * 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.conf; + +import java.util.Properties; + +/** + * + * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at> + */ +public class SMCCConfiguration extends Properties { + + public static final String DISABLE_PINPAD_P = "disable.pinpad"; + + public void setDisablePinpad(String value) { + this.setProperty(DISABLE_PINPAD_P, value); + } +} |