From d89f36b67ea1d838a78523538a24e044518f3587 Mon Sep 17 00:00:00 2001 From: mcentner Date: Tue, 26 Jan 2010 16:22:56 +0000 Subject: MOCCA 1.2.11 with SHA-2 enabled. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/branches/mocca-1.2.11-sha2@599 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/stalx/service/STALPortType.java | 45 +++++ .../java/at/gv/egiz/stalx/service/STALService.java | 73 +++++++ .../translator/STALXTranslationHandler.java | 217 +++++++++++++++++++++ 3 files changed, 335 insertions(+) create mode 100644 mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALPortType.java create mode 100644 mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALService.java create mode 100644 mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/translator/STALXTranslationHandler.java (limited to 'mocca-1.2.11/STALXService/src/main/java/at/gv/egiz') diff --git a/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALPortType.java b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALPortType.java new file mode 100644 index 00000000..b31e60ce --- /dev/null +++ b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALPortType.java @@ -0,0 +1,45 @@ +package at.gv.egiz.stalx.service; + +//import at.buergerkarte.namespaces.cardchannel.service.ObjectFactory; +//import at.buergerkarte.namespaces.cardchannel.service.ScriptType; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; + +/** + * Dummy PortType to add at.buergerkarte.namespaces.cardchannel.service to the + * JAXB context seed. + * + * overriding a webmethod results in ClassCastEx for the WebResult + * ClassCastException: at.gv.egiz.stal.service.types.GetNextRequestResponseType + * cannot be cast to at.buergerkarte.namespaces.cardchannel.service.GetNextRequestResponseType + * + * adding a new method results in Error: Undefined operation name + * + * adding a constant doesn't seed + */ +@WebService(name = "STALPortType", targetNamespace = "http://www.egiz.gv.at/wsdl/stal") +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +@XmlSeeAlso({ + at.gv.egiz.stal.service.types.ObjectFactory.class, + at.buergerkarte.namespaces.cardchannel.service.ObjectFactory.class +}) +interface STALPortType extends at.gv.egiz.stal.service.STALPortType { + + // doesn't seed +// public static final ScriptType seed = (new ObjectFactory()).createScriptType(); + /** + * dummy method to put at.buergerkarte.namespaces.cardchannel.service as JAXB context seed + * @return + */ +// @WebMethod +// @WebResult(name = "Script", targetNamespace = "http://www.buergerkarte.at/cardchannel", partName = "part1") + //java.lang.Error: Undefined operation name seedJAXBContext +// ScriptType seedJAXBContext(); + +// @WebMethod +// @WebResult(name = "GetNextRequestResponse", targetNamespace = "http://www.egiz.gv.at/stal", partName = "part1") +// @Override +// public GetNextRequestResponseType connect( +// @WebParam(name = "SessionId", targetNamespace = "http://www.egiz.gv.at/stal", partName = "part1") String sessionId); +} diff --git a/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALService.java b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALService.java new file mode 100644 index 00000000..eccd2c4f --- /dev/null +++ b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/STALService.java @@ -0,0 +1,73 @@ + +package at.gv.egiz.stalx.service; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.logging.Logger; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.1.3-b02- + * Generated source version: 2.1 + * + */ +@WebServiceClient(name = "STALService", targetNamespace = "http://www.egiz.gv.at/wsdl/stal") +//, wsdlLocation = "file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl") +public class STALService + extends Service +{ + +// private final static URL STALSERVICE_WSDL_LOCATION; + private final static Logger logger = Logger.getLogger(at.gv.egiz.stalx.service.STALService.class.getName()); + +// static { +// URL url = null; +// try { +// URL baseUrl; +// baseUrl = at.gv.egiz.stal.service.STALService.class.getResource("."); +// url = new URL(baseUrl, "file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl"); +// } catch (MalformedURLException e) { +// logger.warning("Failed to create URL for the wsdl Location: 'file:/home/clemens/workspace/mocca/BKUOnline/src/main/webapp/WEB-INF/wsdl/stal-service.wsdl', retrying as a local file"); +// logger.warning(e.getMessage()); +// } +// STALSERVICE_WSDL_LOCATION = url; +// } + + public STALService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + +// public STALService() { +// super(STALSERVICE_WSDL_LOCATION, new QName("http://www.egiz.gv.at/wsdl/stal", "STALService")); +// } + + /** + * Do not export package protected STALXPortType interface + * (this is a dummy interface to make JAXB include the STAL-X types) + * @return + * returns STALPortType + */ + @WebEndpoint(name = "STALPort") + public at.gv.egiz.stal.service.STALPortType getSTALPort() { + return super.getPort(new QName("http://www.egiz.gv.at/wsdl/stal", "STALPort"), STALPortType.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns STALPortType + */ +// @WebEndpoint(name = "STALPort") +// public STALPortType getSTALPort(WebServiceFeature... features) { +// return super.getPort(new QName("http://www.egiz.gv.at/wsdl/stal", "STALPort"), STALPortType.class, features); +// } + +} diff --git a/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/translator/STALXTranslationHandler.java b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/translator/STALXTranslationHandler.java new file mode 100644 index 00000000..d432b170 --- /dev/null +++ b/mocca-1.2.11/STALXService/src/main/java/at/gv/egiz/stalx/service/translator/STALXTranslationHandler.java @@ -0,0 +1,217 @@ +/* + * 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.stalx.service.translator; + +import at.buergerkarte.namespaces.cardchannel.service.ATRType; +import at.buergerkarte.namespaces.cardchannel.service.CommandAPDUType; +import at.buergerkarte.namespaces.cardchannel.service.ObjectFactory; +import at.buergerkarte.namespaces.cardchannel.service.ResetType; +import at.buergerkarte.namespaces.cardchannel.service.ResponseAPDUType; +import at.buergerkarte.namespaces.cardchannel.service.ScriptType; +import at.buergerkarte.namespaces.cardchannel.service.VerifyAPDUType; +import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STALResponse; +import at.gv.egiz.stal.ext.APDUScriptRequest; +import at.gv.egiz.stal.ext.APDUScriptRequest.RequestScriptElement; +import at.gv.egiz.stal.ext.APDUScriptResponse; +import at.gv.egiz.stal.service.translator.STALTranslator; +import at.gv.egiz.stal.service.translator.TranslationException; +import at.gv.egiz.stal.service.types.RequestType; +import at.gv.egiz.stal.service.types.ResponseType; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.xml.bind.JAXBElement; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * + * @author Clemens Orthacker + */ +public class STALXTranslationHandler implements STALTranslator.TranslationHandler { + + private static final Log log = LogFactory.getLog(STALXTranslationHandler.class); + ObjectFactory of; + + public STALXTranslationHandler() { + of = new ObjectFactory(); + } + + @Override + public List getSupportedTypes() { + return Arrays.asList(new Class[]{ScriptType.class, + at.buergerkarte.namespaces.cardchannel.service.ResponseType.class, + APDUScriptRequest.class, + APDUScriptResponse.class}); + } + + @Override + public JAXBElement translate(STALRequest request) throws TranslationException { + if (request instanceof APDUScriptRequest) { + log.trace("translate at.gv.egiz.stal.ext.APDUScriptRequest -> at.buergerkarte.namespaces.cardchannel.service.ScriptType"); + + ScriptType scriptT = of.createScriptType(); + + List script = ((APDUScriptRequest) request).getScript(); + for (RequestScriptElement requestScriptElement : script) { + if (requestScriptElement instanceof APDUScriptRequest.Reset) { + scriptT.getResetOrCommandAPDUOrVerifyAPDU().add(of.createResetType()); + } else if (requestScriptElement instanceof APDUScriptRequest.Command) { + APDUScriptRequest.Command cmd = (APDUScriptRequest.Command) requestScriptElement; + CommandAPDUType commandAPDUType = of.createCommandAPDUType(); + commandAPDUType.setSequence(BigInteger.valueOf(cmd.getSequence())); + commandAPDUType.setValue(cmd.getCommandAPDU()); + commandAPDUType.setExpectedSW(cmd.getExpectedSW()); + scriptT.getResetOrCommandAPDUOrVerifyAPDU().add(commandAPDUType); + } else { + log.error("invalid requestScriptElement " + requestScriptElement.getClass()); + throw new TranslationException(requestScriptElement.getClass()); + } + } + + return of.createScript(scriptT); + } else { + log.error("cannot translate " + request.getClass()); + throw new TranslationException(request.getClass()); + } + } + + @Override + public STALRequest translate(RequestType request) throws TranslationException { + if (request instanceof ScriptType) { + + log.trace("translate at.buergerkarte.namespaces.cardchannel.service.ScriptType -> at.gv.egiz.stal.ext.APDUScriptRequest"); + + List resetOrCommandAPDUOrVerifyAPDU = ((ScriptType) request).getResetOrCommandAPDUOrVerifyAPDU(); + List requestScript = new ArrayList(); + + for (Object element : resetOrCommandAPDUOrVerifyAPDU) { + + if (element instanceof ResetType) { + + requestScript.add(new APDUScriptRequest.Reset()); + + } else if (element instanceof CommandAPDUType) { + + CommandAPDUType commandAPDU = (CommandAPDUType) element; + int sequence = (commandAPDU.getSequence() != null) + ? commandAPDU.getSequence().intValue() + : 0; + + requestScript.add( + new APDUScriptRequest.Command( + sequence, + commandAPDU.getValue(), + commandAPDU.getExpectedSW())); + + } else if (element instanceof VerifyAPDUType) { + log.error("CardChannel script command 'VerifyAPDU' not implemented."); + throw new TranslationException(VerifyAPDUType.class); + } else { + log.error("invalid requestScriptElement element " + element.getClass()); + throw new TranslationException(element.getClass()); + } + } + + return new APDUScriptRequest(requestScript); + + } else { + log.error("cannot translate " + request.getClass()); + throw new TranslationException(request.getClass()); + } + } + + @Override + public JAXBElement translate(STALResponse response) throws TranslationException { + if (response instanceof APDUScriptResponse) { + log.trace("translate at.gv.egiz.stal.ext.APDUScriptResponse -> at.buergerkarte.namespaces.cardchannel.service.ResponseType"); + at.buergerkarte.namespaces.cardchannel.service.ResponseType responseT = of.createResponseType(); + List responseScript = ((APDUScriptResponse) response).getScript(); + + for (APDUScriptResponse.ResponseScriptElement element : responseScript) { + + if (element instanceof APDUScriptResponse.ATR) { + + byte[] atr = ((APDUScriptResponse.ATR) element).getAtr(); + + ATRType atrType = of.createATRType(); + atrType.setValue(atr); + atrType.setRc(BigInteger.ZERO); + responseT.getATROrResponseAPDU().add(atrType); + + } else if (element instanceof APDUScriptResponse.Response) { + + APDUScriptResponse.Response resp = (APDUScriptResponse.Response) element; + + ResponseAPDUType responseAPDUType = of.createResponseAPDUType(); + responseAPDUType.setSequence(BigInteger.valueOf(resp.getSequence())); + responseAPDUType.setRc(BigInteger.valueOf(resp.getRc())); + responseAPDUType.setSW(resp.getSw()); + responseAPDUType.setValue(resp.getApdu()); + + responseT.getATROrResponseAPDU().add(responseAPDUType); + } else { + log.error("invalid responseScriptElement " + element.getClass()); + throw new TranslationException(element.getClass()); + } + } + return of.createResponse(responseT); + } else { + log.error("cannot translate " + response.getClass()); + throw new TranslationException(response.getClass()); + } + } + + @Override + public STALResponse translate(ResponseType response) throws TranslationException { + if (response instanceof at.buergerkarte.namespaces.cardchannel.service.ResponseType) { + log.trace("translate at.buergerkarte.namespaces.cardchannel.service.ResponseType -> at.gv.egiz.stal.ext.APDUScriptResponse"); + + List atrOrResponseAPDU = ((at.buergerkarte.namespaces.cardchannel.service.ResponseType) response).getATROrResponseAPDU(); + List responseScript = new ArrayList(); + + for (Object object : atrOrResponseAPDU) { + if (object instanceof ATRType) { + byte[] atr = ((ATRType) object).getValue(); + responseScript.add(new APDUScriptResponse.ATR(atr)); + } else if (object instanceof ResponseAPDUType) { + ResponseAPDUType respAPDU = (ResponseAPDUType) object; + int sequence = (respAPDU.getSequence() != null) + ? respAPDU.getSequence().intValue() + : 0; + int rc = (respAPDU.getRc() != null) + ? respAPDU.getRc().intValue() + : 0; + responseScript.add(new APDUScriptResponse.Response(sequence, + respAPDU.getValue(), + respAPDU.getSW(), + rc)); + } else { + log.error("invalid responseScriptElement " + object.getClass()); + throw new TranslationException(object.getClass()); + } + } + return new APDUScriptResponse(responseScript); + + } else { + log.error("cannot translate " + response.getClass()); + throw new TranslationException(response.getClass()); + } + } +} -- cgit v1.2.3