From 678f2d84046c8e3ab7abe459d984868d4c9d2a3c Mon Sep 17 00:00:00 2001 From: clemenso Date: Mon, 18 Jan 2010 15:55:46 +0000 Subject: support reader configuration (disablePinpad) in BKUWebStart webstart-local -> template-local.xml pkcs11sign -> template.xml default -> template-unstable.xml git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@576 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/smcc/conf/SMCCConfiguration.java | 22 +++++++++---- .../java/at/gv/egiz/smcc/reader/ReaderFactory.java | 37 ++++++++++------------ 2 files changed, 33 insertions(+), 26 deletions(-) (limited to 'smcc/src/main/java/at') 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 index 696709bd..136ca283 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/conf/SMCCConfiguration.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/conf/SMCCConfiguration.java @@ -17,19 +17,29 @@ package at.gv.egiz.smcc.conf; -import java.util.Properties; - /** * * @author Clemens Orthacker */ -public class SMCCConfiguration extends Properties { +public class SMCCConfiguration { private static final long serialVersionUID = 1L; - public static final String DISABLE_PINPAD_P = "disable.pinpad"; + boolean disablePinpad; + + /** + * @return the disablePinpad + */ + public boolean isDisablePinpad() { + return disablePinpad; + } - public void setDisablePinpad(String value) { - this.setProperty(DISABLE_PINPAD_P, value); + /** + * @param disablePinpad the disablePinpad to set + */ + public void setDisablePinpad(boolean disablePinpad) { + this.disablePinpad = disablePinpad; } + + } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/reader/ReaderFactory.java b/smcc/src/main/java/at/gv/egiz/smcc/reader/ReaderFactory.java index eb197d9f..bf1730e9 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/reader/ReaderFactory.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/reader/ReaderFactory.java @@ -19,6 +19,7 @@ package at.gv.egiz.smcc.reader; import at.gv.egiz.smcc.conf.SMCCConfiguration; import at.gv.egiz.smcc.util.SMCCHelper; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.smartcardio.Card; @@ -35,16 +36,16 @@ public class ReaderFactory { protected final static Log log = LogFactory.getLog(ReaderFactory.class); - protected SMCCConfiguration configuration; + protected static SMCCConfiguration configuration; - private ReaderFactory() { - } - - /** - * @param configuration the configuration to set - */ public void setConfiguration(SMCCConfiguration configuration) { - this.configuration = configuration; + if (configuration != null) { + log.debug("reader configuration: disablePinpad=" + configuration.isDisablePinpad()); + } + //spring injects configuration into singleton ReaderFactory instance, + //but we access the ReaderFactory statically (getReader) + //(we rather should query the application context to obtain a reader factory) + ReaderFactory.configuration = configuration; } public static CardReader getReader(Card icc, CardTerminal ct) { @@ -52,19 +53,15 @@ public class ReaderFactory { String name = ct.getName(); log.info("creating reader " + name); - Map features = queryFeatures(icc); - boolean disablePinpad = false; + Map features; + if (configuration != null && configuration.isDisablePinpad()) { + features = Collections.emptyMap(); + } else { + features = queryFeatures(icc); + } + CardReader reader; - - //TODO query application context for reader config -// if (configuration != null) { -// String disablePinpad = configuration.getProperty(SMCCConfiguration.DISABLE_PINPAD_P); -// log.debug("setting disablePinpad to " + Boolean.parseBoolean(disablePinpad)); -// reader.setDisablePinpad(Boolean.parseBoolean(disablePinpad)); -// } - log.warn("card reader configuration is not considered"); - - if (features.isEmpty() || disablePinpad) { + if (features.isEmpty()) { reader = new DefaultCardReader(ct); } else { reader = new PinpadCardReader(ct, features); -- cgit v1.2.3