From 35b64892bad13c846f19260311c7625d88cef7a1 Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 5 Sep 2008 13:39:53 +0000 Subject: HashDataInput git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@23 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 196 ++++++++++----------- 1 file changed, 96 insertions(+), 100 deletions(-) (limited to 'smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java') diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java index 7bd9e264..56c8340b 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java @@ -14,103 +14,99 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.bku.smccstal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import at.gv.egiz.bku.gui.BKUGUIFacade; -import at.gv.egiz.smcc.PINProvider; -import at.gv.egiz.smcc.SignatureCard; -import at.gv.egiz.smcc.util.SMCCHelper; -import at.gv.egiz.stal.ErrorResponse; -import at.gv.egiz.stal.InfoboxReadRequest; -import at.gv.egiz.stal.STAL; -import at.gv.egiz.stal.STALRequest; -import at.gv.egiz.stal.STALResponse; -import at.gv.egiz.stal.SignRequest; - -public abstract class AbstractSMCCSTAL implements STAL { - private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class); - - protected Locale locale = Locale.getDefault(); - protected SMCCHelper smccHelper = new SMCCHelper(); - protected SignatureCard signatureCard = null; - protected static Map handlerMap = new HashMap(); - - static { - addRequestHandler(InfoboxReadRequest.class, new InfoBoxReadRequestHandler()); - addRequestHandler(SignRequest.class, new SignRequestHandler()); - } - - public AbstractSMCCSTAL() { - } - - /** - * Implementations must assign the signature card within this method. - * - * @return if the user canceled - */ - protected abstract boolean waitForCard(); - - protected abstract BKUGUIFacade getGUI(); - - @Override - public List handleRequest( - List requestList) { - log.debug("Got request list containing " + requestList.size() - + " STAL requests"); - List responseList = new ArrayList(requestList - .size()); - for (STALRequest request : requestList) { - log.info("Processing: " + request); - SMCCSTALRequestHandler handler = null; - handler = handlerMap.get(request.getClass().getSimpleName()); - if (handler != null) { - if (handler.requireCard()) { - if (waitForCard()) { - responseList.add(new ErrorResponse(6001)); - break; - } - } - try { - handler = handler.newInstance(); - handler.init(signatureCard, getGUI()); - responseList.add(handler.handleRequest(request)); - } catch (Exception e) { - log.info("Error while handling STAL request:" + e); - responseList.add(new ErrorResponse(6000)); - } - } else { - log.error("Cannot find a handler for STAL request: " + request); - responseList.add(new ErrorResponse()); - } - } - return responseList; - } - - public static void addRequestHandler(Class id, - SMCCSTALRequestHandler handler) { - log.debug("Registering STAL request handler: " + id.getSimpleName()); - handlerMap.put(id.getSimpleName(), handler); - } - - public static SMCCSTALRequestHandler getRequestHandler( - Class request) { - return handlerMap.get(request.getSimpleName()); - } - - @Override - public void setLocale(Locale locale) { - if (locale == null) { - throw new NullPointerException("Locale must not be set to null"); - } - this.locale = locale; - } -} +package at.gv.egiz.bku.smccstal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.gv.egiz.bku.gui.BKUGUIFacade; +import at.gv.egiz.smcc.SignatureCard; +import at.gv.egiz.smcc.util.SMCCHelper; +import at.gv.egiz.stal.ErrorResponse; +import at.gv.egiz.stal.InfoboxReadRequest; +import at.gv.egiz.stal.STAL; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.SignRequest; + +public abstract class AbstractSMCCSTAL implements STAL { + private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class); + + protected Locale locale = Locale.getDefault(); + protected SMCCHelper smccHelper = new SMCCHelper(); + protected SignatureCard signatureCard = null; + protected static Map handlerMap = new HashMap(); + + static { + addRequestHandler(InfoboxReadRequest.class, new InfoBoxReadRequestHandler()); + addRequestHandler(SignRequest.class, new SignRequestHandler()); + } + + /** + * Implementations must assign the signature card within this method. + * + * @return if the user canceled + */ + protected abstract boolean waitForCard(); + + protected abstract BKUGUIFacade getGUI(); + + @Override + public List handleRequest( + List requestList) { + log.debug("Got request list containing " + requestList.size() + + " STAL requests"); + List responseList = new ArrayList(requestList + .size()); + for (STALRequest request : requestList) { + log.info("Processing: " + request); + SMCCSTALRequestHandler handler = null; + handler = handlerMap.get(request.getClass().getSimpleName()); + if (handler != null) { + if (handler.requireCard()) { + if (waitForCard()) { + responseList.add(new ErrorResponse(6001)); + break; + } + } + try { + handler = handler.newInstance(); + handler.init(signatureCard, getGUI()); + responseList.add(handler.handleRequest(request)); + } catch (Exception e) { + log.info("Error while handling STAL request:" + e); + responseList.add(new ErrorResponse(6000)); + } + } else { + log.error("Cannot find a handler for STAL request: " + request); + responseList.add(new ErrorResponse()); + } + } + return responseList; + } + + public static void addRequestHandler(Class id, + SMCCSTALRequestHandler handler) { + log.debug("Registering STAL request handler: " + id.getSimpleName()); + handlerMap.put(id.getSimpleName(), handler); + } + + public static SMCCSTALRequestHandler getRequestHandler( + Class request) { + return handlerMap.get(request.getSimpleName()); + } + + @Override + public void setLocale(Locale locale) { + if (locale == null) { + throw new NullPointerException("Locale must not be set to null"); + } + this.locale = locale; + } +} -- cgit v1.2.3