From 2882e14d19cfa58ea382083434210aaf0cfea3e3 Mon Sep 17 00:00:00 2001 From: wbauer Date: Fri, 13 Mar 2009 07:49:49 +0000 Subject: Fixed Bug#405 and added according test case Fixed Bug#402 Added Feature#403 git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@320 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../gv/egiz/bku/local/conf/SpringConfigurator.java | 2 + .../egiz/bku/local/webapp/BKURequestHandler.java | 21 ++++- .../gv/egiz/bku/local/webapp/SpringBKUServlet.java | 67 ++++++++------- BKULocal/src/main/webapp/WEB-INF/web.xml | 2 +- .../java/at/gv/egiz/bku/local/app/BKULauncher.java | 1 + .../gv/egiz/bku/online/webapp/ResultServlet.java | 23 ++++-- bkucommon/pom.xml | 80 ++++++++++-------- .../gv/egiz/bku/binding/DataUrlConnectionImpl.java | 16 +++- .../gv/egiz/bku/binding/HTTPBindingProcessor.java | 4 +- .../main/java/at/gv/egiz/bku/binding/HttpUtil.java | 3 +- .../java/at/gv/egiz/bku/conf/Configurator.java | 59 ++++++++++--- .../slcommands/impl/xsect/LocRefDereferencer.java | 1 - .../bku/binding/EmptyMultipartSLRequestTest.java | 96 ++++++++++++++++++++++ .../at/gv/egiz/bku/binding/MultipartEmpty.txt | 17 ++++ .../HTTPURLProtocolHandlerImpl.java | 9 +- 15 files changed, 307 insertions(+), 94 deletions(-) create mode 100644 bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java create mode 100644 bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java index bcb96c2f..09b0ebab 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/SpringConfigurator.java @@ -29,6 +29,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import at.gv.egiz.bku.conf.Configurator; +import at.gv.egiz.bku.local.webapp.SpringBKUServlet; import at.gv.egiz.bku.slexceptions.SLRuntimeException; public class SpringConfigurator extends Configurator implements @@ -72,6 +73,7 @@ public class SpringConfigurator extends Configurator implements defaultInit(); } super.configure(); + SpringBKUServlet.setConfigurator(this); } public void defaultInit() { diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java index 62705d1e..b39b4d02 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java @@ -33,16 +33,15 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.binding.BindingProcessorManager; import at.gv.egiz.bku.binding.HTTPBindingProcessor; import at.gv.egiz.bku.binding.HttpUtil; +import at.gv.egiz.bku.conf.Configurator; import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage; -public abstract class BKURequestHandler extends HttpServlet { +public class BKURequestHandler extends SpringBKUServlet { public final static String ENCODING = "UTF-8"; protected Log log = LogFactory.getLog(BKURequestHandler.class); - protected abstract BindingProcessorManager getBindingProcessorManager(); - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException { log.debug("Got new request"); @@ -77,6 +76,22 @@ public abstract class BKURequestHandler extends HttpServlet { String header = it.next(); resp.setHeader(header, bindingProcessor.getResponseHeaders().get(header)); } + String sigLayout=""; + String version = configurator.getProperty(Configurator.SIGNATURE_LAYOUT); + if ((version != null) && (!"".equals(version.trim()))) { + resp.setHeader(Configurator.SIGNATURE_LAYOUT, version); + } else { + log.debug("Do not set siglayout header"); + } + + if (configurator.getProperty(Configurator.USERAGENT_CONFIG_P) != null) { + resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, configurator + .getProperty(Configurator.USERAGENT_CONFIG_P)); + } else { + resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, + Configurator.USERAGENT_DEFAULT); + } + resp.setContentType(bindingProcessor.getResultContentType()); resp.setCharacterEncoding(ENCODING); bindingProcessor.writeResultTo(resp.getOutputStream(), ENCODING); diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java index c573e52f..3bd50ba7 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java @@ -1,30 +1,39 @@ /* -* 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.bku.local.webapp; - -import at.gv.egiz.bku.binding.BindingProcessorManager; - -public class SpringBKUServlet extends BKURequestHandler { - - public final static String BEAN_NAME="bindingProcessorManager"; - - @Override - protected BindingProcessorManager getBindingProcessorManager() { - return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME); - } - -} + * 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.bku.local.webapp; + +import javax.servlet.http.HttpServlet; + +import at.gv.egiz.bku.binding.BindingProcessorManager; +import at.gv.egiz.bku.conf.Configurator; + +public abstract class SpringBKUServlet extends HttpServlet { + + public final static String BEAN_NAME = "bindingProcessorManager"; + + protected static Configurator configurator; + + protected BindingProcessorManager getBindingProcessorManager() { + return (BindingProcessorManager) getServletContext() + .getAttribute(BEAN_NAME); + } + + public static void setConfigurator(Configurator conf) { + configurator = conf; + } + +} diff --git a/BKULocal/src/main/webapp/WEB-INF/web.xml b/BKULocal/src/main/webapp/WEB-INF/web.xml index 36087d17..3b2e7e10 100644 --- a/BKULocal/src/main/webapp/WEB-INF/web.xml +++ b/BKULocal/src/main/webapp/WEB-INF/web.xml @@ -34,7 +34,7 @@ BKUServlet - at.gv.egiz.bku.local.webapp.SpringBKUServlet + at.gv.egiz.bku.local.webapp.BKURequestHandler help diff --git a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java index b2022d22..09695808 100644 --- a/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java +++ b/BKULocalApp/src/main/java/at/gv/egiz/bku/local/app/BKULauncher.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.local.ui.BKUControllerInterface; import at.gv.egiz.bku.local.ui.TrayIconDialog; +import at.gv.egiz.bku.utils.HexDump; import at.gv.egiz.bku.utils.StreamUtil; public class BKULauncher implements BKUControllerInterface { diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java index a4d3e5d1..e9d9a38a 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java @@ -79,7 +79,21 @@ public class ResultServlet extends SpringBKUServlet { } protected void doGet(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, java.io.IOException { + throws ServletException, java.io.IOException { + String version = configurator.getProperty(Configurator.SIGNATURE_LAYOUT); + if ((version != null) && (!"".equals(version.trim()))) { + resp.setHeader(Configurator.SIGNATURE_LAYOUT, version); + } else { + log.debug("Do not set siglayout header"); + } + + if (configurator.getProperty(Configurator.USERAGENT_CONFIG_P) != null) { + resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, configurator + .getProperty(Configurator.USERAGENT_CONFIG_P)); + } else { + resp.setHeader(HttpUtil.HTTP_HEADER_SERVER, + Configurator.USERAGENT_DEFAULT); + } HttpSession session = req.getSession(false); if (session == null) { @@ -119,13 +133,6 @@ public class ResultServlet extends SpringBKUServlet { resp.setHeader("Cache-Control", "no-store"); // HTTP 1.1 resp.setHeader("Pragma", "no-cache"); // HTTP 1.0 resp.setDateHeader("Expires", 0); - if (configurator.getProperty(Configurator.USERAGENT_CONFIG_P) != null) { - resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, configurator - .getProperty(Configurator.USERAGENT_CONFIG_P)); - } else { - resp.setHeader(HttpUtil.HTTP_HEADER_USER_AGENT, - Configurator.USERAGENT_DEFAULT); - } for (Iterator it = bp.getResponseHeaders().keySet().iterator(); it .hasNext();) { String header = it.next(); diff --git a/bkucommon/pom.xml b/bkucommon/pom.xml index ccc1814d..5084abcb 100644 --- a/bkucommon/pom.xml +++ b/bkucommon/pom.xml @@ -1,5 +1,6 @@ - + bku at.gv.egiz @@ -10,7 +11,43 @@ bkucommon BKU Common 1.0.5-SNAPSHOT - http://maven.apache.org + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + + + 1.0 + + + + + + at.gv.egiz @@ -58,35 +95,14 @@ compile - org.springframework - spring-context - test - - - - com.sun.xml.bind - jaxb-impl - + org.springframework + spring-context + test + + + + com.sun.xml.bind + jaxb-impl + - - - - - - \ No newline at end of file diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java index 4c235456..c8bddbbd 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/DataUrlConnectionImpl.java @@ -225,10 +225,17 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { this.url = url; boundary = "--" + IdFactory.getInstance().createId().toString(); requestHttpHeaders = new HashMap(); - if ((config != null) - && (config.getProperty(Configurator.USERAGENT_CONFIG_P) != null)) { - requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, config - .getProperty(Configurator.USERAGENT_CONFIG_P)); + + if (config != null) { + String sigLayout=""; + String version = config.getProperty(Configurator.SIGNATURE_LAYOUT); + if ((version != null) && (!"".equals(version.trim()))) { + requestHttpHeaders.put(Configurator.SIGNATURE_LAYOUT, version); + } else { + log.debug("Do not set siglayout header"); + } + String userAgent = config.getProperty(Configurator.USERAGENT_CONFIG_P, Configurator.USERAGENT_DEFAULT); + requestHttpHeaders.put(HttpUtil.HTTP_HEADER_USER_AGENT, userAgent); } else { requestHttpHeaders .put(HttpUtil.HTTP_HEADER_USER_AGENT, Configurator.USERAGENT_DEFAULT); @@ -251,6 +258,7 @@ public class DataUrlConnectionImpl implements DataUrlConnectionSPI { DataUrlConnectionSPI uc = new DataUrlConnectionImpl(); uc.setConfiguration(config); uc.setSSLSocketFactory(sslSocketFactory); + uc.setHostnameVerifier(hostnameVerifier); return uc; } diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java index 43f42331..d0b2dac1 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java @@ -672,10 +672,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements } else { FormParameterStore fps = new FormParameterStore(); fps.init(fp); - if (!fps.isEmpty()) { + //if (!fps.isEmpty()) { log.debug("Setting form parameter: " + fps.getFormParameterName()); formParameterMap.put(fps.getFormParameterName(), fps); - } + //} } } if (slCommand == null) { diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java index b11a4d85..5ea7b25e 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HttpUtil.java @@ -29,7 +29,8 @@ public class HttpUtil { public final static String CHAR_SET = "charset"; public final static String DEFAULT_CHARSET = "ISO-8859-1"; public final static String HTTP_HEADER_CONTENT_TYPE = "Content-Type"; - public static final String HTTP_HEADER_USER_AGENT = "User-Agent"; + public static final String HTTP_HEADER_USER_AGENT = "User-Agent"; + public static final String HTTP_HEADER_SERVER = "Server"; public final static String HTTP_HEADER_REFERER = "Referer"; public final static String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; public final static String MULTIPART_FOTMDATA = "multipart/form-data"; diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java index 6213ffcf..8a94e88d 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/conf/Configurator.java @@ -9,6 +9,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; +import java.net.URL; import java.security.GeneralSecurityException; import java.security.InvalidAlgorithmParameterException; import java.security.NoSuchAlgorithmException; @@ -26,6 +27,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.Set; +import java.util.jar.Attributes; +import java.util.jar.Manifest; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -39,7 +42,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import at.gv.egiz.bku.binding.DataUrl; -import at.gv.egiz.bku.binding.DataUrlConnection; import at.gv.egiz.bku.slcommands.impl.xsect.DataObject; import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; import at.gv.egiz.bku.slexceptions.SLRuntimeException; @@ -55,10 +57,12 @@ public abstract class Configurator { public static final String USERAGENT_DEFAULT = "citizen-card-environment/1.2 MOCCA/UNKNOWN"; public static final String USERAGENT_BASE = "citizen-card-environment/1.2 MOCCA/"; + public static final String SIGNATURE_LAYOUT = "SignatureLayout"; protected Properties properties; protected CertValidator certValidator; + protected String signaturLayoutVersion; protected Configurator() { } @@ -161,7 +165,7 @@ public abstract class Configurator { log.debug("Registering security providers"); Security.insertProviderAt(new IAIK(), 1); Security.insertProviderAt(new ECCProvider(false), 2); - + // registering STALProvider as delegation provider for XSECT STALProvider stalProvider = new STALProvider(); Set services = stalProvider.getServices(); @@ -171,8 +175,10 @@ public abstract class Configurator { XSecProvider.setDelegationProvider(algorithm, stalProvider.getName()); sb.append("\n" + algorithm); } - log.debug("Registered STALProvider as XSecProvider delegation provider for the following services : " + sb.toString()); - + log + .debug("Registered STALProvider as XSecProvider delegation provider for the following services : " + + sb.toString()); + Security.addProvider(stalProvider); XSecProvider.addAsProvider(false); sb = new StringBuilder(); @@ -193,6 +199,31 @@ public abstract class Configurator { } } + public void configureSingatureLayoutVersion() { + if (properties.get(SIGNATURE_LAYOUT) == null) { + try { + String classContainer = Configurator.class.getProtectionDomain() + .getCodeSource().getLocation().toString(); + URL manifestUrl = new URL("jar:" + classContainer + + "!/META-INF/MANIFEST.MF"); + Manifest manifest = new Manifest(manifestUrl.openStream()); + Attributes att = manifest.getMainAttributes(); + String layout = null; + if (att != null) { + layout = att.getValue(SIGNATURE_LAYOUT); + } + if (layout != null) { + log.info("Setting signature layout to: " + layout); + properties.put(SIGNATURE_LAYOUT, layout); + } else { + log.warn("No signature layout version defined"); + } + } catch (Exception ex) { + log.warn("Cannot read manifest", ex); + } + } + } + public void configureNetwork() { String proxy = getProperty("HTTPProxyHost"); String portString = getProperty("HTTPProxyPort"); @@ -217,15 +248,15 @@ public abstract class Configurator { if (is != null) { p.load(getManifest()); String version = p.getProperty("Implementation-Build"); - properties.setProperty(USERAGENT_CONFIG_P, - USERAGENT_BASE + version); + if (version == null) { + version="UNKNOWN"; + } + properties.setProperty(USERAGENT_CONFIG_P, USERAGENT_BASE + version); log.debug("Setting user agent to: " - + properties - .getProperty(USERAGENT_CONFIG_P)); + + properties.getProperty(USERAGENT_CONFIG_P)); } else { log.warn("Cannot read manifest"); - properties.setProperty(USERAGENT_CONFIG_P, - USERAGENT_DEFAULT); + properties.setProperty(USERAGENT_CONFIG_P, USERAGENT_DEFAULT); } } catch (IOException e) { log.error(e); @@ -240,6 +271,7 @@ public abstract class Configurator { configViewer(); configureSSL(); configureVersion(); + configureSingatureLayoutVersion(); configureNetwork(); } @@ -280,11 +312,14 @@ public abstract class Configurator { sslCtx.init(km, new TrustManager[] { pkixTM }, null); } DataUrl.setSSLSocketFactory(sslCtx.getSocketFactory()); - URLDereferencer.getInstance().setSSLSocketFactory(sslCtx.getSocketFactory()); + URLDereferencer.getInstance().setSSLSocketFactory( + sslCtx.getSocketFactory()); } catch (Exception e) { log.error("Cannot configure SSL", e); } - if ((disableAll != null && Boolean.parseBoolean(disableAll)) || (disableHostnameVerification != null && Boolean.parseBoolean(disableHostnameVerification))) { + if ((disableAll != null && Boolean.parseBoolean(disableAll)) + || (disableHostnameVerification != null && Boolean + .parseBoolean(disableHostnameVerification))) { log.warn("---------------------------------"); log.warn(" Disabling Hostname Verification "); log.warn("---------------------------------"); diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java index a6399c9b..f5394157 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/xsect/LocRefDereferencer.java @@ -105,7 +105,6 @@ public class LocRefDereferencer implements URIDereferencer { throw new URIReferenceException("Failed to dereference URI '" + locRef + "'. " + e.getMessage(), e); } - return new OctetStreamData(streamData.getStream(), locRef, streamData .getContentType()); } diff --git a/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java new file mode 100644 index 00000000..dd315f7f --- /dev/null +++ b/bkucommon/src/test/java/at/gv/egiz/bku/binding/EmptyMultipartSLRequestTest.java @@ -0,0 +1,96 @@ +/* + * 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.bku.binding; + +import iaik.security.ecc.provider.ECCProvider; +import iaik.security.provider.IAIK; +import iaik.xml.crypto.XSecProvider; + +import java.io.InputStream; +import java.net.MalformedURLException; +import java.security.Provider; +import java.security.Security; +import java.security.Provider.Service; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; + +import at.gv.egiz.bku.conf.Configurator; +import at.gv.egiz.bku.slcommands.SLCommandFactory; +import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider; + +public class EmptyMultipartSLRequestTest { + + private static Log log = LogFactory.getLog(EmptyMultipartSLRequestTest.class); + + protected String resourceName = "at/gv/egiz/bku/binding/MultipartEmpty.txt"; + + protected BindingProcessor bindingProcessor; + protected InputStream dataStream; + protected BindingProcessorManager manager; + + @Before + public void setUp() throws MalformedURLException, ClassNotFoundException { + manager = new BindingProcessorManagerImpl(new DummyStalFactory(), + new SLCommandInvokerImpl()); + HTTPBindingProcessor http = (HTTPBindingProcessor) manager + .createBindingProcessor("http://www.at/", null); + Map headers = new HashMap(); + headers.put("Content-Type", InputDecoderFactory.MULTIPART_FORMDATA + + ";boundary=uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o"); + http.setHTTPHeaders(headers); + dataStream = getClass().getClassLoader().getResourceAsStream(resourceName); + bindingProcessor = http; + Map commandMap = new HashMap(); + commandMap + .put( + "http://www.buergerkarte.at/namespaces/securitylayer/1.2#:CreateXMLSignatureRequest", + "at.gv.egiz.bku.slcommands.impl.CreateXMLSignatureCommandImpl"); + commandMap + .put( + "http://www.buergerkarte.at/namespaces/securitylayer/1.2#:InfoboxReadRequest", + "at.gv.egiz.bku.slcommands.impl.InfoboxReadCommandImpl"); + SLCommandFactory.getInstance().setCommandImpl(commandMap); + Security.insertProviderAt(new IAIK(), 1); + Security.insertProviderAt(new ECCProvider(false), 2); + XSecProvider.addAsProvider(false); + // registering STALProvider as delegation provider for XSECT + STALProvider stalProvider = new STALProvider(); + Security.addProvider(stalProvider); + Set services = stalProvider.getServices(); + StringBuilder sb = new StringBuilder(); + for (Service service : services) { + String algorithm = service.getType() + "." + service.getAlgorithm(); + XSecProvider.setDelegationProvider(algorithm, stalProvider.getName()); + sb.append("\n" + algorithm); + } + log.debug(sb); + } + + @Test + public void testBasicNop() { + bindingProcessor.consumeRequestStream(dataStream); + // manager.process(bindingProcessor); + bindingProcessor.run(); + } + +} diff --git a/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt b/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt new file mode 100644 index 00000000..97c29894 --- /dev/null +++ b/bkucommon/src/test/resources/at/gv/egiz/bku/binding/MultipartEmpty.txt @@ -0,0 +1,17 @@ +POST /http-security-layer-request HTTP/1.1 +User-Agent: Jakarta Commons-HttpClient/3.0 +Host: 127.0.0.1:13495 +Content-Length: 855 +Content-Type: multipart/form-data; boundary=uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o + +--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o +Content-Disposition: form-data; name="XMLRequest" + +SecureSignatureKeypairformdata:fileuploadtext/plain +--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o +Content-Disposition: form-data; name="fileupload"; filename="myfile.txt" +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: binary + + +--uW10q_I9UeqKyw-1o5EW4jtEAaGs7-mC6o-- diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java index 99f804b7..dfe7d5e6 100644 --- a/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java +++ b/utils/src/main/java/at/gv/egiz/bku/utils/urldereferencer/HTTPURLProtocolHandlerImpl.java @@ -81,6 +81,13 @@ public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler { .getInputStream()); } + /** + * + * @param aUrl + * @param aContext + * @return + * @throws IOException if the data cannot be found or reading the stream failed. + */ protected StreamData dereferenceFormData(String aUrl, URLDereferencerContext aContext) throws IOException { log.debug("Dereferencing formdata url: " + aUrl); @@ -96,7 +103,7 @@ public class HTTPURLProtocolHandlerImpl implements URLProtocolHandler { if (is != null) { return new StreamData(aUrl, contentType, is); } - return null; + throw new IOException("Cannot dereference url: formdata not found"); } @Override -- cgit v1.2.3